0028793: Visualization, TKV3d - make BVH_Builder::Build() const for propagating build...
[occt.git] / src / OpenGl / OpenGl_BVHClipPrimitiveSet.hxx
1 // Created on: 2013-12-25
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 1999-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 _OpenGl_BVHClipPrimitiveSet_HeaderFile
17 #define _OpenGl_BVHClipPrimitiveSet_HeaderFile
18
19 #include <BVH_PrimitiveSet.hxx>
20 #include <NCollection_Array1.hxx>
21 #include <NCollection_IndexedMap.hxx>
22
23 #include <OpenGl_Structure.hxx>
24
25 //! Set of OpenGl_Structures for building BVH tree.
26 class OpenGl_BVHClipPrimitiveSet : public BVH_PrimitiveSet<Standard_Real, 3>
27 {
28 protected:
29
30   using BVH_PrimitiveSet<Standard_Real, 3>::Box;
31
32 public:
33
34   //! Creates an empty primitive set for BVH clipping.
35   OpenGl_BVHClipPrimitiveSet();
36
37   //! Returns total number of structures.
38   virtual Standard_Integer Size() const Standard_OVERRIDE;
39
40   //! Returns AABB of the structure.
41   virtual Graphic3d_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
42
43   //! Calculates center of the AABB along given axis.
44   virtual Standard_Real Center (const Standard_Integer theIdx,
45                                 const Standard_Integer theAxis) const Standard_OVERRIDE;
46
47   //! Swaps structures with the given indices.
48   virtual void Swap (const Standard_Integer theIdx1,
49                      const Standard_Integer theIdx2) Standard_OVERRIDE;
50
51   //! Adds structure to the set.
52   //! @return true if structure added, otherwise returns false (structure already in the set).
53   Standard_Boolean Add (const OpenGl_Structure* theStruct);
54
55   //! Removes the given structure from the set.
56   //! @return true if structure removed, otherwise returns false (structure is not in the set).
57   Standard_Boolean Remove (const OpenGl_Structure* theStruct);
58
59   //! Cleans the whole primitive set.
60   void Clear();
61
62   //! Returns the structure corresponding to the given ID.
63   const OpenGl_Structure* GetStructureById (Standard_Integer theId);
64
65 private:
66
67   NCollection_IndexedMap<const OpenGl_Structure*> myStructs;    //!< Indexed map of structures.
68
69 };
70
71 #endif // _OpenGl_BVHClipPrimitiveSet_HeaderFile