private bool GetMultiStagePath(Path edgePath, MsmtRectilinearPath shortestPathRouter, List <VisibilityVertex> sourceVertices, List <VisibilityVertex> targetVertices, bool lastChance) { var waypointVertices = PortManager.FindWaypointVertices(edgePath.EdgeGeometry.Waypoints); var paths = shortestPathRouter.GetPath(sourceVertices, waypointVertices, targetVertices); if (paths == null) { if (!lastChance) { return(false); } // Get each stage individually. They won't necessarily be ideal but this should be very rare and // with at least one stage being "forced" through obstacles, the path is not good anyway. foreach (var stagePath in this.edgeGeomsToSplittedEdgePaths[edgePath.EdgeGeometry]) { var stageGeom = stagePath.EdgeGeometry; GetSingleStagePath(stagePath, shortestPathRouter, this.PortManager.FindVertices(stageGeom.SourcePort), this.PortManager.FindVertices(stageGeom.TargetPort), lastChance: true); } return(true); } // Record the path for each state. var pathsEnum = paths.GetEnumerator(); foreach (var stagePath in this.edgeGeomsToSplittedEdgePaths[edgePath.EdgeGeometry]) { pathsEnum.MoveNext(); stagePath.PathPoints = pathsEnum.Current; } return(true); }
internal virtual bool GeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath, bool lastChance = false) { var sourceVertices = PortManager.FindVertices(edgePath.EdgeGeometry.SourcePort); var targetVertices = PortManager.FindVertices(edgePath.EdgeGeometry.TargetPort); return(edgePath.EdgeGeometry.HasWaypoints ? this.GetMultiStagePath(edgePath, shortestPathRouter, sourceVertices, targetVertices, lastChance) : GetSingleStagePath(edgePath, shortestPathRouter, sourceVertices, targetVertices, lastChance)); }
private static bool GetSingleStagePath(Path edgePath, MsmtRectilinearPath shortestPathRouter, List <VisibilityVertex> sourceVertices, List <VisibilityVertex> targetVertices, bool lastChance) { edgePath.PathPoints = shortestPathRouter.GetPath(sourceVertices, targetVertices); if (lastChance) { EnsureNonNullPath(edgePath); } return(edgePath.PathPoints != null); }
internal virtual void SpliceVisibilityAndGeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath) { this.PortManager.AddControlPointsToGraph(edgePath.EdgeGeometry, this.ShapeToObstacleMap); this.PortManager.TransUtil.DevTrace_VerifyAllVertices(this.VisibilityGraph); this.PortManager.TransUtil.DevTrace_VerifyAllEdgeIntersections(this.VisibilityGraph); if (!this.GeneratePath(shortestPathRouter, edgePath)) { this.RetryPathsWithAdditionalGroupsEnabled(shortestPathRouter, edgePath); } this.PortManager.RemoveControlPointsFromGraph(); }
private void FillEdgePathsWithShortestPaths(IEnumerable <Path> edgePaths) { this.PortManager.BeginRouteEdges(); var shortestPathRouter = new MsmtRectilinearPath(this.BendPenaltyAsAPercentageOfDistance); foreach (Path edgePath in edgePaths) { this.ProgressStep(); AddControlPointsAndGeneratePath(shortestPathRouter, edgePath); } this.PortManager.EndRouteEdges(); }
internal virtual void RetryPathsWithAdditionalGroupsEnabled(MsmtRectilinearPath shortestPathRouter, Path edgePath) { // Insert any spatial parent groups that are not in our hierarchical parent tree and retry, // if we haven't already done this. if (!PortManager.SetAllAncestorsActive(edgePath.EdgeGeometry, ShapeToObstacleMap) || !GeneratePath(shortestPathRouter, edgePath)) { // Last chance: enable all groups (if we have any). Only do this on a per-path basis so a single degenerate // path won't make the entire graph look bad. PortManager.SetAllGroupsActive(); GeneratePath(shortestPathRouter, edgePath, lastChance: true); } }
private void AddControlPointsAndGeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath) { if (!edgePath.EdgeGeometry.HasWaypoints) { Point[] intersectPoints = PortManager.GetPortVisibilityIntersection(edgePath.EdgeGeometry); if (intersectPoints != null) { GeneratePathThroughVisibilityIntersection(edgePath, intersectPoints); return; } } this.SpliceVisibilityAndGeneratePath(shortestPathRouter, edgePath); }
private bool GetMultiStagePath(Path edgePath, MsmtRectilinearPath shortestPathRouter, List<VisibilityVertex> sourceVertices, List<VisibilityVertex> targetVertices, bool lastChance) { var waypointVertices = PortManager.FindWaypointVertices(edgePath.EdgeGeometry.Waypoints); var paths = shortestPathRouter.GetPath(sourceVertices, waypointVertices, targetVertices); if (paths == null) { if (!lastChance) { return false; } // Get each stage individually. They won't necessarily be ideal but this should be very rare and // with at least one stage being "forced" through obstacles, the path is not good anyway. foreach (var stagePath in this.edgeGeomsToSplittedEdgePaths[edgePath.EdgeGeometry]) { var stageGeom = stagePath.EdgeGeometry; GetSingleStagePath(stagePath, shortestPathRouter, this.PortManager.FindVertices(stageGeom.SourcePort), this.PortManager.FindVertices(stageGeom.TargetPort), lastChance:true); } return true; } // Record the path for each state. var pathsEnum = paths.GetEnumerator(); foreach (var stagePath in this.edgeGeomsToSplittedEdgePaths[edgePath.EdgeGeometry]) { pathsEnum.MoveNext(); stagePath.PathPoints = pathsEnum.Current; } return true; }
internal virtual void RetryPathsWithAdditionalGroupsEnabled(MsmtRectilinearPath shortestPathRouter, Path edgePath) { // Insert any spatial parent groups that are not in our hierarchical parent tree and retry, // if we haven't already done this. if (!PortManager.SetAllAncestorsActive(edgePath.EdgeGeometry, ShapeToObstacleMap) || !GeneratePath(shortestPathRouter, edgePath)) { // Last chance: enable all groups (if we have any). Only do this on a per-path basis so a single degenerate // path won't make the entire graph look bad. PortManager.SetAllGroupsActive(); GeneratePath(shortestPathRouter, edgePath, lastChance:true); } }
private static bool GetSingleStagePath(Path edgePath, MsmtRectilinearPath shortestPathRouter, List<VisibilityVertex> sourceVertices, List<VisibilityVertex> targetVertices, bool lastChance) { edgePath.PathPoints = shortestPathRouter.GetPath(sourceVertices, targetVertices); if (lastChance) { EnsureNonNullPath(edgePath); } return (edgePath.PathPoints != null); }
internal virtual bool GeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath, bool lastChance = false) { var sourceVertices = PortManager.FindVertices(edgePath.EdgeGeometry.SourcePort); var targetVertices = PortManager.FindVertices(edgePath.EdgeGeometry.TargetPort); return edgePath.EdgeGeometry.HasWaypoints ? this.GetMultiStagePath(edgePath, shortestPathRouter, sourceVertices, targetVertices, lastChance) : GetSingleStagePath(edgePath, shortestPathRouter, sourceVertices, targetVertices, lastChance); }
internal virtual void SpliceVisibilityAndGeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath) { this.PortManager.AddControlPointsToGraph(edgePath.EdgeGeometry, this.ShapeToObstacleMap); this.PortManager.TransUtil.DevTrace_VerifyAllVertices(this.VisibilityGraph); this.PortManager.TransUtil.DevTrace_VerifyAllEdgeIntersections(this.VisibilityGraph); if (!this.GeneratePath(shortestPathRouter, edgePath)) { this.RetryPathsWithAdditionalGroupsEnabled(shortestPathRouter, edgePath); } this.PortManager.RemoveControlPointsFromGraph(); }
private void AddControlPointsAndGeneratePath(MsmtRectilinearPath shortestPathRouter, Path edgePath) { if (!edgePath.EdgeGeometry.HasWaypoints) { Point[] intersectPoints = PortManager.GetPortVisibilityIntersection(edgePath.EdgeGeometry); if (intersectPoints != null) { GeneratePathThroughVisibilityIntersection(edgePath, intersectPoints); return; } } this.SpliceVisibilityAndGeneratePath(shortestPathRouter, edgePath); }
private void FillEdgePathsWithShortestPaths(IEnumerable<Path> edgePaths) { this.PortManager.BeginRouteEdges(); var shortestPathRouter = new MsmtRectilinearPath(this.BendPenaltyAsAPercentageOfDistance); foreach (Path edgePath in edgePaths) { this.ProgressStep(); AddControlPointsAndGeneratePath(shortestPathRouter, edgePath); } this.PortManager.EndRouteEdges(); }