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 //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 ...
21 #include <Select3D_SensitiveFace.hxx>
22 #include <Select3D_SensitivePoly.hxx>
23 #include <Select3D_InteriorSensitivePointSet.hxx>
26 #include <Precision.hxx>
29 IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity)
31 //==================================================
32 // Function: Hide this constructor to the next version...
33 // Purpose : simply avoid interfering with the version update
34 //==================================================
35 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
36 const TColgp_Array1OfPnt& thePoints,
37 const Select3D_TypeOfSensitivity theType)
38 : Select3D_SensitiveEntity (theOwnerId),
41 if (mySensType == Select3D_TOS_INTERIOR)
43 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints);
47 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True);
51 //==================================================
54 //==================================================
55 Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
56 const Handle(TColgp_HArray1OfPnt)& thePoints,
57 const Select3D_TypeOfSensitivity theType)
58 : Select3D_SensitiveEntity (theOwnerId),
61 if (mySensType == Select3D_TOS_INTERIOR)
63 myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1());
67 myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True);
71 //=======================================================================
72 // function : GetPoints
73 // purpose : Initializes the given array theHArrayOfPnt by 3d
74 // coordinates of vertices of the face
75 //=======================================================================
76 void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
78 if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly)))
80 Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt);
84 Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt);
89 //=======================================================================
91 // purpose : Builds BVH tree for the face
92 //=======================================================================
93 void Select3D_SensitiveFace::BVH()
98 //=======================================================================
100 // purpose : Checks whether the face overlaps current selecting volume
101 //=======================================================================
102 Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr,
103 SelectBasics_PickResult& thePickResult)
105 return myFacePoints->Matches (theMgr, thePickResult);
108 //=======================================================================
109 //function : GetConnected
111 //=======================================================================
112 Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected()
114 // Create a copy of this
115 Handle(TColgp_HArray1OfPnt) aPoints;
118 Handle(Select3D_SensitiveEntity) aNewEntity =
119 new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType);
124 //=======================================================================
125 // function : BoundingBox
126 // purpose : Returns bounding box of the face. If location transformation
127 // is set, it will be applied
128 //=======================================================================
129 Select3D_BndBox3d Select3D_SensitiveFace::BoundingBox()
131 return myFacePoints->BoundingBox();
134 //=======================================================================
135 // function : CenterOfGeometry
136 // purpose : Returns center of the face. If location transformation
137 // is set, it will be applied
138 //=======================================================================
139 gp_Pnt Select3D_SensitiveFace::CenterOfGeometry() const
141 return myFacePoints->CenterOfGeometry();
144 //=======================================================================
145 // function : NbSubElements
146 // purpose : Returns the amount of sub-entities (points or planar convex
148 //=======================================================================
149 Standard_Integer Select3D_SensitiveFace::NbSubElements()
151 return myFacePoints->NbSubElements();