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 IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
20 //=======================================================================
21 // function : SelectMgr_SelectingVolume
22 // purpose : Creates new selecting volume with pixel toletance set to 2,
23 // orthographic camera and empty frustum builder
24 //=======================================================================
25 SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
26 : myPixelTolerance (2),
27 myIsOrthographic (Standard_True)
29 myBuilder = new SelectMgr_FrustumBuilder();
32 //=======================================================================
33 // function : SetCamera
34 // purpose : Passes camera projection and orientation matrices to builder
35 //=======================================================================
36 void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
38 myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
39 myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix());
40 myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
41 myIsOrthographic = theCamera->IsOrthographic();
42 myBuilder->InvalidateViewport();
45 //=======================================================================
46 // function : SetCamera
47 // purpose : Passes camera projection and orientation matrices to builder
48 //=======================================================================
49 void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
50 const Graphic3d_Mat4d& theWorldView,
51 const Standard_Integer theIsOrthographic,
52 const Graphic3d_WorldViewProjState& theWVPState)
54 myBuilder->SetWorldViewMatrix (theWorldView);
55 myBuilder->SetProjectionMatrix (theProjection);
56 myBuilder->SetWorldViewProjState (theWVPState);
57 myIsOrthographic = theIsOrthographic;
60 //=======================================================================
61 // function : ProjectionMatrix
62 // purpose : Returns current camera projection transformation common for
63 // all selecting volumes
64 //=======================================================================
65 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const
67 return myBuilder->ProjectionMatrix();
70 //=======================================================================
71 // function : WorldViewMatrix
72 // purpose : Returns current camera world view transformation common for
73 // all selecting volumes
74 //=======================================================================
75 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const
77 return myBuilder->WorldViewMatrix();
80 //=======================================================================
81 // function : WorldViewProjState
82 // purpose : Returns current camera world view projection transformation
84 //=======================================================================
85 const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
87 return myBuilder->WorldViewProjState();
90 //=======================================================================
91 // function : SetViewport
92 // purpose : Passes viewport parameters to builder
93 //=======================================================================
94 void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
95 const Standard_Real theY,
96 const Standard_Real theWidth,
97 const Standard_Real theHeight)
99 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
102 //=======================================================================
103 // function : SetPixelTolerance
105 //=======================================================================
106 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol)
108 myPixelTolerance = theTol;
111 //=======================================================================
112 // function : SetWindowSize
114 //=======================================================================
115 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
117 myBuilder->SetWindowSize (theWidth, theHeight);
120 //=======================================================================
121 // function : SetBuilder
123 //=======================================================================
124 void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
127 myBuilder = theBuilder;
130 //=======================================================================
131 // function : Overlaps
132 // purpose : SAT intersection test between defined volume and
133 // given axis-aligned box
134 //=======================================================================
135 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
136 const SelectMgr_Vec3& /*theBoxMax*/,
137 Standard_Real& /*theDepth*/)
139 return Standard_False;
142 //=======================================================================
143 // function : Overlaps
144 // purpose : Intersection test between defined volume and given point
145 //=======================================================================
146 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
147 const SelectMgr_Vec3& /*theBoxMax*/,
148 Standard_Boolean* /*theInside*/)
150 return Standard_False;
153 //=======================================================================
154 // function : Overlaps
155 // purpose : Intersection test between defined volume and given point
156 //=======================================================================
157 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
158 Standard_Real& /*theDepth*/)
160 return Standard_False;
163 //=======================================================================
164 // function : Overlaps
165 // purpose : Intersection test between defined volume and given point
166 //=======================================================================
167 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/)
169 return Standard_False;
172 //=======================================================================
173 // function : Overlaps
174 // purpose : SAT intersection test between defined volume and given
175 // ordered set of points, representing line segments. The test
176 // may be considered of interior part or boundary line defined
177 // by segments depending on given sensitivity type
178 //=======================================================================
179 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPnts*/,
180 Select3D_TypeOfSensitivity /*theSensType*/,
181 Standard_Real& /*theDepth*/)
183 return Standard_False;
186 //=======================================================================
187 // function : Overlaps
188 // purpose : SAT intersection test between defined volume and given
189 // triangle. The test may be considered of interior part or
190 // boundary line defined by triangle vertices depending on
191 // given sensitivity type
192 //=======================================================================
193 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
194 const gp_Pnt& /*thePt2*/,
195 const gp_Pnt& /*thePt3*/,
196 Select3D_TypeOfSensitivity /*theSensType*/,
197 Standard_Real& /*theDepth*/)
199 return Standard_False;
202 //=======================================================================
203 // function : Overlaps
204 // purpose : Checks if line segment overlaps selecting volume
205 //=======================================================================
206 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
207 const gp_Pnt& /*thePnt2*/,
208 Standard_Real& /*theDepth*/)
210 return Standard_False;
213 //=======================================================================
214 // function : DistToGeometryCenter
215 // purpose : Measures distance between 3d projection of user-picked
216 // screen point and given point theCOG
217 //=======================================================================
218 Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/)
223 gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
225 return gp_Pnt (RealLast(), RealLast(), RealLast());
228 //=======================================================================
229 // function : IsClipped
230 // purpose : Checks if the point of sensitive in which selection was
231 // detected belongs to the region defined by clipping planes
232 //=======================================================================
233 Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/,
234 const Standard_Real /*theDepth*/)
236 return Standard_True;