public void DeleteEdge(Edge edge) { if (!edges.Contains(edge)) { return; } RemoveRelation(edge); var splitVertex = edge.GetSplitVertex(); foreach (var e in edges) { if (e.End == edge.Begin) { e.End = splitVertex; } else if (e.Begin == edge.End) { e.Begin = splitVertex; } } vertices.Remove(edge.Begin); vertices.Remove(edge.End); vertices.Add(splitVertex); edges.Remove(edge); }
public bool SplitEdge(Edge edge) { if (edge.Length < DrawingConstants.MinimumSplitLength) { return(false); } if (!edges.Contains(edge)) { return(false); } RemoveRelation(edge); var splitVertex = edge.GetSplitVertex(); lastProcessedVertex = edge.End; var secondEdge = new Edge(splitVertex, edge.End, this); edge.End = splitVertex; edges.Insert(edges.IndexOf(edge) + 1, secondEdge); vertices.Insert(vertices.IndexOf(edge.Begin) + 1, splitVertex); return(true); }
private static void RotateNeighboursToPerpendicular(Edge first, Edge second) { var temp = new Edge(first.Begin, second.End); var middle = temp.GetSplitVertex(); var oldPos = first.End.Position; first.End.Position = middle.Position; var direction = first.GetDirection(); var positionFirst = first.End.Position.Add(new Point(-(int)Math.Round(direction.Y), (int)Math.Round(direction.X))); var positionSecond = first.End.Position.Add(new Point((int)Math.Round(direction.Y), -(int)Math.Round(direction.X))); first.End.Position = positionFirst.DistanceSquaredTo(oldPos) > positionSecond.DistanceSquaredTo(oldPos) ? positionSecond : positionFirst; }