1 // Copyright (c) 2021 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _SelectMgr_AxisIntersector_HeaderFile
15 #define _SelectMgr_AxisIntersector_HeaderFile
17 #include <SelectMgr_BaseIntersector.hxx>
21 //! This class contains representation of selecting axis, created in case of point selection
22 //! and algorithms for overlap detection between this axis and sensitive entities.
23 class SelectMgr_AxisIntersector : public SelectMgr_BaseIntersector
28 Standard_EXPORT SelectMgr_AxisIntersector();
31 virtual ~SelectMgr_AxisIntersector() {}
33 //! Initializes selecting axis according to the input one
34 Standard_EXPORT void Init (const gp_Ax1& theAxis);
36 //! Builds axis according to internal parameters.
37 //! NOTE: it should be called after Init() method
38 Standard_EXPORT virtual void Build() Standard_OVERRIDE;
40 //! IMPORTANT: Scaling doesn't make sense for this intersector.
41 //! Returns a copy of the intersector transformed using the matrix given.
42 //! Builder is an optional argument that represents corresponding settings for re-constructing transformed
43 //! frustum from scratch. Can be null if reconstruction is not expected furthermore.
44 Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector)
45 ScaleAndTransform (const Standard_Integer theScaleFactor,
46 const gp_GTrsf& theTrsf,
47 const Handle(SelectMgr_FrustumBuilder)& theBuilder = Handle(SelectMgr_FrustumBuilder)()) const Standard_OVERRIDE;
51 //! Intersection test between defined axis and given axis-aligned box
52 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
53 const SelectMgr_Vec3& theBoxMax,
54 const SelectMgr_ViewClipRange& theClipRange,
55 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
57 //! Returns true if selecting axis intersects axis-aligned bounding box
58 //! with minimum corner at point theMinPt and maximum at point theMaxPt
59 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
60 const SelectMgr_Vec3& theBoxMax,
61 Standard_Boolean* theInside) const Standard_OVERRIDE;
63 //! Intersection test between defined axis and given point
64 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
65 const SelectMgr_ViewClipRange& theClipRange,
66 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
68 //! Intersection test between defined axis and given point
69 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) const Standard_OVERRIDE;
71 //! Intersection test between defined axis and given ordered set of points,
72 //! representing line segments. The test may be considered of interior part or
73 //! boundary line defined by segments depending on given sensitivity type
74 Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPnts,
75 Select3D_TypeOfSensitivity theSensType,
76 const SelectMgr_ViewClipRange& theClipRange,
77 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
79 //! Checks if selecting axis intersects line segment
80 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
81 const gp_Pnt& thePnt2,
82 const SelectMgr_ViewClipRange& theClipRange,
83 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
85 //! Intersection test between defined axis and given triangle. The test may
86 //! be considered of interior part or boundary line defined by triangle vertices
87 //! depending on given sensitivity type
88 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
89 const gp_Pnt& thePnt2,
90 const gp_Pnt& thePnt3,
91 Select3D_TypeOfSensitivity theSensType,
92 const SelectMgr_ViewClipRange& theClipRange,
93 SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
97 //! Measures distance between start axis point and given point theCOG.
98 Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
100 //! Calculates the point on a axis ray that was detected during the run of selection algo by given depth
101 Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
103 //! Returns near point along axis.
104 Standard_EXPORT virtual const gp_Pnt& GetNearPnt() const Standard_OVERRIDE;
106 //! Returns far point along axis (infinite).
107 Standard_EXPORT virtual const gp_Pnt& GetFarPnt() const Standard_OVERRIDE;
109 //! Returns axis direction.
110 Standard_EXPORT virtual const gp_Dir& GetViewRayDirection() const Standard_OVERRIDE;
112 //! Dumps the content of me into the stream
113 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
117 //! Returns true if selecting axis intersects axis-aligned bounding box
118 //! with minimum corner at point theBoxMin and maximum at point theBoxMax.
119 //! Also returns enter and leave time of axis-box intersection.
120 Standard_EXPORT Standard_Boolean hasIntersection (const SelectMgr_Vec3& theBoxMin,
121 const SelectMgr_Vec3& theBoxMax,
122 Standard_Real& theTimeEnter,
123 Standard_Real& theTimeLeave) const;
125 //! Returns true if selecting axis intersects point.
126 //! Also returns time of axis-point intersection.
127 Standard_EXPORT Standard_Boolean hasIntersection (const gp_Pnt& thePnt,
128 Standard_Real& theDepth) const;
130 //! Returns true if selecting axis intersects segment.
131 //! Also saves time of axis-segment intersection and intersection point as pick result.
132 Standard_EXPORT Standard_Boolean raySegmentDistance (const gp_Pnt& theSegPnt1,
133 const gp_Pnt& theSegPnt2,
134 SelectBasics_PickResult& thePickResult) const;
136 //! Returns true if selecting axis intersects plane.
137 //! Also saves time of axis-plane intersection and intersection point as pick result.
138 Standard_EXPORT Standard_Boolean rayPlaneIntersection (const gp_Vec& thePlane,
139 const gp_Pnt& thePntOnPlane,
140 SelectBasics_PickResult& thePickResult) const;
147 #endif // _SelectMgr_AxisIntersector_HeaderFile