parameter settings (voxel size, half width, background value)

148 views
Skip to first unread message

Peter Koro

unread,
Dec 1, 2021, 8:15:24 AM12/1/21
to OpenVDB Forum
Hi,

I have a question on how to set the voxel size and other parameters (half width, background value, ...) for a problem.

As an example I took a sphere with R=5. I tried to calculate the first and second principal curvatures.
To generate the sphere I use the code from openvdb/unittest/TestMeanCurvature.cc:
openvdb::FloatGrid::Ptr sphere_grid = openvdb::FloatGrid::create(/*backgroundValue=*/0.75);
sphere_grid->setTransform(openvdb::math::Transform::createLinearTransform(/*voxelsize=*/0.075));
const openvdb::Coord dim(160,160,160);
const openvdb::Vec3f center(6.0f, 6.0f, 6.0f);
const float radius=5.0f;
unittest_util::makeSphere<openvdb::FloatGrid>(dim, center, radius, *sphere_grid, unittest_util::SPHERE_DENSE_NARROW_BAND);


First I calulated the curvature values with a voxel size = 0.25 (background value=0.75)
Everything fine, the curvature values are correct around 0.2.

Then I tried to run the same code with a smaller voxel size (voxel size = 0.15, background value=0.75) and suddenly the curvature values become nan-s.

Can someone explain me what is happening here? Is there some rule of thumb how to set the above parameters (voxel size, background value, half width length). Is there a lower limit for the voxelsize?
I saw that the curvature is calculated on a 19 point stencil so I guess the half width has to be least 3 voxels but I couldn't find out why the code crash for smaller voxel sizes. I also tried to increase the domain so we are far from the boundary but that doesn't matter.

(The figures are just the middle sections of the curvature FloatGrid.)

Kind Regards,
Peter
min_curvature_DENSE_BAND_voxel_size_015.png
min_curvature_DENSE_BAND_voxel_size_025.png

Peter Koro

unread,
Dec 22, 2021, 7:05:12 AM12/22/21
to OpenVDB Forum
Ok, I found the problem. There is a bug in the principal curvature calculation. If the principal curvatures are equal then k_mean² = k_gaussian and the term sqrt(k_mean² - k_gaussian ) should be zero but due to some numerical error k_mean² - k_gaussian might be a very small negative number (e.g. -1e-21).

edward

unread,
Dec 22, 2021, 2:24:53 PM12/22/21
to OpenVDB Forum
Hi Peter,

For some reason, I had to fish this reply out of my gmail spam folder. It's probably best for you to log it this bug at https://github.com/AcademySoftwareFoundation/openvdb/issues so that the devs can look at this eventually.

Thanks,
-Edward

Reply all
Reply to author
Forward
0 new messages