Allow conditioned walking
This commit is contained in:
parent
b8a67a50eb
commit
145b298730
@ -49,10 +49,16 @@ namespace CosmoTool
|
||||
|
||||
template<typename FunT>
|
||||
void walkTree(FunT f)
|
||||
{
|
||||
walkTree(f, unconditioned);
|
||||
}
|
||||
|
||||
template<typename FunT, typename CondT>
|
||||
void walkTree(FunT f, CondT condition)
|
||||
{
|
||||
OctCoords rootCenter = { octCoordCenter, octCoordCenter, octCoordCenter };
|
||||
|
||||
walkTreeElements(f, 0, rootCenter, octCoordCenter);
|
||||
walkTreeElements(f, condition, 0, rootCenter, octCoordCenter);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -66,8 +72,14 @@ namespace CosmoTool
|
||||
float xMin[3];
|
||||
|
||||
|
||||
template<typename FunT>
|
||||
void walkTreeElements(FunT f, octPtr node,
|
||||
static bool unconditioned()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename FunT, typename CondT>
|
||||
void walkTreeElements(FunT f, CondT condition,
|
||||
octPtr node,
|
||||
const OctCoords& icoord,
|
||||
octCoordType halfNodeLength)
|
||||
{
|
||||
@ -83,6 +95,11 @@ namespace CosmoTool
|
||||
f(realCenter, cells[node].numberLeaves, lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||
cells[node].children[0] == invalidOctCell, // True if this is a meta-node
|
||||
false);
|
||||
|
||||
if (!condition(realCenter, cells[node].numberLeaves,
|
||||
lenNorm*halfNodeLength/(float)octCoordCenter,
|
||||
cells[node].children[0] == invalidOctCell))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
@ -108,7 +125,8 @@ namespace CosmoTool
|
||||
false, true);
|
||||
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