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 NCollection_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 const 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 const Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theMinPt*/,
111 const SelectMgr_Vec3& /*theMaxPt*/)
113 return Standard_False;
116 //=======================================================================
117 // function : Overlaps
118 // purpose : Intersection test between defined volume and given point
119 //=======================================================================
120 const Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt*/,
121 Standard_Real& /*theDepth*/)
123 return Standard_False;
126 //=======================================================================
127 // function : Overlaps
128 // purpose : SAT intersection test between defined volume and given
129 // ordered set of points, representing line segments. The test
130 // may be considered of interior part or boundary line defined
131 // by segments depending on given sensitivity type
132 //=======================================================================
133 const Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const Handle(TColgp_HArray1OfPnt)& /*theArrayOfPts*/,
134 Select3D_TypeOfSensitivity /*theSensType*/,
135 Standard_Real& /*theDepth*/)
137 return Standard_False;
140 //=======================================================================
141 // function : Overlaps
142 // purpose : SAT intersection test between defined volume and given
143 // triangle. The test may be considered of interior part or
144 // boundary line defined by triangle vertices depending on
145 // given sensitivity type
146 //=======================================================================
147 const Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
148 const gp_Pnt& /*thePt2*/,
149 const gp_Pnt& /*thePt3*/,
150 Select3D_TypeOfSensitivity /*theSensType*/,
151 Standard_Real& /*theDepth*/)
153 return Standard_False;
156 //=======================================================================
157 // function : Overlaps
158 // purpose : Checks if line segment overlaps selecting volume
159 //=======================================================================
160 const Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
161 const gp_Pnt& /*thePt2*/,
162 Standard_Real& /*theDepth*/)
164 return Standard_False;
167 //=======================================================================
168 // function : DistToGeometryCenter
169 // purpose : Measures distance between 3d projection of user-picked
170 // screen point and given point theCOG
171 //=======================================================================
172 const Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/)
177 SelectMgr_Vec3 SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
179 return SelectMgr_Vec3 (RealLast());
182 //=======================================================================
183 // function : IsClipped
184 // purpose : Checks if the point of sensitive in which selection was
185 // detected belongs to the region defined by clipping planes
186 //=======================================================================
187 const Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/,
188 const Standard_Real /*theDepth*/)
190 return Standard_True;