0024739: TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and...
[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>
20#include <BVH_Tree.hxx>
21
22#include <NCollection_Vector.hxx>
23
24namespace
25{
26 //! Minimum node size to split.
27 const Standard_Real THE_NODE_MIN_SIZE = 1e-5;
28}
29
30//! Performs building of BVH tree.
31template<class T, int N>
32class BVH_Builder
33{
34public:
35
36 //! Creates abstract BVH builder.
37 BVH_Builder (const Standard_Integer theLeafNodeSize,
38 const Standard_Integer theMaxTreeDepth);
39
40 //! Releases resources of BVH builder.
41 virtual ~BVH_Builder() = 0;
42
43public:
44
45 //! Builds BVH using specified algorithm.
46 void Build (BVH_Set<T, N>* theSet,
47 BVH_Tree<T, N>* theBVH,
48 const BVH_Box<T, N>& theBox);
49
50protected:
51
52 //! Builds BVH node for specified task info.
53 virtual void BuildNode (BVH_Set<T, N>* theSet,
54 BVH_Tree<T, N>* theBVH,
55 const Standard_Integer theTask);
56
fc73a202 57 //! Updates depth of constructed BVH tree.
58 void UpdateDepth (BVH_Tree<T, N>* theBVH,
59 const Standard_Integer theLevel)
60 {
61 if (theLevel > theBVH->myDepth)
62 {
63 theBVH->myDepth = theLevel;
64 }
65 }
66
3c4e78f2 67protected:
68
69 Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
70 Standard_Integer myLeafNodeSize; //!< Maximum number of primitives per leaf
71 NCollection_Vector<Standard_Integer> myTasksQueue; //!< Queue to manage BVH node building tasks
72
73};
74
75#include <BVH_Builder.lxx>
76
77#endif // _BVH_Builder_Header