Using a non-POD type for the LeafNode::ValueType

152 views
Skip to first unread message

Brett Tully

unread,
Oct 28, 2013, 1:59:55 PM10/28/13
to openvd...@googlegroups.com
Hi there,
I am curious to know if it is possible to make a tree/grid that holds a user defined object in a leaf node (i.e. something other than float, double, int or bool). What operators would this class need to provide? I presume you would also need to provide template functions for the Math.h etc as well?
Thanks,
Brett.

wes

unread,
Oct 28, 2013, 2:22:47 PM10/28/13
to openvd...@googlegroups.com
I tried doing this and found that it was just not feasible in the end do to the assumptions built into the templates that the values stored in grids have certain numeric properties.  Maybe my approach was wrong, but in the end, I ended up using the an integer grid where the integers are used as keys to look up instances of a particular data structure. My use case was storing mesh vertices in voxels, so I just store the vertex ID at the appropriate grid cell.

wes

Ken Museth

unread,
Oct 29, 2013, 2:28:23 PM10/29/13
to openvd...@googlegroups.com
Hi Brett and Wes,

It certainly is possible to use non-POD data types as voxel values in VDB, in fact we do it all the time! However, I admit that the documentation could be much better - to put it mildly :) In fact the best description and example is to look at the local class BlindData in ParticlesToLevelSet.h. It's a simple non-POD data type that includes all the methods needed to perform some simple level set operations (CSG). The exact number of methods required for a custom value type varies somewhat with the methods you call on the corresponding tree, and BlindData might even include methods that are not needed in your case. The sad truth is that the only way to be sure is by trial and error, but of course it helps to start out with a good guess like the set of methods in BlindData. We've tried to reduce the number of required methods on custom value types, but unfortunately found that to do so we have to remove algorithms from the tree structure and make them external stand-alone functions which in turn can impair performance. On the upside most of these methods are also required by std container classes and the ones that are not can easily be implemented as nops. Hope this was helpful advise?!

-Ken

Brett Tully

unread,
Oct 30, 2013, 7:11:20 AM10/30/13
to openvd...@googlegroups.com
This is great, thanks Ken. The primary functionality I am looking for at the moment is interpolation; indeed, I was having a quick look yesterday at the interpolation tests and could see it being done with the Vec3f class which I suppose answered my question too! I will use the example you pointed at to get started.
Cheers,
Brett
Reply all
Reply to author
Forward
0 new messages