diff --git a/src/app.js b/src/app.js index 02afc46..69ad9b1 100644 --- a/src/app.js +++ b/src/app.js @@ -239,6 +239,13 @@ function attachEdgeTabsToNearestBusbars(busbars, geometries, positions, options) } for (const best of selectedByBusbar) { + // Skip if the anchor is too far horizontally from the tab centre — this + // means the busbar doesn't straddle the slot and the arm would require a + // hard 90° bend (e.g. a single-column vertical busbar next to a tab). + // Valid connections have an edge midpoint exactly at tab.x → deltaX ≈ 0. + // Invalid single-column case has deltaX ≈ ±pitch/2 > cellRadius. + if (Math.abs(best.deltaX) > cellRadius) continue; + const sameTabCandidates = conflictsByTab.get(best.tabKey) || []; const leftCandidate = sameTabCandidates.find((candidate) => candidate.deltaX < -betweenBusbarThreshold); const rightCandidate = sameTabCandidates.find((candidate) => candidate.deltaX > betweenBusbarThreshold); diff --git a/src/busbar-geometry.js b/src/busbar-geometry.js index d49fa91..c67fde0 100644 --- a/src/busbar-geometry.js +++ b/src/busbar-geometry.js @@ -309,18 +309,12 @@ function computeEdgeOverlapFeatures(cellIndices, positions, layoutType, overlapL return { extraPads: [], extraSegments: [] }; } - // Skip overlap if it would create a hard 90° bend at every boundary cell. - // This happens when no boundary cell has any busbar neighbour in the same row - // (i.e. the busbar only spans one column and all its internal connections are - // vertical). In that case the horizontal arm is perpendicular to every - // connection and would overlap adjacent busbars. - const hasSameRowBusbarNeighbour = boundaryEntries.some((entry) => - selected.some((other) => - other.index !== entry.index && - Math.abs(other.pos[1] - entry.pos[1]) <= yTolerance - ) - ); - if (!hasSameRowBusbarNeighbour) { + // Skip overlap if the busbar spans only one column (all cells share the same + // X-coordinate, rounded to 0.1 mm). A single-column busbar's internal edges + // are all vertical, so a horizontal arm would be at 90° to every connection + // and would visually overlap adjacent busbars. + const uniqueXCount = new Set(selected.map(e => Math.round(e.pos[0] * 10))).size; + if (uniqueXCount < 2) { return { extraPads: [], extraSegments: [] }; }