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_RectangularFrustum_HeaderFile |
17 | #define _SelectMgr_RectangularFrustum_HeaderFile |
18 | |
19 | #include <SelectMgr_Frustum.hxx> |
20 | |
21 | //! This class contains representation of rectangular selecting frustum, created in case |
22 | //! of point and box selection, and algorithms for overlap detection between selecting |
23 | //! frustum and sensitive entities. The principle of frustum calculation: |
24 | //! - for point selection: on a near view frustum plane rectangular neighborhood of |
25 | //! user-picked point is created according to the pixel tolerance |
26 | //! given and then this rectangle is projected onto far view frustum |
27 | //! plane. This rectangles define the parallel bases of selecting frustum; |
28 | //! - for box selection: box points are projected onto near and far view frustum planes. |
29 | //! These 2 projected rectangles define parallel bases of selecting frustum. |
30 | //! Overlap detection tests are implemented according to the terms of separating axis |
31 | //! theorem (SAT). |
32 | class SelectMgr_RectangularFrustum : public SelectMgr_Frustum<4> |
33 | { |
34 | public: |
35 | |
36 | SelectMgr_RectangularFrustum() {}; |
37 | |
38 | //! Builds volume according to the point and given pixel tolerance |
39 | virtual void Build (const gp_Pnt2d& thePoint) Standard_OVERRIDE; |
40 | |
41 | //! Builds volume according to the selected rectangle |
42 | virtual void Build (const gp_Pnt2d& theMinPnt, |
43 | const gp_Pnt2d& theMaxPnt) Standard_OVERRIDE; |
44 | |
45 | //! Returns a copy of the frustum transformed according to the matrix given |
46 | virtual NCollection_Handle<SelectMgr_BaseFrustum> Transform (const gp_Trsf& theTrsf) Standard_OVERRIDE; |
47 | |
28ee613b |
48 | //! IMPORTANT: Makes sense only for frustum built on a single point! |
49 | //! Returns a copy of the frustum resized according to the scale factor given |
50 | virtual NCollection_Handle<SelectMgr_BaseFrustum> Scale (const Standard_Real theScaleFactor) Standard_OVERRIDE; |
51 | |
f751596e |
52 | |
53 | // SAT Tests for different objects |
54 | |
55 | //! SAT intersection test between defined volume and given axis-aligned box |
7ab15952 |
56 | virtual Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBox, |
57 | Standard_Real& theDepth) Standard_OVERRIDE; |
f751596e |
58 | |
59 | //! Returns true if selecting volume is overlapped by axis-aligned bounding box |
60 | //! with minimum corner at point theMinPt and maximum at point theMaxPt |
7ab15952 |
61 | virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theMinPnt, |
62 | const SelectMgr_Vec3& theMaxPnt) Standard_OVERRIDE; |
f751596e |
63 | |
64 | //! Intersection test between defined volume and given point |
7ab15952 |
65 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt, |
66 | Standard_Real& theDepth) Standard_OVERRIDE; |
f751596e |
67 | |
68 | //! SAT intersection test between defined volume and given ordered set of points, |
69 | //! representing line segments. The test may be considered of interior part or |
70 | //! boundary line defined by segments depending on given sensitivity type |
7ab15952 |
71 | virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPnts, |
72 | Select3D_TypeOfSensitivity theSensType, |
73 | Standard_Real& theDepth) Standard_OVERRIDE; |
f751596e |
74 | |
75 | //! Checks if line segment overlaps selecting frustum |
7ab15952 |
76 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
77 | const gp_Pnt& thePnt2, |
78 | Standard_Real& theDepth) Standard_OVERRIDE; |
f751596e |
79 | |
80 | //! SAT intersection test between defined volume and given triangle. The test may |
81 | //! be considered of interior part or boundary line defined by triangle vertices |
82 | //! depending on given sensitivity type |
7ab15952 |
83 | virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1, |
84 | const gp_Pnt& thePnt2, |
85 | const gp_Pnt& thePnt3, |
86 | Select3D_TypeOfSensitivity theSensType, |
87 | Standard_Real& theDepth) Standard_OVERRIDE; |
f751596e |
88 | |
89 | //! Measures distance between 3d projection of user-picked |
90 | //! screen point and given point theCOG |
7ab15952 |
91 | virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE; |
f751596e |
92 | |
93 | //! Calculates the point on a view ray that was detected during the run of selection algo by given depth |
94 | virtual SelectMgr_Vec3 DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE; |
95 | |
96 | //! Checks if the point of sensitive in which selection was detected belongs |
97 | //! to the region defined by clipping planes |
7ab15952 |
98 | virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes, |
99 | const Standard_Real theDepth) Standard_OVERRIDE; |
f751596e |
100 | |
101 | protected: |
102 | |
103 | void segmentSegmentDistance (const gp_Pnt& theSegPnt1, |
104 | const gp_Pnt& theSegPnt2, |
105 | Standard_Real& theDepth); |
106 | |
107 | void segmentPlaneIntersection (const SelectMgr_Vec3& thePlane, |
108 | const gp_Pnt& thePntOnPlane, |
109 | Standard_Real& theDepth); |
110 | |
111 | private: |
112 | |
113 | SelectMgr_Vec3 myNearPickedPnt; //!< 3d projection of user-picked selection point onto near view plane |
28ee613b |
114 | SelectMgr_Vec3 myFarPickedPnt; //!< 3d projection of user-picked selection point onto far view plane |
f751596e |
115 | SelectMgr_Vec3 myViewRayDir; |
28ee613b |
116 | gp_Pnt2d myMousePos; //!< Mouse coordinates |
f751596e |
117 | }; |
118 | |
119 | #endif // _SelectMgr_RectangularFrustum_HeaderFile |