@tscircuit/schematic-trace-solver 0.0.45 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bun-formatcheck.yml +1 -1
- package/.github/workflows/bun-pver-release.yml +1 -1
- package/.github/workflows/bun-test.yml +1 -1
- package/.github/workflows/bun-typecheck.yml +1 -1
- package/dist/index.d.ts +35 -9
- package/dist/index.js +543 -186
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/TraceLabelOverlapAvoidanceSolver.ts +92 -50
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/detectTraceLabelOverlap.ts +26 -11
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/rerouteCollidingTrace.ts +16 -5
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/LabelMergingSolver.ts +95 -75
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/filterLabelsAtTraceEdges.ts +74 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/groupLabelsByChipAndOrientation.ts +45 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/LabelMergingSolver/mergeLabelGroup.ts +71 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/OverlapAvoidanceStepSolver.ts +162 -28
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/doesTraceStartOrEndInLabel.ts +58 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/isPointInsideLabel.ts +23 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/OverlapAvoidanceStepSolver/visualizeDecomposition.ts +54 -0
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/sub-solvers/SingleOverlapSolver/SingleOverlapSolver.ts +13 -1
- package/lib/solvers/TraceLabelOverlapAvoidanceSolver/tryFourPointDetour.ts +110 -60
- package/package.json +1 -1
- package/site/examples/example27.page.tsx +4 -0
- package/tests/assets/example27.json +168 -0
- package/tests/examples/__snapshots__/example03.snap.svg +67 -67
- package/tests/examples/__snapshots__/example16.snap.svg +3 -3
- package/tests/examples/__snapshots__/example30.snap.svg +258 -0
- package/tests/examples/example30.test.ts +12 -0
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/__snapshots__/TraceLabelOverlapAvoidanceSolver.snap.svg +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -396,13 +396,20 @@ interface LabelMergingSolverOutput {
|
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
398
398
|
* Merges multiple net labels into a single, larger label if they are on the
|
|
399
|
-
* same side of the same chip
|
|
399
|
+
* same side of the same chip and physically adjacent.
|
|
400
400
|
*/
|
|
401
401
|
declare class MergedNetLabelObstacleSolver extends BaseSolver {
|
|
402
402
|
private input;
|
|
403
403
|
private output;
|
|
404
404
|
private inputProblem;
|
|
405
405
|
private traces;
|
|
406
|
+
private pipelineStep;
|
|
407
|
+
private filteredLabels;
|
|
408
|
+
private labelGroups;
|
|
409
|
+
private groupKeysToProcess;
|
|
410
|
+
private finalPlacements;
|
|
411
|
+
private mergedLabelNetIdMap;
|
|
412
|
+
private activeMergingGroupKey;
|
|
406
413
|
constructor(solverInput: LabelMergingSolverInput);
|
|
407
414
|
_step(): void;
|
|
408
415
|
getOutput(): LabelMergingSolverOutput;
|
|
@@ -428,6 +435,7 @@ declare class SingleOverlapSolver extends BaseSolver {
|
|
|
428
435
|
problem: InputProblem;
|
|
429
436
|
obstacles: ReturnType<typeof getObstacleRects>;
|
|
430
437
|
label: NetLabelPlacement;
|
|
438
|
+
_tried: number;
|
|
431
439
|
constructor(solverInput: SingleOverlapSolverInput);
|
|
432
440
|
_step(): void;
|
|
433
441
|
visualize(): GraphicsObject;
|
|
@@ -436,8 +444,10 @@ declare class SingleOverlapSolver extends BaseSolver {
|
|
|
436
444
|
interface OverlapCollectionSolverInput {
|
|
437
445
|
inputProblem: InputProblem;
|
|
438
446
|
traces: SolvedTracePath[];
|
|
439
|
-
|
|
447
|
+
initialNetLabelPlacements: NetLabelPlacement[];
|
|
448
|
+
mergedNetLabelPlacements: NetLabelPlacement[];
|
|
440
449
|
mergedLabelNetIdMap: Record<string, Set<string>>;
|
|
450
|
+
detourCounts: Map<string, number>;
|
|
441
451
|
}
|
|
442
452
|
/**
|
|
443
453
|
* This is an internal solver that manages the step-by-step process of avoiding
|
|
@@ -445,20 +455,24 @@ interface OverlapCollectionSolverInput {
|
|
|
445
455
|
*/
|
|
446
456
|
declare class OverlapAvoidanceStepSolver extends BaseSolver {
|
|
447
457
|
inputProblem: InputProblem;
|
|
448
|
-
|
|
458
|
+
initialNetLabelPlacements: NetLabelPlacement[];
|
|
459
|
+
mergedNetLabelPlacements: NetLabelPlacement[];
|
|
449
460
|
mergedLabelNetIdMap: Record<string, Set<string>>;
|
|
450
461
|
allTraces: SolvedTracePath[];
|
|
451
462
|
modifiedTraces: SolvedTracePath[];
|
|
452
|
-
private detourCountByLabel;
|
|
453
463
|
private readonly PADDING_BUFFER;
|
|
464
|
+
private detourCounts;
|
|
454
465
|
activeSubSolver: SingleOverlapSolver | null;
|
|
455
466
|
private overlapQueue;
|
|
456
467
|
private recentlyFailed;
|
|
468
|
+
private currentlyProcessingOverlap;
|
|
469
|
+
private decomposedChildLabels;
|
|
457
470
|
constructor(solverInput: OverlapCollectionSolverInput);
|
|
458
471
|
_step(): void;
|
|
459
472
|
getOutput(): {
|
|
460
473
|
allTraces: SolvedTracePath[];
|
|
461
474
|
modifiedTraces: SolvedTracePath[];
|
|
475
|
+
detourCounts: Map<string, number>;
|
|
462
476
|
};
|
|
463
477
|
visualize(): GraphicsObject;
|
|
464
478
|
}
|
|
@@ -469,16 +483,28 @@ interface TraceLabelOverlapAvoidanceSolverInput {
|
|
|
469
483
|
netLabelPlacements: NetLabelPlacement[];
|
|
470
484
|
}
|
|
471
485
|
/**
|
|
472
|
-
*
|
|
473
|
-
*
|
|
486
|
+
* Resolves overlaps between schematic traces and net labels using a two-phase,
|
|
487
|
+
* "fire-and-forget" dispatching strategy.
|
|
488
|
+
*
|
|
489
|
+
* This solver operates in two distinct phases:
|
|
490
|
+
*
|
|
491
|
+
* 1. **Dispatch Phase**: Iterates through traces, identifying clean ones and dispatching
|
|
492
|
+
* colliding ones to dedicated `OverlapAvoidanceStepSolver` instances.
|
|
493
|
+
*
|
|
494
|
+
* 2. **Execution Phase**: Steps through all dispatched sub-solvers until they complete.
|
|
495
|
+
*
|
|
496
|
+
* The final output combines clean traces with results from sub-solvers. A final
|
|
497
|
+
* `MergedNetLabelObstacleSolver` ensures pipeline compatibility.
|
|
474
498
|
*/
|
|
475
499
|
declare class TraceLabelOverlapAvoidanceSolver extends BaseSolver {
|
|
476
500
|
inputProblem: InputProblem;
|
|
477
|
-
traces: SolvedTracePath[];
|
|
478
501
|
netLabelPlacements: NetLabelPlacement[];
|
|
502
|
+
unprocessedTraces: SolvedTracePath[];
|
|
503
|
+
cleanTraces: SolvedTracePath[];
|
|
504
|
+
subSolvers: OverlapAvoidanceStepSolver[];
|
|
505
|
+
private phase;
|
|
506
|
+
detourCounts: Map<string, number>;
|
|
479
507
|
labelMergingSolver?: MergedNetLabelObstacleSolver;
|
|
480
|
-
overlapAvoidanceSolver?: OverlapAvoidanceStepSolver;
|
|
481
|
-
pipelineStepIndex: number;
|
|
482
508
|
constructor(solverInput: TraceLabelOverlapAvoidanceSolverInput);
|
|
483
509
|
_step(): void;
|
|
484
510
|
getOutput(): {
|