1 // Created on: 2013-12-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-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 _BVH_Builder_Header
17 #define _BVH_Builder_Header
19 #include <BVH_Set.hxx>
20 #include <BVH_BinaryTree.hxx>
22 //! A non-template class for using as base for BVH_Builder
23 //! (just to have a named base class).
24 class BVH_BuilderTransient : public Standard_Transient
26 DEFINE_STANDARD_RTTIEXT(BVH_BuilderTransient, Standard_Transient)
29 //! Returns the maximum depth of constructed BVH.
30 Standard_Integer MaxTreeDepth() const { return myMaxTreeDepth; }
32 //! Returns the maximum number of sub-elements in the leaf.
33 Standard_Integer LeafNodeSize() const { return myLeafNodeSize; }
37 //! Creates new abstract BVH builder.
38 BVH_BuilderTransient (const Standard_Integer theLeafNodeSize,
39 const Standard_Integer theMaxTreeDepth)
40 : myMaxTreeDepth (theMaxTreeDepth),
41 myLeafNodeSize (theLeafNodeSize) {}
45 Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
46 Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
50 //! Performs construction of BVH tree using bounding
51 //! boxes (AABBs) of abstract objects.
52 //! \tparam T Numeric data type
53 //! \tparam N Vector dimension
54 template<class T, int N>
55 class BVH_Builder : public BVH_BuilderTransient
59 //! Builds BVH using specific algorithm.
60 virtual void Build (BVH_Set<T, N>* theSet,
61 BVH_Tree<T, N>* theBVH,
62 const BVH_Box<T, N>& theBox) const = 0;
66 //! Creates new abstract BVH builder.
67 BVH_Builder (const Standard_Integer theLeafNodeSize,
68 const Standard_Integer theMaxTreeDepth)
69 : BVH_BuilderTransient (theLeafNodeSize, theMaxTreeDepth) {}
71 //! Updates depth of constructed BVH tree.
72 void updateDepth (BVH_Tree<T, N>* theBVH,
73 const Standard_Integer theLevel) const
75 if (theLevel > theBVH->myDepth)
77 theBVH->myDepth = theLevel;
83 #endif // _BVH_Builder_Header