pmp-library icon indicating copy to clipboard operation
pmp-library copied to clipboard

fill_hole() generates bad results

Open cdcseacave opened this issue 11 months ago • 5 comments

Describe the bug Closing holes generates very bad results (with new vertices very far away) even on simple meshes.

To Reproduce Steps to reproduce the behavior:

  1. load the attached mesh
  2. pmp::fill_hole(mesh, pmp::Halfedge(5));

Expected behavior input: image get: image expected: image

holeMesh_41.obj.zip

cdcseacave avatar Jan 13 '25 12:01 cdcseacave

Thanks for reporting, I could reproduce the issue.

The input mesh has a degenerate face (0 area triangle) that spoils the fairing step used at the end of the hole filling algorithm. You could either remove the degenerate face (or otherwise repair the input) or do without the fairing step.

Leaving the issue open as a reminder that we might want to have a check for this before running the algorithm.

dsieger avatar Jan 13 '25 21:01 dsieger

Thank you for the quick reply, however the input mesh does not have any face with zero or close to zero area. Does PMP have functionality to find and remove zero area faces? Or you meant immediately after hole filling the mesh and before fairing it has faces with zero area?

cdcseacave avatar Jan 14 '25 06:01 cdcseacave

The input mesh has a degenerate face with area 0.000002 at the boundary

image

You can't see the face, but the shading gives you a hint. After removing this face:

image

Running hole filling after removing this face:

image

dsieger avatar Jan 14 '25 08:01 dsieger

Thank you! Is there a function in pmp that can remove such faces? Which is the minimum area for a face to be considered safe for hole filling?

cdcseacave avatar Jan 14 '25 08:01 cdcseacave

We currently have no general function for repairing degenerate faces. This particular case was straightforward since the face was directly on the boundary, so I just removed it like this:

for (auto f : mesh.faces())
    if (face_area(mesh, f) < 1.0e-5)
        mesh.delete_face(f);
mesh.garbage_collection();

dsieger avatar Jan 19 '25 20:01 dsieger