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 | |
e1eb39d2 |
19 | #include <SelectMgr_BaseIntersector.hxx> |
0904aa63 |
20 | |
f751596e |
21 | //! This class is an interface for different types of selecting frustums, |
22 | //! defining different selection types, like point, box or polyline |
23 | //! selection. It contains signatures of functions for detection of |
24 | //! overlap by sensitive entity and initializes some data for building |
25 | //! the selecting frustum |
e1eb39d2 |
26 | class SelectMgr_BaseFrustum : public SelectMgr_BaseIntersector |
f751596e |
27 | { |
28 | public: |
29 | |
30 | //! Creates new selecting volume with pixel toletance set to 2, |
31 | //! orthographic camera and empty frustum builder |
1f3913c6 |
32 | Standard_EXPORT SelectMgr_BaseFrustum(); |
f751596e |
33 | |
e1eb39d2 |
34 | //! Destructor |
bf3977c9 |
35 | virtual ~SelectMgr_BaseFrustum() {} |
f751596e |
36 | |
e1eb39d2 |
37 | //! Nullifies the builder created in the constructor and copies the pointer given |
38 | Standard_EXPORT void SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder); |
39 | |
3fe9ce0e |
40 | //! Return camera definition. |
e1eb39d2 |
41 | virtual const Handle(Graphic3d_Camera)& Camera() const Standard_OVERRIDE { return myCamera; } |
3fe9ce0e |
42 | |
f751596e |
43 | //! Passes camera projection and orientation matrices to builder |
e1eb39d2 |
44 | Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE; |
f751596e |
45 | |
46 | //! Passes camera projection and orientation matrices to builder |
e1eb39d2 |
47 | Standard_EXPORT virtual void SetCamera (const Graphic3d_Mat4d& theProjection, |
48 | const Graphic3d_Mat4d& theWorldView, |
49 | const Standard_Boolean theIsOrthographic, |
50 | const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState()) Standard_OVERRIDE; |
825aa485 |
51 | |
52 | //! @return current camera projection transformation common for all selecting volumes |
e1eb39d2 |
53 | Standard_EXPORT virtual const Graphic3d_Mat4d& ProjectionMatrix() const Standard_OVERRIDE; |
825aa485 |
54 | |
55 | //! @return current camera world view transformation common for all selecting volumes |
e1eb39d2 |
56 | Standard_EXPORT virtual const Graphic3d_Mat4d& WorldViewMatrix() const Standard_OVERRIDE; |
825aa485 |
57 | |
58 | //! @return current camera world view projection transformation state |
e1eb39d2 |
59 | Standard_EXPORT virtual const Graphic3d_WorldViewProjState& WorldViewProjState() const Standard_OVERRIDE; |
f751596e |
60 | |
e1eb39d2 |
61 | Standard_EXPORT virtual void SetPixelTolerance (const Standard_Integer theTol) Standard_OVERRIDE; |
f751596e |
62 | |
e1eb39d2 |
63 | Standard_EXPORT virtual void SetWindowSize (const Standard_Integer theWidth, |
64 | const Standard_Integer theHeight) Standard_OVERRIDE; |
f751596e |
65 | |
e1eb39d2 |
66 | Standard_EXPORT virtual void WindowSize (Standard_Integer& theWidth, |
67 | Standard_Integer& theHeight) const Standard_OVERRIDE; |
91d96372 |
68 | |
f751596e |
69 | //! Passes viewport parameters to builder |
e1eb39d2 |
70 | Standard_EXPORT virtual void SetViewport (const Standard_Real theX, |
71 | const Standard_Real theY, |
72 | const Standard_Real theWidth, |
73 | const Standard_Real theHeight) Standard_OVERRIDE; |
f751596e |
74 | |
f751596e |
75 | |
28ee613b |
76 | |
f751596e |
77 | //! SAT intersection test between defined volume and given axis-aligned box |
03c9cc86 |
78 | Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, |
79 | const SelectMgr_Vec3& theBoxMax, |
80 | const SelectMgr_ViewClipRange& theClipRange, |
81 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
82 | |
83 | //! Returns true if selecting volume is overlapped by axis-aligned bounding box |
84 | //! with minimum corner at point theMinPt and maximum at point theMaxPt |
03c9cc86 |
85 | Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin, |
86 | const SelectMgr_Vec3& theBoxMax, |
87 | Standard_Boolean* theInside = NULL) const Standard_OVERRIDE; |
f751596e |
88 | |
89 | //! Intersection test between defined volume and given point |
03c9cc86 |
90 | Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt, |
91 | const SelectMgr_ViewClipRange& theClipRange, |
92 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
93 | |
3bf9a45f |
94 | //! Intersection test between defined volume and given point |
95 | //! Does not perform depth calculation, so this method is defined as |
96 | //! helper function for inclusion test. Therefore, its implementation |
97 | //! makes sense only for rectangular frustum with box selection mode activated. |
03c9cc86 |
98 | Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE; |
3bf9a45f |
99 | |
f751596e |
100 | //! SAT intersection test between defined volume and given ordered set of points, |
101 | //! representing line segments. The test may be considered of interior part or |
102 | //! boundary line defined by segments depending on given sensitivity type |
03c9cc86 |
103 | Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts, |
104 | Select3D_TypeOfSensitivity theSensType, |
105 | const SelectMgr_ViewClipRange& theClipRange, |
106 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
107 | |
108 | //! Checks if line segment overlaps selecting frustum |
03c9cc86 |
109 | Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1, |
110 | const gp_Pnt& thePnt2, |
111 | const SelectMgr_ViewClipRange& theClipRange, |
112 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
113 | |
114 | //! SAT intersection test between defined volume and given triangle. The test may |
115 | //! be considered of interior part or boundary line defined by triangle vertices |
116 | //! depending on given sensitivity type |
03c9cc86 |
117 | Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePt1, |
118 | const gp_Pnt& thePt2, |
119 | const gp_Pnt& thePt3, |
120 | Select3D_TypeOfSensitivity theSensType, |
121 | const SelectMgr_ViewClipRange& theClipRange, |
122 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
871dcdc2 |
123 | |
0904aa63 |
124 | //! Dumps the content of me into the stream |
e1eb39d2 |
125 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
0904aa63 |
126 | |
e1eb39d2 |
127 | DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector) |
c04c30b3 |
128 | |
f751596e |
129 | protected: |
3bf9a45f |
130 | Standard_Integer myPixelTolerance; //!< Pixel tolerance |
131 | Standard_Boolean myIsOrthographic; //!< Defines if current camera is orthographic |
f751596e |
132 | |
bf3977c9 |
133 | Handle(SelectMgr_FrustumBuilder) myBuilder; //!< A tool implementing methods for volume build |
3fe9ce0e |
134 | Handle(Graphic3d_Camera) myCamera; //!< camera definition |
f751596e |
135 | }; |
136 | |
137 | #endif // _SelectMgr_BaseFrustum_HeaderFile |