1 // Created on: 2014-05-22
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <SelectMgr_BaseFrustum.hxx>
18 #include <Message.hxx>
20 #include <Standard_Dump.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
24 //=======================================================================
25 // function : SelectMgr_SelectingVolume
26 // purpose : Creates new selecting volume with pixel toletance set to 2,
27 // orthographic camera and empty frustum builder
28 //=======================================================================
29 SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
30 : myPixelTolerance (2),
31 myIsOrthographic (Standard_True)
33 myBuilder = new SelectMgr_FrustumBuilder();
36 //=======================================================================
37 // function : SetCamera
38 // purpose : Passes camera projection and orientation matrices to builder
39 //=======================================================================
40 void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
43 myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
44 myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix());
45 myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
46 myIsOrthographic = theCamera->IsOrthographic();
47 myBuilder->InvalidateViewport();
50 //=======================================================================
51 // function : SetCamera
52 // purpose : Passes camera projection and orientation matrices to builder
53 //=======================================================================
54 void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
55 const Graphic3d_Mat4d& theWorldView,
56 const Standard_Boolean theIsOrthographic,
57 const Graphic3d_WorldViewProjState& theWVPState)
60 myBuilder->SetWorldViewMatrix (theWorldView);
61 myBuilder->SetProjectionMatrix (theProjection);
62 myBuilder->SetWorldViewProjState (theWVPState);
63 myIsOrthographic = theIsOrthographic;
66 //=======================================================================
67 // function : ProjectionMatrix
68 // purpose : Returns current camera projection transformation common for
69 // all selecting volumes
70 //=======================================================================
71 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const
73 return myBuilder->ProjectionMatrix();
76 //=======================================================================
77 // function : WorldViewMatrix
78 // purpose : Returns current camera world view transformation common for
79 // all selecting volumes
80 //=======================================================================
81 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const
83 return myBuilder->WorldViewMatrix();
86 //=======================================================================
87 // function : WorldViewProjState
88 // purpose : Returns current camera world view projection transformation
90 //=======================================================================
91 const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
93 return myBuilder->WorldViewProjState();
96 //=======================================================================
97 // function : SetViewport
98 // purpose : Passes viewport parameters to builder
99 //=======================================================================
100 void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
101 const Standard_Real theY,
102 const Standard_Real theWidth,
103 const Standard_Real theHeight)
105 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
108 //=======================================================================
109 // function : SetPixelTolerance
111 //=======================================================================
112 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol)
114 myPixelTolerance = theTol;
117 //=======================================================================
118 // function : SetWindowSize
120 //=======================================================================
121 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
123 myBuilder->SetWindowSize (theWidth, theHeight);
126 //=======================================================================
127 // function : WindowSize
129 //=======================================================================
130 void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth,
131 Standard_Integer& theHeight) const
133 myBuilder->WindowSize (theWidth, theHeight);
136 //=======================================================================
137 // function : SetBuilder
139 //=======================================================================
140 void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
143 myBuilder = theBuilder;
146 //=======================================================================
147 // function : Overlaps
148 // purpose : SAT intersection test between defined volume and
149 // given axis-aligned box
150 //=======================================================================
151 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
152 const SelectMgr_Vec3& /*theBoxMax*/,
153 const SelectMgr_ViewClipRange& /*theClipRange*/,
154 SelectBasics_PickResult& /*thePickResult*/) const
156 return Standard_False;
159 //=======================================================================
160 // function : Overlaps
161 // purpose : Intersection test between defined volume and given point
162 //=======================================================================
163 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
164 const SelectMgr_Vec3& /*theBoxMax*/,
165 Standard_Boolean* /*theInside*/) const
167 return Standard_False;
170 //=======================================================================
171 // function : Overlaps
172 // purpose : Intersection test between defined volume and given point
173 //=======================================================================
174 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
175 const SelectMgr_ViewClipRange& /*theClipRange*/,
176 SelectBasics_PickResult& ) const
178 return Standard_False;
181 //=======================================================================
182 // function : Overlaps
183 // purpose : Intersection test between defined volume and given point
184 //=======================================================================
185 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) const
187 return Standard_False;
190 //=======================================================================
191 // function : Overlaps
192 // purpose : SAT intersection test between defined volume and given
193 // ordered set of points, representing line segments. The test
194 // may be considered of interior part or boundary line defined
195 // by segments depending on given sensitivity type
196 //=======================================================================
197 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
198 Select3D_TypeOfSensitivity /*theSensType*/,
199 const SelectMgr_ViewClipRange& /*theClipRange*/,
200 SelectBasics_PickResult& ) const
202 return Standard_False;
205 //=======================================================================
206 // function : Overlaps
207 // purpose : SAT intersection test between defined volume and given
208 // triangle. The test may be considered of interior part or
209 // boundary line defined by triangle vertices depending on
210 // given sensitivity type
211 //=======================================================================
212 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
213 const gp_Pnt& /*thePt2*/,
214 const gp_Pnt& /*thePt3*/,
215 Select3D_TypeOfSensitivity /*theSensType*/,
216 const SelectMgr_ViewClipRange& /*theClipRange*/,
217 SelectBasics_PickResult& ) const
219 return Standard_False;
222 //=======================================================================
223 // function : Overlaps
224 // purpose : Checks if line segment overlaps selecting volume
225 //=======================================================================
226 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
227 const gp_Pnt& /*thePnt2*/,
228 const SelectMgr_ViewClipRange& /*theClipRange*/,
229 SelectBasics_PickResult& ) const
231 return Standard_False;
234 //=======================================================================
235 // function : DistToGeometryCenter
236 // purpose : Measures distance between 3d projection of user-picked
237 // screen point and given point theCOG
238 //=======================================================================
239 Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/) const
244 //=======================================================================
245 // function : DetectedPoint
247 //=======================================================================
248 gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
250 return gp_Pnt (RealLast(), RealLast(), RealLast());
253 //=======================================================================
254 //function : DumpJson
256 //=======================================================================
257 void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
259 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
261 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
262 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic)
263 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
264 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)