@tscircuit/schematic-trace-solver 0.0.79 → 0.0.80
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.js
CHANGED
|
@@ -5314,6 +5314,33 @@ var segmentRunsAlongRectBoundary = (start, end, rect) => {
|
|
|
5314
5314
|
return false;
|
|
5315
5315
|
};
|
|
5316
5316
|
|
|
5317
|
+
// lib/solvers/Example28Solver/getMovedAnchorPointForReroute.ts
|
|
5318
|
+
var getMovedAnchorPointForReroute = (anchorPoint, originalTracePath, reroutedTracePath) => {
|
|
5319
|
+
const originalSegment = findSegmentContainingPoint(
|
|
5320
|
+
originalTracePath,
|
|
5321
|
+
anchorPoint
|
|
5322
|
+
);
|
|
5323
|
+
if (!originalSegment) return null;
|
|
5324
|
+
const preferredSegment = findPreferredReroutedSegment(
|
|
5325
|
+
reroutedTracePath,
|
|
5326
|
+
originalSegment.index,
|
|
5327
|
+
originalTracePath.length - 1,
|
|
5328
|
+
originalSegment.orientation,
|
|
5329
|
+
anchorPoint
|
|
5330
|
+
);
|
|
5331
|
+
if (!preferredSegment) {
|
|
5332
|
+
return projectPointToPath(anchorPoint, reroutedTracePath);
|
|
5333
|
+
}
|
|
5334
|
+
return projectPointToSegment(
|
|
5335
|
+
anchorPoint,
|
|
5336
|
+
preferredSegment.start,
|
|
5337
|
+
preferredSegment.end
|
|
5338
|
+
);
|
|
5339
|
+
};
|
|
5340
|
+
|
|
5341
|
+
// lib/solvers/Example28Solver/isLabelAttachedToTrace.ts
|
|
5342
|
+
var isLabelAttachedToTrace = (label, trace) => label.globalConnNetId === trace.globalConnNetId || label.mspConnectionPairIds.includes(trace.mspPairId);
|
|
5343
|
+
|
|
5317
5344
|
// lib/solvers/Example28Solver/labelMovement.ts
|
|
5318
5345
|
var moveAttachedLabelsToReroutedTrace = ({
|
|
5319
5346
|
trace,
|
|
@@ -5341,29 +5368,6 @@ var moveAttachedLabelsToReroutedTrace = ({
|
|
|
5341
5368
|
}
|
|
5342
5369
|
};
|
|
5343
5370
|
});
|
|
5344
|
-
var isLabelAttachedToTrace = (label, trace) => label.globalConnNetId === trace.globalConnNetId || label.mspConnectionPairIds.includes(trace.mspPairId);
|
|
5345
|
-
var getMovedAnchorPointForReroute = (anchorPoint, originalTracePath, reroutedTracePath) => {
|
|
5346
|
-
const originalSegment = findSegmentContainingPoint(
|
|
5347
|
-
originalTracePath,
|
|
5348
|
-
anchorPoint
|
|
5349
|
-
);
|
|
5350
|
-
if (!originalSegment) return null;
|
|
5351
|
-
const preferredSegment = findPreferredReroutedSegment(
|
|
5352
|
-
reroutedTracePath,
|
|
5353
|
-
originalSegment.index,
|
|
5354
|
-
originalTracePath.length - 1,
|
|
5355
|
-
originalSegment.orientation,
|
|
5356
|
-
anchorPoint
|
|
5357
|
-
);
|
|
5358
|
-
if (!preferredSegment) {
|
|
5359
|
-
return projectPointToPath(anchorPoint, reroutedTracePath);
|
|
5360
|
-
}
|
|
5361
|
-
return projectPointToSegment(
|
|
5362
|
-
anchorPoint,
|
|
5363
|
-
preferredSegment.start,
|
|
5364
|
-
preferredSegment.end
|
|
5365
|
-
);
|
|
5366
|
-
};
|
|
5367
5371
|
|
|
5368
5372
|
// lib/utils/dir.ts
|
|
5369
5373
|
var dir = (facingDirection) => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Point } from "@tscircuit/math-utils"
|
|
2
|
+
import {
|
|
3
|
+
findPreferredReroutedSegment,
|
|
4
|
+
findSegmentContainingPoint,
|
|
5
|
+
projectPointToPath,
|
|
6
|
+
projectPointToSegment,
|
|
7
|
+
} from "./geometry"
|
|
8
|
+
|
|
9
|
+
export const getMovedAnchorPointForReroute = (
|
|
10
|
+
anchorPoint: Point,
|
|
11
|
+
originalTracePath: Point[],
|
|
12
|
+
reroutedTracePath: Point[],
|
|
13
|
+
) => {
|
|
14
|
+
const originalSegment = findSegmentContainingPoint(
|
|
15
|
+
originalTracePath,
|
|
16
|
+
anchorPoint,
|
|
17
|
+
)
|
|
18
|
+
if (!originalSegment) return null
|
|
19
|
+
|
|
20
|
+
const preferredSegment = findPreferredReroutedSegment(
|
|
21
|
+
reroutedTracePath,
|
|
22
|
+
originalSegment.index,
|
|
23
|
+
originalTracePath.length - 1,
|
|
24
|
+
originalSegment.orientation,
|
|
25
|
+
anchorPoint,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
if (!preferredSegment) {
|
|
29
|
+
return projectPointToPath(anchorPoint, reroutedTracePath)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return projectPointToSegment(
|
|
33
|
+
anchorPoint,
|
|
34
|
+
preferredSegment.start,
|
|
35
|
+
preferredSegment.end,
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NetLabelPlacement } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
|
|
2
|
+
import type { SolvedTracePath } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver"
|
|
3
|
+
|
|
4
|
+
export const isLabelAttachedToTrace = (
|
|
5
|
+
label: NetLabelPlacement,
|
|
6
|
+
trace: SolvedTracePath,
|
|
7
|
+
) =>
|
|
8
|
+
label.globalConnNetId === trace.globalConnNetId ||
|
|
9
|
+
label.mspConnectionPairIds.includes(trace.mspPairId)
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { Point } from "@tscircuit/math-utils"
|
|
2
2
|
import type { NetLabelPlacement } from "lib/solvers/NetLabelPlacementSolver/NetLabelPlacementSolver"
|
|
3
3
|
import type { SolvedTracePath } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceLinesSolver"
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
findSegmentContainingPoint,
|
|
7
|
-
projectPointToPath,
|
|
8
|
-
projectPointToSegment,
|
|
9
|
-
} from "./geometry"
|
|
4
|
+
import { getMovedAnchorPointForReroute } from "./getMovedAnchorPointForReroute"
|
|
5
|
+
import { isLabelAttachedToTrace } from "./isLabelAttachedToTrace"
|
|
10
6
|
|
|
11
7
|
export const moveAttachedLabelsToReroutedTrace = ({
|
|
12
8
|
trace,
|
|
@@ -43,40 +39,3 @@ export const moveAttachedLabelsToReroutedTrace = ({
|
|
|
43
39
|
},
|
|
44
40
|
}
|
|
45
41
|
})
|
|
46
|
-
|
|
47
|
-
const isLabelAttachedToTrace = (
|
|
48
|
-
label: NetLabelPlacement,
|
|
49
|
-
trace: SolvedTracePath,
|
|
50
|
-
) =>
|
|
51
|
-
label.globalConnNetId === trace.globalConnNetId ||
|
|
52
|
-
label.mspConnectionPairIds.includes(trace.mspPairId)
|
|
53
|
-
|
|
54
|
-
const getMovedAnchorPointForReroute = (
|
|
55
|
-
anchorPoint: Point,
|
|
56
|
-
originalTracePath: Point[],
|
|
57
|
-
reroutedTracePath: Point[],
|
|
58
|
-
) => {
|
|
59
|
-
const originalSegment = findSegmentContainingPoint(
|
|
60
|
-
originalTracePath,
|
|
61
|
-
anchorPoint,
|
|
62
|
-
)
|
|
63
|
-
if (!originalSegment) return null
|
|
64
|
-
|
|
65
|
-
const preferredSegment = findPreferredReroutedSegment(
|
|
66
|
-
reroutedTracePath,
|
|
67
|
-
originalSegment.index,
|
|
68
|
-
originalTracePath.length - 1,
|
|
69
|
-
originalSegment.orientation,
|
|
70
|
-
anchorPoint,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
if (!preferredSegment) {
|
|
74
|
-
return projectPointToPath(anchorPoint, reroutedTracePath)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return projectPointToSegment(
|
|
78
|
-
anchorPoint,
|
|
79
|
-
preferredSegment.start,
|
|
80
|
-
preferredSegment.end,
|
|
81
|
-
)
|
|
82
|
-
}
|