Exemple #1
0
        static void DemoEdgeRouterHelper(GeometryGraph graph)
        {
            DemoRoutingFromPortToPort(graph);

            var router = new SplineRouter(graph, 3, 3, Math.PI / 6, null);


            router.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif

            var rectRouter = new RectilinearEdgeRouter(graph, 3, 3, true);
            rectRouter.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif
        }
        internal static void RouteEdges(GeometryGraph component, LayoutAlgorithmSettings settings, CancelToken cancelToken)
        {
            EdgeRoutingMode mode = settings.EdgeRoutingSettings.EdgeRoutingMode;

            // Use straight line routing on very large graphs otherwise it is too slow
            if (component.Nodes.Count >= 2000)
            {
                mode = EdgeRoutingMode.StraightLine;
            }

            switch (mode)
            {
            case EdgeRoutingMode.Spline:
                var splineRouter = new SplineRouter(
                    component,
                    settings.EdgeRoutingSettings.Padding,
                    settings.NodeSeparation, settings.EdgeRoutingSettings.ConeAngle, null);
                splineRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.SplineBundling:
                splineRouter = new SplineRouter(
                    component,
                    settings.EdgeRoutingSettings.Padding,
                    settings.NodeSeparation / 20, settings.EdgeRoutingSettings.ConeAngle,
                    new BundlingSettings());
                splineRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.Rectilinear:
                double edgePadding           = settings.EdgeRoutingSettings.Padding;
                double cornerRadius          = settings.EdgeRoutingSettings.CornerRadius;
                var    rectilinearEdgeRouter = new RectilinearEdgeRouter(component, edgePadding, cornerRadius,
                                                                         true);
                rectilinearEdgeRouter.Run(cancelToken);
                break;

            case EdgeRoutingMode.StraightLine:
                var router = new StraightLineEdges(component.Edges,
                                                   settings.EdgeRoutingSettings.Padding);
                router.Run(cancelToken);
                break;
            }
        }
        public void SimpleClusterGraphRectilinear()
        {
            var g       = new GeometryGraph();
            var node0   = new Node(CurveFactory.CreateRectangle(10, 10, new Point()), 0);
            var node1   = new Node(CurveFactory.CreateRectangle(10, 10, new Point()), 1);
            var cluster = new Cluster(new[] { node1 });

            cluster.UserData      = 2;
            cluster.BoundaryCurve = CurveFactory.CreateRectangle(10, 10, new Point());
            var edge = new Edge(node0, node1)
            {
                Length = 100
            };

            g.Nodes.Add(node0);
            g.Nodes.Add(node1);
            g.Edges.Add(edge);
            var cluster2 = new Cluster(new[] { node0 }, new[] { cluster });

            cluster2.UserData      = 3;
            cluster2.BoundaryCurve = CurveFactory.CreateRectangle(10, 10, new Point());
            g.RootCluster          = cluster2;
            InitialLayout initialLayout = new InitialLayout(g, new FastIncrementalLayoutSettings()
            {
                AvoidOverlaps = true
            });

            initialLayout.Run();

            RectilinearEdgeRouter router = new RectilinearEdgeRouter(g, 1, 1, false);

            router.Run();
            EnableDebugViewer();
            ShowGraphInDebugViewer(g);
            var bb0 = node0.BoundingBox;

            bb0.Pad(1);
            Assert.IsTrue(bb0.Contains(edge.EdgeGeometry.Curve.Start));
            var bb1 = node1.BoundingBox;

            bb1.Pad(1);
            Assert.IsTrue(bb1.Contains(edge.EdgeGeometry.Curve.End));
        }
        static void DemoEdgeRouterHelper(GeometryGraph graph)
        {
            DemoRoutingFromPortToPort(graph);

            var bundlingSettings = new BundlingSettings();
            // set bundling settings to null to disable the bundling of the edges

            var router = new SplineRouter(graph, 3, 3, Math.PI / 6, bundlingSettings);


            router.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif

            var rectRouter = new RectilinearEdgeRouter(graph, 3, 3, true);
            rectRouter.Run();
#if TEST
            LayoutAlgorithmSettings.ShowGraph(graph);
#endif
        }
Exemple #5
0
        private void ApplyLayout(GeometryGraph geometryGraph)
        {
            InitialLayout initialLayout = new InitialLayout(geometryGraph,
                                                            new FastIncrementalLayoutSettings()
            {
                AvoidOverlaps = true
            });

            initialLayout.Run();

            RectilinearEdgeRouter router = new RectilinearEdgeRouter(geometryGraph, 1, 1, false);

            router.Run();

            foreach (var msNode in geometryGraph.Nodes)
            {
                Entity entity = (Entity)msNode.UserData;
                AddPositionComponent(entity, msNode.BoundingBox.LeftTop);

                Console.WriteLine($"{entity.Name} is at {msNode.BoundingBox.LeftTop}");
            }
        }