Reputation: 4236
The OpenMesh halfedge mesh library has a split_edge
function, that splits a given edge handle by inserting a new vertex in the edge, but the function does not return the new edges.
How to get the new segments after the split and how can they be oriented with regard to the original edge?
Upvotes: 0
Views: 18
Reputation: 4236
OpenMesh supports triangle meshes and polygon meshes, and handles edges in different ways because triangle meshes need to insert more edges to re-triangulate adjacent faces after the split, while in polygon meshes the resulting polygons just have one more edge.
The source for the split functions can be found here:
In both types of meshes, the original edge is retained as one of the edges adjacent to the split vertex.
For polygonal meshes, the mesh is updated such that the primary halfedge eh.h0()
points away from the new vertex and the primary halfedge of the inserted edge points to the new vertex, i.e., new_eh.h0().to() == new_vh
and eh.h0().from() == new_vh
.
In triangle meshes, the triangulation is adapted, such that the original edge and the inserted edge point away from the new vertex, in a way, such that both primary halfedges, eh.h0()
and new_eh.h0()
, point away from the inserted vertex new_vh
, i.e., new_eh.h0().from() == new_vh
and eh.h0().from() == new_vh
;
For a split in a mesh using PolyConnectivity, the split_edge(EdgeHandle _eh, VertexHandle _vh) function results in new_vh
having valence 2 and being adjacent to the two segments.
When ordering the segments in the direction of the original primary halfedge eh.h0()
, we get the path new_eh.h0().to()
, new_vh
, eh.h0().to()
, with new_eh = eh.h0().prev().edge()
.
This function splits the mesh at a halfedge and returns the segment halfedges that are pointing in the direction of the original halfedge:
template <typename PolyMeshT>
std::pair<OpenMesh::SmartHalfedgeHandle, OpenMesh::SmartHalfedgeHandle> split_edge(PolyMeshT mesh, const OpenMesh::SmartHalfedgeHandle heh, OpenMesh::SmartVertexHandle new_vh) {
auto eh = heh.edge();
mesh.split_edge(eh, new_vh);
auto new_heh = eh.h0().prev();
if(heh == eh.h0()) {
return {new_heh, heh};
} else {
// heh == eh.h1()
return {heh, new_heh.opp()};
}
}
For a split in a mesh using TriConnectivity, the split_edge(EdgeHandle _eh, VertexHandle _vh) function results in new_vh
having valence 4 as two supporting edges connecting new_vh
, and the vertices of the adjacent triangles that are not on the edge, are inserted to re-triangulate the faces.
When ordering the segments in the direction of the original primary halfedge eh.h0()
, we get the path new_eh.h1().to()
, new_vh
, eh.h0().to()
, but as there are now the supporting edges, we need to circulate around new_vh
to find the new edge: new_eh = eh.h0().prev().opp().prev().edge()
.
This function splits the mesh at a halfedge and returns the segment halfedges that are pointing in the direction of the original halfedge:
template <typename TriMeshT>
std::pair<OpenMesh::SmartHalfedgeHandle, OpenMesh::SmartHalfedgeHandle> split_edge(TriMeshT mesh, const OpenMesh::SmartHalfedgeHandle heh, OpenMesh::SmartVertexHandle new_vh) {
auto eh = heh.edge();
mesh.split_edge(eh, new_vh);
auto new_heh = eh.h0().prev().opp().prev();
if(heh == eh.h0()) {
return {new_heh, heh};
} else {
// heh = eh.h1()
return {heh, new_heh.opp()};
}
}
Upvotes: 0