microsoft / microsoft/automatic-graph-layout

InteractiveEdgeRouter does not appear to be respecting BoundaryCurves of square nodes

Open
#260 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
1.5k
Forks
319
Avg merge
38m
Merged PRs (30d)
1

Description

This code is adapted from the EdgeRoutingSample DemoRoutingFromPortToPort and DrawEdgeWithPort methods. However, I notice that the nodes within that particular example are ellipses which appear to make the difference.

The nodes are simple squares, but it seems that the inner InteractiveEdgeRouter is not respecting the boundary curves of the square nodes. The boundary curves passed into the InteractiveEdgeRouter are however correct:

private void DoLayout(GeometryGraph geometryGraph)
{
	IEnumerable<GeometryGraph> subGraphs = GraphConnectedComponents.CreateComponents(geometryGraph.Nodes, geometryGraph.Edges);

	SugiyamaLayoutSettings layoutSettings = new SugiyamaLayoutSettings();
	layoutSettings.EdgeRoutingSettings.EdgeRoutingMode = Microsoft.Msagl.Core.Routing.EdgeRoutingMode.Rectilinear;
	layoutSettings.NodeSeparation = 120;
	layoutSettings.LayerSeparation = 120;
	layoutSettings.Transformation = PlaneTransformation.Rotation(Math.PI);

	foreach (GeometryGraph subgraph in subGraphs)
	{
		LayeredLayout layout = new LayeredLayout(subgraph, layoutSettings);
		subgraph.Margins = layoutSettings.NodeSeparation + 200;
		layout.Run();
	}

	InteractiveEdgeRouter portRouter = new InteractiveEdgeRouter(geometryGraph.Nodes.Select(n => n.BoundaryCurve), 0, 0, 0);
	portRouter.Run();
	foreach (Edge tEdge in geometryGraph.Edges)
	{
		FloatingPort port1 = new FloatingPort(null, new Microsoft.Msagl.Core.Geometry.Point(tEdge.Source.BoundingBox.Center.X, tEdge.Source.BoundingBox.Bottom - 10));
		FloatingPort port2 = new FloatingPort(null, new Microsoft.Msagl.Core.Geometry.Point(tEdge.Target.BoundingBox.Center.X, tEdge.Target.BoundingBox.Top + 10));
		ICurve spline = portRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(port1, port2, false, out _);

		Arrowheads.TrimSplineAndCalculateArrowheads(tEdge.EdgeGeometry,
			tEdge.Source.BoundaryCurve,
			tEdge.Target.BoundaryCurve,
			spline, true, false);

		DrawSpline(tEdge, spline);
	}

}

NodeBoundaries

I am aware that the ports appear backwards - i.e. exit at the top and entry at the bottom. This is a deliberate setup to test MSAGL.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the DoLayout example in the issue and trace InteractiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady, including the BoundaryCurve values passed to the router. Reproduce the square-node case and compare its routed spline with the ellipse-based EdgeRoutingSample; done means the router respects square node boundaries in this scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.