cf64c8366173ec37c1a179338cfabf416aa89434
[occt.git] / src / SelectMgr / SelectMgr_BaseFrustum.cxx
1 // Created on: 2014-05-22
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <SelectMgr_BaseFrustum.hxx>
17
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)
26 {
27   myBuilder = new SelectMgr_FrustumBuilder();
28 }
29
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)
35 {
36   myBuilder->SetOrientation (theCamera->OrientationMatrix());
37   myBuilder->SetProjection (theCamera->ProjectionMatrix());
38   myIsOrthographic = theCamera->IsOrthographic();
39   myBuilder->InvalidateViewport();
40 }
41
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)
49 {
50   myBuilder->SetOrientation (theOrientation);
51   myBuilder->SetProjection (theProjection);
52   myIsOrthographic = theIsOrthographic;
53 }
54
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)
63 {
64   myBuilder->SetViewport (theX, theY, theWidth, theHeight);
65 }
66
67 //=======================================================================
68 // function : SetPixelTolerance
69 // purpose  :
70 //=======================================================================
71 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Real theTol)
72 {
73   myPixelTolerance = theTol;
74 }
75
76 //=======================================================================
77 // function : SetWindowSize
78 // purpose  :
79 //=======================================================================
80 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
81 {
82   myBuilder->SetWindowSize (theWidth, theHeight);
83 }
84
85 //=======================================================================
86 // function : SetBuilder
87 // purpose  :
88 //=======================================================================
89 void SelectMgr_BaseFrustum::SetBuilder (const NCollection_Handle<SelectMgr_FrustumBuilder>& theBuilder)
90 {
91   myBuilder.Nullify();
92   myBuilder = theBuilder;
93 }
94
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*/)
102 {
103   return Standard_False;
104 }
105
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*/)
112 {
113   return Standard_False;
114 }
115
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*/)
122 {
123   return Standard_False;
124 }
125
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*/)
136 {
137   return Standard_False;
138 }
139
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*/)
152 {
153   return Standard_False;
154 }
155
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*/)
163 {
164   return Standard_False;
165 }
166
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*/)
173 {
174   return DBL_MAX;
175 }
176
177 SelectMgr_Vec3 SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
178 {
179   return SelectMgr_Vec3 (RealLast());
180 }
181
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*/)
189 {
190   return Standard_True;
191 }