1 // Created on: 2013-12-25
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 1999-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 _Graphic3d_BvhCStructureSet_HeaderFile
17 #define _Graphic3d_BvhCStructureSet_HeaderFile
19 #include <BVH_PrimitiveSet3d.hxx>
20 #include <Graphic3d_BndBox3d.hxx>
21 #include <NCollection_IndexedMap.hxx>
23 class Graphic3d_CStructure;
25 //! Set of OpenGl_Structures for building BVH tree.
26 class Graphic3d_BvhCStructureSet : public BVH_PrimitiveSet3d
28 DEFINE_STANDARD_RTTIEXT(Graphic3d_BvhCStructureSet, BVH_PrimitiveSet3d)
31 using BVH_PrimitiveSet3d::Box;
35 //! Creates an empty primitive set for BVH clipping.
36 Standard_EXPORT Graphic3d_BvhCStructureSet();
38 //! Returns total number of structures.
39 Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
41 //! Returns AABB of the structure.
42 Standard_EXPORT virtual Graphic3d_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
44 //! Calculates center of the AABB along given axis.
45 Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
46 const Standard_Integer theAxis) const Standard_OVERRIDE;
48 //! Swaps structures with the given indices.
49 Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
50 const Standard_Integer theIdx2) Standard_OVERRIDE;
52 //! Adds structure to the set.
53 //! @return true if structure added, otherwise returns false (structure already in the set).
54 Standard_EXPORT Standard_Boolean Add (const Graphic3d_CStructure* theStruct);
56 //! Removes the given structure from the set.
57 //! @return true if structure removed, otherwise returns false (structure is not in the set).
58 Standard_EXPORT Standard_Boolean Remove (const Graphic3d_CStructure* theStruct);
60 //! Cleans the whole primitive set.
61 Standard_EXPORT void Clear();
63 //! Returns the structure corresponding to the given ID.
64 Standard_EXPORT const Graphic3d_CStructure* GetStructureById (Standard_Integer theId);
66 //! Access directly a collection of structures.
67 const NCollection_IndexedMap<const Graphic3d_CStructure*>& Structures() const { return myStructs; }
71 NCollection_IndexedMap<const Graphic3d_CStructure*> myStructs; //!< Indexed map of structures.
75 #endif // _Graphic3d_BvhCStructureSet_HeaderFile