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_BinnedBuilder_Header |
17 | #define _BVH_BinnedBuilder_Header |
18 | |
19 | #include <BVH_Builder.hxx> |
20 | |
21 | //! Stores parameters of single node bin (slice of AABB). |
22 | template<class T, int N> |
23 | struct BVH_Bin |
24 | { |
25 | //! Creates new node bin. |
26 | BVH_Bin() : Count (0) {} |
27 | |
28 | Standard_Integer Count; //!< Number of primitives in the bin |
228de226 |
29 | BVH_Box<T, N> Box; //!< AABB of primitives in the bin |
3c4e78f2 |
30 | }; |
31 | |
32 | //! Performs building of BVH tree using binned SAH algorithm. |
33 | //! Number of Bins controls tree's quality (greater - better) in cost of construction time. |
34 | template<class T, int N, int Bins = 32> |
35 | class BVH_BinnedBuilder : public BVH_Builder<T, N> |
36 | { |
37 | public: |
38 | |
39 | //! Type for the array of bins of BVH tree node. |
40 | typedef BVH_Bin<T, N> BVH_BinVector[Bins]; |
41 | |
42 | public: |
43 | |
44 | //! Creates binned SAH BVH builder. |
45 | BVH_BinnedBuilder (const Standard_Integer theLeafNodeSize = 5, |
46 | const Standard_Integer theMaxTreeDepth = 32); |
47 | |
48 | //! Releases resources of binned SAH BVH builder. |
49 | virtual ~BVH_BinnedBuilder(); |
50 | |
51 | protected: |
52 | |
53 | //! Builds BVH node for specified task info. |
54 | virtual void BuildNode (BVH_Set<T, N>* theSet, |
55 | BVH_Tree<T, N>* theBVH, |
56 | const Standard_Integer theNode); |
57 | |
58 | //! Arranges node primitives into bins. |
59 | virtual void GetSubVolumes (BVH_Set<T, N>* theSet, |
60 | BVH_Tree<T, N>* theBVH, |
61 | const Standard_Integer theNode, |
62 | BVH_BinVector& theBins, |
63 | const Standard_Integer theAxis); |
64 | |
65 | }; |
66 | |
67 | #include <BVH_BinnedBuilder.lxx> |
68 | |
69 | #endif // _BVH_BinnedBuilder_Header |