1 // Created on: 1995-03-27
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Select3D_SensitiveFace.hxx>
19 #include <Select3D_SensitivePoly.hxx>
20 #include <Select3D_InteriorSensitivePointSet.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity)
24 //==================================================
25 // Function: Hide this constructor to the next version...
26 // Purpose : simply avoid interfering with the version update
27 //==================================================
28 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
29 const TColgp_Array1OfPnt& thePoints,
30 const Select3D_TypeOfSensitivity theType)
31 : Select3D_SensitiveEntity (theOwnerId),
34 if (mySensType == Select3D_TOS_INTERIOR)
36 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints);
40 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
44 //==================================================
47 //==================================================
48 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId,
49 const Handle(TColgp_HArray1OfPnt)& thePoints,
50 const Select3D_TypeOfSensitivity theType)
51 : Select3D_SensitiveEntity (theOwnerId),
54 if (mySensType == Select3D_TOS_INTERIOR)
56 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1());
60 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
64 //=======================================================================
65 // function : GetPoints
66 // purpose : Initializes the given array theHArrayOfPnt by 3d
67 // coordinates of vertices of the face
68 //=======================================================================
69 void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
71 if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
73 Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
77 Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
82 //=======================================================================
84 // purpose : Builds BVH tree for the face
85 //=======================================================================
86 void Select3D_SensitiveFace::BVH()
91 //=======================================================================
93 // purpose : Checks whether the face overlaps current selecting volume
94 //=======================================================================
95 Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr,
96 SelectBasics_PickResult& thePickResult)
98 return myFacePoints->Matches (theMgr, thePickResult);
101 //=======================================================================
102 //function : GetConnected
104 //=======================================================================
105 Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
107 // Create a copy of this
108 Handle(TColgp_HArray1OfPnt) aPoints;
111 Handle(Select3D_SensitiveEntity) aNewEntity =
112 new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);
117 //=======================================================================
118 // function : BoundingBox
119 // purpose : Returns bounding box of the face. If location transformation
120 // is set, it will be applied
121 //=======================================================================
122 Select3D_BndBox3d Select3D_SensitiveFace::BoundingBox()
124 return myFacePoints->BoundingBox();
127 //=======================================================================
128 // function : CenterOfGeometry
129 // purpose : Returns center of the face. If location transformation
130 // is set, it will be applied
131 //=======================================================================
132 gp_Pnt Select3D_SensitiveFace::CenterOfGeometry() const
134 return myFacePoints->CenterOfGeometry();
137 //=======================================================================
138 // function : NbSubElements
139 // purpose : Returns the amount of sub-entities (points or planar convex
141 //=======================================================================
142 Standard_Integer Select3D_SensitiveFace::NbSubElements()
144 return myFacePoints->NbSubElements();