1 #ifndef GfxTL__SLIDINGMIDPOINTSPLITTINGKDTREESTRATEGY_HEADER__
2 #define GfxTL__SLIDINGMIDPOINTSPLITTINGKDTREESTRATEGY_HEADER__
8 template<
class InheritedStrategyT >
11 typedef typename InheritedStrategyT::value_type
value_type;
14 :
public InheritedStrategyT::CellData
17 template<
class BaseT >
19 :
public InheritedStrategyT::template
StrategyBase< BaseT >
31 template<
class BuildInformationT >
35 Sub(bi.CellBBox()[1], bi.CellBBox()[0], &cellDiff);
37 Sub(bi.BBox()[1], bi.BBox()[0], &diff);
38 unsigned int axis = 0;
41 for (
unsigned int j = 1; j < BaseType::m_dim; ++j)
43 if ((cellDiff[j] > length && spread < 2 * diff[j])
44 || (cellDiff[j] == length && diff[j] > spread)
45 || diff[j] > 2 * spread)
52 cell->SplitAxis() = axis;
54 (bi.CellBBox()[0][axis] + bi.CellBBox()[1][axis]) / 2;
55 if (cell->SplitValue() < bi.BBox()[0][axis]
56 || cell->SplitValue() > bi.BBox()[1][axis])
58 cell->SplitValue() = (bi.BBox()[1][axis] + bi.BBox()[0][axis]) / 2;
64 template<
class BuildInformationT >
69 Sub(bi.CellBBox()[1], bi.CellBBox()[0], &cellDiff);
71 Sub(bi.BBox()[1], bi.BBox()[0], &diff);
72 cell->SplitAxis() = axis;
74 (bi.CellBBox()[0][axis] + bi.CellBBox()[1][axis]) / 2;
75 if (cell->SplitValue() < bi.BBox()[0][axis])
77 cell->SplitValue() = bi.BBox()[0][axis];
79 else if (cell->SplitValue() > bi.BBox()[1][axis])
81 cell->SplitValue() = bi.BBox()[1][axis];
87 template<
class BuildInformationT >
90 unsigned int axis = (cell->SplitAxis() + 1) % BaseType::m_dim;
91 cell->SplitAxis() = axis;
93 (bi.CellBBox()[1][axis] + bi.CellBBox()[0][axis]) / 2;
94 if (cell->SplitValue() < bi.BBox()[0][axis])
96 cell->SplitValue() = bi.BBox()[0][axis];
98 else if (cell->SplitValue() > bi.BBox()[1][axis])
100 cell->SplitValue() = bi.BBox()[1][axis];