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_SensitiveEntitySet_HeaderFile |
17 | #define _SelectMgr_SensitiveEntitySet_HeaderFile |
18 | |
19 | #include <BVH_PrimitiveSet.hxx> |
20 | |
21 | #include <NCollection_Sequence.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 | //! This class is used to store all calculated sensitive entites of one selectable |
30 | //! object. It provides an interface for building BVH tree which is used to speed-up |
31 | //! the performance of searching for overlap among sensitives of one selectable object |
32 | class SelectMgr_SensitiveEntitySet : public BVH_PrimitiveSet<Standard_Real, 3> |
33 | { |
34 | public: |
35 | |
36 | SelectMgr_SensitiveEntitySet(); |
37 | |
38 | virtual ~SelectMgr_SensitiveEntitySet() {}; |
39 | |
40 | //! Adds new entity to the set and marks BVH tree for rebuild |
7ab15952 |
41 | void Append (const Handle(SelectMgr_SensitiveEntity)& theEntity); |
f751596e |
42 | |
43 | //! Adds every entity of selection theSelection to the set and marks |
44 | //! BVH tree for rebuild |
45 | void Append (const Handle(SelectMgr_Selection)& theSelection); |
46 | |
47 | //! Removes entity from the set and marks BVH tree for rebuild |
7ab15952 |
48 | void Remove (const Handle(SelectMgr_SensitiveEntity)& theEntity); |
f751596e |
49 | |
50 | //! Removes every entity of selection theSelection from the set |
51 | //! and marks BVH tree for rebuild |
52 | void Remove (const Handle(SelectMgr_Selection)& theSelection); |
53 | |
54 | //! Returns bounding box of entity with index theIdx |
55 | virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE; |
56 | |
57 | //! Returns geometry center of sensitive entity index theIdx |
58 | //! along the given axis theAxis |
59 | virtual Standard_Real Center (const Standard_Integer theIndex, |
60 | const Standard_Integer theAxis) const Standard_OVERRIDE; |
61 | |
62 | //! Swaps items with indexes theIdx1 and theIdx2 |
63 | virtual void Swap (const Standard_Integer theIndex1, |
64 | const Standard_Integer theIndex2) Standard_OVERRIDE; |
65 | |
66 | //! Returns the amount of entities |
67 | virtual Standard_Integer Size() const Standard_OVERRIDE; |
68 | |
69 | //! Returns the entity with index theIndex in the set |
7ab15952 |
70 | const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const; |
f751596e |
71 | |
72 | private: |
73 | |
7ab15952 |
74 | NCollection_Sequence<Handle(SelectMgr_SensitiveEntity)> myEntities; //!< A sequence of calculated sensitives of the object |
75 | NCollection_Sequence<Standard_Integer> myEntityIdxs; //!< Cached indexes for faster BVH build |
f751596e |
76 | }; |
77 | |
78 | #endif // _SelectMgr_SensitiveEntitySet_HeaderFile |