@tscircuit/schematic-trace-solver 0.0.146 → 0.0.147
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 -2
- package/dist/index.js +96 -74
- package/lib/solvers/AvailableNetOrientationSolver/AvailableNetOrientationSolver.ts +38 -30
- package/lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver.ts +6 -21
- package/lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts +7 -23
- package/lib/solvers/TraceAnchoredNetLabelOverlapSolver/candidates.ts +7 -14
- package/lib/types/InputProblem.ts +8 -0
- package/lib/utils/getNetLabelWidthForConnection.ts +63 -0
- package/package.json +1 -1
- package/tests/repros/__snapshots__/repro-ti-power-output-section.snap.svg +80 -0
- package/tests/repros/repro-ti-power-output-section.input.ts +341 -0
- package/tests/repros/repro-ti-power-output-section.test.ts +13 -0
- package/tests/solvers/InlineNetLabelSolver/__snapshots__/fallback-net-label-width.snap.svg +69 -0
- package/tests/solvers/InlineNetLabelSolver/fallback-net-label-width.test.ts +152 -0
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ interface InputDirectConnection {
|
|
|
88
88
|
pinIds: [PinId, PinId];
|
|
89
89
|
netId?: string;
|
|
90
90
|
netLabelWidth?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Width of the conventional anchored label to use only when an inline label
|
|
93
|
+
* cannot be placed. Unlike `netLabelWidth`, this does not affect whether or
|
|
94
|
+
* how the point-to-point connection is routed.
|
|
95
|
+
*/
|
|
96
|
+
fallbackNetLabelWidth?: number;
|
|
91
97
|
/**
|
|
92
98
|
* When true, this point-to-point connection may be labeled with an "inline
|
|
93
99
|
* net label": the net name is drawn parallel to (and offset from) the routed
|
|
@@ -116,6 +122,7 @@ interface InputNetConnection {
|
|
|
116
122
|
netId: string;
|
|
117
123
|
pinIds: Array<PinId>;
|
|
118
124
|
netLabelWidth?: number;
|
|
125
|
+
fallbackNetLabelWidth?: number;
|
|
119
126
|
netLabelHeight?: number;
|
|
120
127
|
/**
|
|
121
128
|
* When true, a named one- or two-pin net may use inline labels. A single-pin
|
|
@@ -221,7 +228,6 @@ declare class SchematicTraceSingleLineSolver2 extends BaseSolver {
|
|
|
221
228
|
});
|
|
222
229
|
getConstructorParams(): ConstructorParameters<typeof SchematicTraceSingleLineSolver2>[0];
|
|
223
230
|
private getTextBoxPaddingForConnectionPair;
|
|
224
|
-
private getNetLabelWidthForConnectionPair;
|
|
225
231
|
private getNetLabelHeightForConnectionPair;
|
|
226
232
|
private axisOfSegment;
|
|
227
233
|
private pathLength;
|
|
@@ -855,7 +861,6 @@ declare class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
855
861
|
private getSearchDistanceLimit;
|
|
856
862
|
private getLateralColumnMaxDistance;
|
|
857
863
|
private createCandidate;
|
|
858
|
-
private getNetLabelWidth;
|
|
859
864
|
private getNetLabelHeight;
|
|
860
865
|
private getCandidateStatus;
|
|
861
866
|
private isAcceptableTraceAnchorChipCollision;
|
package/dist/index.js
CHANGED
|
@@ -678,6 +678,50 @@ import "graphics-debug";
|
|
|
678
678
|
// lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/SchematicTraceSingleLineSolver2.ts
|
|
679
679
|
import { calculateElbow as calculateElbow2 } from "calculate-elbow";
|
|
680
680
|
|
|
681
|
+
// lib/utils/getNetLabelWidthForConnection.ts
|
|
682
|
+
var getConfiguredWidth = (connections, includeFallbackNetLabelWidth) => {
|
|
683
|
+
const explicitWidth = connections.find(
|
|
684
|
+
(connection) => connection?.netLabelWidth !== void 0
|
|
685
|
+
)?.netLabelWidth;
|
|
686
|
+
if (explicitWidth !== void 0) return explicitWidth;
|
|
687
|
+
if (!includeFallbackNetLabelWidth) return void 0;
|
|
688
|
+
return connections.find(
|
|
689
|
+
(connection) => connection?.fallbackNetLabelWidth !== void 0
|
|
690
|
+
)?.fallbackNetLabelWidth;
|
|
691
|
+
};
|
|
692
|
+
var getNetLabelWidthForConnection = ({
|
|
693
|
+
inputProblem,
|
|
694
|
+
netId,
|
|
695
|
+
pinIds,
|
|
696
|
+
includeFallbackNetLabelWidth = true
|
|
697
|
+
}) => {
|
|
698
|
+
if (netId) {
|
|
699
|
+
const widthByNetId = getConfiguredWidth(
|
|
700
|
+
[
|
|
701
|
+
inputProblem.netConnections.find(
|
|
702
|
+
(connection) => connection.netId === netId
|
|
703
|
+
),
|
|
704
|
+
inputProblem.directConnections.find(
|
|
705
|
+
(connection) => connection.netId === netId
|
|
706
|
+
)
|
|
707
|
+
],
|
|
708
|
+
includeFallbackNetLabelWidth
|
|
709
|
+
);
|
|
710
|
+
if (widthByNetId !== void 0) return widthByNetId;
|
|
711
|
+
}
|
|
712
|
+
return getConfiguredWidth(
|
|
713
|
+
[
|
|
714
|
+
inputProblem.directConnections.find(
|
|
715
|
+
(connection) => connection.pinIds.some((pinId) => pinIds.includes(pinId))
|
|
716
|
+
),
|
|
717
|
+
inputProblem.netConnections.find(
|
|
718
|
+
(connection) => connection.pinIds.some((pinId) => pinIds.includes(pinId))
|
|
719
|
+
)
|
|
720
|
+
],
|
|
721
|
+
includeFallbackNetLabelWidth
|
|
722
|
+
);
|
|
723
|
+
};
|
|
724
|
+
|
|
681
725
|
// lib/utils/textBoxBounds.ts
|
|
682
726
|
function getTextBoxBounds(textBox, padding = {}) {
|
|
683
727
|
return {
|
|
@@ -1281,7 +1325,12 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver {
|
|
|
1281
1325
|
const netId = this.connectionPair?.userNetId;
|
|
1282
1326
|
if (!netId) return {};
|
|
1283
1327
|
const orientations = this.inputProblem.availableNetLabelOrientations[netId] ?? ["x+", "x-", "y+", "y-"];
|
|
1284
|
-
const netLabelWidth =
|
|
1328
|
+
const netLabelWidth = getNetLabelWidthForConnection({
|
|
1329
|
+
inputProblem: this.inputProblem,
|
|
1330
|
+
netId,
|
|
1331
|
+
pinIds: this.pins.map((pin) => pin.pinId),
|
|
1332
|
+
includeFallbackNetLabelWidth: false
|
|
1333
|
+
});
|
|
1285
1334
|
const netLabelHeight = this.getNetLabelHeightForConnectionPair(netId);
|
|
1286
1335
|
const padding = {
|
|
1287
1336
|
minX: 0,
|
|
@@ -1315,24 +1364,6 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver {
|
|
|
1315
1364
|
}
|
|
1316
1365
|
return padding;
|
|
1317
1366
|
}
|
|
1318
|
-
getNetLabelWidthForConnectionPair(netId) {
|
|
1319
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
1320
|
-
(nc) => nc.netId === netId
|
|
1321
|
-
)?.netLabelWidth;
|
|
1322
|
-
if (ncWidth !== void 0) return ncWidth;
|
|
1323
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
1324
|
-
(dc) => dc.netId === netId
|
|
1325
|
-
)?.netLabelWidth;
|
|
1326
|
-
if (dcWidthByNetId !== void 0) return dcWidthByNetId;
|
|
1327
|
-
const pinIds = this.pins.map((p) => p.pinId);
|
|
1328
|
-
const dcWidthByPinId = this.inputProblem.directConnections.find(
|
|
1329
|
-
(dc) => dc.pinIds.some((pid) => pinIds.includes(pid))
|
|
1330
|
-
)?.netLabelWidth;
|
|
1331
|
-
if (dcWidthByPinId !== void 0) return dcWidthByPinId;
|
|
1332
|
-
return this.inputProblem.netConnections.find(
|
|
1333
|
-
(nc) => nc.pinIds.some((pid) => pinIds.includes(pid))
|
|
1334
|
-
)?.netLabelWidth;
|
|
1335
|
-
}
|
|
1336
1367
|
getNetLabelHeightForConnectionPair(netId) {
|
|
1337
1368
|
const ncHeight = this.inputProblem.netConnections.find(
|
|
1338
1369
|
(nc) => nc.netId === netId
|
|
@@ -3217,27 +3248,15 @@ var NetLabelPlacementSolver = class extends BaseSolver {
|
|
|
3217
3248
|
return groups;
|
|
3218
3249
|
}
|
|
3219
3250
|
getNetLabelWidthForGroup(group) {
|
|
3220
|
-
if (group.netId) {
|
|
3221
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
3222
|
-
(nc) => nc.netId === group.netId
|
|
3223
|
-
)?.netLabelWidth;
|
|
3224
|
-
if (ncWidth !== void 0) return ncWidth;
|
|
3225
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
3226
|
-
(dc) => dc.netId === group.netId
|
|
3227
|
-
)?.netLabelWidth;
|
|
3228
|
-
if (dcWidthByNetId !== void 0) return dcWidthByNetId;
|
|
3229
|
-
}
|
|
3230
3251
|
const pinIds = group.overlappingTraces?.pins.map((p) => p.pinId) ?? [];
|
|
3231
3252
|
if (group.portOnlyPinId) {
|
|
3232
3253
|
pinIds.push(group.portOnlyPinId);
|
|
3233
3254
|
}
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
(nc) => nc.pinIds.some((pid) => pinIds.includes(pid))
|
|
3240
|
-
)?.netLabelWidth;
|
|
3255
|
+
return getNetLabelWidthForConnection({
|
|
3256
|
+
inputProblem: this.inputProblem,
|
|
3257
|
+
netId: group.netId,
|
|
3258
|
+
pinIds
|
|
3259
|
+
});
|
|
3241
3260
|
}
|
|
3242
3261
|
getNetLabelHeightForGroup(group) {
|
|
3243
3262
|
if (group.netId) {
|
|
@@ -8527,13 +8546,21 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
8527
8546
|
const bY = this.outputNetLabelPlacements[b].anchorPoint.y;
|
|
8528
8547
|
return requiredOrientation === "y+" ? bY - aY : aY - bY;
|
|
8529
8548
|
});
|
|
8530
|
-
const blockedLabelWidth =
|
|
8549
|
+
const blockedLabelWidth = getNetLabelWidthForConnection({
|
|
8550
|
+
inputProblem: this.inputProblem,
|
|
8551
|
+
netId: blockedLabel.netId,
|
|
8552
|
+
pinIds: blockedLabel.pinIds
|
|
8553
|
+
});
|
|
8531
8554
|
let columnLabelIndex;
|
|
8532
8555
|
if (blockedLabelWidth !== void 0) {
|
|
8533
8556
|
columnLabelIndex = labelsToOrder.find((index) => {
|
|
8534
8557
|
if (index === blockedStandaloneLabelIndex) return false;
|
|
8535
8558
|
const label = this.outputNetLabelPlacements[index];
|
|
8536
|
-
return
|
|
8559
|
+
return getNetLabelWidthForConnection({
|
|
8560
|
+
inputProblem: this.inputProblem,
|
|
8561
|
+
netId: label.netId,
|
|
8562
|
+
pinIds: label.pinIds
|
|
8563
|
+
}) === blockedLabelWidth;
|
|
8537
8564
|
});
|
|
8538
8565
|
}
|
|
8539
8566
|
if (columnLabelIndex !== void 0) {
|
|
@@ -8754,7 +8781,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
8754
8781
|
if (!chip) return null;
|
|
8755
8782
|
const { width, height } = getDimsForOrientation({
|
|
8756
8783
|
orientation,
|
|
8757
|
-
netLabelWidth:
|
|
8784
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
8785
|
+
inputProblem: this.inputProblem,
|
|
8786
|
+
netId: label.netId,
|
|
8787
|
+
pinIds: label.pinIds
|
|
8788
|
+
}),
|
|
8758
8789
|
netLabelHeight: this.getNetLabelHeight(label)
|
|
8759
8790
|
});
|
|
8760
8791
|
const nextPinToRight = this.outputNetLabelPlacements.map((otherLabel, index) => ({
|
|
@@ -9188,7 +9219,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9188
9219
|
labelIntersectsDifferentNetTrace(label) {
|
|
9189
9220
|
const { width, height } = getDimsForOrientation({
|
|
9190
9221
|
orientation: label.orientation,
|
|
9191
|
-
netLabelWidth:
|
|
9222
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
9223
|
+
inputProblem: this.inputProblem,
|
|
9224
|
+
netId: label.netId,
|
|
9225
|
+
pinIds: label.pinIds
|
|
9226
|
+
}),
|
|
9192
9227
|
netLabelHeight: this.getNetLabelHeight(label)
|
|
9193
9228
|
});
|
|
9194
9229
|
const center = getCenterFromAnchor(
|
|
@@ -9206,7 +9241,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9206
9241
|
const anchorPoint = this.getWickOffsetAnchor(label.anchorPoint, orientation);
|
|
9207
9242
|
const { width, height } = getDimsForOrientation({
|
|
9208
9243
|
orientation,
|
|
9209
|
-
netLabelWidth:
|
|
9244
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
9245
|
+
inputProblem: this.inputProblem,
|
|
9246
|
+
netId: label.netId,
|
|
9247
|
+
pinIds: label.pinIds
|
|
9248
|
+
}),
|
|
9210
9249
|
netLabelHeight: this.getNetLabelHeight(label)
|
|
9211
9250
|
});
|
|
9212
9251
|
const searchStartAnchor = this.getSideOffsetAnchor({
|
|
@@ -9261,7 +9300,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9261
9300
|
getSearchDistanceLimit(label, orientation) {
|
|
9262
9301
|
const { width, height } = getDimsForOrientation({
|
|
9263
9302
|
orientation,
|
|
9264
|
-
netLabelWidth:
|
|
9303
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
9304
|
+
inputProblem: this.inputProblem,
|
|
9305
|
+
netId: label.netId,
|
|
9306
|
+
pinIds: label.pinIds
|
|
9307
|
+
}),
|
|
9265
9308
|
netLabelHeight: this.getNetLabelHeight(label)
|
|
9266
9309
|
});
|
|
9267
9310
|
const labelLength = orientation === "y+" || orientation === "y-" ? height : width;
|
|
@@ -9312,7 +9355,11 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9312
9355
|
createCandidate(label, anchorPoint, orientation, connectorSource) {
|
|
9313
9356
|
const { width, height } = getDimsForOrientation({
|
|
9314
9357
|
orientation,
|
|
9315
|
-
netLabelWidth:
|
|
9358
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
9359
|
+
inputProblem: this.inputProblem,
|
|
9360
|
+
netId: label.netId,
|
|
9361
|
+
pinIds: label.pinIds
|
|
9362
|
+
}),
|
|
9316
9363
|
netLabelHeight: this.getNetLabelHeight(label)
|
|
9317
9364
|
});
|
|
9318
9365
|
return {
|
|
@@ -9324,25 +9371,6 @@ var AvailableNetOrientationSolver = class extends BaseSolver {
|
|
|
9324
9371
|
center: getCenterFromAnchor(anchorPoint, orientation, width, height)
|
|
9325
9372
|
};
|
|
9326
9373
|
}
|
|
9327
|
-
getNetLabelWidth(label) {
|
|
9328
|
-
if (label.netId) {
|
|
9329
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
9330
|
-
(connection) => connection.netId === label.netId
|
|
9331
|
-
)?.netLabelWidth;
|
|
9332
|
-
if (ncWidth !== void 0) return ncWidth;
|
|
9333
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
9334
|
-
(dc) => dc.netId === label.netId
|
|
9335
|
-
)?.netLabelWidth;
|
|
9336
|
-
if (dcWidthByNetId !== void 0) return dcWidthByNetId;
|
|
9337
|
-
}
|
|
9338
|
-
const dcWidthByPinId = this.inputProblem.directConnections.find(
|
|
9339
|
-
(dc) => dc.pinIds.some((pid) => label.pinIds.includes(pid))
|
|
9340
|
-
)?.netLabelWidth;
|
|
9341
|
-
if (dcWidthByPinId !== void 0) return dcWidthByPinId;
|
|
9342
|
-
return this.inputProblem.netConnections.find(
|
|
9343
|
-
(nc) => nc.pinIds.some((pid) => label.pinIds.includes(pid))
|
|
9344
|
-
)?.netLabelWidth;
|
|
9345
|
-
}
|
|
9346
9374
|
getNetLabelHeight(label) {
|
|
9347
9375
|
if (label.netId) {
|
|
9348
9376
|
const ncHeight = this.inputProblem.netConnections.find(
|
|
@@ -10541,18 +10569,12 @@ var getChipBounds = (inputProblem) => {
|
|
|
10541
10569
|
};
|
|
10542
10570
|
};
|
|
10543
10571
|
var getNetLabelWidth = (inputProblem, label) => {
|
|
10544
|
-
const
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10549
|
-
|
|
10550
|
-
)?.netLabelWidth;
|
|
10551
|
-
if (dcWidth !== void 0) return dcWidth;
|
|
10552
|
-
const ncWidthByPinId = inputProblem.netConnections.find(
|
|
10553
|
-
(nc) => nc.pinIds.some((pid) => label.pinIds.includes(pid))
|
|
10554
|
-
)?.netLabelWidth;
|
|
10555
|
-
if (ncWidthByPinId !== void 0) return ncWidthByPinId;
|
|
10572
|
+
const configuredWidth = getNetLabelWidthForConnection({
|
|
10573
|
+
inputProblem,
|
|
10574
|
+
netId: label.netId,
|
|
10575
|
+
pinIds: label.pinIds
|
|
10576
|
+
});
|
|
10577
|
+
if (configuredWidth !== void 0) return configuredWidth;
|
|
10556
10578
|
if (label.orientation === "y+" || label.orientation === "y-") {
|
|
10557
10579
|
return label.height;
|
|
10558
10580
|
}
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
InputProblem,
|
|
17
17
|
} from "lib/types/InputProblem"
|
|
18
18
|
import { dir, type FacingDirection } from "lib/utils/dir"
|
|
19
|
+
import { getNetLabelWidthForConnection } from "lib/utils/getNetLabelWidthForConnection"
|
|
19
20
|
import { rectIntersectsAnyTextBox } from "lib/utils/textBoxBounds"
|
|
20
21
|
import {
|
|
21
22
|
EPS,
|
|
@@ -180,13 +181,23 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
180
181
|
const bY = this.outputNetLabelPlacements[b]!.anchorPoint.y
|
|
181
182
|
return requiredOrientation === "y+" ? bY - aY : aY - bY
|
|
182
183
|
})
|
|
183
|
-
const blockedLabelWidth =
|
|
184
|
+
const blockedLabelWidth = getNetLabelWidthForConnection({
|
|
185
|
+
inputProblem: this.inputProblem,
|
|
186
|
+
netId: blockedLabel.netId,
|
|
187
|
+
pinIds: blockedLabel.pinIds,
|
|
188
|
+
})
|
|
184
189
|
let columnLabelIndex: number | undefined
|
|
185
190
|
if (blockedLabelWidth !== undefined) {
|
|
186
191
|
columnLabelIndex = labelsToOrder.find((index) => {
|
|
187
192
|
if (index === blockedStandaloneLabelIndex) return false
|
|
188
193
|
const label = this.outputNetLabelPlacements[index]!
|
|
189
|
-
return
|
|
194
|
+
return (
|
|
195
|
+
getNetLabelWidthForConnection({
|
|
196
|
+
inputProblem: this.inputProblem,
|
|
197
|
+
netId: label.netId,
|
|
198
|
+
pinIds: label.pinIds,
|
|
199
|
+
}) === blockedLabelWidth
|
|
200
|
+
)
|
|
190
201
|
})
|
|
191
202
|
}
|
|
192
203
|
if (columnLabelIndex !== undefined) {
|
|
@@ -481,7 +492,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
481
492
|
|
|
482
493
|
const { width, height } = getDimsForOrientation({
|
|
483
494
|
orientation,
|
|
484
|
-
netLabelWidth:
|
|
495
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
496
|
+
inputProblem: this.inputProblem,
|
|
497
|
+
netId: label.netId,
|
|
498
|
+
pinIds: label.pinIds,
|
|
499
|
+
}),
|
|
485
500
|
netLabelHeight: this.getNetLabelHeight(label),
|
|
486
501
|
})
|
|
487
502
|
|
|
@@ -1094,7 +1109,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1094
1109
|
private labelIntersectsDifferentNetTrace(label: NetLabelPlacement) {
|
|
1095
1110
|
const { width, height } = getDimsForOrientation({
|
|
1096
1111
|
orientation: label.orientation,
|
|
1097
|
-
netLabelWidth:
|
|
1112
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
1113
|
+
inputProblem: this.inputProblem,
|
|
1114
|
+
netId: label.netId,
|
|
1115
|
+
pinIds: label.pinIds,
|
|
1116
|
+
}),
|
|
1098
1117
|
netLabelHeight: this.getNetLabelHeight(label),
|
|
1099
1118
|
})
|
|
1100
1119
|
const center = getCenterFromAnchor(
|
|
@@ -1118,7 +1137,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1118
1137
|
const anchorPoint = this.getWickOffsetAnchor(label.anchorPoint, orientation)
|
|
1119
1138
|
const { width, height } = getDimsForOrientation({
|
|
1120
1139
|
orientation,
|
|
1121
|
-
netLabelWidth:
|
|
1140
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
1141
|
+
inputProblem: this.inputProblem,
|
|
1142
|
+
netId: label.netId,
|
|
1143
|
+
pinIds: label.pinIds,
|
|
1144
|
+
}),
|
|
1122
1145
|
netLabelHeight: this.getNetLabelHeight(label),
|
|
1123
1146
|
})
|
|
1124
1147
|
|
|
@@ -1197,7 +1220,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1197
1220
|
) {
|
|
1198
1221
|
const { width, height } = getDimsForOrientation({
|
|
1199
1222
|
orientation,
|
|
1200
|
-
netLabelWidth:
|
|
1223
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
1224
|
+
inputProblem: this.inputProblem,
|
|
1225
|
+
netId: label.netId,
|
|
1226
|
+
pinIds: label.pinIds,
|
|
1227
|
+
}),
|
|
1201
1228
|
netLabelHeight: this.getNetLabelHeight(label),
|
|
1202
1229
|
})
|
|
1203
1230
|
const labelLength =
|
|
@@ -1278,7 +1305,11 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1278
1305
|
): CandidateLabel {
|
|
1279
1306
|
const { width, height } = getDimsForOrientation({
|
|
1280
1307
|
orientation,
|
|
1281
|
-
netLabelWidth:
|
|
1308
|
+
netLabelWidth: getNetLabelWidthForConnection({
|
|
1309
|
+
inputProblem: this.inputProblem,
|
|
1310
|
+
netId: label.netId,
|
|
1311
|
+
pinIds: label.pinIds,
|
|
1312
|
+
}),
|
|
1282
1313
|
netLabelHeight: this.getNetLabelHeight(label),
|
|
1283
1314
|
})
|
|
1284
1315
|
return {
|
|
@@ -1291,29 +1322,6 @@ export class AvailableNetOrientationSolver extends BaseSolver {
|
|
|
1291
1322
|
}
|
|
1292
1323
|
}
|
|
1293
1324
|
|
|
1294
|
-
private getNetLabelWidth(label: NetLabelPlacement) {
|
|
1295
|
-
if (label.netId) {
|
|
1296
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
1297
|
-
(connection) => connection.netId === label.netId,
|
|
1298
|
-
)?.netLabelWidth
|
|
1299
|
-
if (ncWidth !== undefined) return ncWidth
|
|
1300
|
-
|
|
1301
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
1302
|
-
(dc) => dc.netId === label.netId,
|
|
1303
|
-
)?.netLabelWidth
|
|
1304
|
-
if (dcWidthByNetId !== undefined) return dcWidthByNetId
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
const dcWidthByPinId = this.inputProblem.directConnections.find((dc) =>
|
|
1308
|
-
dc.pinIds.some((pid) => label.pinIds.includes(pid)),
|
|
1309
|
-
)?.netLabelWidth
|
|
1310
|
-
if (dcWidthByPinId !== undefined) return dcWidthByPinId
|
|
1311
|
-
|
|
1312
|
-
return this.inputProblem.netConnections.find((nc) =>
|
|
1313
|
-
nc.pinIds.some((pid) => label.pinIds.includes(pid)),
|
|
1314
|
-
)?.netLabelWidth
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
1325
|
private getNetLabelHeight(label: NetLabelPlacement) {
|
|
1318
1326
|
if (label.netId) {
|
|
1319
1327
|
const ncHeight = this.inputProblem.netConnections.find(
|
|
@@ -9,6 +9,7 @@ import type { GraphicsObject } from "graphics-debug"
|
|
|
9
9
|
import { visualizeInputProblem } from "../SchematicTracePipelineSolver/visualizeInputProblem"
|
|
10
10
|
import { getColorFromString } from "lib/utils/getColorFromString"
|
|
11
11
|
import { getConnectivityMapsFromInputProblem } from "../MspConnectionPairSolver/getConnectivityMapFromInputProblem"
|
|
12
|
+
import { getNetLabelWidthForConnection } from "lib/utils/getNetLabelWidthForConnection"
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* A group of traces that have at least one overlapping segment and
|
|
@@ -261,31 +262,15 @@ export class NetLabelPlacementSolver extends BaseSolver {
|
|
|
261
262
|
private getNetLabelWidthForGroup(
|
|
262
263
|
group: OverlappingSameNetTraceGroup,
|
|
263
264
|
): number | undefined {
|
|
264
|
-
if (group.netId) {
|
|
265
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
266
|
-
(nc) => nc.netId === group.netId,
|
|
267
|
-
)?.netLabelWidth
|
|
268
|
-
if (ncWidth !== undefined) return ncWidth
|
|
269
|
-
|
|
270
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
271
|
-
(dc) => dc.netId === group.netId,
|
|
272
|
-
)?.netLabelWidth
|
|
273
|
-
if (dcWidthByNetId !== undefined) return dcWidthByNetId
|
|
274
|
-
}
|
|
275
|
-
|
|
276
265
|
const pinIds = group.overlappingTraces?.pins.map((p) => p.pinId) ?? []
|
|
277
266
|
if (group.portOnlyPinId) {
|
|
278
267
|
pinIds.push(group.portOnlyPinId)
|
|
279
268
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return this.inputProblem.netConnections.find((nc) =>
|
|
287
|
-
nc.pinIds.some((pid) => pinIds.includes(pid)),
|
|
288
|
-
)?.netLabelWidth
|
|
269
|
+
return getNetLabelWidthForConnection({
|
|
270
|
+
inputProblem: this.inputProblem,
|
|
271
|
+
netId: group.netId,
|
|
272
|
+
pinIds,
|
|
273
|
+
})
|
|
289
274
|
}
|
|
290
275
|
|
|
291
276
|
private getNetLabelHeightForGroup(
|
|
@@ -7,6 +7,7 @@ import { getDimsForOrientation } from "lib/solvers/NetLabelPlacementSolver/Singl
|
|
|
7
7
|
import { visualizeInputProblem } from "lib/solvers/SchematicTracePipelineSolver/visualizeInputProblem"
|
|
8
8
|
import type { InputChip, InputProblem } from "lib/types/InputProblem"
|
|
9
9
|
import type { FacingDirection } from "lib/utils/dir"
|
|
10
|
+
import { getNetLabelWidthForConnection } from "lib/utils/getNetLabelWidthForConnection"
|
|
10
11
|
import { getTextBoxBounds, type RectPadding } from "lib/utils/textBoxBounds"
|
|
11
12
|
import { getPinDirection } from "../SchematicTraceSingleLineSolver/getPinDirection"
|
|
12
13
|
import { calculateDirectShortPath } from "./calculateDirectShortPath"
|
|
@@ -201,7 +202,12 @@ export class SchematicTraceSingleLineSolver2 extends BaseSolver {
|
|
|
201
202
|
const orientations =
|
|
202
203
|
this.inputProblem.availableNetLabelOrientations[netId] ??
|
|
203
204
|
(["x+", "x-", "y+", "y-"] as FacingDirection[])
|
|
204
|
-
const netLabelWidth =
|
|
205
|
+
const netLabelWidth = getNetLabelWidthForConnection({
|
|
206
|
+
inputProblem: this.inputProblem,
|
|
207
|
+
netId,
|
|
208
|
+
pinIds: this.pins.map((pin) => pin.pinId),
|
|
209
|
+
includeFallbackNetLabelWidth: false,
|
|
210
|
+
})
|
|
205
211
|
const netLabelHeight = this.getNetLabelHeightForConnectionPair(netId)
|
|
206
212
|
const padding: Required<RectPadding> = {
|
|
207
213
|
minX: 0,
|
|
@@ -239,28 +245,6 @@ export class SchematicTraceSingleLineSolver2 extends BaseSolver {
|
|
|
239
245
|
return padding
|
|
240
246
|
}
|
|
241
247
|
|
|
242
|
-
private getNetLabelWidthForConnectionPair(netId: string) {
|
|
243
|
-
const ncWidth = this.inputProblem.netConnections.find(
|
|
244
|
-
(nc) => nc.netId === netId,
|
|
245
|
-
)?.netLabelWidth
|
|
246
|
-
if (ncWidth !== undefined) return ncWidth
|
|
247
|
-
|
|
248
|
-
const dcWidthByNetId = this.inputProblem.directConnections.find(
|
|
249
|
-
(dc) => dc.netId === netId,
|
|
250
|
-
)?.netLabelWidth
|
|
251
|
-
if (dcWidthByNetId !== undefined) return dcWidthByNetId
|
|
252
|
-
|
|
253
|
-
const pinIds = this.pins.map((p) => p.pinId)
|
|
254
|
-
const dcWidthByPinId = this.inputProblem.directConnections.find((dc) =>
|
|
255
|
-
dc.pinIds.some((pid) => pinIds.includes(pid)),
|
|
256
|
-
)?.netLabelWidth
|
|
257
|
-
if (dcWidthByPinId !== undefined) return dcWidthByPinId
|
|
258
|
-
|
|
259
|
-
return this.inputProblem.netConnections.find((nc) =>
|
|
260
|
-
nc.pinIds.some((pid) => pinIds.includes(pid)),
|
|
261
|
-
)?.netLabelWidth
|
|
262
|
-
}
|
|
263
|
-
|
|
264
248
|
private getNetLabelHeightForConnectionPair(netId: string) {
|
|
265
249
|
const ncHeight = this.inputProblem.netConnections.find(
|
|
266
250
|
(nc) => nc.netId === netId,
|
|
@@ -8,6 +8,7 @@ import type { InputProblem } from "lib/types/InputProblem"
|
|
|
8
8
|
import { dedupeOrientations } from "lib/utils/dedupeOrientations"
|
|
9
9
|
import type { FacingDirection } from "lib/utils/dir"
|
|
10
10
|
import { getOrientationConstraint } from "lib/utils/getOrientationConstraint"
|
|
11
|
+
import { getNetLabelWidthForConnection } from "lib/utils/getNetLabelWidthForConnection"
|
|
11
12
|
import {
|
|
12
13
|
EPS,
|
|
13
14
|
getManhattanDistance,
|
|
@@ -310,20 +311,12 @@ const getNetLabelWidth = (
|
|
|
310
311
|
inputProblem: InputProblem,
|
|
311
312
|
label: NetLabelPlacement,
|
|
312
313
|
) => {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
dc.pinIds.some((pid) => label.pinIds.includes(pid)),
|
|
320
|
-
)?.netLabelWidth
|
|
321
|
-
if (dcWidth !== undefined) return dcWidth
|
|
322
|
-
|
|
323
|
-
const ncWidthByPinId = inputProblem.netConnections.find((nc) =>
|
|
324
|
-
nc.pinIds.some((pid) => label.pinIds.includes(pid)),
|
|
325
|
-
)?.netLabelWidth
|
|
326
|
-
if (ncWidthByPinId !== undefined) return ncWidthByPinId
|
|
314
|
+
const configuredWidth = getNetLabelWidthForConnection({
|
|
315
|
+
inputProblem,
|
|
316
|
+
netId: label.netId,
|
|
317
|
+
pinIds: label.pinIds,
|
|
318
|
+
})
|
|
319
|
+
if (configuredWidth !== undefined) return configuredWidth
|
|
327
320
|
|
|
328
321
|
if (label.orientation === "y+" || label.orientation === "y-") {
|
|
329
322
|
return label.height
|
|
@@ -35,6 +35,13 @@ export interface InputDirectConnection {
|
|
|
35
35
|
netId?: string
|
|
36
36
|
netLabelWidth?: number
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Width of the conventional anchored label to use only when an inline label
|
|
40
|
+
* cannot be placed. Unlike `netLabelWidth`, this does not affect whether or
|
|
41
|
+
* how the point-to-point connection is routed.
|
|
42
|
+
*/
|
|
43
|
+
fallbackNetLabelWidth?: number
|
|
44
|
+
|
|
38
45
|
/**
|
|
39
46
|
* When true, this point-to-point connection may be labeled with an "inline
|
|
40
47
|
* net label": the net name is drawn parallel to (and offset from) the routed
|
|
@@ -66,6 +73,7 @@ export interface InputNetConnection {
|
|
|
66
73
|
netId: string
|
|
67
74
|
pinIds: Array<PinId>
|
|
68
75
|
netLabelWidth?: number
|
|
76
|
+
fallbackNetLabelWidth?: number
|
|
69
77
|
netLabelHeight?: number
|
|
70
78
|
|
|
71
79
|
/**
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InputDirectConnection,
|
|
3
|
+
InputNetConnection,
|
|
4
|
+
InputProblem,
|
|
5
|
+
NetId,
|
|
6
|
+
PinId,
|
|
7
|
+
} from "lib/types/InputProblem"
|
|
8
|
+
|
|
9
|
+
type ConnectionWithLabelWidth = InputDirectConnection | InputNetConnection
|
|
10
|
+
|
|
11
|
+
const getConfiguredWidth = (
|
|
12
|
+
connections: Array<ConnectionWithLabelWidth | undefined>,
|
|
13
|
+
includeFallbackNetLabelWidth: boolean,
|
|
14
|
+
) => {
|
|
15
|
+
const explicitWidth = connections.find(
|
|
16
|
+
(connection) => connection?.netLabelWidth !== undefined,
|
|
17
|
+
)?.netLabelWidth
|
|
18
|
+
if (explicitWidth !== undefined) return explicitWidth
|
|
19
|
+
if (!includeFallbackNetLabelWidth) return undefined
|
|
20
|
+
|
|
21
|
+
return connections.find(
|
|
22
|
+
(connection) => connection?.fallbackNetLabelWidth !== undefined,
|
|
23
|
+
)?.fallbackNetLabelWidth
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const getNetLabelWidthForConnection = ({
|
|
27
|
+
inputProblem,
|
|
28
|
+
netId,
|
|
29
|
+
pinIds,
|
|
30
|
+
includeFallbackNetLabelWidth = true,
|
|
31
|
+
}: {
|
|
32
|
+
inputProblem: InputProblem
|
|
33
|
+
netId?: NetId
|
|
34
|
+
pinIds: readonly PinId[]
|
|
35
|
+
includeFallbackNetLabelWidth?: boolean
|
|
36
|
+
}): number | undefined => {
|
|
37
|
+
if (netId) {
|
|
38
|
+
const widthByNetId = getConfiguredWidth(
|
|
39
|
+
[
|
|
40
|
+
inputProblem.netConnections.find(
|
|
41
|
+
(connection) => connection.netId === netId,
|
|
42
|
+
),
|
|
43
|
+
inputProblem.directConnections.find(
|
|
44
|
+
(connection) => connection.netId === netId,
|
|
45
|
+
),
|
|
46
|
+
],
|
|
47
|
+
includeFallbackNetLabelWidth,
|
|
48
|
+
)
|
|
49
|
+
if (widthByNetId !== undefined) return widthByNetId
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return getConfiguredWidth(
|
|
53
|
+
[
|
|
54
|
+
inputProblem.directConnections.find((connection) =>
|
|
55
|
+
connection.pinIds.some((pinId) => pinIds.includes(pinId)),
|
|
56
|
+
),
|
|
57
|
+
inputProblem.netConnections.find((connection) =>
|
|
58
|
+
connection.pinIds.some((pinId) => pinIds.includes(pinId)),
|
|
59
|
+
),
|
|
60
|
+
],
|
|
61
|
+
includeFallbackNetLabelWidth,
|
|
62
|
+
)
|
|
63
|
+
}
|