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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #ifndef _Select3D_SensitiveGroup_HeaderFile
19 #define _Select3D_SensitiveGroup_HeaderFile
21 #include <Standard.hxx>
22 #include <Standard_DefineHandle.hxx>
23 #include <Standard_Type.hxx>
25 #include <Select3D_EntitySequence.hxx>
26 #include <Select3D_SensitiveEntity.hxx>
27 #include <Select3D_SensitiveSet.hxx>
28 #include <Handle_SelectBasics_EntityOwner.hxx>
29 #include <SelectMgr_SelectingVolumeManager.hxx>
31 class SelectBasics_EntityOwner;
32 class TopLoc_Location;
35 //! A framework to define selection of a sensitive group
36 //! by a sensitive entity which is a set of 3D sensitive entities.
37 //! Remark: 2 modes are possible for rectangle selection
38 //! the group is considered selected
39 //! 1) when all the entities inside are selected in the rectangle
40 //! 2) only one entity inside is selected by the rectangle
41 //! By default the "Match All entities" mode is set.
42 class Select3D_SensitiveGroup : public Select3D_SensitiveSet
46 //! Constructs an empty sensitive group object.
47 //! This is a set of sensitive 3D entities. The sensitive
48 //! entities will be defined using the function Add to fill
49 //! the entity owner OwnerId. If MatchAll is false, nothing can be added.
50 Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId,
51 const Standard_Boolean theIsMustMatchAll = Standard_True);
53 //! Constructs a sensitive group object defined by the list
54 //! TheList and the entity owner OwnerId. If MatchAll is false, nothing is done.
55 Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId,
56 Select3D_EntitySequence& theEntities,
57 const Standard_Boolean theIsMustMatchAll = Standard_True);
59 //! Adds the list of sensitive entities LL to the empty
60 //! sensitive group object created at construction time.
61 Standard_EXPORT void Add (Select3D_EntitySequence& theEntities);
63 //! Adds the sensitive entity aSensitive to the non-empty
64 //! sensitive group object created at construction time.
65 Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
67 Standard_EXPORT void Remove (const Handle(Select3D_SensitiveEntity)& theSensitive);
69 //! Removes all sensitive entities from the list used at the
70 //! time of construction, or added using the function Add.
71 Standard_EXPORT void Clear();
73 //! Returns true if the sensitive entity aSensitive is in
74 //! the list used at the time of construction, or added using the function Add.
75 Standard_EXPORT Standard_Boolean IsIn (const Handle(Select3D_SensitiveEntity)& theSensitive) const;
77 //! Sets the requirement that all sensitive entities in the
78 //! list used at the time of construction, or added using
79 //! the function Add must be matched.
80 void SetMatchType (const Standard_Boolean theIsMustMatchAll);
82 //! Returns true if all sensitive entities in the list used
83 //! at the time of construction, or added using the function Add must be matched.
84 Standard_Boolean MustMatchAll() const;
86 //! Checks whether the group overlaps current selecting volume
87 Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
88 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
90 //! Returns the amount of sub-entities
91 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
93 Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
95 //! Sets the owner for all entities in group
96 Standard_EXPORT void Set (const Handle(SelectBasics_EntityOwner)& theOwnerId);
98 //! Gets group content
99 const Select3D_EntitySequence& GetEntities() const;
101 //! Returns bounding box of the group. If location transformation
102 //! is set, it will be applied
103 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
105 //! Returns center of entity set. If location transformation
106 //! is set, it will be applied
107 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
109 //! Returns bounding box of sensitive entity with index theIdx
110 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
112 //! Returns geometry center of sensitive entity index theIdx in
113 //! the vector along the given axis theAxis
114 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
115 const Standard_Integer theAxis) const Standard_OVERRIDE;
117 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
118 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
119 const Standard_Integer theIdx2) Standard_OVERRIDE;
121 //! Returns the length of vector of sensitive entities
122 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
124 DEFINE_STANDARD_RTTI(Select3D_SensitiveGroup)
128 //! Checks whether the entity with index theIdx overlaps the current selecting volume
129 virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
130 Standard_Integer theElemIdx,
131 Standard_Real& theMatchDepth) Standard_OVERRIDE;
133 //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
134 virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
138 Select3D_EntitySequence myEntities; //!< Grouped sensitive entities
139 Standard_Boolean myMustMatchAll; //!< Determines whether all entities in the group should be overlapped or not
140 gp_Pnt myCenter; //!< Center of geometry of the group
141 mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the group
142 NCollection_Vector<Standard_Integer> myBVHPrimIndexes; //!< Vector of sub-entities indexes for BVH tree build
145 DEFINE_STANDARD_HANDLE(Select3D_SensitiveGroup, Select3D_SensitiveEntity)
147 #include <Select3D_SensitiveGroup.lxx>
149 #endif // _Select3D_SensitiveGroup_HeaderFile