Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:17:18

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   //! Empty constructor
0027   Standard_EXPORT SelectMgr_AxisIntersector();
0028 
0029   //! Destructor
0030   Standard_EXPORT virtual ~SelectMgr_AxisIntersector();
0031 
0032   //! Initializes selecting axis according to the input one
0033   Standard_EXPORT void Init(const gp_Ax1& theAxis);
0034 
0035   //! Builds axis according to internal parameters.
0036   //! NOTE: it should be called after Init() method
0037   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
0038 
0039   //! Saves camera definition.
0040   //! Do nothing for axis intersector (not applicable to this volume).
0041   Standard_EXPORT virtual void SetCamera(const Handle(Graphic3d_Camera)& theCamera)
0042     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
0050   //! transformed frustum from scratch. Can be null if reconstruction is not expected furthermore.
0051   Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform(
0052     const Standard_Integer                  theScaleFactor,
0053     const gp_GTrsf&                         theTrsf,
0054     const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
0055 
0056   //! Returns a copy of the intersector transformed using the builder configuration given.
0057   //! Builder is an argument that represents corresponding settings for re-constructing transformed
0058   //! frustum from scratch. In this class, builder is not used and theBuilder parameter is ignored.
0059   Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) CopyWithBuilder(
0060     const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
0061 
0062 public:
0063   //! Intersection test between defined axis and given axis-aligned box
0064   Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3&          theBoxMin,
0065                                                        const SelectMgr_Vec3&          theBoxMax,
0066                                                        const SelectMgr_ViewClipRange& theClipRange,
0067                                                        SelectBasics_PickResult& thePickResult) const
0068     Standard_OVERRIDE;
0069 
0070   //! Returns true if selecting axis intersects axis-aligned bounding box
0071   //! with minimum corner at point theMinPt and maximum at point theMaxPt
0072   Standard_EXPORT virtual Standard_Boolean OverlapsBox(const SelectMgr_Vec3& theBoxMin,
0073                                                        const SelectMgr_Vec3& theBoxMax,
0074                                                        Standard_Boolean*     theInside) const
0075     Standard_OVERRIDE;
0076 
0077   //! Intersection test between defined axis and given point
0078   Standard_EXPORT virtual Standard_Boolean OverlapsPoint(
0079     const gp_Pnt&                  thePnt,
0080     const SelectMgr_ViewClipRange& theClipRange,
0081     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0082 
0083   //! Intersection test between defined axis and given point
0084   Standard_EXPORT virtual Standard_Boolean OverlapsPoint(const gp_Pnt& thePnt) const
0085     Standard_OVERRIDE;
0086 
0087   //! Intersection test between defined axis and given ordered set of points,
0088   //! representing line segments. The test may be considered of interior part or
0089   //! boundary line defined by segments depending on given sensitivity type
0090   Standard_EXPORT virtual Standard_Boolean OverlapsPolygon(
0091     const TColgp_Array1OfPnt&      theArrayOfPnts,
0092     Select3D_TypeOfSensitivity     theSensType,
0093     const SelectMgr_ViewClipRange& theClipRange,
0094     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0095 
0096   //! Checks if selecting axis intersects line segment
0097   Standard_EXPORT virtual Standard_Boolean OverlapsSegment(
0098     const gp_Pnt&                  thePnt1,
0099     const gp_Pnt&                  thePnt2,
0100     const SelectMgr_ViewClipRange& theClipRange,
0101     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0102 
0103   //! Intersection test between defined axis and given triangle. The test may
0104   //! be considered of interior part or boundary line defined by triangle vertices
0105   //! depending on given sensitivity type
0106   Standard_EXPORT virtual Standard_Boolean OverlapsTriangle(
0107     const gp_Pnt&                  thePnt1,
0108     const gp_Pnt&                  thePnt2,
0109     const gp_Pnt&                  thePnt3,
0110     Select3D_TypeOfSensitivity     theSensType,
0111     const SelectMgr_ViewClipRange& theClipRange,
0112     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0113 
0114   //! Intersection test between defined axis and given sphere with center theCenter
0115   //! and radius theRadius
0116   Standard_EXPORT virtual Standard_Boolean OverlapsSphere(const gp_Pnt&       theCenter,
0117                                                           const Standard_Real theRadius,
0118                                                           Standard_Boolean* theInside = NULL) const
0119     Standard_OVERRIDE;
0120 
0121   //! Intersection test between defined axis and given sphere with center theCenter
0122   //! and radius theRadius
0123   Standard_EXPORT virtual Standard_Boolean OverlapsSphere(
0124     const gp_Pnt&                  theCenter,
0125     const Standard_Real            theRadius,
0126     const SelectMgr_ViewClipRange& theClipRange,
0127     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0128 
0129   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
0130   //! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
0131   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
0132     const Standard_Real            theBottomRad,
0133     const Standard_Real            theTopRad,
0134     const Standard_Real            theHeight,
0135     const gp_Trsf&                 theTrsf,
0136     const Standard_Boolean         theIsHollow,
0137     const SelectMgr_ViewClipRange& theClipRange,
0138     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0139 
0140   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses
0141   //! theBottomRad and theTopRad, height theHeight and transformation to apply theTrsf.
0142   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder(
0143     const Standard_Real    theBottomRad,
0144     const Standard_Real    theTopRad,
0145     const Standard_Real    theHeight,
0146     const gp_Trsf&         theTrsf,
0147     const Standard_Boolean theIsHollow,
0148     Standard_Boolean*      theInside = NULL) const Standard_OVERRIDE;
0149 
0150   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0151   //! boolean theIsFilled and transformation to apply theTrsf.
0152   //! The position and orientation of the circle are specified
0153   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0154   Standard_EXPORT virtual Standard_Boolean OverlapsCircle(
0155     const Standard_Real            theRadius,
0156     const gp_Trsf&                 theTrsf,
0157     const Standard_Boolean         theIsFilled,
0158     const SelectMgr_ViewClipRange& theClipRange,
0159     SelectBasics_PickResult&       thePickResult) const Standard_OVERRIDE;
0160 
0161   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0162   //! boolean theIsFilled and transformation to apply theTrsf.
0163   //! The position and orientation of the circle are specified
0164   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0165   Standard_EXPORT virtual Standard_Boolean OverlapsCircle(const Standard_Real    theRadius,
0166                                                           const gp_Trsf&         theTrsf,
0167                                                           const Standard_Boolean theIsFilled,
0168                                                           Standard_Boolean* theInside = NULL) const
0169     Standard_OVERRIDE;
0170 
0171 public:
0172   //! Measures distance between start axis point and given point theCOG.
0173   Standard_EXPORT virtual Standard_Real DistToGeometryCenter(const gp_Pnt& theCOG) const
0174     Standard_OVERRIDE;
0175 
0176   //! Calculates the point on a axis ray that was detected during the run of selection algo by given
0177   //! depth
0178   Standard_EXPORT virtual gp_Pnt DetectedPoint(const Standard_Real theDepth) const
0179     Standard_OVERRIDE;
0180 
0181   //! Returns near point along axis.
0182   Standard_EXPORT virtual const gp_Pnt& GetNearPnt() const Standard_OVERRIDE;
0183 
0184   //! Returns far point along axis (infinite).
0185   Standard_EXPORT virtual const gp_Pnt& GetFarPnt() const Standard_OVERRIDE;
0186 
0187   //! Returns axis direction.
0188   Standard_EXPORT virtual const gp_Dir& GetViewRayDirection() const Standard_OVERRIDE;
0189 
0190   //! Dumps the content of me into the stream
0191   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0192                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0193 
0194 protected:
0195   //! Returns true if selecting axis intersects axis-aligned bounding box
0196   //! with minimum corner at point theBoxMin and maximum at point theBoxMax.
0197   //! Also returns enter and leave time of axis-box intersection.
0198   Standard_EXPORT Standard_Boolean hasIntersection(const SelectMgr_Vec3& theBoxMin,
0199                                                    const SelectMgr_Vec3& theBoxMax,
0200                                                    Standard_Real&        theTimeEnter,
0201                                                    Standard_Real&        theTimeLeave) const;
0202 
0203   //! Returns true if selecting axis intersects point.
0204   //! Also returns time of axis-point intersection.
0205   Standard_EXPORT Standard_Boolean hasIntersection(const gp_Pnt&  thePnt,
0206                                                    Standard_Real& theDepth) const;
0207 
0208   //! Returns true if selecting axis intersects segment.
0209   //! Also saves time of axis-segment intersection and intersection point as pick result.
0210   Standard_EXPORT Standard_Boolean raySegmentDistance(const gp_Pnt&            theSegPnt1,
0211                                                       const gp_Pnt&            theSegPnt2,
0212                                                       SelectBasics_PickResult& thePickResult) const;
0213 
0214   //! Returns true if selecting axis intersects plane.
0215   //! Also saves time of axis-plane intersection and intersection point as pick result.
0216   Standard_EXPORT Standard_Boolean
0217     rayPlaneIntersection(const gp_Vec&            thePlane,
0218                          const gp_Pnt&            thePntOnPlane,
0219                          SelectBasics_PickResult& thePickResult) const;
0220 
0221 private:
0222   gp_Ax1 myAxis;
0223 };
0224 
0225 #endif // _SelectMgr_AxisIntersector_HeaderFile