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 | |
f751596e |
17 | #include <Select3D_SensitiveFace.hxx> |
0609d8ee |
18 | |
bf3977c9 |
19 | #include <Select3D_SensitivePoly.hxx> |
20 | #include <Select3D_InteriorSensitivePointSet.hxx> |
21 | |
92efcf78 |
22 | IMPLEMENT_STANDARD_RTTIEXT(Select3D_SensitiveFace,Select3D_SensitiveEntity) |
23 | |
7fd59977 |
24 | //================================================== |
81bba717 |
25 | // Function: Hide this constructor to the next version... |
26 | // Purpose : simply avoid interfering with the version update |
7fd59977 |
27 | //================================================== |
0ef04197 |
28 | Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId, |
f751596e |
29 | const TColgp_Array1OfPnt& thePoints, |
30 | const Select3D_TypeOfSensitivity theType) |
31 | : Select3D_SensitiveEntity (theOwnerId), |
32 | mySensType (theType) |
7fd59977 |
33 | { |
f751596e |
34 | if (mySensType == Select3D_TOS_INTERIOR) |
35 | { |
36 | myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints); |
37 | } |
38 | else |
39 | { |
bf3977c9 |
40 | myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints, Standard_True); |
f751596e |
41 | } |
7fd59977 |
42 | } |
43 | |
44 | //================================================== |
ac04d101 |
45 | // Function: Creation |
7fd59977 |
46 | // Purpose : |
47 | //================================================== |
0ef04197 |
48 | Select3D_SensitiveFace::Select3D_SensitiveFace (const Handle(SelectMgr_EntityOwner)& theOwnerId, |
f751596e |
49 | const Handle(TColgp_HArray1OfPnt)& thePoints, |
50 | const Select3D_TypeOfSensitivity theType) |
51 | : Select3D_SensitiveEntity (theOwnerId), |
52 | mySensType (theType) |
7fd59977 |
53 | { |
f751596e |
54 | if (mySensType == Select3D_TOS_INTERIOR) |
ac04d101 |
55 | { |
1c22cc2d |
56 | myFacePoints = new Select3D_InteriorSensitivePointSet (theOwnerId, thePoints->Array1()); |
7fd59977 |
57 | } |
f751596e |
58 | else |
ac04d101 |
59 | { |
bf3977c9 |
60 | myFacePoints = new Select3D_SensitivePoly (theOwnerId, thePoints->Array1(), Standard_True); |
7fd59977 |
61 | } |
7fd59977 |
62 | } |
63 | |
64 | //======================================================================= |
f751596e |
65 | // function : GetPoints |
66 | // purpose : Initializes the given array theHArrayOfPnt by 3d |
67 | // coordinates of vertices of the face |
7fd59977 |
68 | //======================================================================= |
f751596e |
69 | void Select3D_SensitiveFace::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) |
ac04d101 |
70 | { |
bf3977c9 |
71 | if (myFacePoints->IsKind(STANDARD_TYPE(Select3D_SensitivePoly))) |
72 | { |
73 | Handle(Select3D_SensitivePoly)::DownCast (myFacePoints)->Points3D (theHArrayOfPnt); |
74 | } |
75 | else |
76 | { |
77 | Handle(Select3D_InteriorSensitivePointSet)::DownCast (myFacePoints)->GetPoints (theHArrayOfPnt); |
78 | } |
79 | |
7fd59977 |
80 | } |
81 | |
82 | //======================================================================= |
f751596e |
83 | // function : BVH |
84 | // purpose : Builds BVH tree for the face |
7fd59977 |
85 | //======================================================================= |
f751596e |
86 | void Select3D_SensitiveFace::BVH() |
ac04d101 |
87 | { |
f751596e |
88 | myFacePoints->BVH(); |
89 | } |
7fd59977 |
90 | |
f751596e |
91 | //======================================================================= |
92 | // function : Matches |
93 | // purpose : Checks whether the face overlaps current selecting volume |
94 | //======================================================================= |
95 | Standard_Boolean Select3D_SensitiveFace::Matches (SelectBasics_SelectingVolumeManager& theMgr, |
96 | SelectBasics_PickResult& thePickResult) |
97 | { |
98 | return myFacePoints->Matches (theMgr, thePickResult); |
7fd59977 |
99 | } |
100 | |
7fd59977 |
101 | //======================================================================= |
f751596e |
102 | //function : GetConnected |
aec37c15 |
103 | //purpose : |
7fd59977 |
104 | //======================================================================= |
f751596e |
105 | Handle(Select3D_SensitiveEntity) Select3D_SensitiveFace::GetConnected() |
7fd59977 |
106 | { |
f751596e |
107 | // Create a copy of this |
108 | Handle(TColgp_HArray1OfPnt) aPoints; |
bf3977c9 |
109 | GetPoints (aPoints); |
aec37c15 |
110 | |
f751596e |
111 | Handle(Select3D_SensitiveEntity) aNewEntity = |
112 | new Select3D_SensitiveFace (myOwnerId, aPoints, mySensType); |
aec37c15 |
113 | |
f751596e |
114 | return aNewEntity; |
7fd59977 |
115 | } |
116 | |
117 | //======================================================================= |
f751596e |
118 | // function : BoundingBox |
119 | // purpose : Returns bounding box of the face. If location transformation |
120 | // is set, it will be applied |
7fd59977 |
121 | //======================================================================= |
f751596e |
122 | Select3D_BndBox3d Select3D_SensitiveFace::BoundingBox() |
7fd59977 |
123 | { |
f751596e |
124 | return myFacePoints->BoundingBox(); |
7fd59977 |
125 | } |
ac04d101 |
126 | |
4269bd1b |
127 | //======================================================================= |
f751596e |
128 | // function : CenterOfGeometry |
129 | // purpose : Returns center of the face. If location transformation |
130 | // is set, it will be applied |
4269bd1b |
131 | //======================================================================= |
f751596e |
132 | gp_Pnt Select3D_SensitiveFace::CenterOfGeometry() const |
4269bd1b |
133 | { |
f751596e |
134 | return myFacePoints->CenterOfGeometry(); |
4269bd1b |
135 | } |
136 | |
ac04d101 |
137 | //======================================================================= |
f751596e |
138 | // function : NbSubElements |
139 | // purpose : Returns the amount of sub-entities (points or planar convex |
140 | // polygons) |
ac04d101 |
141 | //======================================================================= |
fe758dbe |
142 | Standard_Integer Select3D_SensitiveFace::NbSubElements() const |
ac04d101 |
143 | { |
f751596e |
144 | return myFacePoints->NbSubElements(); |
aec37c15 |
145 | } |
bc73b006 |
146 | |
147 | //======================================================================= |
148 | //function : DumpJson |
149 | //purpose : |
150 | //======================================================================= |
151 | void Select3D_SensitiveFace::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
152 | { |
153 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
154 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity) |
155 | |
156 | OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType) |
157 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFacePoints.get()) |
158 | } |