MaxIntervalSplittingKdTreeStrategy.h
Go to the documentation of this file.
1 #ifndef GfxTL__MAXINTERVALSPLITTINGKDTREESTRATEGY_HEADER__
2 #define GfxTL__MAXINTERVALSPLITTINGKDTREESTRATEGY_HEADER__
5 
6 namespace GfxTL
7 {
8  template< class InheritedStrategyT >
10  {
11  typedef typename InheritedStrategyT::value_type value_type;
12 
13  struct CellData
14  : public InheritedStrategyT::CellData
15  {};
16 
17  template< class BaseT >
19  : public InheritedStrategyT::template StrategyBase< BaseT >
20  {
21 public:
22  typedef typename InheritedStrategyT::template StrategyBase< BaseT >
24  typedef typename BaseType::CellType CellType;
28  DifferenceType DiffScalarType;
29 
30 protected:
31  template< class BuildInformationT >
32  void ComputeSplit(const BuildInformationT& bi, CellType* cell)
33  {
34  DiffScalarType* diff = new DiffScalarType[BaseType::m_dim];
35  this->Sub(bi.BBox()[1], bi.BBox()[0], &diff);
36  unsigned int axis = 0;
37  DiffScalarType length = diff[0];
38  for (unsigned int j = 1; j < BaseType::m_dim; ++j)
39  {
40  if (diff[j] > length)
41  {
42  axis = j;
43  length = diff[j];
44  }
45  }
46  cell->SplitAxis() = axis;
47  cell->SplitValue() =
48  (bi.BBox()[0][axis] + bi.BBox()[1][axis]) / 2;
49  delete[] diff;
50  }
51 
52  template< class BuildInformationT >
53  void ComputeSplit(unsigned int axis, const BuildInformationT& bi,
54  CellType* cell)
55  {
56  DiffScalarType* diff = new DiffScalarType[BaseType::m_dim];
57  Sub(bi.BBox()[1], bi.BBox()[0], &diff);
58  cell->SplitAxis() = axis;
59  cell->SplitValue() =
60  (bi.BBox()[0][axis] + bi.BBox()[1][axis]) / 2;
61  delete[] diff;
62  }
63 
64  template< class BuildInformationT >
65  bool AlternateSplit(const BuildInformationT& bi, CellType* cell)
66  {
67  unsigned int axis = (cell->SplitAxis() + 1) % BaseType::m_dim;
68  cell->SplitAxis() = axis;
69  cell->SplitValue() =
70  (bi.BBox()[1][axis] + bi.BBox()[0][axis]) / 2;
71  return true;
72  }
73  };
74  };
75 };
76 
77 #endif
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::ComputeSplit
void ComputeSplit(unsigned int axis, const BuildInformationT &bi, CellType *cell)
Definition: MaxIntervalSplittingKdTreeStrategy.h:53
GfxTL::ScalarTypeDeferer
Definition: ScalarTypeDeferer.h:12
GfxTL::MaxIntervalSplittingKdTreeStrategy::value_type
InheritedStrategyT::value_type value_type
Definition: MaxIntervalSplittingKdTreeStrategy.h:11
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase
Definition: MaxIntervalSplittingKdTreeStrategy.h:18
ScalarTypeConversion.h
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::ScalarType
ScalarTypeDeferer< value_type >::ScalarType ScalarType
Definition: MaxIntervalSplittingKdTreeStrategy.h:26
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::CellType
BaseType::CellType CellType
Definition: MaxIntervalSplittingKdTreeStrategy.h:24
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::DiffScalarType
ScalarTypeConversion< ScalarType, ScalarType >::DifferenceType DiffScalarType
Definition: MaxIntervalSplittingKdTreeStrategy.h:28
GfxTL
Definition: AABox.h:8
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::AlternateSplit
bool AlternateSplit(const BuildInformationT &bi, CellType *cell)
Definition: MaxIntervalSplittingKdTreeStrategy.h:65
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::BaseType
InheritedStrategyT::template StrategyBase< BaseT > BaseType
Definition: MaxIntervalSplittingKdTreeStrategy.h:23
GfxTL::ScalarTypeConversion
Definition: ScalarTypeConversion.h:7
GfxTL::MaxIntervalSplittingKdTreeStrategy::StrategyBase::ComputeSplit
void ComputeSplit(const BuildInformationT &bi, CellType *cell)
Definition: MaxIntervalSplittingKdTreeStrategy.h:32
GfxTL::MaxIntervalSplittingKdTreeStrategy
Definition: MaxIntervalSplittingKdTreeStrategy.h:9
ScalarTypeDeferer.h
GfxTL::MaxIntervalSplittingKdTreeStrategy::CellData
Definition: MaxIntervalSplittingKdTreeStrategy.h:13