-
Hi,
The result I get is not a detailed as the first option, it looks like it's not looping though all the voxels, but just the leafs, and assigns the value of the leaf to all its voxels. How could iterate through the voxels of each Leaf iteration? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @drperpen, When you say "a triple loop" I assume you're looping over a rectangular domain in the form: for (int x = minx; x < maxx; ++x)
for (int y = miny; y < maxy; ++y)
for (int z = minz; z < maxz; ++z)
// acc.setValue() ? If you're then using accessor methods like If you actually need a fully dense VDB in the min->max coordinate domain then, in general, you must make sure this topology exists before iterating on it when using multithreaded methods. For example: // Create a mask topology of the domain we need to exist
CoordBBox box(Coord(minx,miny,minz), Coord(maxx,maxy,maxz))
MaskGrid mask;
mask.sparseFill(box, /*value=*/true);
FloatGrid grid = ...;
// Union our grids topology with the mask domain. This makes sure that all node topologies exist but preserves our grids values
grid.topologyUnion(*mask);
mask.clear();
// Forcefully densify the entire VDB (only necessary if you know you need leaf level values)
/* grid.tree().voxelizeActiveTiles() */
// run op
tools::foreach(grid.beginValueAll(), Local::op); |
Beta Was this translation helpful? Give feedback.
Hi @drperpen,
When you say "a triple loop" I assume you're looping over a rectangular domain in the form:
If you're then using accessor methods like
setValue()
then this may produce different behaviour to your::foreach
example. Importantly the::foreach
solution will not modify the volumes topology where as the loop solution will be a) implicitly creating new nodes if they didn't previously exist at the location(x,y,z)
and b) densifying tiles to leaf nodes which, from the looks of things, is unnecessary in this case. I'm not sure how you're visualizing th…