1 // Created on: 2014-08-15
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Select3D_InteriorSensitivePointSet_HeaderFile
17 #define _Select3D_InteriorSensitivePointSet_HeaderFile
19 #include <NCollection_Vector.hxx>
21 #include <Handle_SelectBasics_EntityOwner.hxx>
22 #include <Handle_TColgp_HArray1OfPnt.hxx>
23 #include <Handle_TColStd_HArray1OfInteger.hxx>
25 #include <Select3D_SensitivePoly.hxx>
26 #include <Select3D_SensitiveSet.hxx>
29 class SelectBasics_EntityOwner;
30 class TColgp_Array1OfPnt;
31 class TColgp_HArray1OfPnt;
32 class TColStd_HArray1OfInteger;
34 typedef NCollection_Vector<Handle(Select3D_SensitivePoly)> Select3D_VectorOfHPoly;
36 //! This class handles the selection of arbitrary point set with internal type of sensitivity.
37 //! The main principle is to split the point set given onto planar convex polygons and search
38 //! for the overlap with one or more of them through traverse of BVH tree.
39 class Select3D_InteriorSensitivePointSet : public Select3D_SensitiveSet
43 //! Splits the given point set thePoints onto planar convex polygons
44 Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
45 const TColgp_Array1OfPnt& thePoints);
47 //! Initializes the given array theHArrayOfPnt by 3d coordinates of vertices of the
49 Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
51 //! Returns the length of vector of planar convex polygons
52 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
54 //! Returns bounding box of planar convex polygon with index theIdx
55 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
57 //! Returns geometry center of planar convex polygon with index
58 //! theIdx in the vector along the given axis theAxis
59 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
60 const Standard_Integer theAxis) const Standard_OVERRIDE;
62 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
63 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
64 const Standard_Integer theIdx2) Standard_OVERRIDE;
66 //! Returns bounding box of the point set. If location
67 //! transformation is set, it will be applied
68 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
70 //! Returns center of the point set. If location
71 //! transformation is set, it will be applied
72 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
74 //! Returns the amount of points in set
75 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
77 DEFINE_STANDARD_RTTI(Select3D_InteriorSensitivePointSet)
81 //! Checks whether the planar convex polygon with index theIdx
82 //! in myPlanarPolygons overlaps the current selecting volume
83 Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
84 Standard_Integer theElemIdx,
85 Standard_Real& theMatchDepth) Standard_OVERRIDE;
87 //! Checks whether the entity with index theIdx is inside the current selecting volume
88 Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
89 const Standard_Integer theElemIdx) Standard_OVERRIDE;
91 //! Calculates distance from the 3d projection of used-picked
92 //! screen point to center of the geometry
93 Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
97 Select3D_VectorOfHPoly myPlanarPolygons; //!< Vector of planar polygons
98 Handle_TColStd_HArray1OfInteger myPolygonsIdxs; //!< Indexes array for BVH calculation
99 gp_Pnt myCOG; //!< Center of the point set
100 Select3D_BndBox3d myBndBox; //!< Bounding box of the point set
103 DEFINE_STANDARD_HANDLE(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
105 #endif // _Select3D_InteriorSensitivePointSet_HeaderFile