0024750: Replace instantiations of TCollection generic classes by NCollection templat...
[occt.git] / src / Select3D / Select3D_InteriorSensitivePointSet.hxx
1 // Created on: 2014-08-15
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Select3D_InteriorSensitivePointSet_HeaderFile
17 #define _Select3D_InteriorSensitivePointSet_HeaderFile
18
19 #include <NCollection_Vector.hxx>
20
21 #include <Handle_SelectBasics_EntityOwner.hxx>
22 #include <TColgp_HArray1OfPnt.hxx>
23 #include <TColStd_HArray1OfInteger.hxx>
24
25 #include <Select3D_SensitivePoly.hxx>
26 #include <Select3D_SensitiveSet.hxx>
27
28 class gp_Pnt;
29 class SelectBasics_EntityOwner;
30
31 typedef NCollection_Vector<Handle(Select3D_SensitivePoly)> Select3D_VectorOfHPoly;
32
33 //! This class handles the selection of arbitrary point set with internal type of sensitivity.
34 //! The main principle is to split the point set given onto planar convex polygons and search
35 //! for the overlap with one or more of them through traverse of BVH tree.
36 class Select3D_InteriorSensitivePointSet : public Select3D_SensitiveSet
37 {
38 public:
39
40   //! Splits the given point set thePoints onto planar convex polygons
41   Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
42                                                       const TColgp_Array1OfPnt& thePoints);
43
44   //! Initializes the given array theHArrayOfPnt by 3d coordinates of vertices of the
45   //! whole point set
46   Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
47
48   //! Returns the length of vector of planar convex polygons
49   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
50
51   //! Returns bounding box of planar convex polygon with index theIdx
52   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
53
54   //! Returns geometry center of planar convex polygon with index
55   //! theIdx in the vector along the given axis theAxis
56   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
57                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
58
59   //! Swaps items with indexes theIdx1 and theIdx2 in the vector
60   Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
61                                      const Standard_Integer theIdx2) Standard_OVERRIDE;
62
63   //! Returns bounding box of the point set. If location
64   //! transformation is set, it will be applied
65   Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
66
67   //! Returns center of the point set. If location
68   //! transformation is set, it will be applied
69   Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
70
71   //! Returns the amount of points in set
72   Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
73
74   DEFINE_STANDARD_RTTI(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
75
76 protected:
77
78   //! Checks whether the planar convex polygon with index theIdx
79   //! in myPlanarPolygons overlaps the current selecting volume
80   Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
81                                                             Standard_Integer theElemIdx,
82                                                             Standard_Real& theMatchDepth) Standard_OVERRIDE;
83
84   //! Checks whether the entity with index theIdx is inside the current selecting volume
85   Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
86                                                             const Standard_Integer               theElemIdx) Standard_OVERRIDE;
87
88   //! Calculates distance from the 3d projection of used-picked
89   //! screen point to center of the geometry
90   Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
91
92 protected:
93
94   Select3D_VectorOfHPoly          myPlanarPolygons;     //!< Vector of planar polygons
95   Handle_TColStd_HArray1OfInteger myPolygonsIdxs;       //!< Indexes array for BVH calculation
96   gp_Pnt                          myCOG;                //!< Center of the point set
97   Select3D_BndBox3d               myBndBox;             //!< Bounding box of the point set
98 };
99
100 DEFINE_STANDARD_HANDLE(Select3D_InteriorSensitivePointSet, Select3D_SensitiveSet)
101
102 #endif // _Select3D_InteriorSensitivePointSet_HeaderFile