f751596e |
1 | // Created on: 1998-04-16 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | |
18 | #ifndef _Select3D_SensitiveGroup_HeaderFile |
19 | #define _Select3D_SensitiveGroup_HeaderFile |
20 | |
21 | #include <Standard.hxx> |
ec357c5c |
22 | #include <Standard_Type.hxx> |
f751596e |
23 | #include <Standard_Type.hxx> |
24 | |
25 | #include <Select3D_EntitySequence.hxx> |
26 | #include <Select3D_SensitiveEntity.hxx> |
27 | #include <Select3D_SensitiveSet.hxx> |
f751596e |
28 | #include <SelectMgr_SelectingVolumeManager.hxx> |
29 | |
30 | class SelectBasics_EntityOwner; |
31 | class TopLoc_Location; |
32 | |
33 | |
34 | //! A framework to define selection of a sensitive group |
35 | //! by a sensitive entity which is a set of 3D sensitive entities. |
36 | //! Remark: 2 modes are possible for rectangle selection |
37 | //! the group is considered selected |
38 | //! 1) when all the entities inside are selected in the rectangle |
39 | //! 2) only one entity inside is selected by the rectangle |
40 | //! By default the "Match All entities" mode is set. |
41 | class Select3D_SensitiveGroup : public Select3D_SensitiveSet |
42 | { |
43 | public: |
44 | |
45 | //! Constructs an empty sensitive group object. |
46 | //! This is a set of sensitive 3D entities. The sensitive |
47 | //! entities will be defined using the function Add to fill |
48 | //! the entity owner OwnerId. If MatchAll is false, nothing can be added. |
49 | Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
50 | const Standard_Boolean theIsMustMatchAll = Standard_True); |
51 | |
52 | //! Constructs a sensitive group object defined by the list |
53 | //! TheList and the entity owner OwnerId. If MatchAll is false, nothing is done. |
54 | Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId, |
55 | Select3D_EntitySequence& theEntities, |
56 | const Standard_Boolean theIsMustMatchAll = Standard_True); |
57 | |
58 | //! Adds the list of sensitive entities LL to the empty |
59 | //! sensitive group object created at construction time. |
60 | Standard_EXPORT void Add (Select3D_EntitySequence& theEntities); |
61 | |
62 | //! Adds the sensitive entity aSensitive to the non-empty |
63 | //! sensitive group object created at construction time. |
64 | Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive); |
65 | |
66 | Standard_EXPORT void Remove (const Handle(Select3D_SensitiveEntity)& theSensitive); |
67 | |
68 | //! Removes all sensitive entities from the list used at the |
69 | //! time of construction, or added using the function Add. |
79104795 |
70 | Standard_EXPORT void Clear() Standard_OVERRIDE; |
f751596e |
71 | |
72 | //! Returns true if the sensitive entity aSensitive is in |
73 | //! the list used at the time of construction, or added using the function Add. |
74 | Standard_EXPORT Standard_Boolean IsIn (const Handle(Select3D_SensitiveEntity)& theSensitive) const; |
75 | |
76 | //! Sets the requirement that all sensitive entities in the |
77 | //! list used at the time of construction, or added using |
78 | //! the function Add must be matched. |
79 | void SetMatchType (const Standard_Boolean theIsMustMatchAll); |
80 | |
81 | //! Returns true if all sensitive entities in the list used |
82 | //! at the time of construction, or added using the function Add must be matched. |
83 | Standard_Boolean MustMatchAll() const; |
84 | |
85 | //! Checks whether the group overlaps current selecting volume |
86 | Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr, |
87 | SelectBasics_PickResult& thePickResult) Standard_OVERRIDE; |
88 | |
89 | //! Returns the amount of sub-entities |
90 | Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE; |
91 | |
92 | Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE; |
93 | |
94 | //! Sets the owner for all entities in group |
79104795 |
95 | Standard_EXPORT void Set (const Handle(SelectBasics_EntityOwner)& theOwnerId) Standard_OVERRIDE; |
f751596e |
96 | |
97 | //! Gets group content |
98 | const Select3D_EntitySequence& GetEntities() const; |
99 | |
100 | //! Returns bounding box of the group. If location transformation |
101 | //! is set, it will be applied |
102 | Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; |
103 | |
104 | //! Returns center of entity set. If location transformation |
105 | //! is set, it will be applied |
106 | Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE; |
107 | |
108 | //! Returns bounding box of sensitive entity with index theIdx |
109 | Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE; |
110 | |
111 | //! Returns geometry center of sensitive entity index theIdx in |
112 | //! the vector along the given axis theAxis |
113 | Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx, |
114 | const Standard_Integer theAxis) const Standard_OVERRIDE; |
115 | |
116 | //! Swaps items with indexes theIdx1 and theIdx2 in the vector |
117 | Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1, |
118 | const Standard_Integer theIdx2) Standard_OVERRIDE; |
119 | |
120 | //! Returns the length of vector of sensitive entities |
121 | Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE; |
122 | |
92efcf78 |
123 | DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveGroup,Select3D_SensitiveSet) |
f751596e |
124 | |
125 | private: |
126 | |
127 | //! Checks whether the entity with index theIdx overlaps the current selecting volume |
128 | virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr, |
129 | Standard_Integer theElemIdx, |
130 | Standard_Real& theMatchDepth) Standard_OVERRIDE; |
131 | |
2157d6ac |
132 | //! Checks whether the entity with index theIdx is inside the current selecting volume |
133 | virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr, |
134 | const Standard_Integer theElemIdx) Standard_OVERRIDE; |
135 | |
f751596e |
136 | //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry |
137 | virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE; |
138 | |
139 | private: |
140 | |
141 | Select3D_EntitySequence myEntities; //!< Grouped sensitive entities |
142 | Standard_Boolean myMustMatchAll; //!< Determines whether all entities in the group should be overlapped or not |
143 | gp_Pnt myCenter; //!< Center of geometry of the group |
144 | mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the group |
145 | NCollection_Vector<Standard_Integer> myBVHPrimIndexes; //!< Vector of sub-entities indexes for BVH tree build |
146 | }; |
147 | |
148 | DEFINE_STANDARD_HANDLE(Select3D_SensitiveGroup, Select3D_SensitiveEntity) |
149 | |
150 | #include <Select3D_SensitiveGroup.lxx> |
151 | |
152 | #endif // _Select3D_SensitiveGroup_HeaderFile |