CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
4.98k stars 1.39k forks source link

corefinement_mesh_union: not valid a off #5520

Open Sea421 opened 3 years ago

Sea421 commented 3 years ago

Hi team,

I am trying to union 2 meshes using corefinement_mesh_union.cpp example. But it gives "mesh is not a valid off file" error. But I don't know how to fix the off files. I have googled for a few hours and tried some examples, but no luck. First mesh has self-intersecting faces, second mesh has non-manifolding edges. Is there complete example that fix the broken off file. Please help me. Off files: meshes.zip

Thanks

Environment

sloriot commented 3 years ago

The first issue I see is that part1 contains some non-manifold edge. See the red edges Screenshot from 2021-03-15 07-55-52.

About the fact that you cannot compute the union, I guess your two meshes are somehow tangent at their interface and the output cannot be represented as a surface mesh. Converting the input to Nef_polyhedra, I could do the union. Looking at the output, it seems there is not volumic connection between both parts: Screenshot from 2021-03-15 07-58-33

My guess is that it's coming from the fact that the shared interface paches between the meshes do share the same border vertices but are triangulated in a different way (creating the tangency). I could manually remove those patches and the function stitch_borders() has been able to join the two meshes.

There is nothing available in CGAL to make this working directly and it somehow also depend on your application.

Sea421 commented 3 years ago

Thanks you very much @sloriot , Is there any function that removes the tangent faces or inner faces? Please approach.

sloriot commented 3 years ago

We are working on something automatic to handle those kind of issues but it is not yet ready. In your case, if you know that the boundary are conformal, you could detect shared edges and then remove the patches before stitching.