1 // Created on: 2014-08-15
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _SelectMgr_SensitiveEntitySet_HeaderFile
17 #define _SelectMgr_SensitiveEntitySet_HeaderFile
19 #include <BVH_PrimitiveSet.hxx>
21 #include <NCollection_IndexedMap.hxx>
22 #include <NCollection_Handle.hxx>
24 #include <Select3D_BndBox3d.hxx>
26 #include <SelectMgr_SensitiveEntity.hxx>
27 #include <SelectMgr_Selection.hxx>
29 typedef NCollection_IndexedMap<Handle(SelectMgr_SensitiveEntity)> SelectMgr_IndexedMapOfHSensitive;
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>
38 Standard_EXPORT SelectMgr_SensitiveEntitySet();
40 virtual ~SelectMgr_SensitiveEntitySet() {};
42 //! Adds new entity to the set and marks BVH tree for rebuild
43 Standard_EXPORT void Append (const Handle(SelectMgr_SensitiveEntity)& theEntity);
45 //! Adds every entity of selection theSelection to the set and marks
46 //! BVH tree for rebuild
47 Standard_EXPORT void Append (const Handle(SelectMgr_Selection)& theSelection);
49 //! Removes every entity of selection theSelection from the set
50 //! and marks BVH tree for rebuild
51 Standard_EXPORT void Remove (const Handle(SelectMgr_Selection)& theSelection);
53 //! Returns bounding box of entity with index theIdx
54 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
56 //! Returns geometry center of sensitive entity index theIdx
57 //! along the given axis theAxis
58 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
59 const Standard_Integer theAxis) const Standard_OVERRIDE;
61 //! Swaps items with indexes theIdx1 and theIdx2
62 Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
63 const Standard_Integer theIndex2) Standard_OVERRIDE;
65 //! Returns the amount of entities
66 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
68 //! Returns the entity with index theIndex in the set
69 Standard_EXPORT const Handle(SelectMgr_SensitiveEntity)& GetSensitiveById (const Standard_Integer theIndex) const;
73 SelectMgr_IndexedMapOfHSensitive mySensitives; //!< Map of entities and its corresponding index in BVH
76 #endif // _SelectMgr_SensitiveEntitySet_HeaderFile