0025234: Implementing LBVH builder
[occt.git] / src / BVH / BVH_PrimitiveSet.hxx
1 // Created on: 2013-12-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-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 _BVH_PrimitiveSet_Header
17 #define _BVH_PrimitiveSet_Header
18
19 #include <BVH_Object.hxx>
20 #include <BVH_Builder.hxx>
21
22 //! Set of abstract geometric primitives.
23 template<class T, int N>
24 class BVH_PrimitiveSet : public BVH_Object<T, N>, public BVH_Set<T, N>
25 {
26 protected:
27
28   using BVH_Set<T, N>::Box;
29
30 public:
31
32   //! Creates set of abstract primitives.
33   BVH_PrimitiveSet();
34
35   //! Releases resources of set of abstract primitives.
36   virtual ~BVH_PrimitiveSet();
37
38 public:
39
40   //! Returns AABB of primitive set.
41   virtual BVH_Box<T, N> Box() const;
42
43   //! Returns constructed BVH tree.
44   virtual const NCollection_Handle<BVH_Tree<T, N> >& BVH();
45
46   //! Returns the method (builder) to construct BVH.
47   virtual const NCollection_Handle<BVH_Builder<T, N> >& Builder() const;
48
49   //! Sets the method (builder) to construct BVH.
50   virtual void SetBuilder (NCollection_Handle<BVH_Builder<T, N> >& theBuilder);
51
52 protected:
53
54   //! Updates BVH of primitive set.
55   virtual void Update();
56
57 protected:
58
59   NCollection_Handle<BVH_Tree<T, N> >    myBVH;     //!< Constructed bottom-level BVH
60   NCollection_Handle<BVH_Builder<T, N> > myBuilder; //!< Builder for bottom-level BVH
61
62   mutable BVH_Box<T, N> myBox; //!< Cached bounding box of geometric primitives
63
64 };
65
66 #include <BVH_PrimitiveSet.lxx>
67
68 #endif // _BVH_PrimitiveSet_Header