f751596e |
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 | #ifndef _SelectMgr_BaseFrustum_HeaderFile |
17 | #define _SelectMgr_BaseFrustum_HeaderFile |
18 | |
19 | #include <Bnd_Box.hxx> |
20 | |
21 | #include <gp_Pnt.hxx> |
22 | #include <gp_Pln.hxx> |
23 | |
24 | #include <Graphic3d_Camera.hxx> |
25 | #include <Graphic3d_ClipPlane.hxx> |
26 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
27 | |
28 | #include <NCollection_Handle.hxx> |
29 | #include <TColgp_HArray1OfPnt.hxx> |
30 | #include <TColgp_Array1OfPnt2d.hxx> |
31 | |
32 | #include <Select3D_BndBox3d.hxx> |
33 | #include <SelectMgr_FrustumBuilder.hxx> |
34 | #include <Select3D_TypeOfSensitivity.hxx> |
35 | #include <SelectMgr_VectorTypes.hxx> |
36 | |
37 | //! This class is an interface for different types of selecting frustums, |
38 | //! defining different selection types, like point, box or polyline |
39 | //! selection. It contains signatures of functions for detection of |
40 | //! overlap by sensitive entity and initializes some data for building |
41 | //! the selecting frustum |
42 | class SelectMgr_BaseFrustum |
43 | { |
44 | public: |
45 | |
46 | //! Creates new selecting volume with pixel toletance set to 2, |
47 | //! orthographic camera and empty frustum builder |
48 | SelectMgr_BaseFrustum(); |
49 | |
50 | virtual ~SelectMgr_BaseFrustum() {}; |
51 | |
52 | //! Passes camera projection and orientation matrices to builder |
53 | void SetCamera (const Handle(Graphic3d_Camera)& theCamera); |
54 | |
55 | //! Passes camera projection and orientation matrices to builder |
56 | void SetCamera (const Graphic3d_Mat4d& theProjection, |
57 | const Graphic3d_Mat4d& theOrientation, |
58 | const Standard_Integer theIsOrthographic); |
59 | |
60 | void SetPixelTolerance (const Standard_Real theTol); |
61 | |
62 | void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight); |
63 | |
64 | //! Passes viewport parameters to builder |
65 | void SetViewport (const Standard_Real theX, |
66 | const Standard_Real theY, |
67 | const Standard_Real theWidth, |
68 | const Standard_Real theHeight); |
69 | |
70 | //! Nullifies the builder created in the constructor and copies the pointer given |
71 | void SetBuilder (const NCollection_Handle<SelectMgr_FrustumBuilder>& theBuilder); |
72 | |
73 | |
74 | //! Builds volume according to the point and given pixel tolerance |
75 | virtual void Build (const gp_Pnt2d& /*thePoint*/) {}; |
76 | |
77 | //! Builds volume according to the selected rectangle |
78 | virtual void Build (const gp_Pnt2d& /*theMinPt*/, |
79 | const gp_Pnt2d& /*theMaxPt*/) {}; |
80 | |
81 | //! Builds volume according to the triangle given |
82 | virtual void Build (const gp_Pnt2d& /*theP1*/, |
83 | const gp_Pnt2d& /*theP2*/, |
84 | const gp_Pnt2d& /*theP3*/) {}; |
85 | |
86 | //! Builds selecting volumes set according to polyline points |
87 | virtual void Build (const TColgp_Array1OfPnt2d& /*thePoints*/) {}; |
88 | |
89 | virtual NCollection_Handle<SelectMgr_BaseFrustum> Transform (const gp_Trsf& /*theTrsf*/) { return NULL; } |
90 | |
28ee613b |
91 | //! IMPORTANT: Makes sense only for frustum built on a single point! |
92 | //! Returns a copy of the frustum resized according to the scale factor given |
93 | virtual NCollection_Handle<SelectMgr_BaseFrustum> Scale (const Standard_Real /*theScaleFactor*/) { return NULL; } |
94 | |
f751596e |
95 | //! SAT intersection test between defined volume and given axis-aligned box |
7ab15952 |
96 | virtual Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBndBox, |
97 | Standard_Real& theDepth); |
f751596e |
98 | |
99 | //! Returns true if selecting volume is overlapped by axis-aligned bounding box |
100 | //! with minimum corner at point theMinPt and maximum at point theMaxPt |
2157d6ac |
101 | virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin, |
102 | const SelectMgr_Vec3& theBoxMax, |
103 | Standard_Boolean* theInside = NULL); |
f751596e |
104 | |
105 | //! Intersection test between defined volume and given point |
7ab15952 |
106 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePt, |
107 | Standard_Real& theDepth); |
f751596e |
108 | |
109 | //! SAT intersection test between defined volume and given ordered set of points, |
110 | //! representing line segments. The test may be considered of interior part or |
111 | //! boundary line defined by segments depending on given sensitivity type |
7ab15952 |
112 | virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts, |
113 | Select3D_TypeOfSensitivity theSensType, |
114 | Standard_Real& theDepth); |
f751596e |
115 | |
116 | //! Checks if line segment overlaps selecting frustum |
7ab15952 |
117 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1, |
118 | const gp_Pnt& thePt2, |
119 | Standard_Real& theDepth); |
f751596e |
120 | |
121 | //! SAT intersection test between defined volume and given triangle. The test may |
122 | //! be considered of interior part or boundary line defined by triangle vertices |
123 | //! depending on given sensitivity type |
7ab15952 |
124 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1, |
125 | const gp_Pnt& thePt2, |
126 | const gp_Pnt& thePt3, |
127 | Select3D_TypeOfSensitivity theSensType, |
128 | Standard_Real& theDepth); |
f751596e |
129 | |
130 | //! Measures distance between 3d projection of user-picked |
131 | //! screen point and given point theCOG |
7ab15952 |
132 | virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG); |
f751596e |
133 | |
134 | virtual SelectMgr_Vec3 DetectedPoint (const Standard_Real theDepth) const; |
135 | |
136 | //! Checks if the point of sensitive in which selection was detected belongs |
137 | //! to the region defined by clipping planes |
7ab15952 |
138 | virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, |
139 | const Standard_Real theDepth); |
f751596e |
140 | |
141 | protected: |
142 | Standard_Real myPixelTolerance; //!< Pixel tolerance |
143 | Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic |
144 | |
145 | NCollection_Handle<SelectMgr_FrustumBuilder> myBuilder; //!< A tool implementing methods for volume build |
146 | }; |
147 | |
148 | #endif // _SelectMgr_BaseFrustum_HeaderFile |