@tscircuit/schematic-trace-solver 0.0.184 → 0.0.186

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.
@@ -0,0 +1,74 @@
1
+ import { expect, test } from "bun:test"
2
+ import {
3
+ countPathIntersections,
4
+ getPathLength,
5
+ } from "lib/solvers/Example28Solver/geometry"
6
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
7
+ import { findFirstCollision } from "lib/solvers/SchematicTraceLinesSolver/SchematicTraceSingleLineSolver2/collisions"
8
+ import { UnroutedTraceRecoverySolver } from "lib/solvers/UnroutedTraceRecoverySolver/UnroutedTraceRecoverySolver"
9
+ import type { InputProblem } from "lib/types/InputProblem"
10
+ import inputProblem from "tests/bug-reports/bug-report-20260905T041712Z/bug-report-20260905T041712Z.json"
11
+
12
+ test.each(["chip", "text", "trace"] as const)(
13
+ "rejects a local recovery elbow blocked by a %s",
14
+ (obstacleKind) => {
15
+ const pipeline = new SchematicTracePipelineSolver(
16
+ structuredClone(inputProblem) as InputProblem,
17
+ )
18
+ pipeline.solveUntilPhase("unroutedTraceRecoverySolver")
19
+
20
+ const connectionPair =
21
+ pipeline.schematicTraceLinesSolver!.failedConnectionPairs.find(
22
+ (pair) => pair.mspPairId === "schematic_port_101-schematic_port_125",
23
+ )!
24
+ const problem = pipeline.inputProblem
25
+ const existingTraces = [
26
+ ...pipeline.longDistancePairSolver!.getOutput().allTracesMerged,
27
+ ]
28
+ const blockingBounds = { minX: 3.6, maxX: 3.7, minY: -8.96, maxY: -8.94 }
29
+ const blockingPath = [
30
+ { x: 3.6, y: -8.95 },
31
+ { x: 3.7, y: -8.95 },
32
+ ]
33
+
34
+ if (obstacleKind === "chip") {
35
+ problem.chips.push({
36
+ chipId: "blocking-chip",
37
+ center: { x: 3.65, y: -8.95 },
38
+ width: 0.1,
39
+ height: 0.02,
40
+ pins: [],
41
+ })
42
+ }
43
+ if (obstacleKind === "text") {
44
+ problem.textBoxes!.push({
45
+ center: { x: 3.65, y: -8.95 },
46
+ width: 0.1,
47
+ height: 0.02,
48
+ })
49
+ }
50
+ if (obstacleKind === "trace") {
51
+ const otherNetTrace = existingTraces.find(
52
+ (trace) => trace.globalConnNetId !== connectionPair.globalConnNetId,
53
+ )!
54
+ existingTraces.splice(existingTraces.indexOf(otherNetTrace), 1, {
55
+ ...otherNetTrace,
56
+ tracePath: blockingPath,
57
+ })
58
+ }
59
+
60
+ const recovery = new UnroutedTraceRecoverySolver({
61
+ inputProblem: problem,
62
+ failedConnectionPairs: [connectionPair],
63
+ alreadySolvedTraces: existingTraces,
64
+ })
65
+ recovery.solve()
66
+
67
+ expect(recovery.solved).toBe(true)
68
+ expect(recovery.solvedUnroutedTraces).toHaveLength(1)
69
+ const recoveredPath = recovery.solvedUnroutedTraces[0]!.tracePath
70
+ expect(getPathLength(recoveredPath)).toBeGreaterThan(0.8)
71
+ expect(findFirstCollision(recoveredPath, [blockingBounds])).toBeNull()
72
+ expect(countPathIntersections(recoveredPath, blockingPath)).toBe(0)
73
+ },
74
+ )