public static void Split(TriMesh mesh, EdgeContext ctx) { TriMesh.Vertex left = null; TriMesh.Vertex top = null; TriMesh.Vertex bottom = null; foreach (var v in mesh.Vertices) { if (v.Index == ctx.Left) { left = v; } else if (v.Index == ctx.Top) { top = v; } else if (v.Index == ctx.Bottom) { bottom = v; } } TriMesh.Vertex right = TriMeshModify.VertexSplit(left, top, bottom, ctx.LeftPos, ctx.RightPos); TriMesh.HalfEdge hf = left.FindHalfedgeTo(right); right.Index = ctx.Right; hf.Next.ToVertex.Index = ctx.Top; hf.Opposite.Next.ToVertex.Index = ctx.Bottom; }
protected override TriMesh.Vertex Merge(MergeArgs args) { EdgeContext ctx = TriMeshModify.Merge(args.Target, args.Pos); this.Logs.Add(ctx); return(ctx.Left); }
public bool Forward() { if (this.index < this.method.Logs.Count) { EdgeContext ctx = this.method.Logs[this.index]; TriMesh.Vertex left = null; TriMesh.Vertex right = null; foreach (var v in this.Mesh.Vertices) { if (v.Index == ctx.Left) { left = v; } else if (v.Index == ctx.Right) { right = v; } } TriMesh.Edge edge = left.FindEdgeTo(right); MergeEdge.Merge(edge, ctx.MidPos); index++; return(true); } else { int r = this.method.Run(this.Mesh.Faces.Count - 1); index += r; return(false); } }
public void Split(EdgeContext ctx) { TriMesh.HalfEdge[] hfs = this.FindGroup(ctx.Left, ctx.Top, ctx.Buttom); TriMesh mesh = (TriMesh)ctx.Left.Mesh; ctx.Left.Traits.Position = ctx.LeftPos; ctx.Left.HalfEdge = hfs[0]; ctx.Right.HalfEdge = hfs[1]; mesh.Add(ctx.Right); for (int i = 0; i < hfs.Length - 1; i++) { hfs[i].Opposite.ToVertex = ctx.Right; } TriMesh.HalfEdge[] triangle1 = this.AddInnerTriangle(mesh, ctx.AboveFace, ctx.Left, ctx.Right, ctx.Top); this.InsertEdge(mesh, ctx.TopLeftEdge, triangle1[1], hfs[0]); TriMesh.HalfEdge[] triangle2 = this.AddInnerTriangle(mesh, ctx.UnderFace, ctx.Right, ctx.Left, ctx.Buttom); this.InsertEdge(mesh, ctx.ButtomRightEdge, triangle2[1], hfs[hfs.Length - 1]); ctx.MidEdge.HalfEdge0 = triangle2[0]; triangle1[0].Edge = ctx.MidEdge; triangle2[0].Edge = ctx.MidEdge; triangle1[0].Opposite = triangle2[0]; triangle2[0].Opposite = triangle1[0]; mesh.Add(ctx.MidEdge); }
public bool Backward() { if (this.index == 0) { return(false); } else { index--; EdgeContext ctx = this.method.Logs[this.index]; SplitVertex.Split(this.Mesh, ctx); TriMesh.Vertex left = null; TriMesh.Vertex right = null; foreach (var v in this.Mesh.Vertices) { if (v.Index == ctx.Left) { left = v; } else if (v.Index == ctx.Right) { right = v; } } TriMesh.HalfEdge hf = left.FindHalfedgeTo(right); hf.Face.Traits.Normal = TriMeshUtil.ComputeNormalFace(hf.Face); hf.Opposite.Face.Traits.Normal = TriMeshUtil.ComputeNormalFace(hf.Opposite.Face); left.Traits.Normal = TriMeshUtil.ComputeNormalAreaWeight(left); right.Traits.Normal = TriMeshUtil.ComputeNormalAreaWeight(right); return(true); } }
public void Show() { if (this.index > 0) { EdgeContext ctx = this.method.Logs[index - 1]; ctx.Top.Traits.selectedFlag = 1; ctx.TopLeftEdge.Traits.selectedFlag = 1; ctx.Left.Traits.selectedFlag = 1; ctx.MidEdge.Traits.selectedFlag = 1; ctx.Right.Traits.selectedFlag = 1; ctx.ButtomRightEdge.Traits.selectedFlag = 1; ctx.Buttom.Traits.selectedFlag = 1; } if (this.index < this.method.Logs.Count) { EdgeContext ctx = this.method.Logs[index]; ctx.Top.Traits.selectedFlag = 1; ctx.TopLeftEdge.Traits.selectedFlag = 1; ctx.Left.Traits.selectedFlag = 1; ctx.MidEdge.Traits.selectedFlag = 1; ctx.Right.Traits.selectedFlag = 1; ctx.ButtomRightEdge.Traits.selectedFlag = 1; ctx.Buttom.Traits.selectedFlag = 1; } }
public bool Backward() { if (this.index == 0) { return(false); } else { index--; EdgeContext ctx = this.method.Logs[this.index]; new SplitVertex().Split(ctx); return(true); } }
public bool Forward() { if (this.index < this.method.Logs.Count) { EdgeContext ctx = this.method.Logs[this.index]; TriMeshModify.Merge(ctx.MidEdge, ctx.MidPos); index++; return(true); } else { int r = this.method.Run(this.Mesh.Faces.Count - 1); index += r; return(false); } }
protected override HalfEdgeMesh.Vertex Merge(MergeSimplicationBase <HalfEdgeMesh.Edge> .MergeArgs args) { EdgeContext ctx = MergeEdge.Merge(args.Target, args.Pos); this.Logs.Add(ctx); TriMesh.Vertex left = null; foreach (var v in this.Mesh.Vertices) { if (v.Index == ctx.Left) { left = v; } } return(left); }
public static EdgeContext Merge(TriMesh.Edge edge, Vector3D position) { TriMesh mesh = (TriMesh)edge.Mesh; EdgeContext context = new EdgeContext() { LeftPos = edge.Vertex0.Traits.Position, MidPos = position, RightPos = edge.Vertex1.Traits.Position, Left = edge.Vertex0.Index, Right = edge.Vertex1.Index, Top = edge.HalfEdge1.Next.ToVertex.Index, Bottom = edge.HalfEdge0.Next.ToVertex.Index, }; TriMeshModify.MergeEdge(edge); return(context); }
public static EdgeContext Merge(TriMesh.Edge edge, Vector3D position) { TriMesh mesh = (TriMesh)edge.Mesh; EdgeContext context = new EdgeContext() { LeftPos = edge.Vertex0.Traits.Position, MidPos = position, RightPos = edge.Vertex1.Traits.Position, Left = edge.Vertex0.Index, Right = edge.Vertex1.Index, Top = edge.HalfEdge1.Next.ToVertex.Index, Bottom = edge.HalfEdge0.Next.ToVertex.Index, }; TriMeshModify.MergeEdge(edge); return context; }