-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Repair meshes in manifold & fast-csg routes #4832
base: master
Are you sure you want to change the base?
Conversation
If the orientation fails, remove self intersecting faces and plug any holes, then try orientation again (also, use Epick mesh to avoid inaccurate orientation checks)
CGAL::Surface_mesh<CGAL::Point_3<K>> r; | ||
CGAL::convex_hull_3(points.begin(), points.end(), r); | ||
CGALUtils::copyMesh(r, m); | ||
CGAL::convex_hull_3(points.begin(), points.end(), m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the hull function in manifold. We don't do much optimization for now but we may do them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I probably checked the wrong thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, good to know it's there, not sure about here (would have to inline this logic in a manifold-specific way) but I'll probably give it a spin where we perform the hull primitive itself.
Looking at CGAL, it seems that they do have algorithm for repairing non-manifold triangular soup called I think the existing mesh processing in this PR are for dealing with self-intersections, but not sure if this can deal with topological issues (manifoldness). |
Ah, bad news. I tried |
Good news: We need to first This works for the simple cases where two cubes are touching at a corner/edge. I did not try more complicated cases. Should be nice to include in this PR. That code is basically copied from https://github.com/CGAL/cgal/blob/master/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h |
This PR introduces some crude mesh repairs in
manifold
&fast-csg
modes.Since
orient_to_bound_a_volume
seems happy to throw assert and precondition exceptions at us when the mesh has self-intersections or isn't closed, I'm catching these, remove any self intersections & plug any holes (then try orienting again w/ a more lenient method).This fixes
3D/features/linear_extrude-scale-zero-tests.scad
along with a few models I had that have invalid geometry but that I prefer seeing repaired than exploding in flight.TODO before undrafting:
CGAL::is_closed
)