1#ifndef __GfxTL_INDEXEDTREEDATASTRATEGY_HEADER__
2#define __GfxTL_INDEXEDTREEDATASTRATEGY_HEADER__
10 template <
class InheritedStrategy,
class Data>
15 class IndexedTreeDataCore
19 typedef typename Data::PointType
PointType;
20 typedef typename PointType::ScalarType
ScalarType;
35 PointTranslated(
size_t i)
37 return _data.Point(i);
41 PointTranslated(
size_t i)
const
43 return _data.Point(i);
49 return _data.Point(i);
53 operator[](
size_t i)
const
55 return _data.Point(i);
63 class IndexedTreeDataCore<const Data>
67 typedef typename Data::PointType
PointType;
68 typedef typename PointType::ScalarType
ScalarType;
71 NonConstContainedData()
83 PointTranslated(
size_t i)
const
85 return _data.Point(i);
89 operator[](
size_t i)
const
91 return _data.Point(i);
99 class IndexedTreeDataCore<Data*>
103 typedef typename Data::PointType
PointType;
104 typedef typename PointType::ScalarType
ScalarType;
106 IndexedTreeDataCore() : _data(NULL)
117 ContainedData()
const
123 ContainedDataPtr(Data*
data)
129 PointTranslated(
size_t i)
131 return _data->Point(i);
135 PointTranslated(
size_t i)
const
137 return _data->Point(i);
143 return _data->Point(i);
147 operator[](
size_t i)
const
149 return _data->Point(i);
156 template <
class Data>
157 class IndexedTreeDataCore<const Data*>
161 typedef typename Data::PointType
PointType;
162 typedef typename PointType::ScalarType
ScalarType;
165 ContainedData()
const
171 ContainedDataPtr(
const Data*
data)
177 PointTranslated(
size_t i)
const
179 return _data->Point(i);
183 operator[](
size_t i)
const
185 return _data->Point(i);
196 typedef typename IndexedTreeDataCore<Data>::DataType
DataType;
200 template <
class Po
int>
201 class CellData :
public InheritedStrategy::CellData<Point>
248 _indices =
c._indices;
269 template <
class Base>
271 public InheritedStrategy::StrategyBase<Base>,
272 public IndexedTreeDataCore<Data>
276 typedef typename IndexedTreeDataCore<Data>::DataType
DataType;
292 StrategyBaseType::Clear();
305 return ContainedData().Size();
312 for (
size_t i = 0; i < cell.Size(); ++i)
314 points->push_back(
Translate(cell.Points() + i));
328 bv->Bound(*
this,
Size());
334 ContainedData().Add(
data);
344 ContainedData().Transform(t);
353 ContainedData().Transform(i, t);
361 ContainedData().Translate(translation);
366 template <
class TFunc>
370 ContainedData().TransformFunc(tfunc);
375 template <
class BoundingVolume>
379 ContainedData().Remove(bv);
387 if (_indices.size() != ContainedData().
Size())
389 size_t oldSize = _indices.size();
390 _indices.resize(ContainedData().
Size());
391 for (
size_t i = oldSize; i < _indices.size(); ++i)
399 template <
class BoundingVolume>
403 _indices.resize(ContainedData().
Size());
404 for (
size_t i = 0; i < ContainedData().Size(); ++i)
408 IndicesType::iterator j = _indices.begin();
409 IndicesType::iterator k = _indices.begin() + _indices.size() - 1;
412 if (!bv.IsInside(ContainedData().
Point(*j)))
424 cell->Data(0, j - _indices.begin());
434 if (cell.Size() == 0)
440 IndicesType::iterator j = _indices.begin() + cell.Indices();
441 IndicesType::iterator k = _indices.begin() + cell.Indices() + cell.Size() - 1;
444 if (ContainedData().
Point(*j)[axis] > s)
456 left->Indices(cell.Indices());
457 left->Size(j - (_indices.begin() + cell.Indices()));
458 right->Indices(cell.Indices() + left->Size());
459 right->Size((cell.Indices() + cell.Size()) - right->Indices());
465 cube->BoundingCube(IndexPoints(
data,
data.Indices(),
data.Size()),
data.Size());
void Bound(const Points &points, size_t size)
const CellIndicesType Normals() const
CellData(const CellIndicesType &indices, size_t size)
CellData< Point > ThisType
void Data(const CellIndicesType indices, size_t size)
void Data(const ThisType &c)
const CellIndicesType Points() const
void Indices(CellIndicesType indices)
CellIndicesType Indices() const
void Translate(const PointType &translation)
void SplitAlongAxis(const CellType &cell, unsigned int axis, ScalarType s, CellType *left, CellType *right)
void TransformFunc(TFunc tfunc)
PointType::ScalarType ScalarType
IndexedTreeDataStrategy< InheritedStrategy, Data >::HandleType HandleType
void Transform(const T &t)
IndexedTreeDataCore< Data >::DataType DataType
void BoundingCube(const CellType &data, AACube< PointType > *cube)
void Remove(const BoundingVolume &bv)
IndexedTreeDataStrategy< InheritedStrategy, Data >::IndicesType IndicesType
InheritedStrategy::StrategyBase< Base > StrategyBaseType
void BoundingVolume(BV *bv)
void Add(const DataType &data)
void PointsInCell(const CellType &cell, std::vector< size_t > *points) const
void Transform(size_t i, const T &t)
virtual void RefreshWithNewTreeData(const AACube< PointType > &bc)
void BoundingCube(AACube< PointType > *cube)
void RootCellData(const BoundingVolume &bv, CellType *cell)
DataType::PointType PointType
size_t Translate(HandleType i) const
PointType::ScalarType ScalarType
IndexedTreeDataCore< Data >::DataType DataType
std::vector< HandleType > IndicesType
DataType::PointType PointType