graphicscomputational-geometrymeshcsglibigl

How to make a mesh manifold


I tried trim_with_solid method to drill a hole into a 3D model:

igl::copyleft::cgal::trim_with_solid(m_VA, m_FA, m_VB, m_FB, m_V, m_F, m_D, m_J);

But for hollowed 3D models with inner and outer walls, the hole is not closed:

Inner and outer walls

Possible solution

As posted here, a possible solution might be to use CSG operations of:

igl::copyleft::cgal::mesh_boolean

// or

igl::copyleft::cgal::CSGTree

However, the CSG operations need the input meshes to be manifold.

Question

I couldn't figure out if libigl has any tool to make a mesh manifold. Is there such a tool? Is there any other library which might help?


Solution

  • Eventually, I implemented the hole drilling feature by this Go package: https://github.com/reactivego/csg

    Along with some tricks to make it fast:

    Workaround & tricks

    It's assumed that the user usually creates holes for the flat/simple regions on the 3D model surface. So, these flat/simple regions are less likely to have faulty triangles. Accordingly, the following workaround might be proposed:

    1. Consider the requested hole as a cylinder shape.
      1. This would be the original cylinder.
    2. Scale up the hole cylinder by a percent. Like 20%.
      1. This would be the scaled cylinder.
    3. Extract any triangle of the 3D model which:
      1. ...is inside or intersecting with the scaled cylinder.
      2. 3D model would no longer contain those extracted triangles.
    4. Convert the extracted triangles to CSG polygons.
    5. Perform CGS operation between CSG polygons and the original cylinder.
    6. Get the resulting polygons of CSG operation.
    7. Convert the resulting polygons to new triangles.
    8. Add new triangles to the 3D model.

    Conclusion

    The above workaround was great. The hole drilling is fast and reliable.

    Screenshot