0027590: Visualization, Ray Tracing - port to quad BVH trees (QBVH)
[occt.git] / src / BVH / BVH_Builder.hxx
CommitLineData
3c4e78f2 1// Created on: 2013-12-20
2// Created by: Denis BOGOLEPOV
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
3c4e78f2 4//
5// This file is part of Open CASCADE Technology software library.
6//
d5f74e42 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
3c4e78f2 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_Builder_Header
17#define _BVH_Builder_Header
18
19#include <BVH_Set.hxx>
f2474958 20#include <BVH_BinaryTree.hxx>
3c4e78f2 21
679d3878 22namespace BVH
3c4e78f2 23{
24 //! Minimum node size to split.
25 const Standard_Real THE_NODE_MIN_SIZE = 1e-5;
26}
27
679d3878 28//! Performs construction of BVH tree using bounding
29//! boxes (AABBs) of abstract objects.
30//! \tparam T Numeric data type
31//! \tparam N Vector dimension
3c4e78f2 32template<class T, int N>
33class BVH_Builder
34{
35public:
36
679d3878 37 //! Creates new abstract BVH builder.
3c4e78f2 38 BVH_Builder (const Standard_Integer theLeafNodeSize,
39 const Standard_Integer theMaxTreeDepth);
40
41 //! Releases resources of BVH builder.
0ef61b50 42 virtual ~BVH_Builder();
3c4e78f2 43
679d3878 44 //! Builds BVH using specific algorithm.
0ef61b50 45 virtual void Build (BVH_Set<T, N>* theSet,
46 BVH_Tree<T, N>* theBVH,
47 const BVH_Box<T, N>& theBox) = 0;
3c4e78f2 48
679d3878 49protected:
50
fc73a202 51 //! Updates depth of constructed BVH tree.
52 void UpdateDepth (BVH_Tree<T, N>* theBVH,
53 const Standard_Integer theLevel)
54 {
55 if (theLevel > theBVH->myDepth)
56 {
57 theBVH->myDepth = theLevel;
58 }
59 }
60
3c4e78f2 61protected:
62
679d3878 63 Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
64 Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
3c4e78f2 65
66};
67
68#include <BVH_Builder.lxx>
69
70#endif // _BVH_Builder_Header