public static void RemoveFacesWithTwoEdges(HMesh hmesh) { var faces = new List <Face>(hmesh.GetFaces()); for (int i = 0; i < faces.Count; i++)// (var face in hmesh.GetFaces()) { var edges = faces[i].Circulate(); if (edges.Count == 2) { var opp1 = edges[0].opp; var opp2 = edges[1].opp; var vert1 = edges[0].vert; var vert2 = edges[1].vert; // reassign vertex halfedges to a he not to be destroyed Halfedge.Glue(opp1, opp2); hmesh.Destroy(faces[i]); hmesh.Destroy(edges[0]); hmesh.Destroy(edges[1]); } } }
// destroys linked edges (and vertices if no longer used) public void Dissolve() { var cir = Circulate(); foreach (var c in cir) { var vert = c.vert; if (c.opp != null) { c.opp.opp = null; } hmesh.Destroy(c); if (vert.CirculateAllIngoing().Count == 0) { hmesh.Destroy(vert); } } hmesh.Destroy(this); }
public Vertex Collapse(bool center = false) { if (center) { vert.position = (vert.position + prev.vert.position) * 0.5f; vert.uv1 = (vert.uv1 + prev.vert.uv1) * 0.5f; vert.uv2 = (vert.uv2 + prev.vert.uv2) * 0.5f; } CollapseInternal(false); if (opp != null) { opp.CollapseInternal(true); hmesh.Destroy(opp); } hmesh.Destroy(this); return(vert); }