0031458: Visualization - refine classes across Prs3d and StdPrs packages
[occt.git] / src / Select3D / Select3D_SensitivePoly.hxx
CommitLineData
f751596e 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _Select3D_SensitivePoly_HeaderFile
15#define _Select3D_SensitivePoly_HeaderFile
16
f751596e 17#include <Select3D_PointData.hxx>
f751596e 18#include <Select3D_SensitiveSet.hxx>
19#include <Select3D_TypeOfSensitivity.hxx>
0609d8ee 20#include <TColStd_HArray1OfInteger.hxx>
21#include <TColgp_HArray1OfPnt.hxx>
f751596e 22
23class Standard_ConstructionError;
24class Standard_OutOfRange;
f751596e 25
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
29//! myPolyg.
30class Select3D_SensitivePoly : public Select3D_SensitiveSet
31{
0609d8ee 32 DEFINE_STANDARD_RTTIEXT(Select3D_SensitivePoly, Select3D_SensitiveSet)
f751596e 33public:
34
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.
0ef04197 39 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
f751596e 40 const TColgp_Array1OfPnt& thePoints,
41 const Standard_Boolean theIsBVHEnabled);
42
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.
0ef04197 47 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
f751596e 48 const Handle(TColgp_HArray1OfPnt)& thePoints,
49 const Standard_Boolean theIsBVHEnabled);
50
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.
0ef04197 54 Standard_EXPORT Select3D_SensitivePoly (const Handle(SelectMgr_EntityOwner)& theOwnerId,
f751596e 55 const Standard_Boolean theIsBVHEnabled,
56 const Standard_Integer theNbPnts = 6);
57
58 //! Returns the amount of segments in poly
fe758dbe 59 Standard_EXPORT virtual Standard_Integer NbSubElements() const Standard_OVERRIDE;
f751596e 60
61 //! Returns the 3D points of the array used at construction time.
0609d8ee 62 void Points3D (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
63 {
64 Standard_Integer aSize = myPolyg.Size();
65 theHArrayOfPnt = new TColgp_HArray1OfPnt (1,aSize);
66 for(Standard_Integer anIndex = 1; anIndex <= aSize; anIndex++)
67 {
68 theHArrayOfPnt->SetValue (anIndex, myPolyg.Pnt (anIndex-1));
69 }
70 }
f751596e 71
7f24b768 72 //! Return array bounds.
73 void ArrayBounds (Standard_Integer& theLow,
74 Standard_Integer& theUp) const
75 {
76 theLow = 0;
77 theUp = myPolyg.Size() - 1;
78 }
79
80 //! Return point.
81 gp_Pnt GetPoint3d (const Standard_Integer thePntIdx) const
82 {
83 return (thePntIdx >= 0 && thePntIdx < myPolyg.Size())
84 ? myPolyg.Pnt (thePntIdx)
85 : gp_Pnt();
86 }
87
f751596e 88 //! Returns bounding box of a polygon. If location
89 //! transformation is set, it will be applied
90 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
91
92 //! Returns center of the point set. If location transformation
93 //! is set, it will be applied
94 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
95
96 //! Returns the amount of segments of the poly
97 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
98
99 //! Returns bounding box of segment with index theIdx
100 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
101
102 //! Returns geometry center of sensitive entity index theIdx in the vector along
103 //! the given axis theAxis
104 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
105 const Standard_Integer theAxis) const Standard_OVERRIDE;
106
107 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
108 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
109 const Standard_Integer theIdx2) Standard_OVERRIDE;
110
bc73b006 111 //! Dumps the content of me into the stream
112 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
113
25333d45 114protected:
f751596e 115
116 //! Checks whether the segment with index theIdx overlaps the current selecting volume
25333d45 117 Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_PickResult& thePickResult,
118 SelectBasics_SelectingVolumeManager& theMgr,
119 Standard_Integer theElemIdx,
120 Standard_Boolean theIsFullInside) Standard_OVERRIDE;
f751596e 121
2157d6ac 122 //! Checks whether the entity with index theIdx is inside the current selecting volume
25333d45 123 Standard_EXPORT virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
124 Standard_Integer theElemIdx,
125 Standard_Boolean theIsFullInside) Standard_OVERRIDE;
2157d6ac 126
f751596e 127 //! Calculates distance from the 3d projection of used-picked screen point
128 //! to center of the geometry
25333d45 129 Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
f751596e 130
131protected:
132
133 Select3D_PointData myPolyg; //!< Points of the poly
134 mutable gp_Pnt myCOG; //!< Center of the poly
35c0599a 135 Handle(TColStd_HArray1OfInteger) mySegmentIndexes; //!< Segment indexes for BVH tree build
f751596e 136 Select3D_BndBox3d myBndBox; //!< Bounding box of the poly
2157d6ac 137 mutable Standard_Boolean myIsComputed; //!< Is true if all the points and data structures of polygon are initialized
f751596e 138};
139
140DEFINE_STANDARD_HANDLE(Select3D_SensitivePoly, Select3D_SensitiveSet)
141
f751596e 142#endif // _Select3D_SensitivePoly_HeaderFile