- Welcome, Guest. Please Login or Register
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
Page Index Toggle Pages: 1 Send Topic Print  
Bad Routes
Read 150 times

38Mikes   Offline
YaBB Newbies
Posts: 8
I Love MindFusion!

Bad Routes
Jul 17th, 2017 at 8:52pm
I'm having the problem that the auto-router is creating long and circular routes between nodes that are right next to each other. I have two square shaped nodes right next to each other, when I add a link between them instead of going straight as I would expect it to, it does a full loop around the origination node back to the destination.  The problem goes away if I put some separation between the nodes... but I don't want any separation...
IP Logged    

Slavcho   Offline
God Member
Posts: 1361
Gender: male

Re: Bad Routes
Reply #1 - Jul 18th, 2017 at 8:59am
The router places links in areas unoccupied by nodes by design. You can handle LinkRouted event to replace the automatic route with your own when you detect such adjacent nodes -

private void OnLinkRouted(object sender, LinkEventArgs e)
	var l = e.Link;
	var o = l.Origin.Bounds;
	var d = l.Destination.Bounds;
	if (
		CommonRange(o.Left, o.Right, d.Left, d.Right) &&
		(o.Top == d.Bottom || o.Bottom == d.Top) ||

		CommonRange(o.Top, o.Bottom, d.Top, d.Bottom) &&
		(o.Left == d.Right || o.Right == d.Left))
		l.Shape = LinkShape.Polyline;
		l.SegmentCount = 1;

bool CommonRange(float a1, float a2, float b1, float b2)
	float amin = Math.Min(a1, a2);
	float amax = Math.Max(a1, a2);
	float bmin = Math.Min(b1, b2);
	float bmax = Math.Max(b1, b2);
	if (amin >= bmax)
		return false;
	if (bmin >= amax)
		return false;
	return true;

IP Logged    
Page Index Toggle Pages: 1 Send Topic Print