Introduced proper conditioning of walking the tree
This commit is contained in:
parent
a4ffa66b8d
commit
a194f1f00b
@ -47,12 +47,25 @@ namespace CosmoTool
|
|||||||
return cells[0].numberLeaves;
|
return cells[0].numberLeaves;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool unconditioned(const FCoordinates&, octPtr, float, bool)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename FunT>
|
template<typename FunT>
|
||||||
void walkTree(FunT f)
|
void walkTree(FunT f)
|
||||||
{
|
{
|
||||||
OctCoords rootCenter = { octCoordCenter, octCoordCenter, octCoordCenter };
|
OctCoords rootCenter = { octCoordCenter, octCoordCenter, octCoordCenter };
|
||||||
|
|
||||||
walkTreeElements(f, 0, rootCenter, octCoordCenter);
|
walkTreeElements(f, unconditioned, 0, rootCenter, octCoordCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FunT, typename CondT>
|
||||||
|
void walkTree(FunT f, CondT condition)
|
||||||
|
{
|
||||||
|
OctCoords rootCenter = { octCoordCenter, octCoordCenter, octCoordCenter };
|
||||||
|
|
||||||
|
walkTreeElements(f, condition, 0, rootCenter, octCoordCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -66,8 +79,8 @@ namespace CosmoTool
|
|||||||
float xMin[3];
|
float xMin[3];
|
||||||
|
|
||||||
|
|
||||||
template<typename FunT>
|
template<typename FunT,typename CondT>
|
||||||
void walkTreeElements(FunT f, octPtr node,
|
void walkTreeElements(FunT f, CondT condition, octPtr node,
|
||||||
const OctCoords& icoord,
|
const OctCoords& icoord,
|
||||||
octCoordType halfNodeLength)
|
octCoordType halfNodeLength)
|
||||||
{
|
{
|
||||||
@ -79,11 +92,16 @@ namespace CosmoTool
|
|||||||
center[j] = icoord[j]/(2.*octCoordCenter);
|
center[j] = icoord[j]/(2.*octCoordCenter);
|
||||||
realCenter[j] = xMin[j] + center[j]*lenNorm;
|
realCenter[j] = xMin[j] + center[j]*lenNorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
f(realCenter, cells[node].numberLeaves, lenNorm*halfNodeLength/(float)octCoordCenter,
|
f(realCenter, cells[node].numberLeaves, lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||||
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
if (!condition(realCenter, cells[node].numberLeaves,
|
||||||
|
lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||||
|
cells[node].children[0] == invalidOctCell))
|
||||||
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
octPtr newNode = cells[node].children[i];
|
octPtr newNode = cells[node].children[i];
|
||||||
@ -108,7 +126,7 @@ namespace CosmoTool
|
|||||||
false, true);
|
false, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
walkTreeElements(f, cells[node].children[i], newCoord, halfNodeLength/2);
|
walkTreeElements(f, condition, cells[node].children[i], newCoord, halfNodeLength/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user