3c4e78f2 |
1 | // Created on: 2013-12-20 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2013 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 |
8 | // under the terms of the GNU Lesser General Public 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_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 | |
24 | namespace |
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. |
31 | template<class T, int N> |
32 | class BVH_Builder |
33 | { |
34 | public: |
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 | |
43 | public: |
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 | |
50 | protected: |
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 | |
57 | protected: |
58 | |
59 | Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH |
60 | Standard_Integer myLeafNodeSize; //!< Maximum number of primitives per leaf |
61 | NCollection_Vector<Standard_Integer> myTasksQueue; //!< Queue to manage BVH node building tasks |
62 | |
63 | }; |
64 | |
65 | #include <BVH_Builder.lxx> |
66 | |
67 | #endif // _BVH_Builder_Header |