inside voxel iterator && file write problem

357 views
Skip to first unread message

Bo Wu

unread,
Jan 18, 2015, 12:41:46 AM1/18/15
to openvd...@googlegroups.com
Hello everyone,

I am a rookie of the excellent library and I run into some problems. Hope to get some help.

In general, I have two questions
(1) can I directly iterate all the inside voxels (which have negative values)?

I converted a closed mesh to level sets, and want to get all the inside voxels.  Essentially, I would like to visit inside voxels and their 6 neighbor voxels.
However, it seems that I have to iterate all the values(include both tile and voxel, and test value and  level or depth) to get what I want.  Is there any faster way to iterate just all the voxels (without tile), or even ambitiously just the inside voxels ?

( Because the document says " For more specialized tasks, OpenVDB provides lower-level data accessors that enable fast iteration over all or selected voxels and over the elements of a Tree ")


(2) fail to write .vdb file to disk

the error says openvdb::v3_0_0::IoError: Blosc encoding is not supported

However, I test function file.hasBloscCompression() , it returns true.  And the file.DEFAULT_COMPRESSION_FLAGS is 6.

when I set the file.setCompression to other type, it works well. I have no idea what the problem is.


Thanks in advance,
Bo

Harry Biddle

unread,
Jan 19, 2015, 7:15:31 AM1/19/15
to openvd...@googlegroups.com
Hi Bo,

Here's one way you can iterate over just the on voxels:

        typedef openvdb::FloatTree::LeafNodeType FloatLeaf;
        for (openvdb::FloatTree::LeafCIter leaf(grid->tree().cbeginLeaf()); leaf; ++leaf)
        {
                for (FloatLeaf::ValueOnCIter iter(leaf->cbeginValueOn()); iter; ++iter)
                {
                        const float value = iter.getValue();
                        const openvdb::Coord coord = iter.getCoord();
                }
        }

For your question about just iterating over the inside voxels: I'm not aware of a way of doing this. Probably the best thing to do is to iterate over all the voxels and skip over the ones you don't want.

Alternatively, one trick we are using is to first turn off voxels you don't want to iterate over (i.e. the outside ones), leaving their values unchanged, and then launch an iteration over all on values. That is - using 'off' to mean 'is outside'. If you are passing the VDB grid on to another step you might need to come back and turning them back on. It can get a little fiddly trying to restore the state; you've got to be careful not to call prune; and you're limited in what you can do to active states of voxels in a multi-threaded setting but (depending on what you are doing) you might be able to get better performance going down this route, if that's important to you.

Also bear in mind that the mesh to levelset algorithms in the library don't guarantee that the levelset is filled with voxels in the interior; there could be some constant tile values.

As for the failure to write to disk - I haven't come across this before. Perhaps it is a build thing? I do know you can switch off support for blosc in the Makefile.

Harry

Bo Wu

unread,
Jan 20, 2015, 12:26:15 AM1/20/15
to openvd...@googlegroups.com
Hi Harry,

Thank you very much for the reply. Your way to do that is brilliant.

Your reminder about voxels in levelset algorithm is a very important information to me. Is there any way to force the space inside the mesh is divided into regular voxels? Maybe I should turn to some dense grid library?

OpenVDB Support

unread,
Jan 20, 2015, 7:32:29 PM1/20/15
to openvd...@googlegroups.com
the error says openvdb::v3_0_0::IoError: Blosc encoding is not supported

However, I test function file.hasBloscCompression() , it returns true.  And the file.DEFAULT_COMPRESSION_FLAGS is 6.

For now, you'll need to ensure that OPENVDB_USE_BLOSC is #defined not only when you compile the OpenVDB library but also when you compile your own code.

This issue will be addressed in the next library release.

Harry Biddle

unread,
Jan 26, 2015, 4:58:18 PM1/26/15
to openvd...@googlegroups.com
Oh sure, you can do this! Check out the 'Fill Interior' feature of Houdini's OpenVDB From Polygons SOP. I'm not sure what the API call is to do this, but it should not be too hard to track down. On the API side I do know of "voxelizeActiveTiles" that might be useful for you.
Reply all
Reply to author
Forward
0 new messages