/// <summary> /// Calculates routes for edges in a graph, so that they avoid nodes. /// </summary> public Dictionary <TEdge, RoutedEdge> RouteEdges <TEdge>(IEnumerable <IRect> nodes, IEnumerable <TEdge> edges) where TEdge : class, IEdge { var routeGraph = RouteGraph.InitializeVertices(nodes, edges, 0, 0); var routedEdges = new Dictionary <TEdge, RoutedEdge>(); var occludedEdges = new List <TEdge>(); foreach (var edge in edges) { var straightEdge = routeGraph.TryRouteEdgeStraight(edge); if (straightEdge != null) { routedEdges[edge] = straightEdge; } else { occludedEdges.Add(edge); } } if (occludedEdges.Count > 0) { // there are some edges that couldn't be routed as straight lines routeGraph.ComputeVisibilityGraph(); foreach (var edge in occludedEdges) { RoutedEdge routedEdge = routeGraph.RouteEdge(edge); routedEdges[edge] = routedEdge; } } return(routedEdges); }
public List <RoutedEdge> RouteEdges(IEnumerable <IRect> nodes, IEnumerable <IEdge> edges) { var routeGraph = RouteGraph.InitializeVertices(nodes, edges); List <RoutedEdge> routedEdges = new List <RoutedEdge>(); var occludedEdges = new List <IEdge>(); foreach (IEdge edge in edges) { var straightEdge = routeGraph.TryRouteEdgeStraight(edge); if (straightEdge != null) { routedEdges.Add(straightEdge); } else { occludedEdges.Add(edge); } } if (occludedEdges.Count > 0) { // there are some edges that couldn't be routed as straight lines routeGraph.ComputeVisibilityGraph(); foreach (IEdge edge in occludedEdges) { RoutedEdge routedEdge = routeGraph.RouteEdge(edge); routedEdges.Add(routedEdge); } } return(routedEdges); }
public RoutedEdge BuildRoutedEdge(IEnumerable <IPoint> points) { var routedEdge = new RoutedEdge(); foreach (var point in points) { routedEdge.Points.Add(new Point2D(point.X, point.Y)); } return(routedEdge); }
public RoutedEdge BuildRoutedEdge(IEnumerable<IPoint> points) { var routedEdge = new RoutedEdge(); foreach (var point in points) { routedEdge.Points.Add(new Point2D(point.X, point.Y)); } return routedEdge; }
void SetEdgeSplinePoints(PositionedEdge edge, RoutedEdge routedEdge) { foreach (Point2D point in routedEdge.SplinePoints) { edge.SplinePoints.Add(new Point(point.X, point.Y)); } }