@tscircuit/schematic-trace-solver 0.0.95 → 0.0.96
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/dist/index.d.ts +7 -6
- package/dist/index.js +55 -44
- package/lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver.ts +11 -7
- package/lib/solvers/SchematicTracePipelineSolver/visualizeInputProblem.ts +47 -40
- package/lib/types/InputProblem.ts +1 -0
- package/package.json +1 -1
- package/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260706T213649Z/bug-report-20260706T213649Z.test.ts +3 -1
- package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +1 -1
- package/tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.test.ts +3 -1
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ interface InputProblem {
|
|
|
103
103
|
availableNetLabelOrientations: Record<NetId, FacingDirection[]>;
|
|
104
104
|
maxMspPairDistance?: number;
|
|
105
105
|
_chipObstacleSpatialIndex?: ChipObstacleSpatialIndex;
|
|
106
|
+
_hideRatsNet?: boolean;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
type MspConnectionPairId = string;
|
|
@@ -1012,9 +1013,8 @@ type PipelineStep<T extends new (...args: any[]) => BaseSolver> = {
|
|
|
1012
1013
|
onSolved?: (instance: SchematicTracePipelineSolver) => void;
|
|
1013
1014
|
shouldSkip?: (instance: SchematicTracePipelineSolver) => boolean;
|
|
1014
1015
|
};
|
|
1015
|
-
interface
|
|
1016
|
-
|
|
1017
|
-
allowLongDistanceTraces?: boolean;
|
|
1016
|
+
interface Options {
|
|
1017
|
+
hideRatsNet?: boolean;
|
|
1018
1018
|
}
|
|
1019
1019
|
declare class SchematicTracePipelineSolver extends BaseSolver {
|
|
1020
1020
|
mspConnectionPairSolver?: MspConnectionPairSolver;
|
|
@@ -1036,9 +1036,10 @@ declare class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
1036
1036
|
timeSpentOnPhase: Record<string, number>;
|
|
1037
1037
|
firstIterationOfPhase: Record<string, number>;
|
|
1038
1038
|
inputProblem: InputProblem;
|
|
1039
|
+
hideRatsNet: boolean;
|
|
1039
1040
|
pipelineDef: (PipelineStep<typeof MspConnectionPairSolver> | PipelineStep<typeof SchematicTraceLinesSolver> | PipelineStep<typeof LongDistancePairSolver> | PipelineStep<typeof TraceOverlapShiftSolver> | PipelineStep<typeof NetLabelPlacementSolver> | PipelineStep<typeof TraceLabelOverlapAvoidanceSolver> | PipelineStep<typeof TraceCleanupSolver> | PipelineStep<typeof Example28Solver> | PipelineStep<typeof AvailableNetOrientationSolver> | PipelineStep<typeof RailNetLabelCornerPlacementSolver> | PipelineStep<typeof TraceAnchoredNetLabelOverlapSolver> | PipelineStep<typeof NetLabelTraceCollisionSolver> | PipelineStep<typeof NetLabelNetLabelCollisionSolver>)[];
|
|
1040
|
-
constructor(inputProblem: InputProblem);
|
|
1041
|
-
getConstructorParams(): ConstructorParameters<typeof SchematicTracePipelineSolver
|
|
1041
|
+
constructor(inputProblem: InputProblem, opts?: Options);
|
|
1042
|
+
getConstructorParams(): ConstructorParameters<typeof SchematicTracePipelineSolver>;
|
|
1042
1043
|
currentPipelineStepIndex: number;
|
|
1043
1044
|
private cloneAndCorrectInputProblem;
|
|
1044
1045
|
_step(): void;
|
|
@@ -1052,4 +1053,4 @@ declare class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
1052
1053
|
preview(): GraphicsObject;
|
|
1053
1054
|
}
|
|
1054
1055
|
|
|
1055
|
-
export { type ChipId, type InputChip, type InputDirectConnection, type InputNetConnection, type InputPin, type InputProblem, type NetId, type PinId, SchematicTracePipelineSolver,
|
|
1056
|
+
export { type ChipId, type InputChip, type InputDirectConnection, type InputNetConnection, type InputPin, type InputProblem, type NetId, type PinId, SchematicTracePipelineSolver, SchematicTraceSingleLineSolver2, type SectionId, type TextBoxes };
|
package/dist/index.js
CHANGED
|
@@ -327,7 +327,11 @@ var arePinsInDifferentSchematicSections = (inputProblem, p1, p2) => {
|
|
|
327
327
|
|
|
328
328
|
// lib/solvers/SchematicTracePipelineSolver/visualizeInputProblem.ts
|
|
329
329
|
var visualizeInputProblem = (inputProblem, opts = {}) => {
|
|
330
|
-
const {
|
|
330
|
+
const {
|
|
331
|
+
connectionAlpha = 0.8,
|
|
332
|
+
chipAlpha = 0.8,
|
|
333
|
+
hideRatsNet = inputProblem._hideRatsNet ?? false
|
|
334
|
+
} = opts;
|
|
331
335
|
const graphics = {
|
|
332
336
|
lines: [],
|
|
333
337
|
points: [],
|
|
@@ -367,47 +371,49 @@ ${pin._facingDirection ?? getPinDirection(pin, chip)}`,
|
|
|
367
371
|
strokeColor: "rgba(160, 0, 220, 0.9)"
|
|
368
372
|
});
|
|
369
373
|
}
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
374
|
+
if (!hideRatsNet) {
|
|
375
|
+
for (const directConn of inputProblem.directConnections) {
|
|
376
|
+
const [pinId1, pinId2] = directConn.pinIds;
|
|
377
|
+
const pin1 = pinIdMap.get(pinId1);
|
|
378
|
+
const pin2 = pinIdMap.get(pinId2);
|
|
379
|
+
if (arePinsInDifferentSchematicSections(inputProblem, pin1, pin2)) {
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
graphics.lines.push({
|
|
383
|
+
points: [
|
|
384
|
+
{
|
|
385
|
+
x: pin1.x,
|
|
386
|
+
y: pin1.y
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
x: pin2.x,
|
|
390
|
+
y: pin2.y
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
strokeColor: getColorFromString(
|
|
394
|
+
directConn.netId ?? `${pinId1}-${pinId2}`,
|
|
395
|
+
connectionAlpha
|
|
396
|
+
)
|
|
397
|
+
});
|
|
376
398
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
for (const netConn of inputProblem.netConnections) {
|
|
395
|
-
const pins = netConn.pinIds.map((pinId) => pinIdMap.get(pinId));
|
|
396
|
-
for (let i = 0; i < pins.length - 1; i++) {
|
|
397
|
-
for (let j = i + 1; j < pins.length; j++) {
|
|
398
|
-
const pin1 = pins[i];
|
|
399
|
-
const pin2 = pins[j];
|
|
400
|
-
if (arePinsInDifferentSchematicSections(inputProblem, pin1, pin2)) {
|
|
401
|
-
continue;
|
|
399
|
+
for (const netConn of inputProblem.netConnections) {
|
|
400
|
+
const pins = netConn.pinIds.map((pinId) => pinIdMap.get(pinId));
|
|
401
|
+
for (let i = 0; i < pins.length - 1; i++) {
|
|
402
|
+
for (let j = i + 1; j < pins.length; j++) {
|
|
403
|
+
const pin1 = pins[i];
|
|
404
|
+
const pin2 = pins[j];
|
|
405
|
+
if (arePinsInDifferentSchematicSections(inputProblem, pin1, pin2)) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
graphics.lines.push({
|
|
409
|
+
points: [
|
|
410
|
+
{ x: pin1.x, y: pin1.y },
|
|
411
|
+
{ x: pin2.x, y: pin2.y }
|
|
412
|
+
],
|
|
413
|
+
strokeColor: getColorFromString(netConn.netId, connectionAlpha),
|
|
414
|
+
strokeDash: "4 2"
|
|
415
|
+
});
|
|
402
416
|
}
|
|
403
|
-
graphics.lines.push({
|
|
404
|
-
points: [
|
|
405
|
-
{ x: pin1.x, y: pin1.y },
|
|
406
|
-
{ x: pin2.x, y: pin2.y }
|
|
407
|
-
],
|
|
408
|
-
strokeColor: getColorFromString(netConn.netId, connectionAlpha),
|
|
409
|
-
strokeDash: "4 2"
|
|
410
|
-
});
|
|
411
417
|
}
|
|
412
418
|
}
|
|
413
419
|
}
|
|
@@ -9034,6 +9040,7 @@ var SchematicTracePipelineSolver = class extends BaseSolver {
|
|
|
9034
9040
|
timeSpentOnPhase;
|
|
9035
9041
|
firstIterationOfPhase;
|
|
9036
9042
|
inputProblem;
|
|
9043
|
+
hideRatsNet;
|
|
9037
9044
|
pipelineDef = [
|
|
9038
9045
|
definePipelineStep(
|
|
9039
9046
|
"mspConnectionPairSolver",
|
|
@@ -9233,8 +9240,9 @@ var SchematicTracePipelineSolver = class extends BaseSolver {
|
|
|
9233
9240
|
]
|
|
9234
9241
|
)
|
|
9235
9242
|
];
|
|
9236
|
-
constructor(inputProblem) {
|
|
9243
|
+
constructor(inputProblem, opts) {
|
|
9237
9244
|
super();
|
|
9245
|
+
this.hideRatsNet = opts?.hideRatsNet ?? false;
|
|
9238
9246
|
this.inputProblem = this.cloneAndCorrectInputProblem(inputProblem);
|
|
9239
9247
|
this.MAX_ITERATIONS = 1e6;
|
|
9240
9248
|
this.startTimeOfPhase = {};
|
|
@@ -9243,13 +9251,14 @@ var SchematicTracePipelineSolver = class extends BaseSolver {
|
|
|
9243
9251
|
this.firstIterationOfPhase = {};
|
|
9244
9252
|
}
|
|
9245
9253
|
getConstructorParams() {
|
|
9246
|
-
return this.inputProblem;
|
|
9254
|
+
return [this.inputProblem, { hideRatsNet: this.hideRatsNet }];
|
|
9247
9255
|
}
|
|
9248
9256
|
currentPipelineStepIndex = 0;
|
|
9249
9257
|
cloneAndCorrectInputProblem(original) {
|
|
9250
9258
|
const cloned = structuredClone({
|
|
9251
9259
|
...original,
|
|
9252
|
-
_chipObstacleSpatialIndex: void 0
|
|
9260
|
+
_chipObstacleSpatialIndex: void 0,
|
|
9261
|
+
_hideRatsNet: this.hideRatsNet
|
|
9253
9262
|
});
|
|
9254
9263
|
expandChipsToFitPins(cloned);
|
|
9255
9264
|
correctPinsInsideChips(cloned);
|
|
@@ -9295,7 +9304,9 @@ var SchematicTracePipelineSolver = class extends BaseSolver {
|
|
|
9295
9304
|
if (!this.solved && this.activeSubSolver)
|
|
9296
9305
|
return this.activeSubSolver.visualize();
|
|
9297
9306
|
const visualizations = [
|
|
9298
|
-
visualizeInputProblem(this.inputProblem
|
|
9307
|
+
visualizeInputProblem(this.inputProblem, {
|
|
9308
|
+
hideRatsNet: this.hideRatsNet
|
|
9309
|
+
}),
|
|
9299
9310
|
...this.pipelineDef.map((p) => this[p.solverName]?.visualize()).filter(Boolean).map((viz, stepIndex) => {
|
|
9300
9311
|
for (const rect of viz.rects ?? []) {
|
|
9301
9312
|
rect.step = stepIndex;
|
|
@@ -61,9 +61,8 @@ function definePipelineStep<
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
allowLongDistanceTraces?: boolean
|
|
64
|
+
interface Options {
|
|
65
|
+
hideRatsNet?: boolean
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
export class SchematicTracePipelineSolver extends BaseSolver {
|
|
@@ -89,6 +88,7 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
89
88
|
firstIterationOfPhase: Record<string, number>
|
|
90
89
|
|
|
91
90
|
inputProblem: InputProblem
|
|
91
|
+
hideRatsNet: boolean
|
|
92
92
|
|
|
93
93
|
pipelineDef = [
|
|
94
94
|
definePipelineStep(
|
|
@@ -318,8 +318,9 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
318
318
|
),
|
|
319
319
|
]
|
|
320
320
|
|
|
321
|
-
constructor(inputProblem: InputProblem) {
|
|
321
|
+
constructor(inputProblem: InputProblem, opts?: Options) {
|
|
322
322
|
super()
|
|
323
|
+
this.hideRatsNet = opts?.hideRatsNet ?? false
|
|
323
324
|
this.inputProblem = this.cloneAndCorrectInputProblem(inputProblem)
|
|
324
325
|
this.MAX_ITERATIONS = 1e6
|
|
325
326
|
this.startTimeOfPhase = {}
|
|
@@ -330,8 +331,8 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
330
331
|
|
|
331
332
|
override getConstructorParams(): ConstructorParameters<
|
|
332
333
|
typeof SchematicTracePipelineSolver
|
|
333
|
-
>
|
|
334
|
-
return this.inputProblem
|
|
334
|
+
> {
|
|
335
|
+
return [this.inputProblem, { hideRatsNet: this.hideRatsNet }]
|
|
335
336
|
}
|
|
336
337
|
|
|
337
338
|
currentPipelineStepIndex = 0
|
|
@@ -340,6 +341,7 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
340
341
|
const cloned: InputProblem = structuredClone({
|
|
341
342
|
...original,
|
|
342
343
|
_chipObstacleSpatialIndex: undefined,
|
|
344
|
+
_hideRatsNet: this.hideRatsNet,
|
|
343
345
|
})
|
|
344
346
|
|
|
345
347
|
// First, expand chips so existing pin coordinates sit on or within their edges without shrinking.
|
|
@@ -399,7 +401,9 @@ export class SchematicTracePipelineSolver extends BaseSolver {
|
|
|
399
401
|
return this.activeSubSolver.visualize()
|
|
400
402
|
|
|
401
403
|
const visualizations = [
|
|
402
|
-
visualizeInputProblem(this.inputProblem
|
|
404
|
+
visualizeInputProblem(this.inputProblem, {
|
|
405
|
+
hideRatsNet: this.hideRatsNet,
|
|
406
|
+
}),
|
|
403
407
|
...(this.pipelineDef
|
|
404
408
|
.map((p) => (this as any)[p.solverName]?.visualize())
|
|
405
409
|
.filter(Boolean)
|
|
@@ -9,9 +9,14 @@ export const visualizeInputProblem = (
|
|
|
9
9
|
opts: {
|
|
10
10
|
chipAlpha?: number
|
|
11
11
|
connectionAlpha?: number
|
|
12
|
+
hideRatsNet?: boolean
|
|
12
13
|
} = {},
|
|
13
14
|
): GraphicsObject => {
|
|
14
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
connectionAlpha = 0.8,
|
|
17
|
+
chipAlpha = 0.8,
|
|
18
|
+
hideRatsNet = inputProblem._hideRatsNet ?? false,
|
|
19
|
+
} = opts
|
|
15
20
|
const graphics: Pick<
|
|
16
21
|
Required<GraphicsObject>,
|
|
17
22
|
"lines" | "points" | "rects"
|
|
@@ -58,48 +63,50 @@ export const visualizeInputProblem = (
|
|
|
58
63
|
} as any)
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if (!hideRatsNet) {
|
|
67
|
+
for (const directConn of inputProblem.directConnections) {
|
|
68
|
+
const [pinId1, pinId2] = directConn.pinIds
|
|
69
|
+
const pin1 = pinIdMap.get(pinId1)!
|
|
70
|
+
const pin2 = pinIdMap.get(pinId2)!
|
|
71
|
+
if (arePinsInDifferentSchematicSections(inputProblem, pin1, pin2)) {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
graphics.lines.push({
|
|
75
|
+
points: [
|
|
76
|
+
{
|
|
77
|
+
x: pin1.x,
|
|
78
|
+
y: pin1.y,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
x: pin2.x,
|
|
82
|
+
y: pin2.y,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
strokeColor: getColorFromString(
|
|
86
|
+
directConn.netId ?? `${pinId1}-${pinId2}`,
|
|
87
|
+
connectionAlpha,
|
|
88
|
+
),
|
|
89
|
+
})
|
|
67
90
|
}
|
|
68
|
-
graphics.lines.push({
|
|
69
|
-
points: [
|
|
70
|
-
{
|
|
71
|
-
x: pin1.x,
|
|
72
|
-
y: pin1.y,
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
x: pin2.x,
|
|
76
|
-
y: pin2.y,
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
strokeColor: getColorFromString(
|
|
80
|
-
directConn.netId ?? `${pinId1}-${pinId2}`,
|
|
81
|
-
connectionAlpha,
|
|
82
|
-
),
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
for (const netConn of inputProblem.netConnections) {
|
|
93
|
+
const pins = netConn.pinIds.map((pinId) => pinIdMap.get(pinId)!)
|
|
94
|
+
for (let i = 0; i < pins.length - 1; i++) {
|
|
95
|
+
for (let j = i + 1; j < pins.length; j++) {
|
|
96
|
+
const pin1 = pins[i]!
|
|
97
|
+
const pin2 = pins[j]!
|
|
98
|
+
if (arePinsInDifferentSchematicSections(inputProblem, pin1, pin2)) {
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
101
|
+
graphics.lines.push({
|
|
102
|
+
points: [
|
|
103
|
+
{ x: pin1.x, y: pin1.y },
|
|
104
|
+
{ x: pin2.x, y: pin2.y },
|
|
105
|
+
],
|
|
106
|
+
strokeColor: getColorFromString(netConn.netId, connectionAlpha),
|
|
107
|
+
strokeDash: "4 2",
|
|
108
|
+
})
|
|
94
109
|
}
|
|
95
|
-
graphics.lines.push({
|
|
96
|
-
points: [
|
|
97
|
-
{ x: pin1.x, y: pin1.y },
|
|
98
|
-
{ x: pin2.x, y: pin2.y },
|
|
99
|
-
],
|
|
100
|
-
strokeColor: getColorFromString(netConn.netId, connectionAlpha),
|
|
101
|
-
strokeDash: "4 2",
|
|
102
|
-
})
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
}
|