Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-18 08:30:24

0001 // Copyright (c) 1999-2014 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 _Select3D_SensitivePoly_HeaderFile
0015 #define _Select3D_SensitivePoly_HeaderFile
0016 
0017 #include <gp_Circ.hxx>
0018 #include <Select3D_PointData.hxx>
0019 #include <Select3D_SensitiveSet.hxx>
0020 #include <Select3D_TypeOfSensitivity.hxx>
0021 #include <TColStd_HArray1OfInteger.hxx>
0022 #include <TColgp_HArray1OfPnt.hxx>
0023 
0024 //! Sensitive Entity to make a face selectable.
0025 //! In some cases this class can raise Standard_ConstructionError and
0026 //! Standard_OutOfRange exceptions from its member Select3D_PointData
0027 //! myPolyg.
0028 class Select3D_SensitivePoly : public Select3D_SensitiveSet
0029 {
0030   DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoly, Select3D_SensitiveSet)
0031 public:
0032   //! Constructs a sensitive face object defined by the
0033   //! owner OwnerId, the array of points ThePoints, and
0034   //! the sensitivity type Sensitivity.
0035   //! The array of points is the outer polygon of the geometric face.
0036   Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
0037                                          const TColgp_Array1OfPnt&            thePoints,
0038                                          const Standard_Boolean               theIsBVHEnabled);
0039 
0040   //! Constructs a sensitive face object defined by the
0041   //! owner OwnerId, the array of points ThePoints, and
0042   //! the sensitivity type Sensitivity.
0043   //! The array of points is the outer polygon of the geometric face.
0044   Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
0045                                          const Handle(TColgp_HArray1OfPnt)&   thePoints,
0046                                          const Standard_Boolean               theIsBVHEnabled);
0047 
0048   //! Constructs the sensitive arc object defined by the
0049   //! owner theOwnerId, the circle theCircle, the parameters theU1
0050   //! and theU2, the boolean theIsFilled and the number of points theNbPnts.
0051   //! theU1 and theU2 define the first and last points of the arc on theCircle.
0052   Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
0053                                          const gp_Circ&                       theCircle,
0054                                          const Standard_Real                  theU1,
0055                                          const Standard_Real                  theU2,
0056                                          const Standard_Boolean theIsFilled = Standard_False,
0057                                          const Standard_Integer theNbPnts   = 12);
0058 
0059   //! Constructs a sensitive curve or arc object defined by the
0060   //! owner theOwnerId, the theIsBVHEnabled flag, and the
0061   //! maximum number of points on the curve: theNbPnts.
0062   Standard_EXPORT Select3D_SensitivePoly(const Handle(SelectMgr_EntityOwner)& theOwnerId,
0063                                          const Standard_Boolean               theIsBVHEnabled,
0064                                          const Standard_Integer               theNbPnts = 6);
0065 
0066   //! Checks whether the poly overlaps current selecting volume
0067   Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
0068                                                    SelectBasics_PickResult& thePickResult)
0069     Standard_OVERRIDE;
0070 
0071   //! Returns the amount of segments in poly
0072   Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
0073 
0074   //! Returns the 3D points of the array used at construction time.
0075   void Points3D(Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
0076   {
0077     Standard_Integer aSize = myPolyg.Size();
0078     theHArrayOfPnt         = new TColgp_HArray1OfPnt(1, aSize);
0079     for (Standard_Integer anIndex = 1; anIndex <= aSize; anIndex++)
0080     {
0081       theHArrayOfPnt->SetValue(anIndex, myPolyg.Pnt(anIndex - 1));
0082     }
0083   }
0084 
0085   //! Return array bounds.
0086   void ArrayBounds(Standard_Integer& theLow, Standard_Integer& theUp) const
0087   {
0088     theLow = 0;
0089     theUp  = myPolyg.Size() - 1;
0090   }
0091 
0092   //! Return point.
0093   gp_Pnt GetPoint3d(const Standard_Integer thePntIdx) const
0094   {
0095     return (thePntIdx >= 0 && thePntIdx < myPolyg.Size()) ? myPolyg.Pnt(thePntIdx) : gp_Pnt();
0096   }
0097 
0098   //! Returns bounding box of a polygon. If location
0099   //! transformation is set, it will be applied
0100   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
0101 
0102   //! Returns center of the point set. If location transformation
0103   //! is set, it will be applied
0104   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
0105 
0106   //! Returns the amount of segments of the poly
0107   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
0108 
0109   //! Returns bounding box of segment with index theIdx
0110   Standard_EXPORT virtual Select3D_BndBox3d Box(const Standard_Integer theIdx) const
0111     Standard_OVERRIDE;
0112 
0113   //! Returns geometry center of sensitive entity index theIdx in the vector along
0114   //! the given axis theAxis
0115   Standard_EXPORT virtual Standard_Real Center(const Standard_Integer theIdx,
0116                                                const Standard_Integer theAxis) const
0117     Standard_OVERRIDE;
0118 
0119   //! Swaps items with indexes theIdx1 and theIdx2 in the vector
0120   Standard_EXPORT virtual void Swap(const Standard_Integer theIdx1,
0121                                     const Standard_Integer theIdx2) Standard_OVERRIDE;
0122 
0123   //! Dumps the content of me into the stream
0124   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0125                                         Standard_Integer  theDepth = -1) const Standard_OVERRIDE;
0126 
0127 protected:
0128   //! Checks whether the segment with index theIdx overlaps the current selecting volume
0129   Standard_EXPORT virtual Standard_Boolean overlapsElement(
0130     SelectBasics_PickResult&             thePickResult,
0131     SelectBasics_SelectingVolumeManager& theMgr,
0132     Standard_Integer                     theElemIdx,
0133     Standard_Boolean                     theIsFullInside) Standard_OVERRIDE;
0134 
0135   //! Checks whether the entity with index theIdx is inside the current selecting volume
0136   Standard_EXPORT virtual Standard_Boolean elementIsInside(
0137     SelectBasics_SelectingVolumeManager& theMgr,
0138     Standard_Integer                     theElemIdx,
0139     Standard_Boolean                     theIsFullInside) Standard_OVERRIDE;
0140 
0141   //! Calculates distance from the 3d projection of used-picked screen point
0142   //! to center of the geometry
0143   Standard_EXPORT virtual Standard_Real distanceToCOG(SelectBasics_SelectingVolumeManager& theMgr)
0144     Standard_OVERRIDE;
0145 
0146 protected:
0147   Select3D_PointData               myPolyg;          //!< Points of the poly
0148   mutable gp_Pnt                   myCOG;            //!< Center of the poly
0149   Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
0150   Select3D_BndBox3d                myBndBox;         //!< Bounding box of the poly
0151   // clang-format off
0152   Select3D_TypeOfSensitivity       mySensType;       //!< Type of sensitivity: boundary or interior
0153   mutable Standard_Boolean         myIsComputed;     //!< Is true if all the points and data structures of polygon are initialized
0154   // clang-format on
0155 };
0156 
0157 DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
0158 
0159 #endif // _Select3D_SensitivePoly_HeaderFile