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

Merged

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 <[email protected]>
@ghurstunither ghurstunither requested a review from kmuseth as a code owner April 16, 2024 16:07
@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.

@@ -95,6 +95,19 @@ class LevelSetFilter : public LevelSetTracker<GridT, InterruptT>
Filter f(this, mask); f.meanCurvature();
}

/// @brief One iteration of filleting on the level set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to add @details that provides a reference to where the technique comes from. If I recall correctly, it's from one of Sethian/Osher's book.

@apradhana apradhana merged commit 5201109 into AcademySoftwareFoundation:master Oct 23, 2024
40 checks passed
@danrbailey
Copy link
Contributor

@apradhana @ghurstunither - I think this was merged prematurely, it doesn't appear to have a unit test or a changelog message? At the very least, it would need a couple lines in the unit tests that evaluates this method, but better still of course would be something that validates the results.

@apradhana
Copy link
Contributor

Thanks for pointing this out @danrbailey. I will add a unit test for the new feature and submit a PR. We are lacking unit tests for all the level set filters methods in the LevelSetFilter class in LevelSetFilter.h. It's a good time to start adding tests for those methods.

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

Successfully merging this pull request may close these issues.

4 participants