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; }
35 //! Returns parallel flag.
36 inline Standard_Boolean IsParallel() const
41 //! Set parallel flag contolling possibility of parallel execution.
42 inline void SetParallel(const Standard_Boolean isParallel)
44 myIsParallel = isParallel;
49 //! Creates new abstract BVH builder.
50 BVH_BuilderTransient (const Standard_Integer theLeafNodeSize,
51 const Standard_Integer theMaxTreeDepth)
52 : myMaxTreeDepth (theMaxTreeDepth),
53 myLeafNodeSize (theLeafNodeSize),
54 myIsParallel (Standard_False) {}
58 Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
59 Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
60 Standard_Boolean myIsParallel; //!< Parallel execution flag.
63 //! Performs construction of BVH tree using bounding
64 //! boxes (AABBs) of abstract objects.
65 //! \tparam T Numeric data type
66 //! \tparam N Vector dimension
67 template<class T, int N>
68 class BVH_Builder : public BVH_BuilderTransient
72 //! Builds BVH using specific algorithm.
73 virtual void Build (BVH_Set<T, N>* theSet,
74 BVH_Tree<T, N>* theBVH,
75 const BVH_Box<T, N>& theBox) const = 0;
79 //! Creates new abstract BVH builder.
80 BVH_Builder (const Standard_Integer theLeafNodeSize,
81 const Standard_Integer theMaxTreeDepth)
82 : BVH_BuilderTransient (theLeafNodeSize, theMaxTreeDepth) {}
84 //! Updates depth of constructed BVH tree.
85 void updateDepth (BVH_Tree<T, N>* theBVH,
86 const Standard_Integer theLevel) const
88 if (theLevel > theBVH->myDepth)
90 theBVH->myDepth = theLevel;
96 #endif // _BVH_Builder_Header