示例#1
0
        /// <summary>
        /// calculates maximum possible edge separation for the computed routing
        ///   if it is greater than bundlingSettings.EdgeSeparation, then proceed
        ///   if it is smaller, then either
        ///     stop edge bundling, or
        ///     reduce edge separation, or
        ///     move obstacles to get more free space
        /// </summary>
        bool AnalyzeEdgeSeparation()
        {
            Dictionary <EdgeGeometry, Set <CdtEdge> > crossedCdtEdges = new Dictionary <EdgeGeometry, Set <CdtEdge> >();

            shortestPathRouter.FillCrossedCdtEdges(crossedCdtEdges);
            Dictionary <CdtEdge, Set <EdgeGeometry> > pathsOnCdtEdge = GetPathsOnCdtEdge(crossedCdtEdges);
            double es = CalculateMaxAllowedEdgeSeparation(pathsOnCdtEdge);

            // TimeMeasurer.DebugOutput("opt es: " + es);

            if (es >= bundlingSettings.EdgeSeparation)
            {
                return(true); //we can even enlarge it here
            }
            if (es <= 0.02)
            {
                TimeMeasurer.DebugOutput("edge bundling can't be executed: not enough free space around obstacles");
                foreach (var e in regularEdges)
                {
                    e.Curve = null;
                }

                return(false);
            }
            // reducing edge separation
            // TimeMeasurer.DebugOutput("reducing edge separation to " + es);
            bundlingSettings.EdgeSeparation = es;
            shortestPathRouter.RouteEdges();
            return(true);
        }
示例#2
0
        /// <summary>
        /// edge routing with Ordered Bundles:
        /// 1. route edges with bundling
        /// 2. nudge bundles and hubs
        /// 3. order paths
        /// </summary>
        protected override void RunInternal()
        {
            //TimeMeasurer.DebugOutput("edge bundling started");
            if (ThereAreOverlaps(TightHierarchy))
            {
                /*
                 * LayoutAlgorithmSettings.ShowDebugCurves(
                 *  TightHierarchy.GetAllLeaves().Select(p => new DebugCurve(100, 1, "black", p)).ToArray());*/
                Status = BundlingStatus.Overlaps;
                TimeMeasurer.DebugOutput("overlaps in edge bundling");
                return;
            }

            FixLocationsForHookAnywherePorts(geometryGraph.Edges);
            if (!RoutePathsWithSteinerDijkstra())
            {
                Status = BundlingStatus.EdgeSeparationIsTooLarge;
                return;
            }
            FixChildParentEdges();
            if (!bundlingSettings.StopAfterShortestPaths)
            {
                var metroGraphData = new MetroGraphData(regularEdges.Select(e => e.EdgeGeometry).ToArray(),
                                                        LooseHierarchy,
                                                        TightHierarchy,
                                                        bundlingSettings,
                                                        shortestPathRouter.Cdt,
                                                        EdgeLooseEnterable,
                                                        EdgeTightEnterable,
                                                        loosePolylineOfPort);
                NodePositionsAdjuster.FixRouting(metroGraphData, bundlingSettings);
                new EdgeNudger(metroGraphData, bundlingSettings).Run();
                //TimeMeasurer.DebugOutput("edge bundling ended");
            }
            RouteSelfEdges();
            FixArrowheads();
        }