8c712afc555a724b2fcd9d3c2bdd6fad86eaf6d0
[occt.git] / src / SelectMgr / SelectMgr_SensitiveEntitySet.hxx
1 // Created on: 2014-08-15
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _SelectMgr_SensitiveEntitySet_HeaderFile
17 #define _SelectMgr_SensitiveEntitySet_HeaderFile
18
19 #include <BVH_PrimitiveSet.hxx>
20
21 #include <NCollection_IndexedMap.hxx>
22 #include <NCollection_Handle.hxx>
23
24 #include <Select3D_BndBox3d.hxx>
25
26 #include <SelectMgr_SensitiveEntity.hxx>
27 #include <SelectMgr_Selection.hxx>
28
29 typedef NCollection_IndexedMap<Handle(SelectMgr_SensitiveEntity)> SelectMgr_IndexedMapOfHSensitive;
30
31 //! This class is used to store all calculated sensitive entites of one selectable
32 //! object. It provides an interface for building BVH tree which is used to speed-up
33 //! the performance of searching for overlap among sensitives of one selectable object
34 class SelectMgr_SensitiveEntitySet : public BVH_PrimitiveSet<Standard_Real, 3>
35 {
36   Handle(SelectMgr_SensitiveEntity) EMPTY_ENT;
37
38 public:
39
40   Standard_EXPORT SelectMgr_SensitiveEntitySet();
41
42   virtual ~SelectMgr_SensitiveEntitySet() {};
43
44   //! Adds new entity to the set and marks BVH tree for rebuild
45   Standard_EXPORT void Append (const Handle(SelectMgr_SensitiveEntity)& theEntity);
46
47   //! Adds every entity of selection theSelection to the set and marks
48   //! BVH tree for rebuild
49   Standard_EXPORT void Append (const Handle(SelectMgr_Selection)& theSelection);
50
51   //! Removes every entity of selection theSelection from the set
52   //! and marks BVH tree for rebuild
53   Standard_EXPORT void Remove (const Handle(SelectMgr_Selection)& theSelection);
54
55   //! Returns bounding box of entity with index theIdx
56   Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
57
58   //! Returns geometry center of sensitive entity index theIdx
59   //! along the given axis theAxis
60   Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
61                                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
62
63   //! Swaps items with indexes theIdx1 and theIdx2
64   Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
65                                      const Standard_Integer theIndex2) Standard_OVERRIDE;
66
67   //! Returns the amount of entities
68   Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
69
70   //! Returns the entity with index theIndex in the set
71   Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const;
72
73 private:
74
75   SelectMgr_IndexedMapOfHSensitive mySensitives;     //!< Map of entities and its corresponding index in BVH
76 };
77
78 #endif // _SelectMgr_SensitiveEntitySet_HeaderFile