BBoxDistanceKdTreeStrategy.h
Go to the documentation of this file.
1#ifndef GfxTL__BBOXDISTANCEKDTREESTRATEGY_HEADER__
2#define GfxTL__BBOXDISTANCEKDTREESTRATEGY_HEADER__
3
6
7namespace GfxTL
8{
9 template <class InheritedStrategyT>
11 {
12 typedef typename InheritedStrategyT::value_type value_type;
13
14 class CellData : public InheritedStrategyT::CellData
15 {
16 public:
17 typedef typename InheritedStrategyT::CellData BaseType;
18 typedef typename BaseType::value_type value_type;
20
22 {
23 m_bbox[0] = m_bbox[1] = NULL;
24 }
25
27 {
28 delete[] m_bbox[0];
29 delete[] m_bbox[1];
30 }
31
34 {
35 return m_bbox;
36 }
37
38 const ScalarType* const*
39 BBox() const
40 {
41 return m_bbox;
42 }
43
44 private:
45 ScalarType* m_bbox[2];
46 };
47
48 template <class BaseT>
49 class StrategyBase : public InheritedStrategyT::template StrategyBase<BaseT>
50 {
51 public:
52 typedef typename InheritedStrategyT::template StrategyBase<BaseT> BaseType;
53 typedef typename BaseType::CellType CellType;
55 typedef typename BaseType::DereferencedType DereferencedType;
58
60 {
61 }
62
64 {
65 }
66
67 protected:
68 template <class BuildInformationT>
69 void
70 InitRoot(const BuildInformationT& bi, CellType* cell)
71 {
72 BaseType::InitRoot(bi, cell);
73 cell->BBox()[0] = new ScalarType[BaseType::m_dim];
74 cell->BBox()[1] = new ScalarType[BaseType::m_dim];
75 BaseType::AssignVector(bi.BBox()[0], &cell->BBox()[0]);
76 BaseType::AssignVector(bi.BBox()[1], &cell->BBox()[1]);
77 }
78
79 template <class BuildInformationT>
80 void
81 InitCell(const CellType& parent,
82 const BuildInformationT& parentInfo,
83 unsigned int childIdx,
84 const BuildInformationT& bi,
85 CellType* cell)
86 {
87 BaseType::InitCell(parent, parentInfo, childIdx, bi, cell);
88 cell->BBox()[0] = new ScalarType[BaseType::m_dim];
89 cell->BBox()[1] = new ScalarType[BaseType::m_dim];
90 BaseType::AssignVector(bi.BBox()[0], &cell->BBox()[0]);
91 BaseType::AssignVector(bi.BBox()[1], &cell->BBox()[1]);
92 }
93
94 template <class TraversalInformationT>
95 void
96 UpdateCellWithBack(const TraversalInformationT& ti, CellType* cell)
97 {
98 BaseType::UpdateCellWithBack(ti, cell);
99 BaseType::IncludeInAABox(BaseType::back(), cell->BBox());
100 }
101
102 template <class TraversalInformationT>
103 typename BaseType::template DistanceType<
105 typename ScalarTypeDeferer<
106 typename TraversalInformationT::GlobalType::PointType>::ScalarType>::Type
107 CellSqrDistance(const CellType& cell, const TraversalInformationT& ti) const
108 {
109 return BaseType::BoxSqrDistance(
110 ti.Global().Point(), cell.BBox()[0], cell.BBox()[1]);
111 }
112 };
113 };
114}; // namespace GfxTL
115
116#endif
ScalarTypeDeferer< value_type >::ScalarType ScalarType
ScalarTypeDeferer< value_type >::ScalarType ScalarType
void UpdateCellWithBack(const TraversalInformationT &ti, CellType *cell)
BaseType::template DistanceType< ScalarType, typenameScalarTypeDeferer< typenameTraversalInformationT::GlobalType::PointType >::ScalarType >::Type CellSqrDistance(const CellType &cell, const TraversalInformationT &ti) const
void InitRoot(const BuildInformationT &bi, CellType *cell)
InheritedStrategyT::template StrategyBase< BaseT > BaseType
ScalarTypeConversion< ScalarType, ScalarType >::DifferenceType DiffScalarType
void InitCell(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, const BuildInformationT &bi, CellType *cell)
Definition AABox.h:10
InheritedStrategyT::value_type value_type
PointT::value_type ScalarType