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->SetOrientation (theCamera->OrientationMatrix());
37 myBuilder->SetProjection (theCamera->ProjectionMatrix());
38 myIsOrthographic = theCamera->IsOrthographic();
39 myBuilder->InvalidateViewport();
42 //=======================================================================
43 // function : SetCamera
44 // purpose : Passes camera projection and orientation matrices to builder
45 //=======================================================================
46 void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
47 const Graphic3d_Mat4d& theOrientation,
48 const Standard_Integer theIsOrthographic)
50 myBuilder->SetOrientation (theOrientation);
51 myBuilder->SetProjection (theProjection);
52 myIsOrthographic = theIsOrthographic;
55 //=======================================================================
56 // function : SetViewport
57 // purpose : Passes viewport parameters to builder
58 //=======================================================================
59 void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
60 const Standard_Real theY,
61 const Standard_Real theWidth,
62 const Standard_Real theHeight)
64 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
67 //=======================================================================
68 // function : SetPixelTolerance
70 //=======================================================================
71 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Real theTol)
73 myPixelTolerance = theTol;
76 //=======================================================================
77 // function : SetWindowSize
79 //=======================================================================
80 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
82 myBuilder->SetWindowSize (theWidth, theHeight);
85 //=======================================================================
86 // function : SetBuilder
88 //=======================================================================
89 void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
92 myBuilder = theBuilder;
95 //=======================================================================
96 // function : Overlaps
97 // purpose : SAT intersection test between defined volume and
98 // given axis-aligned box
99 //=======================================================================
100 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const BVH_Box<Standard_Real, 3>& /*theBndBox*/,
101 Standard_Real& /*theDepth*/)
103 return Standard_False;
106 //=======================================================================
107 // function : Overlaps
108 // purpose : Intersection test between defined volume and given point
109 //=======================================================================
110 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
111 const SelectMgr_Vec3& /*theBoxMax*/,
112 Standard_Boolean* /*theInside*/)
114 return Standard_False;
117 //=======================================================================
118 // function : Overlaps
119 // purpose : Intersection test between defined volume and given point
120 //=======================================================================
121 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt*/,
122 Standard_Real& /*theDepth*/)
124 return Standard_False;
127 //=======================================================================
128 // function : Overlaps
129 // purpose : SAT intersection test between defined volume and given
130 // ordered set of points, representing line segments. The test
131 // may be considered of interior part or boundary line defined
132 // by segments depending on given sensitivity type
133 //=======================================================================
134 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPts*/,
135 Select3D_TypeOfSensitivity /*theSensType*/,
136 Standard_Real& /*theDepth*/)
138 return Standard_False;
141 //=======================================================================
142 // function : Overlaps
143 // purpose : SAT intersection test between defined volume and given
144 // triangle. The test may be considered of interior part or
145 // boundary line defined by triangle vertices depending on
146 // given sensitivity type
147 //=======================================================================
148 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
149 const gp_Pnt& /*thePt2*/,
150 const gp_Pnt& /*thePt3*/,
151 Select3D_TypeOfSensitivity /*theSensType*/,
152 Standard_Real& /*theDepth*/)
154 return Standard_False;
157 //=======================================================================
158 // function : Overlaps
159 // purpose : Checks if line segment overlaps selecting volume
160 //=======================================================================
161 Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
162 const gp_Pnt& /*thePt2*/,
163 Standard_Real& /*theDepth*/)
165 return Standard_False;
168 //=======================================================================
169 // function : DistToGeometryCenter
170 // purpose : Measures distance between 3d projection of user-picked
171 // screen point and given point theCOG
172 //=======================================================================
173 Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/)
178 SelectMgr_Vec3 SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
180 return SelectMgr_Vec3 (RealLast());
183 //=======================================================================
184 // function : IsClipped
185 // purpose : Checks if the point of sensitive in which selection was
186 // detected belongs to the region defined by clipping planes
187 //=======================================================================
188 Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/,
189 const Standard_Real /*theDepth*/)
191 return Standard_True;