0028495: The maximal depth of the tree is used implicitly in type 'BVH_PrimitiveSet'
[occt.git] / src / BVH / BVH_PrimitiveSet.lxx
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#include <BVH_BinnedBuilder.hxx>
17
18// =======================================================================
19// function : BVH_PrimitiveSet
20// purpose :
21// =======================================================================
22template<class T, int N>
23BVH_PrimitiveSet<T, N>::BVH_PrimitiveSet()
24: myBVH (new BVH_Tree<T, N>())
25{
26 // Set default builder - binned SAH split
e99816df 27 myBuilder = new BVH_BinnedBuilder<T, N, 48> (5, MaxTreeDepth);
3c4e78f2 28}
29
30// =======================================================================
31// function : ~BVH_PrimitiveSet
32// purpose :
33// =======================================================================
34template<class T, int N>
35BVH_PrimitiveSet<T, N>::~BVH_PrimitiveSet()
36{
37 myBVH.Nullify();
38 myBuilder.Nullify();
39}
40
41// =======================================================================
42// function : BVH
43// purpose :
44// =======================================================================
45template<class T, int N>
46const NCollection_Handle<BVH_Tree<T, N> >& BVH_PrimitiveSet<T, N>::BVH()
47{
48 if (BVH_Object<T, N>::myIsDirty)
49 {
50 Update();
51 }
52
53 return myBVH;
54}
55
56// =======================================================================
57// function : Box
58// purpose :
59// =======================================================================
60template<class T, int N>
61BVH_Box<T, N> BVH_PrimitiveSet<T, N>::Box() const
62{
63 if (!BVH_Object<T, N>::myIsDirty)
64 {
65 return myBox;
66 }
67
68 myBox = BVH_Set<T, N>::Box();
69 return myBox;
70}
71
72// =======================================================================
73// function : Update
74// purpose :
75// =======================================================================
76template<class T, int N>
77void BVH_PrimitiveSet<T, N>::Update()
78{
79 if (!BVH_Object<T, N>::myIsDirty)
80 {
81 return;
82 }
83
84 myBuilder->Build (this, myBVH.operator->(), Box());
85 BVH_Object<T, N>::myIsDirty = Standard_False;
86}
87
88// =======================================================================
89// function : Builder
90// purpose :
91// =======================================================================
92template<class T, int N>
93const NCollection_Handle<BVH_Builder<T, N> >& BVH_PrimitiveSet<T, N>::Builder() const
94{
95 return myBuilder;
96}
97
98// =======================================================================
99// function : SetBuilder
100// purpose :
101// =======================================================================
102template<class T, int N>
103void BVH_PrimitiveSet<T, N>::SetBuilder (NCollection_Handle<BVH_Builder<T, N> >& theBuilder)
104{
105 myBuilder = theBuilder;
106}