1 #ifndef __GfxTL_INDEXEDTREEDATASTRATEGY_HEADER__
2 #define __GfxTL_INDEXEDTREEDATASTRATEGY_HEADER__
10 template<
class InheritedStrategy,
class Data >
14 template<
class Data >
15 class IndexedTreeDataCore
20 typedef typename PointType::ScalarType
ScalarType;
27 const Data& ContainedData()
const
34 return _data.Point(i);
37 const PointType PointTranslated(
size_t i)
const
39 return _data.Point(i);
44 return _data.Point(i);
47 const PointType operator[](
size_t i)
const
49 return _data.Point(i);
56 template<
class Data >
57 class IndexedTreeDataCore< const Data >
62 typedef typename PointType::ScalarType
ScalarType;
64 Data& NonConstContainedData()
69 const Data& ContainedData()
const
74 const PointType PointTranslated(
size_t i)
const
76 return _data.Point(i);
79 const PointType operator[](
size_t i)
const
81 return _data.Point(i);
88 template<
class Data >
89 class IndexedTreeDataCore< Data* >
94 typedef typename PointType::ScalarType
ScalarType;
100 Data& ContainedData()
105 const Data& ContainedData()
const
110 void ContainedDataPtr(Data*
data)
117 return _data->Point(i);
120 const PointType PointTranslated(
size_t i)
const
122 return _data->Point(i);
127 return _data->Point(i);
130 const PointType operator[](
size_t i)
const
132 return _data->Point(i);
139 template<
class Data >
140 class IndexedTreeDataCore< const Data* >
145 typedef typename PointType::ScalarType
ScalarType;
147 const Data& ContainedData()
const
152 void ContainedDataPtr(
const Data*
data)
157 const PointType PointTranslated(
size_t i)
const
159 return _data->Point(i);
162 const PointType operator[](
size_t i)
const
164 return _data->Point(i);
175 typedef typename IndexedTreeDataCore< Data >::DataType
181 template<
class Po
int >
183 :
public InheritedStrategy::CellData< Point >
225 _indices =
c._indices;
244 template<
class Base >
246 :
public InheritedStrategy::StrategyBase< Base >
247 ,
public IndexedTreeDataCore< Data >
251 typedef typename IndexedTreeDataCore< Data >::DataType
267 typedef typename InheritedStrategy::StrategyBase< Base >
275 StrategyBaseType::Clear();
286 return ContainedData().Size();
290 std::vector< size_t >* points)
const
293 for (
size_t i = 0; i < cell.Size(); ++i)
295 points->push_back(
Translate(cell.Points() + i));
307 bv->Bound(*
this,
Size());
312 ContainedData().Add(
data);
321 ContainedData().Transform(t);
329 ContainedData().Transform(i, t);
336 ContainedData().Translate(translation);
341 template<
class TFunc >
344 ContainedData().TransformFunc(tfunc);
349 template<
class BoundingVolume >
352 ContainedData().Remove(bv);
360 if (_indices.size() != ContainedData().
Size())
362 size_t oldSize = _indices.size();
363 _indices.resize(ContainedData().
Size());
364 for (
size_t i = oldSize; i < _indices.size(); ++i)
372 template<
class BoundingVolume >
375 _indices.resize(ContainedData().
Size());
376 for (
size_t i = 0; i < ContainedData().Size(); ++i)
380 IndicesType::iterator j = _indices.begin();
381 IndicesType::iterator k = _indices.begin() +
386 ContainedData().
Point(*j)))
398 cell->Data(0, j - _indices.begin());
404 if (cell.Size() == 0)
410 IndicesType::iterator j = _indices.begin() +
412 IndicesType::iterator k = _indices.begin() +
413 cell.Indices() + cell.Size() - 1;
416 if (ContainedData().
Point(*j)[axis] >
s)
428 left->Indices(cell.Indices());
429 left->Size(j - (_indices.begin() + cell.Indices()));
430 right->Indices(cell.Indices() + left->Size());
431 right->Size((cell.Indices() + cell.Size())