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