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