Example #1
0
        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);
        }