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_SelectableObjectSet_HeaderFile
17 #define _SelectMgr_SelectableObjectSet_HeaderFile
19 #include <BVH_PrimitiveSet.hxx>
21 #include <Select3D_BndBox3d.hxx>
22 #include <SelectMgr_SelectableObject.hxx>
23 #include <SelectMgr_VectorTypes.hxx>
25 #include <NCollection_IndexedMap.hxx>
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>
34 //! Creates new empty objects set and initializes BVH tree
35 //! builder to Binned builder with 1 element per list
36 Standard_EXPORT SelectMgr_SelectableObjectSet();
38 //! Releases resources of selectable object set.
39 virtual ~SelectMgr_SelectableObjectSet() { }
41 //! Adds new object to the set and marks BVH tree for rebuild.
42 //! @return true if structure added, otherwise returns false (structure already in the set).
43 Standard_EXPORT Standard_Boolean Append (const Handle(SelectMgr_SelectableObject)& theObject);
45 //! Removes object theObject from set and marks BVH tree for rebuild.
46 //! @return true if structure removed, otherwise returns false (structure is not in the set).
47 Standard_EXPORT Standard_Boolean Remove (const Handle(SelectMgr_SelectableObject)& theObject);
49 //! Returns bounding box of object with index theIndex
50 Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIndex) const Standard_OVERRIDE;
52 //! Returns center of object with index theIndex in the set
53 //! along the given axis theAxis
54 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIndex,
55 const Standard_Integer theAxis) const Standard_OVERRIDE;
57 //! Swaps items with indexes theIndex1 and theIndex2 in the set
58 Standard_EXPORT virtual void Swap (const Standard_Integer theIndex1,
59 const Standard_Integer theIndex2) Standard_OVERRIDE;
61 //! Returns size of objects set
62 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
64 //! Returns object from set by theIndex given
65 const Handle(SelectMgr_SelectableObject)& GetObjectById (const Standard_Integer theIndex) const
67 return myObjects.FindKey (theIndex + 1);
70 //! Returns true if this objects set contains theObject given
71 Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
73 return myObjects.Contains (theObject);
78 NCollection_IndexedMap<Handle(SelectMgr_SelectableObject)> myObjects;
81 #endif // _SelectMgr_SelectableObjectSet_HeaderFile