fix(elksharp): preserve source/target endpoints in corridor reroute clearance push
When the corridor reroute pushes a horizontal segment away from a blocking node, preserve the first point (source connection) and insert a vertical step to reconnect the last point (target connection) at the original Y. Previously, pushing all points uniformly would disconnect the edge from its target node when the push Y exceeded the target node's boundary. Fixes edge/9 (Retry Decision → Set batchGenerateFailed) which was pushed to Y=653 but the target node bottom is at Y=614 — the endpoint now steps back up to Y=592 to reconnect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -209,12 +209,30 @@ internal static partial class ElkEdgeRouterIterative
|
|||||||
&& bestPushY < graphMaxY + 56d
|
&& bestPushY < graphMaxY + 56d
|
||||||
&& Math.Abs(bestPushY - laneY) > 2d)
|
&& Math.Abs(bestPushY - laneY) > 2d)
|
||||||
{
|
{
|
||||||
var newPath = new List<ElkPoint>(path.Count);
|
var newPath = new List<ElkPoint>(path.Count + 2);
|
||||||
for (var i = 0; i < path.Count; i++)
|
for (var i = 0; i < path.Count; i++)
|
||||||
{
|
{
|
||||||
if (i >= bestSegStart && i <= bestSegStart + 1
|
if (i >= bestSegStart && i <= bestSegStart + 1
|
||||||
&& Math.Abs(path[i].Y - laneY) <= 2d)
|
&& Math.Abs(path[i].Y - laneY) <= 2d)
|
||||||
{
|
{
|
||||||
|
// Preserve source connection (first point).
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
newPath.Add(path[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preserve target connection (last point) —
|
||||||
|
// insert a vertical step to reconnect.
|
||||||
|
if (i == path.Count - 1)
|
||||||
|
{
|
||||||
|
var stepX = path[i].X + (path[i - 1].X > path[i].X ? 24d : -24d);
|
||||||
|
newPath.Add(new ElkPoint { X = stepX, Y = bestPushY });
|
||||||
|
newPath.Add(new ElkPoint { X = stepX, Y = path[i].Y });
|
||||||
|
newPath.Add(path[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
newPath.Add(new ElkPoint { X = path[i].X, Y = bestPushY });
|
newPath.Add(new ElkPoint { X = path[i].X, Y = bestPushY });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user