CellBBoxBuildInformationKdTreeStrategy.h
Go to the documentation of this file.
1 #ifndef GfxTL__CELLBBOXBUILDINFORMATIONKDTREESTRATEGY_HEADER__
2 #define GfxTL__CELLBBOXBUILDINFORMATIONKDTREESTRATEGY_HEADER__
3 
4 namespace GfxTL
5 {
6  template< class InheritedStrategyT >
8  {
9  typedef typename InheritedStrategyT::value_type value_type;
10 
11  class CellData
12  : public InheritedStrategyT::CellData
13  {};
14 
15  template< class BaseT >
17  : public InheritedStrategyT::template StrategyBase< BaseT >
18  {
19 public:
20  typedef typename InheritedStrategyT::template StrategyBase< BaseT >
22  typedef typename BaseType::CellType CellType;
25  typedef typename ScalarTypeConversion< ScalarType,
26  ScalarType >::DifferenceType DiffScalarType;
27 
29  {
30  m_bbox[0] = NULL;
31  m_bbox[1] = NULL;
32  }
33 
35  {
36  delete [] m_bbox[0];
37  delete [] m_bbox[1];
38  }
39 
40  const ScalarType* const* RootCellBBox() const
41  {
42  return m_bbox;
43  }
44 
45 protected:
47  : public BaseType::BuildInformation
48  {
49  public:
51  {
52  return m_oldBound;
53  }
54  const ScalarType OldBound() const
55  {
56  return m_oldBound;
57  }
58  const ScalarType* const* CellBBox() const
59  {
60  return m_cellBbox;
61  }
62  void CellBBox(ScalarType** cellBbox)
63  {
64  m_cellBbox = cellBbox;
65  }
66 
67  private:
68  ScalarType m_oldBound;
69  ScalarType** m_cellBbox;
70  };
71 
72  template< class BuildInformationT >
73  void InitRootBuildInformation(BuildInformationT* bi)
74  {
75  BaseType::InitRootBuildInformation(bi);
76  delete [] m_bbox[0]; // delete because dimension could have changed
77  delete [] m_bbox[1];
78  // init bbox
79  m_bbox[0] = new ScalarType[BaseType::m_dim];
80  m_bbox[1] = new ScalarType[BaseType::m_dim];
81  // init the values (box of zero volume)
82  typename BaseType::HandleType i = bi->Range().first;
83  this->AssignAsAABoxMin(this->at(this->Dereference(i)), &m_bbox[0]);
84  this->AssignAsAABoxMax(this->at(this->Dereference(i)), &m_bbox[1]);
85  for (++i; i != bi->Range().second; ++i)
86  {
87  this->IncludeInAABox(this->at(this->Dereference(i)), m_bbox);
88  }
89  bi->CellBBox(m_bbox);
90  }
91 
92  template< class BuildInformationT >
93  void InitBuildInformation(const CellType& parent,
94  const BuildInformationT& parentInfo, unsigned int childIdx,
95  BuildInformationT* bi)
96  {
97  BaseType::InitBuildInformation(parent, parentInfo, childIdx, bi);
98  bi->CellBBox(m_bbox);
99  }
100 
101  template< class BuildInformationT >
103  BuildInformationT* bi)
104  {
105  BaseType::EnterGlobalBuildInformation(cell, bi);
106  if (bi->CreateChild() == 0)
107  {
108  bi->OldBound() = m_bbox[1][cell.SplitAxis()];
109  m_bbox[1][cell.SplitAxis()] = cell.SplitValue();
110  }
111  else
112  {
113  bi->OldBound() = m_bbox[0][cell.SplitAxis()];
114  m_bbox[0][cell.SplitAxis()] = cell.SplitValue();
115  }
116  }
117 
118  template< class BuildInformationT >
120  const BuildInformationT& bi)
121  {
122  BaseType::LeaveGlobalBuildInformation(cell, bi);
123  if (bi.CreateChild() == 1)
124  {
125  m_bbox[1][cell.SplitAxis()] = bi.OldBound();
126  }
127  else
128  {
129  m_bbox[0][cell.SplitAxis()] = bi.OldBound();
130  }
131  }
132 
133 private:
134  ScalarType* m_bbox[2];
135  };
136  };
137 };
138 
139 #endif
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::RootCellBBox
const ScalarType *const * RootCellBBox() const
Definition: CellBBoxBuildInformationKdTreeStrategy.h:40
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BuildInformation
Definition: CellBBoxBuildInformationKdTreeStrategy.h:46
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::InitRootBuildInformation
void InitRootBuildInformation(BuildInformationT *bi)
Definition: CellBBoxBuildInformationKdTreeStrategy.h:73
GfxTL::ScalarTypeDeferer
Definition: ScalarTypeDeferer.h:12
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BuildInformation::CellBBox
const ScalarType *const * CellBBox() const
Definition: CellBBoxBuildInformationKdTreeStrategy.h:58
GfxTL::CellBBoxBuildInformationKdTreeStrategy::CellData
Definition: CellBBoxBuildInformationKdTreeStrategy.h:11
GfxTL::CellBBoxBuildInformationKdTreeStrategy
Definition: CellBBoxBuildInformationKdTreeStrategy.h:7
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::CellType
BaseType::CellType CellType
Definition: CellBBoxBuildInformationKdTreeStrategy.h:22
GfxTL::CellBBoxBuildInformationKdTreeStrategy::value_type
InheritedStrategyT::value_type value_type
Definition: CellBBoxBuildInformationKdTreeStrategy.h:9
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::LeaveGlobalBuildInformation
void LeaveGlobalBuildInformation(const CellType &cell, const BuildInformationT &bi)
Definition: CellBBoxBuildInformationKdTreeStrategy.h:119
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::ScalarType
ScalarTypeDeferer< value_type >::ScalarType ScalarType
Definition: CellBBoxBuildInformationKdTreeStrategy.h:24
GfxTL
Definition: AABox.h:8
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::~StrategyBase
~StrategyBase()
Definition: CellBBoxBuildInformationKdTreeStrategy.h:34
GfxTL::ScalarTypeConversion
Definition: ScalarTypeConversion.h:7
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BaseType
InheritedStrategyT::template StrategyBase< BaseT > BaseType
Definition: CellBBoxBuildInformationKdTreeStrategy.h:21
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BuildInformation::OldBound
ScalarType & OldBound()
Definition: CellBBoxBuildInformationKdTreeStrategy.h:50
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BuildInformation::CellBBox
void CellBBox(ScalarType **cellBbox)
Definition: CellBBoxBuildInformationKdTreeStrategy.h:62
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::StrategyBase
StrategyBase()
Definition: CellBBoxBuildInformationKdTreeStrategy.h:28
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase
Definition: CellBBoxBuildInformationKdTreeStrategy.h:16
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::DiffScalarType
ScalarTypeConversion< ScalarType, ScalarType >::DifferenceType DiffScalarType
Definition: CellBBoxBuildInformationKdTreeStrategy.h:26
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::InitBuildInformation
void InitBuildInformation(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, BuildInformationT *bi)
Definition: CellBBoxBuildInformationKdTreeStrategy.h:93
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::BuildInformation::OldBound
const ScalarType OldBound() const
Definition: CellBBoxBuildInformationKdTreeStrategy.h:54
GfxTL::CellBBoxBuildInformationKdTreeStrategy::StrategyBase::EnterGlobalBuildInformation
void EnterGlobalBuildInformation(const CellType &cell, BuildInformationT *bi)
Definition: CellBBoxBuildInformationKdTreeStrategy.h:102