f751596e |
1 | // Created on: 2014-05-22 |
2 | // Created by: Varvara POSKONINA |
3 | // Copyright (c) 2005-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #include <SelectMgr_BaseFrustum.hxx> |
17 | |
18 | //======================================================================= |
19 | // function : SelectMgr_SelectingVolume |
20 | // purpose : Creates new selecting volume with pixel toletance set to 2, |
21 | // orthographic camera and empty frustum builder |
22 | //======================================================================= |
23 | SelectMgr_BaseFrustum::SelectMgr_BaseFrustum() |
24 | : myPixelTolerance (2), |
25 | myIsOrthographic (Standard_True) |
26 | { |
27 | myBuilder = new SelectMgr_FrustumBuilder(); |
28 | } |
29 | |
30 | //======================================================================= |
31 | // function : SetCamera |
32 | // purpose : Passes camera projection and orientation matrices to builder |
33 | //======================================================================= |
34 | void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera) |
35 | { |
825aa485 |
36 | myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix()); |
37 | myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix()); |
38 | myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState()); |
f751596e |
39 | myIsOrthographic = theCamera->IsOrthographic(); |
40 | myBuilder->InvalidateViewport(); |
41 | } |
42 | |
43 | //======================================================================= |
44 | // function : SetCamera |
45 | // purpose : Passes camera projection and orientation matrices to builder |
46 | //======================================================================= |
47 | void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection, |
825aa485 |
48 | const Graphic3d_Mat4d& theWorldView, |
49 | const Standard_Integer theIsOrthographic, |
50 | const Graphic3d_WorldViewProjState& theWVPState) |
f751596e |
51 | { |
825aa485 |
52 | myBuilder->SetWorldViewMatrix (theWorldView); |
53 | myBuilder->SetProjectionMatrix (theProjection); |
54 | myBuilder->SetWorldViewProjState (theWVPState); |
f751596e |
55 | myIsOrthographic = theIsOrthographic; |
56 | } |
57 | |
58 | //======================================================================= |
825aa485 |
59 | // function : ProjectionMatrix |
60 | // purpose : Returns current camera projection transformation common for |
61 | // all selecting volumes |
62 | //======================================================================= |
63 | const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const |
64 | { |
65 | return myBuilder->ProjectionMatrix(); |
66 | } |
67 | |
68 | //======================================================================= |
69 | // function : WorldViewMatrix |
70 | // purpose : Returns current camera world view transformation common for |
71 | // all selecting volumes |
72 | //======================================================================= |
73 | const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const |
74 | { |
75 | return myBuilder->WorldViewMatrix(); |
76 | } |
77 | |
78 | //======================================================================= |
79 | // function : WorldViewProjState |
80 | // purpose : Returns current camera world view projection transformation |
81 | // state |
82 | //======================================================================= |
83 | const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const |
84 | { |
85 | return myBuilder->WorldViewProjState(); |
86 | } |
87 | |
88 | //======================================================================= |
f751596e |
89 | // function : SetViewport |
90 | // purpose : Passes viewport parameters to builder |
91 | //======================================================================= |
92 | void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX, |
93 | const Standard_Real theY, |
94 | const Standard_Real theWidth, |
95 | const Standard_Real theHeight) |
96 | { |
97 | myBuilder->SetViewport (theX, theY, theWidth, theHeight); |
98 | } |
99 | |
100 | //======================================================================= |
101 | // function : SetPixelTolerance |
102 | // purpose : |
103 | //======================================================================= |
3bf9a45f |
104 | void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol) |
f751596e |
105 | { |
106 | myPixelTolerance = theTol; |
107 | } |
108 | |
109 | //======================================================================= |
110 | // function : SetWindowSize |
111 | // purpose : |
112 | //======================================================================= |
113 | void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight) |
114 | { |
115 | myBuilder->SetWindowSize (theWidth, theHeight); |
116 | } |
117 | |
118 | //======================================================================= |
119 | // function : SetBuilder |
120 | // purpose : |
121 | //======================================================================= |
bf3977c9 |
122 | void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder) |
f751596e |
123 | { |
124 | myBuilder.Nullify(); |
125 | myBuilder = theBuilder; |
126 | } |
127 | |
128 | //======================================================================= |
129 | // function : Overlaps |
130 | // purpose : SAT intersection test between defined volume and |
131 | // given axis-aligned box |
132 | //======================================================================= |
3bf9a45f |
133 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/, |
134 | const SelectMgr_Vec3& /*theBoxMax*/, |
7ab15952 |
135 | Standard_Real& /*theDepth*/) |
f751596e |
136 | { |
137 | return Standard_False; |
138 | } |
139 | |
140 | //======================================================================= |
141 | // function : Overlaps |
142 | // purpose : Intersection test between defined volume and given point |
143 | //======================================================================= |
2157d6ac |
144 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/, |
145 | const SelectMgr_Vec3& /*theBoxMax*/, |
146 | Standard_Boolean* /*theInside*/) |
f751596e |
147 | { |
148 | return Standard_False; |
149 | } |
150 | |
151 | //======================================================================= |
152 | // function : Overlaps |
153 | // purpose : Intersection test between defined volume and given point |
154 | //======================================================================= |
3bf9a45f |
155 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/, |
7ab15952 |
156 | Standard_Real& /*theDepth*/) |
f751596e |
157 | { |
158 | return Standard_False; |
159 | } |
160 | |
3bf9a45f |
161 | //======================================================================= |
162 | // function : Overlaps |
163 | // purpose : Intersection test between defined volume and given point |
164 | //======================================================================= |
165 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) |
166 | { |
167 | return Standard_False; |
168 | } |
169 | |
f751596e |
170 | //======================================================================= |
171 | // function : Overlaps |
172 | // purpose : SAT intersection test between defined volume and given |
173 | // ordered set of points, representing line segments. The test |
174 | // may be considered of interior part or boundary line defined |
175 | // by segments depending on given sensitivity type |
176 | //======================================================================= |
3bf9a45f |
177 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPnts*/, |
7ab15952 |
178 | Select3D_TypeOfSensitivity /*theSensType*/, |
179 | Standard_Real& /*theDepth*/) |
f751596e |
180 | { |
181 | return Standard_False; |
182 | } |
183 | |
184 | //======================================================================= |
185 | // function : Overlaps |
186 | // purpose : SAT intersection test between defined volume and given |
187 | // triangle. The test may be considered of interior part or |
188 | // boundary line defined by triangle vertices depending on |
189 | // given sensitivity type |
190 | //======================================================================= |
7ab15952 |
191 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/, |
192 | const gp_Pnt& /*thePt2*/, |
193 | const gp_Pnt& /*thePt3*/, |
194 | Select3D_TypeOfSensitivity /*theSensType*/, |
195 | Standard_Real& /*theDepth*/) |
f751596e |
196 | { |
197 | return Standard_False; |
198 | } |
199 | |
200 | //======================================================================= |
201 | // function : Overlaps |
202 | // purpose : Checks if line segment overlaps selecting volume |
203 | //======================================================================= |
3bf9a45f |
204 | Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/, |
205 | const gp_Pnt& /*thePnt2*/, |
7ab15952 |
206 | Standard_Real& /*theDepth*/) |
f751596e |
207 | { |
208 | return Standard_False; |
209 | } |
210 | |
211 | //======================================================================= |
212 | // function : DistToGeometryCenter |
213 | // purpose : Measures distance between 3d projection of user-picked |
214 | // screen point and given point theCOG |
215 | //======================================================================= |
7ab15952 |
216 | Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/) |
f751596e |
217 | { |
218 | return DBL_MAX; |
219 | } |
220 | |
3bf9a45f |
221 | gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const |
f751596e |
222 | { |
3bf9a45f |
223 | return gp_Pnt (RealLast(), RealLast(), RealLast()); |
f751596e |
224 | } |
225 | |
226 | //======================================================================= |
227 | // function : IsClipped |
228 | // purpose : Checks if the point of sensitive in which selection was |
229 | // detected belongs to the region defined by clipping planes |
230 | //======================================================================= |
7ab15952 |
231 | Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/, |
232 | const Standard_Real /*theDepth*/) |
f751596e |
233 | { |
234 | return Standard_True; |
235 | } |