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 //=======================================================================
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)
27 myBuilder = new SelectMgr_FrustumBuilder();
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)
36 myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
37 myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix());
38 myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
39 myIsOrthographic = theCamera->IsOrthographic();
40 myBuilder->InvalidateViewport();
43 //=======================================================================
44 // function : SetCamera
45 // purpose : Passes camera projection and orientation matrices to builder
46 //=======================================================================
47 void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
48 const Graphic3d_Mat4d& theWorldView,
49 const Standard_Integer theIsOrthographic,
50 const Graphic3d_WorldViewProjState& theWVPState)
52 myBuilder->SetWorldViewMatrix (theWorldView);
53 myBuilder->SetProjectionMatrix (theProjection);
54 myBuilder->SetWorldViewProjState (theWVPState);
55 myIsOrthographic = theIsOrthographic;
58 //=======================================================================
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
65 return myBuilder->ProjectionMatrix();
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
75 return myBuilder->WorldViewMatrix();
78 //=======================================================================
79 // function : WorldViewProjState
80 // purpose : Returns current camera world view projection transformation
82 //=======================================================================
83 const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
85 return myBuilder->WorldViewProjState();
88 //=======================================================================
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)
97 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
100 //=======================================================================
101 // function : SetPixelTolerance
103 //=======================================================================
104 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Real theTol)
106 myPixelTolerance = theTol;
109 //=======================================================================
110 // function : SetWindowSize
112 //=======================================================================
113 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
115 myBuilder->SetWindowSize (theWidth, theHeight);
118 //=======================================================================
119 // function : SetBuilder
121 //=======================================================================
122 void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
125 myBuilder = theBuilder;
128 //=======================================================================
129 // function : Overlaps
130 // purpose : SAT intersection test between defined volume and
131 // given axis-aligned box
132 //=======================================================================
133 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const BVH_Box<Standard_Real, 3>& /*theBndBox*/,
134 Standard_Real& /*theDepth*/)
136 return Standard_False;
139 //=======================================================================
140 // function : Overlaps
141 // purpose : Intersection test between defined volume and given point
142 //=======================================================================
143 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
144 const SelectMgr_Vec3& /*theBoxMax*/,
145 Standard_Boolean* /*theInside*/)
147 return Standard_False;
150 //=======================================================================
151 // function : Overlaps
152 // purpose : Intersection test between defined volume and given point
153 //=======================================================================
154 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt*/,
155 Standard_Real& /*theDepth*/)
157 return Standard_False;
160 //=======================================================================
161 // function : Overlaps
162 // purpose : SAT intersection test between defined volume and given
163 // ordered set of points, representing line segments. The test
164 // may be considered of interior part or boundary line defined
165 // by segments depending on given sensitivity type
166 //=======================================================================
167 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPts*/,
168 Select3D_TypeOfSensitivity /*theSensType*/,
169 Standard_Real& /*theDepth*/)
171 return Standard_False;
174 //=======================================================================
175 // function : Overlaps
176 // purpose : SAT intersection test between defined volume and given
177 // triangle. The test may be considered of interior part or
178 // boundary line defined by triangle vertices depending on
179 // given sensitivity type
180 //=======================================================================
181 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
182 const gp_Pnt& /*thePt2*/,
183 const gp_Pnt& /*thePt3*/,
184 Select3D_TypeOfSensitivity /*theSensType*/,
185 Standard_Real& /*theDepth*/)
187 return Standard_False;
190 //=======================================================================
191 // function : Overlaps
192 // purpose : Checks if line segment overlaps selecting volume
193 //=======================================================================
194 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
195 const gp_Pnt& /*thePt2*/,
196 Standard_Real& /*theDepth*/)
198 return Standard_False;
201 //=======================================================================
202 // function : DistToGeometryCenter
203 // purpose : Measures distance between 3d projection of user-picked
204 // screen point and given point theCOG
205 //=======================================================================
206 Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/)
211 SelectMgr_Vec3 SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
213 return SelectMgr_Vec3 (RealLast());
216 //=======================================================================
217 // function : IsClipped
218 // purpose : Checks if the point of sensitive in which selection was
219 // detected belongs to the region defined by clipping planes
220 //=======================================================================
221 Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/,
222 const Standard_Real /*theDepth*/)
224 return Standard_True;