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_TriangularFrustumSet_HeaderFile |
17 | #define _SelectMgr_TriangularFrustumSet_HeaderFile |
18 | |
19 | #include <NCollection_Handle.hxx> |
20 | #include <NCollection_List.hxx> |
21 | |
22 | #include <SelectMgr_BaseFrustum.hxx> |
23 | #include <SelectMgr_TriangularFrustum.hxx> |
24 | |
c04c30b3 |
25 | typedef NCollection_List<Handle(SelectMgr_TriangularFrustum)> SelectMgr_TriangFrustums; |
26 | typedef NCollection_List<Handle(SelectMgr_TriangularFrustum)>::Iterator SelectMgr_TriangFrustumsIter; |
f751596e |
27 | |
28 | //! This class is used to handle polyline selection. The main principle of polyline selection |
29 | //! algorithm is to split the polygon defined by polyline onto triangles. Than each of |
30 | //! them is considered as a base for triangular frustum building. In other |
31 | //! words, each triangle vertiex will be projected from 2d screen space to 3d world space |
32 | //! onto near and far view frustum planes. Thus, the projected triangles make up the bases of |
33 | //! selecting frustum. When the set of such frustums is created, the function determining |
34 | //! selection iterates through triangular frustum set and searches for overlap with any |
35 | //! frustum. |
36 | class SelectMgr_TriangularFrustumSet : public SelectMgr_BaseFrustum |
37 | { |
38 | public: |
39 | |
a24a7821 |
40 | SelectMgr_TriangularFrustumSet(); |
f751596e |
41 | |
42 | ~SelectMgr_TriangularFrustumSet() {}; |
43 | |
44 | //! Meshes polygon bounded by polyline. Than organizes a set of triangular frustums, |
45 | //! where each triangle's projection onto near and far view frustum planes is |
46 | //! considered as a frustum base |
1f3913c6 |
47 | Standard_EXPORT virtual void Build (const TColgp_Array1OfPnt2d& thePoints) Standard_OVERRIDE; |
f751596e |
48 | |
49 | //! Returns a copy of the frustum with all sub-volumes transformed according to the matrix given |
099f3513 |
50 | Standard_EXPORT virtual Handle(SelectMgr_BaseFrustum) ScaleAndTransform (const Standard_Integer theScale, |
51 | const gp_GTrsf& theTrsf) const Standard_OVERRIDE; |
f751596e |
52 | |
3bf9a45f |
53 | Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, |
54 | const SelectMgr_Vec3& theMaxPnt, |
d7fa57a7 |
55 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
56 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
57 | |
1f3913c6 |
58 | Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, |
59 | const SelectMgr_Vec3& theMaxPnt, |
4a056d20 |
60 | Standard_Boolean* theInside) const Standard_OVERRIDE; |
f751596e |
61 | |
3bf9a45f |
62 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, |
d7fa57a7 |
63 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
64 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
65 | |
114b7bf1 |
66 | Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts, |
1f3913c6 |
67 | Select3D_TypeOfSensitivity theSensType, |
d7fa57a7 |
68 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
69 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
70 | |
3bf9a45f |
71 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
72 | const gp_Pnt& thePnt2, |
d7fa57a7 |
73 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
74 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
75 | |
3bf9a45f |
76 | Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
77 | const gp_Pnt& thePnt2, |
78 | const gp_Pnt& thePnt3, |
1f3913c6 |
79 | Select3D_TypeOfSensitivity theSensType, |
d7fa57a7 |
80 | const SelectMgr_ViewClipRange& theClipRange, |
4a056d20 |
81 | SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE; |
f751596e |
82 | |
871dcdc2 |
83 | //! Stores plane equation coefficients (in the following form: |
84 | //! Ax + By + Cz + D = 0) to the given vector |
85 | Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE; |
86 | |
a24a7821 |
87 | //! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will |
88 | //! mark both included and overlapped entities as matched |
89 | Standard_EXPORT virtual void SetAllowOverlapDetection (const Standard_Boolean theIsToAllow); |
90 | |
91 | private: |
92 | |
93 | //! Checks whether the segment intersects with the boundary of the current volume selection |
94 | Standard_EXPORT Standard_Boolean isIntersectBoundary (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2) const; |
95 | |
96 | //! Checks whether the triangle intersects with a segment |
97 | Standard_EXPORT Standard_Boolean segmentTriangleIntersection (const gp_Pnt &theOrig, const gp_Vec& theDir, |
98 | const gp_Pnt& theV1, const gp_Pnt& theV2, const gp_Pnt& theV3) const; |
99 | |
f751596e |
100 | private: |
101 | |
a24a7821 |
102 | SelectMgr_TriangFrustums myFrustums; |
103 | TColgp_Array1OfPnt myBoundaryPoints; |
104 | Standard_Boolean myToAllowOverlap; |
f751596e |
105 | }; |
106 | |
107 | #endif // _SelectMgr_TriangularFrustumSet_HeaderFile |