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

[bug]fill_holes: wrong triangle direction #6681

Open
3 tasks done
lslzl3000 opened this issue Mar 7, 2024 · 2 comments
Open
3 tasks done

[bug]fill_holes: wrong triangle direction #6681

lslzl3000 opened this issue Mar 7, 2024 · 2 comments
Labels
bug Not a build issue, this is likely a bug.

Comments

@lslzl3000
Copy link

lslzl3000 commented Mar 7, 2024

Checklist

Describe the issue

Using fill_holes in open3d.t.geometry.TriangleMesh is simple and effective, but the result of filled triangles were create with wrong directions, e.g.:
Screenshot 2024-03-07 at 16 15 56
and cannot be fixed by compute_vertex_normals:
Screenshot 2024-03-07 at 16 18 33

is this a bug? can we configure the triangle direction in fill_holes?
Or how to flip the directions of the filled holes?

Steps to reproduce the bug

import open3d as o3d

mesh = o3d.io.read_triangle_mesh('path')
# ....

# try fill holes 
filled = o3d.t.geometry.TriangleMesh.from_legacy(mesh)
final = filled.fill_holes()
final.compute_vertex_normals()    

o3d.visualization.draw(final)

Error message

No response

Expected behavior

No response

Open3D, Python and System information

- Operating system: macOS 10.15
- Python version: Python 3.11.4
- Open3D version: 0.18
- System architecture: apple-silicon
- How did you install Open3D?: pip

Additional information

The similar functions/filter in other software such as MeshLab, MeshFix would fix holes with right normal/direction

@lslzl3000 lslzl3000 added the bug Not a build issue, this is likely a bug. label Mar 7, 2024
@lslzl3000 lslzl3000 changed the title [bug?] wrong normal/index direction after fill_holes [bug?] fill_holes: wrong triangle direction Mar 7, 2024
@lslzl3000 lslzl3000 changed the title [bug?] fill_holes: wrong triangle direction fill_holes: how to fix wrong triangle direction? Mar 10, 2024
@lslzl3000 lslzl3000 changed the title fill_holes: how to fix wrong triangle direction? [bug?]fill_holes: wrong triangle direction Mar 10, 2024
@lslzl3000
Copy link
Author

lslzl3000 commented Mar 10, 2024

looks like this is a very old bug of vtkFillHolesFilter
https://gitlab.kitware.com/vtk/vtk/-/issues/19269
https://gitlab.kitware.com/vtk/vtk/-/issues/17763

Hope someone cloud fix it, or replace this filter with some new algorithm, like MeshLab/MeshFix does

@lslzl3000 lslzl3000 changed the title [bug?]fill_holes: wrong triangle direction [bug]fill_holes: wrong triangle direction Mar 11, 2024
@stormboy
Copy link

stormboy commented Jun 5, 2024

I was able to work around this issue by editing the open3d::t::geometry::TriangleMesh implementation as follows.

TriangleMesh TriangleMesh::FillHoles(double hole_size) const {
    using namespace vtkutils;
    // do not include triangle attributes because they will not be preserved by
    // the hole filling algorithm
    auto polydata = CreateVtkPolyDataFromGeometry(
            *this, GetVertexAttr().GetKeySet(), {}, {}, {}, false);
    vtkNew<vtkFillHolesFilter> fill_holes;
    fill_holes->SetInputData(polydata);
    fill_holes->SetHoleSize(hole_size);

    // make the triangle winding order consistent
    vtkNew<vtkPolyDataNormals> normals;
    normals->SetInputConnection(fill_holes->GetOutputPort());
    normals->SetConsistency(true);
    normals->SetSplitting(false);
    normals->Update();
    auto result = normals->GetOutput();

    return CreateTriangleMeshFromVtkPolyData(result);
}

I've just created a pull request. #6816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not a build issue, this is likely a bug.
Projects
None yet
Development

No branches or pull requests

2 participants