Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0033   //! Constructs a sensitive face object defined by the
0034   //! owner OwnerId, the array of points ThePoints, and
0035   //! the sensitivity type Sensitivity.
0036   //! The array of points is the outer polygon of the geometric face.
0037   Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
0038                                           const TColgp_Array1OfPnt& thePoints,
0039                                           const Standard_Boolean theIsBVHEnabled);
0040 
0041   //! Constructs a sensitive face object defined by the
0042   //! owner OwnerId, the array of points ThePoints, and
0043   //! the sensitivity type Sensitivity.
0044   //! The array of points is the outer polygon of the geometric face.
0045   Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
0046                                           const Handle(TColgp_HArray1OfPnt)& thePoints,
0047                                           const Standard_Boolean theIsBVHEnabled);
0048 
0049   //! Constructs the sensitive arc object defined by the
0050   //! owner theOwnerId, the circle theCircle, the parameters theU1
0051   //! and theU2, the boolean theIsFilled and the number of points theNbPnts.
0052   //! theU1 and theU2 define the first and last points of the arc on theCircle.
0053   Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
0054                                           const gp_Circ& theCircle,
0055                                           const Standard_Real theU1,
0056                                           const Standard_Real theU2,
0057                                           const Standard_Boolean theIsFilled = Standard_False,
0058                                           const Standard_Integer theNbPnts = 12);
0059 
0060   //! Constructs a sensitive curve or arc object defined by the
0061   //! owner theOwnerId, the theIsBVHEnabled flag, and the
0062   //! maximum number of points on the curve: theNbPnts.
0063   Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
0064                                           const Standard_Boolean theIsBVHEnabled,
0065                                           const Standard_Integer theNbPnts = 6);
0066 
0067   //! Checks whether the poly overlaps current selecting volume
0068   Standard_EXPORT  virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
0069                                                      SelectBasics_PickResult& thePickResult) 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,
0087                     Standard_Integer& theUp) const
0088   {
0089     theLow = 0;
0090     theUp = myPolyg.Size() - 1;
0091   }
0092 
0093   //! Return point.
0094   gp_Pnt GetPoint3d (const Standard_Integer thePntIdx) const
0095   {
0096     return (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
0097          ? myPolyg.Pnt (thePntIdx)
0098          : gp_Pnt();
0099   }
0100 
0101   //! Returns bounding box of a polygon. If location
0102   //! transformation is set, it will be applied
0103   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
0104 
0105   //! Returns center of the point set. If location transformation
0106   //! is set, it will be applied
0107   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
0108 
0109   //! Returns the amount of segments of the poly
0110   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
0111 
0112   //! Returns bounding box of segment with index theIdx
0113   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
0114 
0115   //! Returns geometry center of sensitive entity index theIdx in the vector along
0116   //! the given axis theAxis
0117   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
0118                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
0119 
0120   //! Swaps items with indexes theIdx1 and theIdx2 in the vector
0121   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
0122                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
0123 
0124   //! Dumps the content of me into the stream
0125   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0126 
0127 protected:
0128 
0129   //! Checks whether the segment with index theIdx overlaps the current selecting volume
0130   Standard_EXPORT virtual Standard_Boolean overlapsElement (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 (SelectBasics_SelectingVolumeManager& theMgr,
0137                                                             Standard_Integer theElemIdx,
0138                                                             Standard_Boolean theIsFullInside) Standard_OVERRIDE;
0139 
0140   //! Calculates distance from the 3d projection of used-picked screen point
0141   //! to center of the geometry
0142   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
0143 
0144 protected:
0145 
0146   Select3D_PointData               myPolyg;          //!< Points of the poly
0147   mutable gp_Pnt                   myCOG;            //!< Center of the poly
0148   Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
0149   Select3D_BndBox3d                myBndBox;         //!< Bounding box of the poly
0150   Select3D_TypeOfSensitivity       mySensType;       //!< Type of sensitivity: boundary or interior
0151   mutable Standard_Boolean         myIsComputed;     //!< Is true if all the points and data structures of polygon are initialized
0152 };
0153 
0154 DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
0155 
0156 #endif // _Select3D_SensitivePoly_HeaderFile