0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / Select3D / Select3D_SensitiveFace.cxx
CommitLineData
b311480e 1// Created on: 1995-03-27
2// Created by: Robert COUBLANC
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17//Modif on jun-24-97 : introduction de CSLib_Class2d de LBR
18// pour teste si on est dedans ou dehors...
19//Modif on jul-21-97 : changement en harray1 pour eventuelles connexions ...
20
f751596e 21#include <Select3D_SensitiveFace.hxx>
bf3977c9 22#include <Select3D_SensitivePoly.hxx>
23#include <Select3D_InteriorSensitivePointSet.hxx>
24
7fd59977 25#include <gp_Pnt.hxx>
26#include <Precision.hxx>
7fd59977 27
7fd59977 28
92efcf78 29IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity)
30
7fd59977 31//==================================================
81bba717 32// Function: Hide this constructor to the next version...
33// Purpose : simply avoid interfering with the version update
7fd59977 34//==================================================
f751596e 35Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
36 const TColgp_Array1OfPnt& thePoints,
37 const Select3D_TypeOfSensitivity theType)
38: Select3D_SensitiveEntity (theOwnerId),
39 mySensType (theType)
7fd59977 40{
f751596e 41 if (mySensType == Select3D_TOS_INTERIOR)
42 {
43 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints);
44 }
45 else
46 {
bf3977c9 47 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
f751596e 48 }
7fd59977 49}
50
51//==================================================
ac04d101 52// Function: Creation
7fd59977 53// Purpose :
54//==================================================
f751596e 55Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
56 const Handle(TColgp_HArray1OfPnt)& thePoints,
57 const Select3D_TypeOfSensitivity theType)
58: Select3D_SensitiveEntity (theOwnerId),
59 mySensType (theType)
7fd59977 60{
f751596e 61 if (mySensType == Select3D_TOS_INTERIOR)
ac04d101 62 {
1c22cc2d 63 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1());
7fd59977 64 }
f751596e 65 else
ac04d101 66 {
bf3977c9 67 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
7fd59977 68 }
7fd59977 69}
70
71//=======================================================================
f751596e 72// function : GetPoints
73// purpose : Initializes the given array theHArrayOfPnt by 3d
74// coordinates of vertices of the face
7fd59977 75//=======================================================================
f751596e 76void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
ac04d101 77{
bf3977c9 78 if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
79 {
80 Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
81 }
82 else
83 {
84 Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
85 }
86
7fd59977 87}
88
89//=======================================================================
f751596e 90// function : BVH
91// purpose : Builds BVH tree for the face
7fd59977 92//=======================================================================
f751596e 93void Select3D_SensitiveFace::BVH()
ac04d101 94{
f751596e 95 myFacePoints->BVH();
96}
7fd59977 97
f751596e 98//=======================================================================
99// function : Matches
100// purpose : Checks whether the face overlaps current selecting volume
101//=======================================================================
102Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr,
103 SelectBasics_PickResult& thePickResult)
104{
105 return myFacePoints->Matches (theMgr, thePickResult);
7fd59977 106}
107
7fd59977 108//=======================================================================
f751596e 109//function : GetConnected
aec37c15 110//purpose :
7fd59977 111//=======================================================================
f751596e 112Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
7fd59977 113{
f751596e 114 // Create a copy of this
115 Handle(TColgp_HArray1OfPnt) aPoints;
bf3977c9 116 GetPoints (aPoints);
aec37c15 117
f751596e 118 Handle(Select3D_SensitiveEntity) aNewEntity =
119 new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);
aec37c15 120
f751596e 121 return aNewEntity;
7fd59977 122}
123
124//=======================================================================
f751596e 125// function : BoundingBox
126// purpose : Returns bounding box of the face. If location transformation
127// is set, it will be applied
7fd59977 128//=======================================================================
f751596e 129Select3D_BndBox3d Select3D_SensitiveFace::BoundingBox()
7fd59977 130{
f751596e 131 return myFacePoints->BoundingBox();
7fd59977 132}
ac04d101 133
4269bd1b 134//=======================================================================
f751596e 135// function : CenterOfGeometry
136// purpose : Returns center of the face. If location transformation
137// is set, it will be applied
4269bd1b 138//=======================================================================
f751596e 139gp_Pnt Select3D_SensitiveFace::CenterOfGeometry() const
4269bd1b 140{
f751596e 141 return myFacePoints->CenterOfGeometry();
4269bd1b 142}
143
ac04d101 144//=======================================================================
f751596e 145// function : NbSubElements
146// purpose : Returns the amount of sub-entities (points or planar convex
147// polygons)
ac04d101 148//=======================================================================
f751596e 149Standard_Integer Select3D_SensitiveFace::NbSubElements()
ac04d101 150{
f751596e 151 return myFacePoints->NbSubElements();
aec37c15 152}