1#ifndef GfxTL__CELLSIZEDATATREESTRATEGY_HEADER__
2#define GfxTL__CELLSIZEDATATREESTRATEGY_HEADER__
6 template <
class InheritedStrategyT,
class KernelT>
11 class CellData :
public InheritedStrategyT::CellData
32 template <
class BaseT>
40 typedef std::pair<HandleType, HandleType>
CellRange;
64 template <
class BaseTraversalT>
69 template <
class BaseTraversalT>
89 template <
class BuildInformationT>
96 template <
class BuildInformationT>
99 const BuildInformationT& parentInfo,
100 unsigned int childIdx,
101 BuildInformationT* bi)
const
103 Range(parent, parentInfo.Range(), childIdx, &bi->Range());
106 template <
class BuildInformationT>
110 cell->m_size = bi.Range().second - bi.Range().first;
113 template <
class BuildInformationT>
116 const BuildInformationT& parentInfo,
117 unsigned int childIdx,
118 const BuildInformationT& bi,
121 cell->m_size = bi.Range().second - bi.Range().first;
124 template <
class TraversalInformationT>
131 template <
class TraversalInformationT>
134 const TraversalInformationT& pTi,
135 unsigned int childIdx,
136 TraversalInformationT* ti)
const
138 Range(parent, pTi.Range(), childIdx, &ti->Range());
144 r->first = KernelT::BeginHandle();
145 r->second = KernelT::EndHandle();
154 r->first = parentRange.first;
155 for (
unsigned int i = 0; i < child; ++i)
158 r->first += parent[i].m_size;
160 r->second = r->first + parent[child].m_size;
163 template <
class TraversalInformationT>
166 const TraversalInformationT& ti,
172 template <
class SplitterT,
class BuildInformationT>
176 const BuildInformationT& parentInfo,
180 unsigned int sizes[2];
181 SplitData(split, parentInfo.Range(), &sizes[0], &sizes[1]);
182 left->m_size = sizes[0];
183 right->m_size = sizes[1];
186 template <
class SplitterT,
class BuildInformationT>
189 const unsigned int numSplitters,
191 const BuildInformationT& parentInfo,
194 unsigned int* sizes =
new unsigned int[1 << numSplitters];
195 SplitData(splitters, numSplitters, parentInfo.Range(), sizes);
196 unsigned int childCount = 0;
197 for (
unsigned int i = 0; i < (unsigned)(1 << numSplitters); ++i)
201 cells[i]->m_size = sizes[i];
208 if (!cells[0] && childCount)
215 template <
class SplitterT>
218 const unsigned int numSplitters,
222 const unsigned int numChildren = 1 << numSplitters;
223 SplitData(splitters[0], range, &(sizes[0]), &(sizes[numChildren >> 1]));
224 if (numSplitters == 1)
228 CellRange leftRange(range.first, range.first + sizes[0]),
229 rightRange(leftRange.second, range.second);
230 SplitData(splitters + 1, numSplitters - 1, leftRange, sizes);
231 SplitData(splitters + 1, numSplitters - 1, rightRange, sizes + (numChildren >> 1));
234 template <
class SplitterT>
241 if (range.second - range.first == 0)
251 while (j <= k && split(at(Dereference(j))))
255 while (j < k && !split(at(Dereference(k))))
270 *left = j - range.first;
271 *right = (range.second - range.first) - *left;
274 template <
class SplitterT>
281 if (split(KernelT::back()))
296 KernelT::InsertBack(range.second - 1);
KernelT::value_type value_type
void Size(unsigned int s)
KernelT::value_type value_type
void SplitData(const SplitterT *splitters, const unsigned int numSplitters, const CellRange &range, unsigned int *sizes)
void InitRootTraversalInformation(const CellType &root, TraversalInformationT *ti) const
void InitRoot(const BuildInformationT &bi, CellType *cell)
KernelT::HandleType HandleType
void SplitData(const SplitterT &split, const CellRange &range, unsigned int *left, unsigned int *right)
void Range(const CellType &parent, const CellRange &parentRange, unsigned int child, CellRange *r) const
void SplitData(const SplitterT &split, const CellType &, const BuildInformationT &parentInfo, CellType *left, CellType *right)
void RootRange(CellRange *r) const
bool Remove(CellType &cell, DereferencedType s)
void InitBuildInformation(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, BuildInformationT *bi) const
bool SplitAndInsert(const SplitterT &split, CellRange parentRange, CellType *left, CellType *right)
InheritedStrategyT::template StrategyBase< BaseT > BaseType
void InsertBack(const CellRange &range, CellType *)
std::pair< HandleType, HandleType > CellRange
void Remove(DereferencedType s, CellType *)
void GetCellRange(const CellType &cell, const TraversalInformationT &ti, CellRange *range) const
void InitRootBuildInformation(BuildInformationT *bi) const
StrategyBase< BaseT > ThisType
void SplitData(const SplitterT *splitters, const unsigned int numSplitters, const CellType &, const BuildInformationT &parentInfo, CellType **cells)
void InitCell(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, const BuildInformationT &bi, CellType *cell)
void InitTraversalInformation(const CellType &parent, const TraversalInformationT &pTi, unsigned int childIdx, TraversalInformationT *ti) const
KernelT::DereferencedType DereferencedType
KernelT::value_type value_type