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_TriangularFrustum_HeaderFile |
17 | #define _SelectMgr_TriangularFrustum_HeaderFile |
18 | |
19 | #include <SelectMgr_Frustum.hxx> |
20 | |
21 | //! This class contains representation of triangular selecting frustum, created in case |
22 | //! of polyline selection, and algorithms for overlap detection between selecting |
23 | //! frustum and sensitive entities. |
24 | //! Overlap detection tests are implemented according to the terms of separating axis |
25 | //! theorem (SAT). |
26 | class SelectMgr_TriangularFrustum : public SelectMgr_Frustum<3> |
27 | { |
28 | public: |
29 | |
30 | //! Creates new triangular frustum with bases of triangles with vertices theP1, |
31 | //! theP2 and theP3 projections onto near and far view frustum planes |
32 | SelectMgr_TriangularFrustum() {}; |
33 | |
1f3913c6 |
34 | Standard_EXPORT ~SelectMgr_TriangularFrustum(); |
f751596e |
35 | |
36 | //! Creates new triangular frustum with bases of triangles with vertices theP1, theP2 and theP3 |
37 | //! projections onto near and far view frustum planes (only for triangular frustums) |
1f3913c6 |
38 | Standard_EXPORT virtual void Build (const gp_Pnt2d& theP1, |
39 | const gp_Pnt2d& theP2, |
40 | const gp_Pnt2d& theP3) Standard_OVERRIDE; |
f751596e |
41 | |
42 | //! Returns a copy of the frustum transformed according to the matrix given |
099f3513 |
43 | Standard_EXPORT virtual Handle(SelectMgr_BaseFrustum) ScaleAndTransform (const Standard_Integer theScale, |
44 | const gp_GTrsf& theTrsf) const Standard_OVERRIDE; |
f751596e |
45 | |
46 | // SAT Tests for different objects |
47 | |
48 | //! SAT intersection test between defined volume and given axis-aligned box |
3bf9a45f |
49 | Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, |
50 | const SelectMgr_Vec3& theMaxPnt, |
d7fa57a7 |
51 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
52 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
53 | |
54 | //! Returns true if selecting volume is overlapped by axis-aligned bounding box |
55 | //! with minimum corner at point theMinPt and maximum at point theMaxPt |
1f3913c6 |
56 | Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPt, |
57 | const SelectMgr_Vec3& theMaxPt, |
4a056d20 |
58 | Standard_Boolean* theInside) const Standard_OVERRIDE; |
f751596e |
59 | |
60 | //! Intersection test between defined volume and given point |
1f3913c6 |
61 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, |
d7fa57a7 |
62 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
63 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
64 | |
65 | //! SAT intersection test between defined volume and given ordered set of points, |
66 | //! representing line segments. The test may be considered of interior part or |
67 | //! boundary line defined by segments depending on given sensitivity type |
114b7bf1 |
68 | Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, |
1f3913c6 |
69 | Select3D_TypeOfSensitivity theSensType, |
d7fa57a7 |
70 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
71 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
72 | |
73 | //! Checks if line segment overlaps selecting frustum |
1f3913c6 |
74 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
75 | const gp_Pnt& thePnt2, |
d7fa57a7 |
76 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
77 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
78 | |
79 | //! SAT intersection test between defined volume and given triangle. The test may |
80 | //! be considered of interior part or boundary line defined by triangle vertices |
81 | //! depending on given sensitivity type |
1f3913c6 |
82 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
83 | const gp_Pnt& thePnt2, |
84 | const gp_Pnt& thePnt3, |
85 | Select3D_TypeOfSensitivity theSensType, |
d7fa57a7 |
86 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
87 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
88 | |
89 | //! Nullifies the handle to corresponding builder instance to prevent memory leaks |
1f3913c6 |
90 | Standard_EXPORT void Clear(); |
c04c30b3 |
91 | |
871dcdc2 |
92 | //! Stores plane equation coefficients (in the following form: |
93 | //! Ax + By + Cz + D = 0) to the given vector |
94 | Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE; |
95 | |
3bf9a45f |
96 | private: |
97 | |
099f3513 |
98 | void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const; |
3bf9a45f |
99 | |
0e9fe060 |
100 | DEFINE_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum,SelectMgr_Frustum<3>) |
f751596e |
101 | }; |
102 | |
103 | #endif // _SelectMgr_TriangularFrustum_HeaderFile |