0028849: [Regression to 7.1.0] Exception in Boolean operation
[occt.git] / src / Select3D / Select3D_SensitiveGroup.hxx
CommitLineData
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
f751596e 17#ifndef _Select3D_SensitiveGroup_HeaderFile
18#define _Select3D_SensitiveGroup_HeaderFile
19
f751596e 20#include <Select3D_EntitySequence.hxx>
21#include <Select3D_SensitiveEntity.hxx>
22#include <Select3D_SensitiveSet.hxx>
f751596e 23#include <SelectMgr_SelectingVolumeManager.hxx>
24
f751596e 25//! A framework to define selection of a sensitive group
26//! by a sensitive entity which is a set of 3D sensitive entities.
27//! Remark: 2 modes are possible for rectangle selection
28//! the group is considered selected
29//! 1) when all the entities inside are selected in the rectangle
30//! 2) only one entity inside is selected by the rectangle
31//! By default the "Match All entities" mode is set.
32class Select3D_SensitiveGroup : public Select3D_SensitiveSet
33{
0609d8ee 34 DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveGroup, Select3D_SensitiveSet)
f751596e 35public:
36
37 //! Constructs an empty sensitive group object.
38 //! This is a set of sensitive 3D entities. The sensitive
39 //! entities will be defined using the function Add to fill
40 //! the entity owner OwnerId. If MatchAll is false, nothing can be added.
41 Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId,
42 const Standard_Boolean theIsMustMatchAll = Standard_True);
43
44 //! Constructs a sensitive group object defined by the list
45 //! TheList and the entity owner OwnerId. If MatchAll is false, nothing is done.
46 Standard_EXPORT Select3D_SensitiveGroup (const Handle(SelectBasics_EntityOwner)& theOwnerId,
47 Select3D_EntitySequence& theEntities,
48 const Standard_Boolean theIsMustMatchAll = Standard_True);
49
50 //! Adds the list of sensitive entities LL to the empty
51 //! sensitive group object created at construction time.
52 Standard_EXPORT void Add (Select3D_EntitySequence& theEntities);
53
54 //! Adds the sensitive entity aSensitive to the non-empty
55 //! sensitive group object created at construction time.
56 Standard_EXPORT void Add (const Handle(Select3D_SensitiveEntity)& theSensitive);
57
58 Standard_EXPORT void Remove (const Handle(Select3D_SensitiveEntity)& theSensitive);
59
60 //! Removes all sensitive entities from the list used at the
61 //! time of construction, or added using the function Add.
79104795 62 Standard_EXPORT void Clear() Standard_OVERRIDE;
f751596e 63
64 //! Returns true if the sensitive entity aSensitive is in
65 //! the list used at the time of construction, or added using the function Add.
66 Standard_EXPORT Standard_Boolean IsIn (const Handle(Select3D_SensitiveEntity)& theSensitive) const;
67
68 //! Sets the requirement that all sensitive entities in the
69 //! list used at the time of construction, or added using
70 //! the function Add must be matched.
0609d8ee 71 void SetMatchType (const Standard_Boolean theIsMustMatchAll) { myMustMatchAll = theIsMustMatchAll; }
f751596e 72
73 //! Returns true if all sensitive entities in the list used
74 //! at the time of construction, or added using the function Add must be matched.
0609d8ee 75 Standard_Boolean MustMatchAll() const { return myMustMatchAll; }
f751596e 76
77 //! Checks whether the group overlaps current selecting volume
78 Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
79 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
80
81 //! Returns the amount of sub-entities
82 Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
83
84 Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
85
86 //! Sets the owner for all entities in group
79104795 87 Standard_EXPORT void Set (const Handle(SelectBasics_EntityOwner)& theOwnerId) Standard_OVERRIDE;
f751596e 88
89 //! Gets group content
0609d8ee 90 const Select3D_EntitySequence& GetEntities() const { return myEntities; }
f751596e 91
92 //! Returns bounding box of the group. If location transformation
93 //! is set, it will be applied
94 Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
95
96 //! Returns center of entity set. If location transformation
97 //! is set, it will be applied
98 Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
99
100 //! Returns bounding box of sensitive entity with index theIdx
101 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
102
103 //! Returns geometry center of sensitive entity index theIdx in
104 //! the vector along the given axis theAxis
105 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
106 const Standard_Integer theAxis) const Standard_OVERRIDE;
107
108 //! Swaps items with indexes theIdx1 and theIdx2 in the vector
109 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
110 const Standard_Integer theIdx2) Standard_OVERRIDE;
111
112 //! Returns the length of vector of sensitive entities
113 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
114
f751596e 115private:
116
117 //! Checks whether the entity with index theIdx overlaps the current selecting volume
118 virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
119 Standard_Integer theElemIdx,
120 Standard_Real& theMatchDepth) Standard_OVERRIDE;
121
2157d6ac 122 //! Checks whether the entity with index theIdx is inside the current selecting volume
123 virtual Standard_Boolean elementIsInside (SelectBasics_SelectingVolumeManager& theMgr,
124 const Standard_Integer theElemIdx) Standard_OVERRIDE;
125
f751596e 126 //! Calculates distance from the 3d projection of used-picked screen point to center of the geometry
127 virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
128
129private:
130
131 Select3D_EntitySequence myEntities; //!< Grouped sensitive entities
132 Standard_Boolean myMustMatchAll; //!< Determines whether all entities in the group should be overlapped or not
133 gp_Pnt myCenter; //!< Center of geometry of the group
134 mutable Select3D_BndBox3d myBndBox; //!< Bounding box of the group
135 NCollection_Vector<Standard_Integer> myBVHPrimIndexes; //!< Vector of sub-entities indexes for BVH tree build
136};
137
138DEFINE_STANDARD_HANDLE(Select3D_SensitiveGroup, Select3D_SensitiveEntity)
139
f751596e 140#endif // _Select3D_SensitiveGroup_HeaderFile