implemented crossing minimizing offset algorithm #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently working on this to make the testcases work and improve the logic, no need of review as of now, Thanks.
High-level
Detailed, review-friendly notes
Imports and type/style harmonization
TraceOverlapIssueSolver.tsto match project preferences; no functional impact.Core algorithm replacement in
_step()offsetswith an alternating pattern:(floor(idx/2)+1) * SHIFT_DISTANCE- + - + ...regardless of resulting crossings.correctedTraceMap.(floor(idx/2)+1) * SHIFT_DISTANCEper overlapping group.2^Nsign patterns, where bit i represents ± for group i.correctedTraceMap.Inline helpers added to
_step()for simulation/scoring (orthogonal-only)orthogonalSegmentsIntersect(a1,a2,b1,b2): booleancountCrossingsBetweenPaths(pathA, pathB): numberorthogonalSegmentsIntersect.Simulation flow for scoring candidates
applyOffsetsToMap(offsets):applyJogToTerminalSegmentto preserve endpoint orthogonality via jogs.scoreOffsets(offsets):bestScore.Application of chosen configuration
correctedTraceMap.applyJogToTerminalSegment.Fallback logic and performance guardrails
Visualization unchanged
visualize()still:correctedTraceMap.New test:
tests/solvers/TraceOverlapShiftSolver/TraceOverlapIssueSolver_minCrossings.test.tsTraceOverlapIssueSolverand asserts:Minor utilities/consistency
SHIFT_DISTANCEas the jog size in both simulation and the final application to produce consistent jog geometry.samePointhelper.What didn’t change
findNextOverlapIssue) inTraceOverlapShiftSolverwas not modified.applyJogToTerminalSegment) remains unchanged; only reused where appropriate.Why this is safe and compatible
_step()and uses only local helpers and existing utilities.If you want code pointers, here are the key areas to review:
The new helpers and candidate search/scoring inside
_step().The two application passes: one for simulation (
applyOffsetsToMap) and one for final application tocorrectedTraceMap.The unchanged
visualize()confirming red-original vs blue-corrected overlays.The new test file under
tests/solvers/TraceOverlapShiftSolver/TraceOverlapIssueSolver_minCrossings.test.ts.Implemented crossing-minimizing search with pruning and fallback; integrated with jog and cleanup.
Added orthogonal intersection/crossing helpers inline.
Preserved visualization and external behavior; added a multi-trace overlap test.