internal static double CapacityOverflowPenaltyMultiplier(BundlingSettings bundlingSettings) { return(bundlingSettings.CapacityOverflowCoefficient * (bundlingSettings.PathLengthImportance + bundlingSettings.InkImportance)); }
/// <summary> /// fix routing by simulated annealing algorithm /// </summary> internal static bool FixRouting(MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { return(FixRouting(metroGraphData, bundlingSettings, null)); }
internal static bool FixRouting(MetroGraphData metroGraphData, BundlingSettings bundlingSettings, HashSet <Point> changedPoints) { return(new SimulatedAnnealing(metroGraphData, bundlingSettings).FixRouting(changedPoints)); }
public OptimizationsEnabled(BundlingSettings bundlingSettings, IStringResourceProvider stringResourceProvider) { _bundlingSettings = bundlingSettings; _stringResourceProvider = stringResourceProvider; }
internal HubDebugger(MetroGraphData mgd, BundlingSettings bundlingSettings) { this.mgd = mgd; this.bundlingSettings = bundlingSettings; }
static void ProcessDotFile(GViewer gviewer, ArgsParser.ArgsParser argsParser, string dotFileName) { int line; int col; string msg; Graph graph = Parser.Parse(dotFileName, out line, out col, out msg); if (graph == null) { Console.WriteLine("{0}({1},{2}): error: {3}", dotFileName, line, col, msg); Environment.Exit(1); } if (argsParser.OptionIsUsed(RecoverSugiyamaTestOption)) { gviewer.CalculateLayout(graph); graph.GeometryGraph.AlgorithmData = null; LayeredLayout.RecoverAlgorithmData(graph.GeometryGraph); Node node = graph.GeometryGraph.Nodes[1]; node.BoundaryCurve = node.BoundaryCurve.Transform(new PlaneTransformation(3, 0, 0, 0, 3, 0)); LayeredLayout.IncrementalLayout(graph.GeometryGraph, node); gviewer.NeedToCalculateLayout = false; gviewer.Graph = graph; gviewer.NeedToCalculateLayout = true; return; } if (argsParser.OptionIsUsed(MdsOption)) { graph.LayoutAlgorithmSettings = new MdsLayoutSettings(); } else if (argsParser.OptionIsUsed(FdOption)) { graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings(); } if (argsParser.OptionIsUsed(BundlingOption)) { graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling; BundlingSettings bs = GetBundlingSettings(argsParser); graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings = bs; string ink = argsParser.GetValueOfOptionWithAfterString(InkImportanceOption); if (ink != null) { double inkCoeff; if (double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } else { Console.WriteLine("cannot parse {0}", ink); Environment.Exit(1); } } string esString = argsParser.GetValueOfOptionWithAfterString(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { Console.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } } gviewer.Graph = graph; }
NodePositionsAdjuster(MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; }
/// <summary> /// Returns the ideal radius of the hub /// </summary> static double CalculateIdealHubRadiusWithAdjacentEdges(MetroGraphData metroGraphData, BundlingSettings bundlingSettings, Station node) { double r = bundlingSettings.MaxHubRadius; foreach (var adj in node.Neighbors) { r = Math.Min(r, (node.Position - adj.Position).Length / 2); } return(r); }
/// <summary> /// Radius we need to draw to separate adjacent bundles ab and ac /// </summary> internal static double GetMinRadiusForTwoAdjacentBundles(double r, Point a, Point b, Point c, double widthAB, double widthAC, MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { if (widthAB < ApproximateComparer.DistanceEpsilon || widthAC < ApproximateComparer.DistanceEpsilon) { return(r); } double angle = Point.Angle(b, a, c); angle = Math.Min(angle, Math.PI * 2 - angle); if (angle < ApproximateComparer.DistanceEpsilon) { return(2 * bundlingSettings.MaxHubRadius); } if (angle >= Math.PI / 2) { return(r * 1.05); } //find the intersection point of two bundles double sina = Math.Sin(angle); double cosa = Math.Cos(angle); double aa = widthAB / (4 * sina); double bb = widthAC / (4 * sina); double d = 2 * Math.Sqrt(aa * aa + bb * bb + 2 * aa * bb * cosa); d = Math.Min(d, 2 * bundlingSettings.MaxHubRadius); d = Math.Max(d, r); return(d); }
internal FlipCollapser(MetroGraphData metroGraphData, BundlingSettings bundlingSettings, Cdt cdt) { this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; this.cdt = cdt; }
/// <summary> /// Returns the ideal radius of the hub /// </summary> internal static double CalculateIdealHubRadiusWithNeighbors(MetroGraphData metroGraphData, BundlingSettings bundlingSettings, Station node, Point newPosition) { double r = CalculateIdealHubRadius(metroGraphData, bundlingSettings, node); if (node.Neighbors.Count() > 1) { Station[] adjNodes = node.Neighbors; //there must be enough space between neighbor bundles for (int i = 0; i < adjNodes.Length; i++) { Station adj = adjNodes[i]; Station nextAdj = adjNodes[(i + 1) % adjNodes.Length]; r = Math.Max(r, GetMinRadiusForTwoAdjacentBundles(r, node, newPosition, adj, nextAdj, metroGraphData, bundlingSettings)); } } r = Math.Min(r, 2 * bundlingSettings.MaxHubRadius); return(r); }
public CdtIntersections(MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; }
/// <summary> /// Error of path lengths /// </summary> static internal double PathLengthsError(double oldLength, double newLength, double idealLength, BundlingSettings bundlingSettings) { return((oldLength - newLength) * (bundlingSettings.PathLengthImportance / idealLength)); }
/// <summary> /// Error of ink /// </summary> static internal double InkError(double oldInk, double newInk, BundlingSettings bundlingSettings) { return((oldInk - newInk) * bundlingSettings.InkImportance); }
internal BundleBasesCalculator(IMetroMapOrderingAlgorithm metroOrdering, MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { this.metroOrdering = metroOrdering; this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; }
internal static double GetMinRadiusForTwoAdjacentBundlesOld(double r, Station node, Point nodePosition, Station adj0, Station adj1, MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { double w0 = metroGraphData.GetWidth(node, adj0, bundlingSettings.EdgeSeparation); double w1 = metroGraphData.GetWidth(node, adj1, bundlingSettings.EdgeSeparation); return(GetMinRadiusForTwoAdjacentBundlesOld(r, nodePosition, adj0.Position, adj1.Position, w0, w1, metroGraphData, bundlingSettings)); }
/// <summary> /// Constructor /// </summary> internal EdgeNudger(MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; }
/// <summary> /// Radius we need to draw two adjacent bundles ab and ac /// </summary> internal static double GetMinRadiusForTwoAdjacentBundlesOld(double r, Point a, Point b, Point c, double widthAB, double widthAC, MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { if (widthAB < ApproximateComparer.DistanceEpsilon || widthAC < ApproximateComparer.DistanceEpsilon) { return(r); } double angle = Point.Angle(b, a, c); angle = Math.Min(angle, Math.PI * 2 - angle); if (angle < ApproximateComparer.DistanceEpsilon) { return(2 * bundlingSettings.MaxHubRadius); } //binary search //TODO: solve the equation double L = r; double R = 2 * bundlingSettings.MaxHubRadius; while (Math.Abs(R - L) > 0.1) { double C = (L + R) / 2; double alpha0 = Math.Asin(widthAB / (2 * C)); double alpha1 = Math.Asin(widthAC / (2 * C)); if (alpha0 + alpha1 <= angle) { R = C; } else { L = C; } } return(L); }
static void Main(string[] args) { #if DEBUG DisplayGeometryGraph.SetShowFunctions(); #endif ArgsParser.ArgsParser argsParser = SetArgsParser(args); if (argsParser.OptionIsUsed(PolygonDistanceTestOption)) { TestPolygonDistance(); } else if (argsParser.OptionIsUsed(TestCdtThreaderOption)) { TestCdtThreader(); } else if (argsParser.OptionIsUsed(RandomBundlingTest)) { RandomBundlingTests.RsmContent(); } bundling = argsParser.OptionIsUsed(BundlingOption); var gviewer = new GViewer(); gviewer.MouseMove += Draw.GviewerMouseMove; if (argsParser.OptionIsUsed(FdOption)) { TestFD(); gviewer.CurrentLayoutMethod = LayoutMethod.IcrementalLayout; } Form form = CreateForm(null, gviewer); if (argsParser.OptionIsUsed(AsyncLayoutOption)) { gviewer.AsyncLayout = true; } string listOfFilesFile = argsParser.GetValueOfOptionWithAfterString(ListOfFilesOption); if (listOfFilesFile != null) { ProcessListOfFiles(listOfFilesFile, argsParser); return; } string fileName = argsParser.GetValueOfOptionWithAfterString(FileOption); string ext = Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLower(); if (ext == ".dot") { ProcessDotFile(gviewer, argsParser, fileName); } else { if (ext == ".geom") { GeometryGraph geometryGraph = GeometryGraphReader.CreateFromFile(fileName); geometryGraph.Margins = 10; FixHookPorts(geometryGraph); // if (argsParser.OptionIsUsed(BundlingOption)) { for (int i = 0; i < 1; i++) { #if DEBUG /*DisplayGeometryGraph.ShowGraph(geometryGraph); * var l = new List<DebugCurve>(); l.AddRange(geometryGraph.Nodes.Select(n=>new DebugCurve(100,1,"black",n.BoundaryCurve))); * l.AddRange(geometryGraph.Edges.Select(e=>new DebugCurve(100,1,"black", new LineSegment(e.Source.Center,e.Target.Center)))); * foreach (var cl in geometryGraph.RootCluster.AllClustersDepthFirst()) { * l.Add(new DebugCurve(100,2,"blue",cl.BoundaryCurve)); * foreach (var node in cl.Nodes) * l.Add(new DebugCurve(100, 2, "brown", node.BoundaryCurve)); * * foreach (var e in cl.Edges) * l.Add(new DebugCurve(100, 2, "pink", new LineSegment(e.Source.Center, e.Target.Center))); * * } * * DisplayGeometryGraph.ShowDebugCurves(l.ToArray());*/ #endif BundlingSettings bs = GetBundlingSettings(argsParser); double loosePadding; double tightPadding = GetPaddings(argsParser, out loosePadding); if (argsParser.OptionIsUsed(MdsOption)) { var mdsLayoutSettings = new MdsLayoutSettings { RemoveOverlaps = true, NodeSeparation = loosePadding * 3 }; var mdsLayout = new MdsGraphLayout(mdsLayoutSettings, geometryGraph); mdsLayout.Run(); } else { if (argsParser.OptionIsUsed(FdOption)) { var settings = new FastIncrementalLayoutSettings { AvoidOverlaps = true }; (new InitialLayout(geometryGraph, settings)).Run(); } } var splineRouter = new SplineRouter(geometryGraph, geometryGraph.Edges, tightPadding, loosePadding, Math.PI / 6, bs); splineRouter.Run(); } #if DEBUG DisplayGeometryGraph.ShowGraph(geometryGraph); #endif return; } else { if (ext == ".msagl") { Graph graph = Graph.Read(fileName); // DisplayGeometryGraph.ShowGraph(graph.GeometryGraph); if (graph != null) { if (argsParser.OptionIsUsed(BundlingOption)) { BundlingSettings bs = GetBundlingSettings(argsParser); double loosePadding; double tightPadding = GetPaddings(argsParser, out loosePadding); var br = new SplineRouter(graph.GeometryGraph, tightPadding, loosePadding, Math.PI / 6, bs); br.Run(); // DisplayGeometryGraph.ShowGraph(graph.GeometryGraph); } } gviewer.NeedToCalculateLayout = false; gviewer.Graph = graph; gviewer.NeedToCalculateLayout = true; } } } } else if (argsParser.OptionIsUsed(TestCdtOption)) { Triangulation(argsParser.OptionIsUsed(ReverseXOption)); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption0)) { TestTriangulationOnSmallGraph(argsParser); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption2)) { TestTriangulationOnPolys(); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption1)) { ThreadThroughCdt(); Environment.Exit(0); } else if (argsParser.OptionIsUsed(ConstraintsTestOption)) { TestGraphWithConstraints(); } Application.Run(form); }
internal HubRadiiCalculator(MetroGraphData metroGraphData, BundlingSettings bundlingSettings) { this.metroGraphData = metroGraphData; this.bundlingSettings = bundlingSettings; }
/// <summary> /// Returns the ideal radius of the hub /// </summary> internal static double CalculateIdealHubRadiusWithNeighbors(MetroGraphData metroGraphData, BundlingSettings bundlingSettings, Station node) { return(CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, node, node.Position)); }
internal MultiEdgeRouter(List <Edge[]> multiEdgeGeoms, InteractiveEdgeRouter interactiveEdgeRouter, IEnumerable <ICurve> nodeBoundaryCurves, BundlingSettings bundlingSettings, Func <EdgeGeometry, List <Shape> > transparentShapeSetter) { multiEdgeGeometries = multiEdgeGeoms.Select(l => l.Select(e => e.EdgeGeometry).ToArray()).ToList(); this.interactiveEdgeRouter = interactiveEdgeRouter; this.bundlingSettings = bundlingSettings; this.transparentShapeSetter = transparentShapeSetter; nodeTree = RectangleNode <ICurve> .CreateRectangleNodeOnData(nodeBoundaryCurves, c => c.BoundingBox); }