6 template<
class Po
int,
class Base >
7 AACubeCell< Point, Base >::AACubeCell()
10 memset(_children, 0,
sizeof(_children));
13 template<
class Po
int,
class Base >
14 AACubeCell< Point, Base >::AACubeCell(ThisType* parent,
19 memset(_children, 0,
sizeof(_children));
22 template<
class Po
int,
class Base >
23 AACubeCell< Point, Base >::~AACubeCell()
25 for (
int i = 0; i < NChildren; ++i)
34 template<
class Po
int,
class Base >
35 const AACubeCell< Point, Base >*
36 AACubeCell< Point, Base >::operator[](
unsigned int index)
const
38 return _children[
index];
41 template<
class Po
int,
class Base >
42 AACubeCell< Point, Base >*
43 AACubeCell< Point, Base >::operator[](
unsigned int index)
45 return _children[
index];
48 template<
class Po
int,
class Base >
49 void AACubeCell< Point, Base >::Child(
unsigned int index, ThisType* child)
51 _children[
index] = child;
54 template<
class Po
int,
class Base >
55 typename AACubeCell< Point, Base >::CubeType&
56 AACubeCell< Point, Base >::Cube()
61 template<
class Po
int,
class Base >
62 const typename AACubeCell< Point, Base >::CubeType&
63 AACubeCell< Point, Base >::Cube()
const
68 template<
class Po
int,
class Base >
69 AACubeCell< Point, Base >*
70 AACubeCell< Point, Base >::Parent()
75 template<
class Po
int,
class Base >
76 const AACubeCell< Point, Base >*
77 AACubeCell< Point, Base >::Parent()
const
82 template<
class Po
int,
class Base >
83 void AACubeCell< Point, Base >::Parent(ThisType* parent)
88 template<
class Po
int,
class Base >
89 AACubeCell< Point, Base >*
90 AACubeCell< Point, Base >::FaceNeighborIndexed(
unsigned int index,
93 int axis =
index >> 1;
99 return FaceNeighbor(axis, level);
102 template<
class Po
int,
class Base >
103 const AACubeCell< Point, Base >*
104 AACubeCell< Point, Base >::FaceNeighborIndexed(
unsigned int index,
105 unsigned int* level)
const
107 int axis =
index >> 1;
113 return FaceNeighbor(axis, level);
116 template<
class Po
int,
class Base >
117 AACubeCell< Point, Base >*
118 AACubeCell< Point, Base >::FaceNeighbor(
int axis,
unsigned int* level)
131 return (*_parent)[box & ~(1 <<
a)];
137 if (!(box & (1 <<
a)))
139 return (*_parent)[box | (1 <<
a)];
142 unsigned int l = *level;
144 ThisType*
c = _parent->FaceNeighbor(axis, level);
150 if (invBox & (1 <<
a))
158 if (*level == l + 1 && (*
c)[invBox])
166 template<
class Po
int,
class Base >
167 const AACubeCell< Point, Base >*
168 AACubeCell< Point, Base >::
169 FaceNeighbor(
int axis,
unsigned int* level)
const
171 return const_cast< ThisType*
>(
this)->FaceNeighbor(axis, level);
174 template<
class Po
int,
class Base >
175 int AACubeCell< Point, Base >::SubBox()
const
182 if (!(_parent->Cube().IsSubCube(&box, Cube())))
192 template<
class Strategies >
193 void AACubeTree< Strategies >::Clear()
195 StrategyBaseType::Clear();
199 template<
class Strategies >
202 AABox< PointType > bbox;
203 BoundingVolume(&bbox);
205 bbox.Center(¢er);
206 ScalarType w = (bbox.Max() - bbox.Min()).Length();
208 for (
unsigned int i = 0; i < PointType::Dim; ++i)
210 bbl[i] = center[i] - (w / 2);
215 CubeType cc(bc[CubeType::NCorners - 1] * (ScalarType)1.2,
216 bc.Width() * (ScalarType)1.2);
220 template<
class Strategies >
225 std::queue< CellType* >*
q;
226 std::queue< CellType* >* qq;
227 std::queue< CellType* > q1, q2, level;
229 CellType*
c =
new CellType(NULL, bc);
245 if (ShouldSubdivide(*
c))
248 for (
int i = 0; i < CellType::NChildren; ++i)
252 _cellCount += CellType::NChildren;
255 std::queue< CellType* >* qqq =
q;
263 InitLevelDependentCellData(
c);
269 template<
class Strategies >
272 Subdivide(cell, 0, 0, cell);
273 for (
unsigned int i = 0; i < CellType::NChildren; ++i)
275 InitCellData((*cell)[i]);
279 template<
class Strategies >
280 void 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 >
308 void AACubeTree< Strategies >::ReadjustChildrenData(CellType* cell,
309 unsigned int axis,
unsigned int box, CellType*
data)
313 (*cell)[box]->Data(*
data);
318 cell->Cube().DividingPlane(axis, &
s);
319 CellType left, right;
320 SplitAlongAxis(*
data, axis,
s, &left, &right);
322 ReadjustChildrenData(cell, axis + 1, box | (1 << axis), &left);
323 ReadjustChildrenData(cell, axis + 1, box & (~(1 << axis)), &right);
327 template<
class Strategies >
329 unsigned int box, CellType*
data)
333 CellType* child =
new CellType;
336 child->Cube() = CubeType(box, cell->Cube());
337 cell->Child(box, child);
342 cell->Cube().DividingPlane(axis, &
s);
343 CellType left, right;
344 SplitAlongAxis(*
data, axis,
s, &left, &right);
346 Subdivide(cell, axis + 1, box | (1 << axis), &left);
347 Subdivide(cell, axis + 1, box & (~(1 << axis)), &right);