-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Is there a way to determine if libavoid failed to route an edge? For example, when elements overlap, making it impossible to find a clear path without obstacles.
Currently, we rely on a heuristic to check if the route was successfully found.
Our logic for reference:
isRouteValid(
route,
sourceElement,
targetElement,
sourcePortId,
targetPortId
) {
const size = route.size();
if (size > 2) {
// when the libavoid route has more than 2 points,
// we consider it valid.
return true;
}
const sourcePs = route.get_ps(0);
const targetPs = route.get_ps(size - 1);
if (sourcePs.x !== targetPs.x && sourcePs.y !== targetPs.y) {
// The route is not straight.
return false;
}
const margin = this.margin;
if (
sourcePortId &&
targetElement.getBBox().inflate(margin).containsPoint(sourcePs)
) {
// The source point is inside the target element.
return false;
}
if (
targetPortId &&
sourceElement.getBBox().inflate(margin).containsPoint(targetPs)
) {
// The target point is inside the source element.
return false;
}
return true;
}Metadata
Metadata
Assignees
Labels
No labels