Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2014-05-22
0002 // Created by: Varvara POSKONINA
0003 // Copyright (c) 2005-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _SelectMgr_TriangularFrustum_HeaderFile
0017 #define _SelectMgr_TriangularFrustum_HeaderFile
0018 
0019 #include <SelectMgr_Frustum.hxx>
0020 
0021 //! This class contains representation of triangular selecting frustum, created in case
0022 //! of polyline selection, and algorithms for overlap detection between selecting frustum and sensitive entities.
0023 //! Overlap detection tests are implemented according to the terms of separating axis theorem (SAT).
0024 //! NOTE: the object of this class can be created only as part of SelectMgr_TriangularFrustumSet.
0025 class SelectMgr_TriangularFrustum : public SelectMgr_Frustum<3>
0026 {
0027 public:
0028 
0029   //! Auxiliary structure to define selection triangle
0030   struct SelectionTriangle
0031   {
0032     gp_Pnt2d Points[3];
0033   };
0034 
0035 public:
0036 
0037   //! Destructor.
0038   Standard_EXPORT virtual ~SelectMgr_TriangularFrustum();
0039 
0040   //! Initializes selection triangle by input points
0041   Standard_EXPORT void Init (const gp_Pnt2d& theP1,
0042                              const gp_Pnt2d& theP2,
0043                              const gp_Pnt2d& theP3);
0044 
0045   //! Creates new triangular frustum with bases of triangles with vertices theP1, theP2 and theP3
0046   //! projections onto near and far view frustum planes (only for triangular frustums)
0047   //! NOTE: it should be called after Init() method
0048   Standard_EXPORT virtual void Build() Standard_OVERRIDE;
0049 
0050   //! Returns FALSE (not applicable to this volume).
0051   virtual Standard_Boolean IsScalable() const Standard_OVERRIDE { return false; }
0052 
0053   //! Returns a copy of the frustum transformed according to the matrix given
0054   Standard_EXPORT virtual Handle(SelectMgr_BaseIntersector) ScaleAndTransform (const Standard_Integer theScale,
0055                                                                                const gp_GTrsf& theTrsf,
0056                                                                                const Handle(SelectMgr_FrustumBuilder)& theBuilder) const Standard_OVERRIDE;
0057 
0058 public: //! @name SAT Tests for different objects
0059 
0060   //! SAT intersection test between defined volume and given axis-aligned box
0061   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPnt,
0062                                                         const SelectMgr_Vec3& theMaxPnt,
0063                                                         const SelectMgr_ViewClipRange& theClipRange,
0064                                                         SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0065 
0066   //! Returns true if selecting volume is overlapped by axis-aligned bounding box
0067   //! with minimum corner at point theMinPt and maximum at point theMaxPt
0068   Standard_EXPORT virtual Standard_Boolean OverlapsBox (const SelectMgr_Vec3& theMinPt,
0069                                                         const SelectMgr_Vec3& theMaxPt,
0070                                                         Standard_Boolean* theInside) const Standard_OVERRIDE;
0071 
0072   //! Intersection test between defined volume and given point
0073   Standard_EXPORT virtual Standard_Boolean OverlapsPoint (const gp_Pnt& thePnt,
0074                                                           const SelectMgr_ViewClipRange& theClipRange,
0075                                                           SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0076 
0077   //! Always returns FALSE (not applicable to this selector).
0078   virtual Standard_Boolean OverlapsPoint (const gp_Pnt& ) const Standard_OVERRIDE
0079   {
0080     return Standard_False;
0081   }
0082 
0083   //! SAT intersection test between defined volume and given ordered set of points,
0084   //! representing line segments. The test may be considered of interior part or
0085   //! boundary line defined by segments depending on given sensitivity type
0086   Standard_EXPORT virtual Standard_Boolean OverlapsPolygon (const TColgp_Array1OfPnt& theArrayOfPnts,
0087                                                             Select3D_TypeOfSensitivity theSensType,
0088                                                             const SelectMgr_ViewClipRange& theClipRange,
0089                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0090 
0091   //! Checks if line segment overlaps selecting frustum
0092   Standard_EXPORT virtual Standard_Boolean OverlapsSegment (const gp_Pnt& thePnt1,
0093                                                             const gp_Pnt& thePnt2,
0094                                                             const SelectMgr_ViewClipRange& theClipRange,
0095                                                             SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0096 
0097   //! SAT intersection test between defined volume and given triangle. The test may
0098   //! be considered of interior part or boundary line defined by triangle vertices
0099   //! depending on given sensitivity type
0100   Standard_EXPORT virtual Standard_Boolean OverlapsTriangle (const gp_Pnt& thePnt1,
0101                                                              const gp_Pnt& thePnt2,
0102                                                              const gp_Pnt& thePnt3,
0103                                                              Select3D_TypeOfSensitivity theSensType,
0104                                                              const SelectMgr_ViewClipRange& theClipRange,
0105                                                              SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0106 
0107   //! Returns true if selecting volume is overlapped by 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                                                            Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0112 
0113   //! Returns true if selecting volume is overlapped by sphere with center theCenter
0114   //! and radius theRadius
0115   Standard_EXPORT virtual Standard_Boolean OverlapsSphere (const gp_Pnt& theCenter,
0116                                                            const Standard_Real theRadius,
0117                                                            const SelectMgr_ViewClipRange& theClipRange,
0118                                                            SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0119 
0120   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
0121   //! and theTopRad, height theHeight and transformation to apply theTrsf.
0122   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (const Standard_Real theBottomRad,
0123                                                              const Standard_Real theTopRad,
0124                                                              const Standard_Real theHeight,
0125                                                              const gp_Trsf& theTrsf,
0126                                                              const Standard_Boolean theIsHollow,
0127                                                              const SelectMgr_ViewClipRange& theClipRange,
0128                                                              SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0129 
0130   //! Returns true if selecting volume is overlapped by cylinder (or cone) with radiuses theBottomRad
0131   //! and theTopRad, height theHeight and transformation to apply theTrsf.
0132   Standard_EXPORT virtual Standard_Boolean OverlapsCylinder (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                                                              Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0138 
0139   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0140   //! boolean theIsFilled and transformation to apply theTrsf.
0141   //! The position and orientation of the circle are specified
0142   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0143   Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
0144                                                            const gp_Trsf& theTrsf,
0145                                                            const Standard_Boolean theIsFilled,
0146                                                            const SelectMgr_ViewClipRange& theClipRange,
0147                                                            SelectBasics_PickResult& thePickResult) const Standard_OVERRIDE;
0148 
0149   //! Returns true if selecting volume is overlapped by circle with radius theRadius,
0150   //! boolean theIsFilled and transformation to apply theTrsf.
0151   //! The position and orientation of the circle are specified
0152   //! via theTrsf transformation for gp::XOY() with center in gp::Origin().
0153   Standard_EXPORT virtual Standard_Boolean OverlapsCircle (const Standard_Real theRadius,
0154                                                            const gp_Trsf& theTrsf,
0155                                                            const Standard_Boolean theIsFilled,
0156                                                            Standard_Boolean* theInside = NULL) const Standard_OVERRIDE;
0157 
0158 public:
0159 
0160   //! Nullifies the handle to corresponding builder instance to prevent memory leaks
0161   Standard_EXPORT void Clear();
0162 
0163   //! Stores plane equation coefficients (in the following form:
0164   //! Ax + By + Cz + D = 0) to the given vector
0165   Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
0166 
0167   //! Dumps the content of me into the stream
0168   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0169 
0170 protected:
0171 
0172   //! Creates an empty triangular frustum.
0173   Standard_EXPORT SelectMgr_TriangularFrustum();
0174 
0175 private:
0176 
0177   void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum) const;
0178 
0179 protected:
0180 
0181   SelectionTriangle mySelTriangle; //!< parameters of selection triangle (it is used to build triangle frustum)
0182 
0183 public:
0184 
0185   DEFINE_STANDARD_RTTIEXT(SelectMgr_TriangularFrustum, SelectMgr_Frustum<3>)
0186   friend class SelectMgr_TriangularFrustumSet;
0187 };
0188 
0189 #endif // _SelectMgr_TriangularFrustum_HeaderFile