Search code examples
c++cgal

How do I remove many vertices from a surface mesh in CGAL?


I'm trying to iterate over all the vertices in a surface mesh and remove those vertices that satisfy certain criteria. The removal of the vertex should remove the connected faces.

CGAL::Euler::remove_center_vertex seems to do what I hoped but it invalidates the iterator so how should I remove many vertices from a surface mesh?


Solution

  • You probably want to have a look at the simplification package: https://doc.cgal.org/latest/Surface_mesh_simplification/index.html

    EDIT: You should first collect all the vertices you want to remove and then do all the calls to remove_center_vertex() using the collected vertices. Alternatively you might to have a look at the function remove_connected_components(). Collect the set of faces incident to the vertices to be removed and call that function to remove all the faces at once. Note that you might have to call expand_face_selection_for_removal() to prevent the creation of non-manifold vertices.