Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fillet filter in LevelSetFilter.h #1793

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghurstunither
Copy link
Contributor

@ghurstunither ghurstunither commented Apr 16, 2024

Adds a fillet filter, which rounds off concave edges to create a smoother transition between surfaces.

Fillets a level set by

  • offsetting at locations with a negative principal curvature, proportional to its magnitude
  • leaves locations with non-negative principal curvatures untouched
  • this filter converges to the convex hull if iterated enough times

Example

Union 2 spheres:

FloatGrid::Ptr grid1 = openvdb::tools::createLevelSetSphere<FloatGrid>(1.0, Vec3f(0, 0, 0), 0.1, 3.0);
FloatGrid::Ptr grid2 = openvdb::tools::createLevelSetSphere<FloatGrid>(1.0, Vec3f(1.4, 0, 0), 0.1, 3.0);
openvdb::tools::csgUnion(*grid1, *grid2);

std::cout << grid1->evalActiveVoxelBoundingBox() << std::endl
[-12, -12, -12][26, 12, 12]

Visualization:
Screenshot 2024-04-16 at 11 51 10 AM

7 iterations of filleting:

openvdb::tools::LevelSetFilter filter(*grid1);
for(int i = 0; i < 7; ++i)
  filter.fillet();

// non-shrinking filter!
std::cout << grid1->evalActiveVoxelBoundingBox() << std::endl
[-12, -12, -12][26, 12, 12]

Visualization:
Screenshot 2024-04-16 at 11 51 28 AM


Tube radius stays the same after filleting:
Screenshot 2024-04-16 at 2 01 25 PM


Note, only concave corners are filleted:

Screenshot 2024-04-16 at 12 07 11 PM

A level set with a single connected component will transform into its convex hull after indefinite iterations of this filter. Unfortunately it's not practical in most cases, but it's still a neat fact. For example it took 16000 iterations to reasonably approximate the convex hull here:

fillet

Adds fillet filter, which rounds off concave edges to create a smoother transition between surfaces.

Signed-off-by: ghurstunither <62885595+ghurstunither@users.noreply.github.com>
@ghurstunither ghurstunither changed the title Update LevelSetFilter.h Fillet filter in LevelSetFilter.h Apr 16, 2024
@richhones
Copy link
Contributor

LGTM @apradhana feel like this covers some similar ground as the smooth union (e.g. https://iquilezles.org/articles/smin/) but imagine there is still place for both of these operations?

@ghurstunither
Copy link
Contributor Author

ghurstunither commented May 18, 2024

LGTM @apradhana feel like this covers some similar ground as the smooth union (e.g. https://iquilezles.org/articles/smin/) but imagine there is still place for both of these operations?

That's a good point! I think we should include both features.

  1. The fillet filter operates on a single object, and so is not a blending operator.
  2. These type of blending operations can sometimes cause undesired 'bulges' where regions have significant overlap near their boundaries. Here's a comparison combining two tubes, where the smooth/blended union shows the bulge:
Screenshot 2024-05-17 at 9 14 40 PM
  1. The smooth union functionality has advantages, like finer control with extra blending parameters, as well as running much faster for large fillets since it isn't bound by a CFL-like condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants