Openmesh provides the Delete_vertex () function to remove vertices from the grid, and all edges connected to the vertex are deleted at the same time as the vertices are deleted.
The vertex deletion function in the Openmesh official document is declared as follows:
void Openmesh::P olyconnectivity::d Elete_vertex (Vertexhandle _VH, bool _delete_isolated_vertices = TRUE)
Mark Vertex and all incident edges and faces deleted.
Items marked deleted is removed by Garbagecollection ().
Attention: Needs the Attributes::status attribute for vertices, edges and faces.
It is important to note that before you delete a geometry element, you need to get the state properties of the mesh vertices, edges, and polygons, and release them after the deletion is complete. the code for all the correct delete mesh vertices is as follows:
Mymesh Mesh;vector<MyMesh::VertexHandle> DELETE_VH;//Delete A collection of verticesif(!mesh.has_vertex_status ()) mesh.request_vertex_status ();if(!mesh.has_face_status ()) mesh.request_face_status ();if(!mesh.has_edge_status ()) mesh.request_edge_status (); for(Auto Vit=mesh.vertices_begin (); Vit!=mesh.vertices_end (); vit++){ if(Find (Delete_vh.begin (), Delete_vh.end (), vit.handle ()) = =Delete_vh.end ()) {Mesh.delete_vertex (Vit.handle (),true); }}mesh.garbage_collection ();if(Mesh.has_vertex_status ()) mesh.release_vertex_status ();if(Mesh.has_face_status ()) mesh.release_face_status ();if(Mesh.has_edge_status ()) mesh.release_edge_status ();
Openmesh Delete mesh vertices