Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:53

0001 // Copyright (c) 2021 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _SelectMgr_AxisIntersector_HeaderFile
0015 #define _SelectMgr_AxisIntersector_HeaderFile
0016 
0017 #include <SelectMgr_BaseIntersector.hxx>
0018 
0019 #include <gp_Ax1.hxx>
0020 
0021 //! This class contains representation of selecting axis, created in case of point selection
0022 //! and algorithms for overlap detection between this axis and sensitive entities.
0023 class SelectMgr_AxisIntersector : public SelectMgr_BaseIntersector
0024 {
0025 public:
0026 
0027   //! Empty constructor
0028   Standard_EXPORT SelectMgr_AxisIntersector();
0029 
0030   //! Destructor
0031   Standard_EXPORT virtual ~SelectMgr_AxisIntersector();
0032 
0033   //! Initializes selecting axis according to the input one
0034   Standard_EXPORT void Init (const gp_Ax1& theAxis);
0035 
0036   //! Builds axis according to internal parameters.
0037   //! NOTE: it should be called after Init() method
0038   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
0039 
0040   //! Saves camera definition.
0041   //! Do nothing for axis intersector (not applicable to this volume).
0042   Standard_EXPORT virtual void SetCamera (const Handle(Graphic3d_Camera)& theCamera) Standard_OVERRIDE;
0043 
0044   //! Returns FALSE (not applicable to this volume).
0045   virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
0046 
0047   //! IMPORTANT: Scaling doesn't make sense for this intersector.
0048   //! Returns a copy of the intersector transformed using the matrix given.
0049   //! Builder is an optional argument that represents corresponding settings for re-constructing transformed frustum from scratch.
0050   //! Can be null if reconstruction is not expected furthermore.
0051   Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScaleFactor,
0052                                                                                const gp_GTrsf& theTrsf,
0053                                                                                const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
0054 
0055 public:
0056 
0057   //! Intersection test between defined axis and given axis-aligned box
0058   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
0059                                                         const SelectMgr_Vec3& theBoxMax,
0060                                                         const SelectMgr_ViewClipRange& theClipRange,
0061                                                         SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0062 
0063   //! Returns true if selecting axis intersects axis-aligned bounding box
0064   //! with minimum corner at point theMinPt and maximum at point theMaxPt
0065   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theBoxMin,
0066                                                         const SelectMgr_Vec3& theBoxMax,
0067                                                         Standard_Boolean*     theInside) const Standard_OVERRIDE;
0068 
0069   //! Intersection test between defined axis and given point
0070   Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
0071                                                           const SelectMgr_ViewClipRange& theClipRange,
0072                                                           SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0073 
0074   //! Intersection test between defined axis and given point
0075   Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt) const Standard_OVERRIDE;
0076 
0077   //! Intersection test between defined axis and given ordered set of points,
0078   //! representing line segments. The test may be considered of interior part or
0079   //! boundary line defined by segments depending on given sensitivity type
0080   Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
0081                                                             Select3D_TypeOfSensitivity theSensType,
0082                                                             const SelectMgr_ViewClipRange& theClipRange,
0083                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0084 
0085   //! Checks if selecting axis intersects line segment
0086   Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
0087                                                             const gp_Pnt& thePnt2,
0088                                                             const SelectMgr_ViewClipRange& theClipRange,
0089                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0090 
0091   //! Intersection test between defined axis and given triangle. The test may
0092   //! be considered of interior part or boundary line defined by triangle vertices
0093   //! depending on given sensitivity type
0094   Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
0095                                                              const gp_Pnt& thePnt2,
0096                                                              const gp_Pnt& thePnt3,
0097                                                              Select3D_TypeOfSensitivity theSensType,
0098                                                              const SelectMgr_ViewClipRange& theClipRange,
0099                                                              SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0100 
0101   //! Intersection test between defined axis and given sphere with center theCenter
0102   //! and radius theRadius
0103   Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
0104                                                            const Standard_Real theRadius,
0105                                                            Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0106 
0107   //! Intersection test between defined axis and given sphere with center theCenter
0108   //! and radius theRadius
0109   Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
0110                                                            const Standard_Real theRadius,
0111                                                            const SelectMgr_ViewClipRange& theClipRange,
0112                                                            SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0113 
0114   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
0115   //! and theTopRad, height theHeight and transformation to apply theTrsf.
0116   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
0117                                                              const Standard_Real theTopRad,
0118                                                              const Standard_Real theHeight,
0119                                                              const gp_Trsf& theTrsf,
0120                                                              const Standard_Boolean theIsHollow,
0121                                                              const SelectMgr_ViewClipRange& theClipRange,
0122                                                              SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0123 
0124   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
0125   //! and theTopRad, height theHeight and transformation to apply theTrsf.
0126   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
0127                                                              const Standard_Real theTopRad,
0128                                                              const Standard_Real theHeight,
0129                                                              const gp_Trsf& theTrsf,
0130                                                              const Standard_Boolean theIsHollow,
0131                                                              Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0132 
0133   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0134   //! boolean theIsFilled and transformation to apply theTrsf.
0135   //! The position and orientation of the circle are specified
0136   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0137   Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
0138                                                            const gp_Trsf& theTrsf,
0139                                                            const Standard_Boolean theIsFilled,
0140                                                            const SelectMgr_ViewClipRange& theClipRange,
0141                                                            SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0142 
0143   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0144   //! boolean theIsFilled and transformation to apply theTrsf.
0145   //! The position and orientation of the circle are specified
0146   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0147   Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
0148                                                            const gp_Trsf& theTrsf,
0149                                                            const Standard_Boolean theIsFilled,
0150                                                            Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0151 
0152 public:
0153 
0154   //! Measures distance between start axis point and given point theCOG.
0155   Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) const Standard_OVERRIDE;
0156 
0157   //! Calculates the point on a axis ray that was detected during the run of selection algo by given depth
0158   Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
0159 
0160   //! Returns near point along axis.
0161   Standard_EXPORT virtual const gp_Pnt& GetNearPnt() const Standard_OVERRIDE;
0162 
0163   //! Returns far point along axis (infinite).
0164   Standard_EXPORT virtual const gp_Pnt& GetFarPnt() const Standard_OVERRIDE;
0165 
0166   //! Returns axis direction.
0167   Standard_EXPORT virtual const gp_Dir& GetViewRayDirection() const Standard_OVERRIDE;
0168 
0169   //! Dumps the content of me into the stream
0170   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0171 
0172 protected:
0173 
0174   //! Returns true if selecting axis intersects axis-aligned bounding box
0175   //! with minimum corner at point theBoxMin and maximum at point theBoxMax.
0176   //! Also returns enter and leave time of axis-box intersection.
0177   Standard_EXPORT Standard_Boolean hasIntersection (const SelectMgr_Vec3& theBoxMin,
0178                                                     const SelectMgr_Vec3& theBoxMax,
0179                                                     Standard_Real& theTimeEnter,
0180                                                     Standard_Real& theTimeLeave) const;
0181 
0182   //! Returns true if selecting axis intersects point.
0183   //! Also returns time of axis-point intersection.
0184   Standard_EXPORT Standard_Boolean hasIntersection (const gp_Pnt& thePnt,
0185                                                     Standard_Real& theDepth) const;
0186 
0187   //! Returns true if selecting axis intersects segment.
0188   //! Also saves time of axis-segment intersection and intersection point as pick result.
0189   Standard_EXPORT Standard_Boolean raySegmentDistance (const gp_Pnt& theSegPnt1,
0190                                                        const gp_Pnt& theSegPnt2,
0191                                                        SelectBasics_PickResult& thePickResult) const;
0192 
0193   //! Returns true if selecting axis intersects plane.
0194   //! Also saves time of axis-plane intersection and intersection point as pick result.
0195   Standard_EXPORT Standard_Boolean rayPlaneIntersection (const gp_Vec& thePlane,
0196                                                          const gp_Pnt& thePntOnPlane,
0197                                                          SelectBasics_PickResult& thePickResult) const;
0198 private:
0199 
0200   gp_Ax1 myAxis;
0201 
0202 };
0203 
0204 #endif // _SelectMgr_AxisIntersector_HeaderFile