layout: default title: Local Operations permalink: /meshedit/local/ parent: "A2: MeshEdit" has_children: true has_toc: false nav_order: 1
Many of the actions that need to be implemented in the MeshEdit mode are local mesh operations (like edge collapse, face bevel, etc.).
A good recipe for ensuring that all pointers are still valid after a local remeshing operation is:
faceto the correct values in the new (modified) picture. For each vertex, make sure to set its
halfedgepointer. Etc. A convenience method
Halfedge::set_neighbors()has been created for this purpose. You may also want to update any necessary private variables associated with your elements.
The reason for setting all the pointers (and not just the ones that changed) is that it is very easy to miss a pointer, causing your code to crash.
To facilitate user interaction, as well as global mesh processing operations (described below), local mesh operations should return the following values when possible. However, should it happen that the specified values are not available, or that the operation should not work on the given input, we need a way to signify the failure case. To do so, each local operation actually returns a
std::optional value parameterized on the type of element it returns. For example,
Halfedge_Mesh::erase_vertex returns a
optional can hold a value of the specified type, or, similarly to a pointer, a null value (
student/meshedit.cpp for specific examples.
Also, remember that in any case, the program should not crash! So for instance, you should never return a pointer to an element that was deleted.
See the User Guide for demonstrations and more specifics of each local operation.
Halfedge_Mesh::flip_edge- should return the edge that was flipped
Halfedge_Mesh::split_edge- [Note: this method is for triangle meshes only!] should return the inserted vertex
Halfedge_Mesh::collapse_edge- should return the new vertex, corresponding to the collapsed edge
Halfedge_Mesh::inset_face- should return the new, inset face
Halfedge_Mesh::bevel_edge- should return the new face, corresponding to the beveled edge
Halfedge_Mesh::bevel_vertex- should return the new face, corresponding to the beveled vertex
Halfedge_Mesh::collapse_face- should return the new vertex, corresponding to the collapsed face
Halfedge_Mesh::erase_edge- should return the new face, corresponding to the faces originally containing the edge
Halfedge_Mesh::erase_vertex- should return the new face, corresponding to the faces originally containing the vertex
Halfedge_Mesh::bisect_edge- should bisect the edge and return the inserted vertex
Halfedge_Mesh::inset_vertex- should return the newly inserted vertex
Halfedge_Mesh::extrude_vertex- should return the new vertex
Table of Content