1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Select3D_SensitivePoly_HeaderFile
15 #define _Select3D_SensitivePoly_HeaderFile
17 #include <Select3D_PointData.hxx>
18 #include <Select3D_SensitiveSet.hxx>
19 #include <Select3D_TypeOfSensitivity.hxx>
20 #include <TColStd_HArray1OfInteger.hxx>
21 #include <TColgp_HArray1OfPnt.hxx>
23 class Standard_ConstructionError;
24 class Standard_OutOfRange;
26 //! Sensitive Entity to make a face selectable.
27 //! In some cases this class can raise Standard_ConstructionError and
28 //! Standard_OutOfRange exceptions from its member Select3D_PointData
30 class Select3D_SensitivePoly : public Select3D_SensitiveSet
32 DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoly, Select3D_SensitiveSet)
35 //! Constructs a sensitive face object defined by the
36 //! owner OwnerId, the array of points ThePoints, and
37 //! the sensitivity type Sensitivity.
38 //! The array of points is the outer polygon of the geometric face.
39 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
40 const TColgp_Array1OfPnt& thePoints,
41 const Standard_Boolean theIsBVHEnabled);
43 //! Constructs a sensitive face object defined by the
44 //! owner OwnerId, the array of points ThePoints, and
45 //! the sensitivity type Sensitivity.
46 //! The array of points is the outer polygon of the geometric face.
47 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
48 const Handle(TColgp_HArray1OfPnt)& thePoints,
49 const Standard_Boolean theIsBVHEnabled);
51 //! Constructs the sensitive circle object defined by the
52 //! owner OwnerId, the circle Circle, the Boolean
53 //! FilledCircle and the number of points NbOfPoints.
54 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
55 const Standard_Boolean theIsBVHEnabled,
56 const Standard_Integer theNbPnts = 6);
58 //! Returns the amount of segments in poly
59 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
61 //! Returns the 3D points of the array used at construction time.
62 void Points3D (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
64 Standard_Integer aSize = myPolyg.Size();
65 theHArrayOfPnt = new TColgp_HArray1OfPnt (1,aSize);
66 for(Standard_Integer anIndex = 1; anIndex <= aSize; anIndex++)
68 theHArrayOfPnt->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
72 //! Returns bounding box of a polygon. If location
73 //! transformation is set, it will be applied
74 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
76 //! Returns center of the point set. If location transformation
77 //! is set, it will be applied
78 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
80 //! Returns the amount of segments of the poly
81 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
83 //! Returns bounding box of segment with index theIdx
84 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
86 //! Returns geometry center of sensitive entity index theIdx in the vector along
87 //! the given axis theAxis
88 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
89 const Standard_Integer theAxis) const Standard_OVERRIDE;
91 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
92 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
93 const Standard_Integer theIdx2) Standard_OVERRIDE;
97 //! Checks whether the segment with index theIdx overlaps the current selecting volume
98 virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
99 Standard_Integer theElemIdx,
100 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
102 //! Checks whether the entity with index theIdx is inside the current selecting volume
103 virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
104 const Standard_Integer theElemIdx) Standard_OVERRIDE;
106 //! Calculates distance from the 3d projection of used-picked screen point
107 //! to center of the geometry
108 virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
112 Select3D_PointData myPolyg; //!< Points of the poly
113 mutable gp_Pnt myCOG; //!< Center of the poly
114 Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
115 Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
116 mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
119 DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
121 #endif // _Select3D_SensitivePoly_HeaderFile