public void FlipEdge(int eid, bool bInteractive) { if (PreviewMesh.IsEdge(eid) == false) { DebugUtil.Log("MeshEditorTool.FlipEdge: invalid eid!"); return; } RemoveTrianglesMeshChange removeChange = null; AddTrianglesMeshChange addChange = null; previewSO.EditAndUpdateMesh((mesh) => { removeChange = new RemoveTrianglesMeshChange(); removeChange.InitializeFromExisting(mesh, get_edge_tris(mesh, eid)); DMesh3.EdgeFlipInfo flipInfo; if (mesh.FlipEdge(eid, out flipInfo) == MeshResult.Ok) { PreviewSpatial.RemoveTriangle(flipInfo.t0); PreviewSpatial.RemoveTriangle(flipInfo.t1); PreviewSpatial.AddTriangle(flipInfo.t0); PreviewSpatial.AddTriangle(flipInfo.t1); addChange = new AddTrianglesMeshChange(); addChange.InitializeFromExisting(mesh, null, get_edge_tris(mesh, eid)); } }, GeometryEditTypes.ArbitraryEdit); if (addChange != null) { add_replace_change(removeChange, addChange, bInteractive); } }
public void RemoveEdge(int eid, bool bInteractive) { if (PreviewMesh.IsEdge(eid) == false) { DebugUtil.Log("MeshEditorTool.RemoveEdge: invalid eid!"); return; } List <int> tris = get_edge_tris(PreviewMesh, eid); do_remove_triangles(tris, bInteractive); }
public void SplitEdge(int eid, Frame3f posL, bool bInteractive) { if (PreviewMesh.IsEdge(eid) == false) { DebugUtil.Log("MeshEditorTool.SplitEdge: invalid eid!"); return; } Index2i et = PreviewMesh.GetEdgeT(eid); RemoveTrianglesMeshChange removeChange = null; AddTrianglesMeshChange addChange = null; previewSO.EditAndUpdateMesh((mesh) => { removeChange = new RemoveTrianglesMeshChange(); List <int> input_tris = get_edge_tris(mesh, eid); removeChange.InitializeFromExisting(mesh, input_tris); DMesh3.EdgeSplitInfo splitInfo; if (mesh.SplitEdge(eid, out splitInfo) == MeshResult.Ok) { PreviewSpatial.RemoveTriangle(et.a); if (et.b != DMesh3.InvalidID) { PreviewSpatial.RemoveTriangle(et.b); } PreviewSpatial.AddTriangle(et.a); if (et.b != DMesh3.InvalidID) { PreviewSpatial.AddTriangle(et.b); } PreviewSpatial.AddTriangle(splitInfo.eNewT2); input_tris.Add(splitInfo.eNewT2); if (splitInfo.eNewT3 != DMesh3.InvalidID) { PreviewSpatial.AddTriangle(splitInfo.eNewT3); input_tris.Add(splitInfo.eNewT3); } mesh.SetVertex(splitInfo.vNew, posL.Origin); addChange = new AddTrianglesMeshChange(); addChange.InitializeFromExisting(mesh, new List <int>() { splitInfo.vNew }, input_tris); } }, GeometryEditTypes.ArbitraryEdit); if (addChange != null) { add_replace_change(removeChange, addChange, bInteractive); } }
public void BridgeEdges(int ea, int eb, bool bInteractive) { if (PreviewMesh.IsEdge(ea) == false || PreviewMesh.IsEdge(eb) == false) { DebugUtil.Log("MeshEditorTool.BridgeEdges: invalid eid!"); return; } if (PreviewMesh.IsBoundaryEdge(ea) == false || PreviewMesh.IsBoundaryEdge(eb) == false) { DebugUtil.Log("MeshEditorTool.BridgeEdges: edge is not boundary edge!"); return; } Index2i eva = PreviewMesh.GetOrientedBoundaryEdgeV(ea); Index2i evb = PreviewMesh.GetOrientedBoundaryEdgeV(eb); AddTrianglesMeshChange addChange = null; previewSO.EditAndUpdateMesh((mesh) => { int shared_v = IndexUtil.find_shared_edge_v(ref eva, ref evb); if (shared_v == DMesh3.InvalidID) { int t1 = mesh.AppendTriangle(eva.b, eva.a, evb.b); int t2 = mesh.AppendTriangle(evb.b, evb.a, eva.b); PreviewSpatial.AddTriangle(t1); PreviewSpatial.AddTriangle(t2); addChange = new AddTrianglesMeshChange(); addChange.InitializeFromExisting(mesh, null, new List <int>() { t1, t2 }); } else { int ovb = (evb.a == shared_v) ? evb.b : evb.a; int t = mesh.AppendTriangle(eva.b, eva.a, ovb); PreviewSpatial.AddTriangle(t); addChange = new AddTrianglesMeshChange(); addChange.InitializeFromExisting(mesh, null, new List <int>() { t }); } }, GeometryEditTypes.ArbitraryEdit); if (addChange != null) { add_change(addChange, bInteractive); } }
public void CollapseEdge(int eid, Frame3f posL, bool bInteractive) { if (PreviewMesh.IsEdge(eid) == false) { DebugUtil.Log("MeshEditorTool.CollapseEdge: invalid eid!"); return; } Index2i ev = PreviewMesh.GetEdgeV(eid); int keep = ev.a, discard = ev.b; bool boundarya = PreviewMesh.IsBoundaryVertex(keep); bool boundaryb = PreviewMesh.IsBoundaryVertex(discard); if (boundaryb && !boundarya) { keep = ev.b; discard = ev.a; } HashSet <int> removeT = new HashSet <int>(); foreach (int tid in PreviewMesh.VtxTrianglesItr(keep)) { removeT.Add(tid); } foreach (int tid in PreviewMesh.VtxTrianglesItr(discard)) { removeT.Add(tid); } RemoveTrianglesMeshChange removeChange = null; AddTrianglesMeshChange addChange = null; previewSO.EditAndUpdateMesh((mesh) => { removeChange = new RemoveTrianglesMeshChange(); removeChange.InitializeFromExisting(mesh, removeT); DMesh3.EdgeCollapseInfo collapseInfo; if (mesh.CollapseEdge(keep, discard, out collapseInfo) == MeshResult.Ok) { foreach (int tid in removeT) { PreviewSpatial.RemoveTriangle(tid); } foreach (int tid in PreviewMesh.VtxTrianglesItr(keep)) { PreviewSpatial.AddTriangle(tid); } if (boundarya == false & boundaryb == false) { mesh.SetVertex(keep, posL.Origin); } addChange = new AddTrianglesMeshChange(); addChange.InitializeFromExisting(mesh, new List <int>() { keep }, get_vtx_tris(mesh, keep)); } }, GeometryEditTypes.ArbitraryEdit); if (addChange != null) { add_replace_change(removeChange, addChange, bInteractive); } }