6 template <
class Po
int,
class Base>
7 AACubeCell<Point, Base>::AACubeCell() : _parent(NULL)
9 memset(_children, 0,
sizeof(_children));
12 template <
class Po
int,
class Base>
13 AACubeCell<Point, Base>::AACubeCell(ThisType* parent,
const CubeType& cube) :
14 _parent(parent), _cube(cube)
16 memset(_children, 0,
sizeof(_children));
19 template <
class Po
int,
class Base>
20 AACubeCell<Point, Base>::~AACubeCell()
22 for (
int i = 0; i < NChildren; ++i)
31 template <
class Po
int,
class Base>
32 const AACubeCell<Point, Base>*
33 AACubeCell<Point, Base>::operator[](
unsigned int index)
const
35 return _children[
index];
38 template <
class Po
int,
class Base>
39 AACubeCell<Point, Base>*
40 AACubeCell<Point, Base>::operator[](
unsigned int index)
42 return _children[
index];
45 template <
class Po
int,
class Base>
47 AACubeCell<Point, Base>::Child(
unsigned int index, ThisType* child)
49 _children[
index] = child;
52 template <
class Po
int,
class Base>
53 typename AACubeCell<Point, Base>::CubeType&
54 AACubeCell<Point, Base>::Cube()
59 template <
class Po
int,
class Base>
60 const typename AACubeCell<Point, Base>::CubeType&
61 AACubeCell<Point, Base>::Cube()
const
66 template <
class Po
int,
class Base>
67 AACubeCell<Point, Base>*
68 AACubeCell<Point, Base>::Parent()
73 template <
class Po
int,
class Base>
74 const AACubeCell<Point, Base>*
75 AACubeCell<Point, Base>::Parent()
const
80 template <
class Po
int,
class Base>
82 AACubeCell<Point, Base>::Parent(ThisType* parent)
87 template <
class Po
int,
class Base>
88 AACubeCell<Point, Base>*
89 AACubeCell<Point, Base>::FaceNeighborIndexed(
unsigned int index,
unsigned int* level)
91 int axis =
index >> 1;
97 return FaceNeighbor(axis, level);
100 template <
class Po
int,
class Base>
101 const AACubeCell<Point, Base>*
102 AACubeCell<Point, Base>::FaceNeighborIndexed(
unsigned int index,
unsigned int* level)
const
104 int axis =
index >> 1;
110 return FaceNeighbor(axis, level);
113 template <
class Po
int,
class Base>
114 AACubeCell<Point, Base>*
115 AACubeCell<Point, Base>::FaceNeighbor(
int axis,
unsigned int* level)
128 return (*_parent)[box & ~(1 <<
a)];
134 if (!(box & (1 <<
a)))
136 return (*_parent)[box | (1 <<
a)];
139 unsigned int l = *level;
141 ThisType*
c = _parent->FaceNeighbor(axis, level);
147 if (invBox & (1 <<
a))
155 if (*level == l + 1 && (*
c)[invBox])
163 template <
class Po
int,
class Base>
164 const AACubeCell<Point, Base>*
165 AACubeCell<Point, Base>::FaceNeighbor(
int axis,
unsigned int* level)
const
167 return const_cast<ThisType*
>(
this)->FaceNeighbor(axis, level);
170 template <
class Po
int,
class Base>
172 AACubeCell<Point, Base>::SubBox()
const
179 if (!(_parent->Cube().IsSubCube(&box, Cube())))
189 template <
class Strategies>
191 AACubeTree<Strategies>::Clear()
193 StrategyBaseType::Clear();
197 template <
class Strategies>
201 AABox<PointType> bbox;
202 BoundingVolume(&bbox);
205 ScalarType w = (bbox.Max() - bbox.Min()).Length();
207 for (
unsigned int i = 0; i < PointType::Dim; ++i)
209 bbl[i] =
center[i] - (w / 2);
214 CubeType cc(bc[CubeType::NCorners - 1] * (ScalarType)1.2, bc.Width() * (ScalarType)1.2);
218 template <
class Strategies>
224 std::queue<CellType*>*
q;
225 std::queue<CellType*>* qq;
226 std::queue<CellType*> q1, q2, level;
228 CellType*
c =
new CellType(NULL, bc);
244 if (ShouldSubdivide(*
c))
247 for (
int i = 0; i < CellType::NChildren; ++i)
251 _cellCount += CellType::NChildren;
254 std::queue<CellType*>* qqq =
q;
262 InitLevelDependentCellData(
c);
267 template <
class Strategies>
271 Subdivide(cell, 0, 0, cell);
272 for (
unsigned int i = 0; i < CellType::NChildren; ++i)
274 InitCellData((*cell)[i]);
278 template <
class Strategies>
280 AACubeTree<Strategies>::RefreshWithNewTreeData(
const CubeType& bc)
283 CellType*
c = Root();
288 RootCellData(
c->Cube(),
c);
289 std::list<CellType*> stack;
297 ReadjustChildrenData(
c, 0, 0,
c);
298 for (
unsigned int i = 0; i < CellType::NChildren; ++i)
300 stack.push_back((*
c)[i]);
304 StrategyBaseType::RefreshWithNewTreeData(bc);
307 template <
class Strategies>
309 AACubeTree<Strategies>::ReadjustChildrenData(CellType* cell,
316 (*cell)[box]->Data(*
data);
321 cell->Cube().DividingPlane(axis, &
s);
325 ReadjustChildrenData(cell, axis + 1, box | (1 << axis), &
left);
326 ReadjustChildrenData(cell, axis + 1, box & (~(1 << axis)), &
right);
330 template <
class Strategies>
339 CellType* child =
new CellType;
342 child->Cube() = CubeType(box, cell->Cube());
343 cell->Child(box, child);
348 cell->Cube().DividingPlane(axis, &
s);
352 Subdivide(cell, axis + 1, box | (1 << axis), &
left);
353 Subdivide(cell, axis + 1, box & (~(1 << axis)), &
right);