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>
32 class Standard_ConstructionError;
33 class Standard_OutOfRange;
34 class SelectBasics_EntityOwner;
36 //! Sensitive Entity to make a face selectable.
37 //! In some cases this class can raise Standard_ConstructionError and
38 //! Standard_OutOfRange exceptions from its member Select3D_PointData
40 class Select3D_SensitivePoly : public Select3D_SensitiveSet
44 //! Constructs a sensitive face object defined by the
45 //! owner OwnerId, the array of points ThePoints, and
46 //! the sensitivity type Sensitivity.
47 //! The array of points is the outer polygon of the geometric face.
48 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
49 const TColgp_Array1OfPnt& thePoints,
50 const Standard_Boolean theIsBVHEnabled);
52 //! Constructs a sensitive face object defined by the
53 //! owner OwnerId, the array of points ThePoints, and
54 //! the sensitivity type Sensitivity.
55 //! The array of points is the outer polygon of the geometric face.
56 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
57 const Handle(TColgp_HArray1OfPnt)& thePoints,
58 const Standard_Boolean theIsBVHEnabled);
60 //! Constructs the sensitive circle object defined by the
61 //! owner OwnerId, the circle Circle, the Boolean
62 //! FilledCircle and the number of points NbOfPoints.
63 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectBasics_EntityOwner)& theOwnerId,
64 const Standard_Boolean theIsBVHEnabled,
65 const Standard_Integer theNbPnts = 6);
67 //! Returns the amount of segments in poly
68 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
70 //! Returns the 3D points of the array used at construction time.
71 Standard_EXPORT void Points3D (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt);
73 //! Returns bounding box of a polygon. If location
74 //! transformation is set, it will be applied
75 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
77 //! Returns center of the point set. If location transformation
78 //! is set, it will be applied
79 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
81 //! Returns the amount of segments of the poly
82 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
84 //! Returns bounding box of segment with index theIdx
85 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
87 //! Returns geometry center of sensitive entity index theIdx in the vector along
88 //! the given axis theAxis
89 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
90 const Standard_Integer theAxis) const Standard_OVERRIDE;
92 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
93 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
94 const Standard_Integer theIdx2) Standard_OVERRIDE;
96 DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoly,Select3D_SensitiveSet)
100 //! Checks whether the segment with index theIdx overlaps the current selecting volume
101 virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
102 Standard_Integer theElemIdx,
103 Standard_Real& theMatchDepth) Standard_OVERRIDE;
105 //! Checks whether the entity with index theIdx is inside the current selecting volume
106 virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
107 const Standard_Integer theElemIdx) Standard_OVERRIDE;
109 //! Calculates distance from the 3d projection of used-picked screen point
110 //! to center of the geometry
111 virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
115 Select3D_PointData myPolyg; //!< Points of the poly
116 mutable gp_Pnt myCOG; //!< Center of the poly
117 Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
118 Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
119 mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
122 DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
124 #include <Select3D_SensitivePoly.lxx>
126 #endif // _Select3D_SensitivePoly_HeaderFile