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 <NCollection_Handle.hxx>
19 #include <Standard.hxx>
20 #include <Standard_Type.hxx>
21 #include <Standard_Type.hxx>
23 #include <TColStd_HArray1OfInteger.hxx>
24 #include <TColgp_HArray1OfPnt.hxx>
26 #include <Select3D_PointData.hxx>
27 #include <Select3D_Pnt.hxx>
28 #include <Select3D_SensitiveSet.hxx>
29 #include <Select3D_TypeOfSensitivity.hxx>
31 #include <Handle_SelectBasics_EntityOwner.hxx>
33 class Standard_ConstructionError;
34 class Standard_OutOfRange;
35 class SelectBasics_EntityOwner;
37 //! Sensitive Entity to make a face selectable.
38 //! In some cases this class can raise Standard_ConstructionError and
39 //! Standard_OutOfRange exceptions from its member Select3D_PointData
41 class Select3D_SensitivePoly : public Select3D_SensitiveSet
45 //! Constructs a sensitive face object defined by the
46 //! owner OwnerId, the array of points ThePoints, and
47 //! the sensitivity type Sensitivity.
48 //! The array of points is the outer polygon of the geometric face.
49 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
50 const TColgp_Array1OfPnt& thePoints,
51 const Standard_Boolean theIsBVHEnabled);
53 //! Constructs a sensitive face object defined by the
54 //! owner OwnerId, the array of points ThePoints, and
55 //! the sensitivity type Sensitivity.
56 //! The array of points is the outer polygon of the geometric face.
57 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
58 const Handle(TColgp_HArray1OfPnt)& thePoints,
59 const Standard_Boolean theIsBVHEnabled);
61 //! Constructs the sensitive circle object defined by the
62 //! owner OwnerId, the circle Circle, the Boolean
63 //! FilledCircle and the number of points NbOfPoints.
64 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
65 const Standard_Boolean theIsBVHEnabled,
66 const Standard_Integer theNbPnts = 6);
68 //! Returns the amount of segments in poly
69 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
71 //! Returns the 3D points of the array used at construction time.
72 Standard_EXPORT void Points3D (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
74 //! Returns bounding box of a polygon. If location
75 //! transformation is set, it will be applied
76 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
78 //! Returns center of the point set. If location transformation
79 //! is set, it will be applied
80 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
82 //! Returns the amount of segments of the poly
83 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
85 //! Returns bounding box of segment with index theIdx
86 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
88 //! Returns geometry center of sensitive entity index theIdx in the vector along
89 //! the given axis theAxis
90 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
91 const Standard_Integer theAxis) const Standard_OVERRIDE;
93 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
94 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
95 const Standard_Integer theIdx2) Standard_OVERRIDE;
97 DEFINE_STANDARD_RTTI (Select3D_SensitivePoly, Select3D_SensitiveSet)
101 //! Checks whether the segment with index theIdx overlaps the current selecting volume
102 virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
103 Standard_Integer theElemIdx,
104 Standard_Real& theMatchDepth) Standard_OVERRIDE;
106 //! Checks whether the entity with index theIdx is inside the current selecting volume
107 virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
108 const Standard_Integer theElemIdx) Standard_OVERRIDE;
110 //! Calculates distance from the 3d projection of used-picked screen point
111 //! to center of the geometry
112 virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
116 Select3D_PointData myPolyg; //!< Points of the poly
117 mutable gp_Pnt myCOG; //!< Center of the poly
118 Handle_TColStd_HArray1OfInteger mySegmentIndexes; //!< Segment indexes for BVH tree build
119 Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
120 mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
123 DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
125 #include <Select3D_SensitivePoly.lxx>
127 #endif // _Select3D_SensitivePoly_HeaderFile