f751596e |
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_SelectableObjectSet_HeaderFile |
17 | #define _SelectMgr_SelectableObjectSet_HeaderFile |
18 | |
19 | #include <BVH_PrimitiveSet.hxx> |
20 | |
21 | #include <Select3D_BndBox3d.hxx> |
f751596e |
22 | #include <SelectMgr_SelectableObject.hxx> |
23 | #include <SelectMgr_VectorTypes.hxx> |
24 | |
d4aaad5b |
25 | #include <NCollection_IndexedMap.hxx> |
26 | |
f751596e |
27 | //! The purpose of this class is to organize all selectable objects into |
28 | //! data structure, allowing to build BVH tree. For selectable objects |
29 | //! binned BVH builder is used with 32 bins and 1 element per leaf. |
30 | class SelectMgr_SelectableObjectSet : public BVH_PrimitiveSet<Standard_Real, 3> |
31 | { |
d4aaad5b |
32 | Handle(SelectMgr_SelectableObject) EMPTY_OBJ; |
33 | |
f751596e |
34 | public: |
35 | |
36 | //! Creates new empty objects set and initializes BVH tree |
37 | //! builder to Binned builder with 1 element per list |
38 | SelectMgr_SelectableObjectSet(); |
39 | |
d4aaad5b |
40 | //! Releases resources of selectable object set. |
41 | virtual ~SelectMgr_SelectableObjectSet() { } |
f751596e |
42 | |
43 | //! Adds new object to the set and marks BVH tree for rebuild |
44 | void Append (const Handle(SelectMgr_SelectableObject)& theObject); |
45 | |
46 | //! Removes object theObject from set and marks BVH tree for rebuild |
47 | void Remove (const Handle(SelectMgr_SelectableObject)& theObject); |
48 | |
49 | //! Returns bounding box of object with index theIndex |
50 | virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE; |
51 | |
52 | //! Returns center of object with index theIndex in the set |
53 | //! along the given axis theAxis |
54 | virtual Standard_Real Center (const Standard_Integer theIndex, |
55 | const Standard_Integer theAxis) const Standard_OVERRIDE; |
56 | |
57 | //! Swaps items with indexes theIndex1 and theIndex2 in the set |
58 | virtual void Swap (const Standard_Integer theIndex1, |
59 | const Standard_Integer theIndex2) Standard_OVERRIDE; |
60 | |
61 | //! Returns size of objects set |
62 | virtual Standard_Integer Size() const Standard_OVERRIDE; |
63 | |
64 | //! Returns object from set by theIndex given |
65 | const Handle(SelectMgr_SelectableObject)& GetObjectById (const Standard_Integer theIndex) const; |
66 | |
67 | //! Returns true if this objects set contains theObject given |
7ab15952 |
68 | Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const; |
f751596e |
69 | |
70 | private: |
71 | |
d4aaad5b |
72 | NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects; |
f751596e |
73 | }; |
74 | |
75 | #endif // _SelectMgr_SelectableObjectSet_HeaderFile |