@tscircuit/rectdiff 0.0.23 → 0.0.24
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 +133 -74
- package/lib/RectDiffPipeline.ts +4 -37
- package/lib/buildFinalRectDiffVisualization.ts +46 -0
- package/lib/solvers/RectDiffSeedingSolver/RectDiffSeedingSolver.ts +0 -25
- package/lib/solvers/RectDiffSeedingSolver/computeCandidates3D.ts +12 -2
- package/lib/solvers/RectDiffSeedingSolver/computeEdgeCandidates3D.ts +53 -13
- package/lib/utils/buildOutlineGraphics.ts +39 -0
- package/lib/utils/expandRectFromSeed.ts +11 -1
- package/package.json +1 -1
- package/tests/solver/__snapshots__/rectDiffGridSolverPipeline.snap.svg +1 -1
- package/tests/solver/bugreport01-be84eb/__snapshots__/bugreport01-be84eb.snap.svg +2 -2
- package/tests/solver/bugreport02-bc4361/__snapshots__/bugreport02-bc4361.snap.svg +2 -2
- package/tests/solver/bugreport03-fe4a17/__snapshots__/bugreport03-fe4a17.snap.svg +1 -1
- package/tests/solver/bugreport07-d3f3be/__snapshots__/bugreport07-d3f3be.snap.svg +1 -1
- package/tests/solver/bugreport08-e3ec95/__snapshots__/bugreport08-e3ec95.snap.svg +1 -1
- package/tests/solver/bugreport09-618e09/__snapshots__/bugreport09-618e09.snap.svg +2 -2
- package/tests/solver/bugreport10-71239a/__snapshots__/bugreport10-71239a.snap.svg +2 -2
- package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c.snap.svg +1 -1
- package/tests/solver/bugreport11-b2de3c/bugreport11-b2de3c-clearance-equivalence.test.ts +52 -0
- package/tests/solver/bugreport12-35ce1c/__snapshots__/bugreport12-35ce1c.snap.svg +1 -1
- package/tests/solver/bugreport13-b9a758/__snapshots__/bugreport13-b9a758.snap.svg +2 -2
- package/tests/solver/bugreport16-d95f38/__snapshots__/bugreport16-d95f38.snap.svg +2 -2
- package/tests/solver/bugreport19/__snapshots__/bugreport19.snap.svg +1 -1
- package/tests/solver/bugreport22-2a75ce/__snapshots__/bugreport22-2a75ce.snap.svg +1 -1
- package/tests/solver/bugreport23-LGA15x4/__snapshots__/bugreport23-LGA15x4.snap.svg +1 -1
- package/tests/solver/bugreport24-05597c/__snapshots__/bugreport24-05597c.snap.svg +1 -1
- package/tests/solver/bugreport26-66b0b2/__snapshots__/bugreport26-66b0b2.snap.svg +2 -2
- package/tests/solver/bugreport27-dd3734/__snapshots__/bugreport27-dd3734.snap.svg +2 -2
- package/tests/solver/bugreport28-18a9ef/__snapshots__/bugreport28-18a9ef.snap.svg +2 -2
- package/tests/solver/bugreport29-7deae8/__snapshots__/bugreport29-7deae8.snap.svg +2 -2
- package/tests/solver/bugreport30-2174c8/__snapshots__/bugreport30-2174c8.snap.svg +1 -1
- package/tests/solver/bugreport33-213d45/__snapshots__/bugreport33-213d45.snap.svg +2 -2
- package/tests/solver/bugreport34-e9dea2/__snapshots__/bugreport34-e9dea2.snap.svg +2 -2
- package/tests/solver/bugreport35-191db9/__snapshots__/bugreport35-191db9.snap.svg +2 -2
- package/tests/solver/bugreport36-bf8303/__snapshots__/bugreport36-bf8303.snap.svg +1 -1
- package/tests/solver/interaction/__snapshots__/interaction.snap.svg +1 -1
- package/tests/solver/multi-point/__snapshots__/multi-point.snap.svg +1 -1
- package/tests/solver/pcb_trace_id-should-return-root-connection-name/__snapshots__/pcb_trace_id-should-return-root-connection-name.snap.svg +1 -1
- package/tests/solver/bugreport11-b2de3c/__snapshots__/bugreport11-b2de3c-clearance.snap.svg +0 -44
- package/tests/solver/bugreport11-b2de3c/bugreport11-b2de3c-clearance.test.ts +0 -97
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import srj_json from "./bugreport11-b2de3c.json"
|
|
3
|
-
import {
|
|
4
|
-
getBounds,
|
|
5
|
-
getSvgFromGraphicsObject,
|
|
6
|
-
mergeGraphics,
|
|
7
|
-
stackGraphicsVertically,
|
|
8
|
-
type GraphicsObject,
|
|
9
|
-
type Rect,
|
|
10
|
-
} from "graphics-debug"
|
|
11
|
-
import { RectDiffPipeline } from "lib/RectDiffPipeline"
|
|
12
|
-
import { makeCapacityMeshNodeWithLayerInfo } from "tests/fixtures/makeCapacityMeshNodeWithLayerInfo"
|
|
13
|
-
import { makeSimpleRouteOutlineGraphics } from "tests/fixtures/makeSimpleRouteOutlineGraphics"
|
|
14
|
-
|
|
15
|
-
const srj = srj_json.simple_route_json ?? srj_json.simpleRouteJson ?? srj_json
|
|
16
|
-
|
|
17
|
-
// Same scenario as bugreport11-b2de3c but with obstacleClearance applied
|
|
18
|
-
const OBSTACLE_CLEARANCE = 0.015
|
|
19
|
-
|
|
20
|
-
test("bugreport11-b2de3c with clearance", async () => {
|
|
21
|
-
const solver = new RectDiffPipeline({
|
|
22
|
-
simpleRouteJson: srj,
|
|
23
|
-
obstacleClearance: OBSTACLE_CLEARANCE,
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
const outline = makeSimpleRouteOutlineGraphics(srj)
|
|
27
|
-
|
|
28
|
-
solver.solve()
|
|
29
|
-
|
|
30
|
-
const { meshNodes } = solver.getOutput()
|
|
31
|
-
const rectsByCombo = makeCapacityMeshNodeWithLayerInfo(meshNodes)
|
|
32
|
-
const allGraphicsObjects: GraphicsObject[] = []
|
|
33
|
-
|
|
34
|
-
for (const z of Array.from({ length: srj.layerCount }, (_, index) => index)) {
|
|
35
|
-
const layerRects: Rect[] = []
|
|
36
|
-
|
|
37
|
-
for (const [key, rects] of rectsByCombo) {
|
|
38
|
-
const layers = key
|
|
39
|
-
.split(",")
|
|
40
|
-
.map((value) => Number.parseInt(value, 10))
|
|
41
|
-
.filter((value) => !Number.isNaN(value))
|
|
42
|
-
|
|
43
|
-
if (layers.includes(z)) {
|
|
44
|
-
layerRects.push(...rects)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let labelY = 0
|
|
49
|
-
|
|
50
|
-
if (layerRects.length > 0) {
|
|
51
|
-
let maxY = -Infinity
|
|
52
|
-
|
|
53
|
-
for (const rect of layerRects) {
|
|
54
|
-
const top = rect.center.y + rect.height * (2 / 3)
|
|
55
|
-
|
|
56
|
-
if (top > maxY) maxY = top
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
labelY = maxY
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const graphics: GraphicsObject = {
|
|
63
|
-
title: `RectDiffPipeline - z${z} (clearance ${OBSTACLE_CLEARANCE})`,
|
|
64
|
-
texts: [
|
|
65
|
-
{
|
|
66
|
-
anchorSide: "top_right",
|
|
67
|
-
text: `Layer z=${z}`,
|
|
68
|
-
x: 0,
|
|
69
|
-
y: labelY,
|
|
70
|
-
fontSize: 0.5,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
coordinateSystem: "cartesian",
|
|
74
|
-
rects: layerRects,
|
|
75
|
-
points: [],
|
|
76
|
-
lines: [],
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
allGraphicsObjects.push(mergeGraphics(graphics, outline))
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const stackedGraphics = stackGraphicsVertically(allGraphicsObjects)
|
|
83
|
-
const bounds = getBounds(stackedGraphics)
|
|
84
|
-
const boundsWidth = Math.max(1, bounds.maxX - bounds.minX)
|
|
85
|
-
const boundsHeight = Math.max(1, bounds.maxY - bounds.minY)
|
|
86
|
-
const svgWidth = 640
|
|
87
|
-
const svgHeight = Math.max(
|
|
88
|
-
svgWidth,
|
|
89
|
-
Math.ceil((boundsHeight / boundsWidth) * svgWidth),
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
const svg = getSvgFromGraphicsObject(stackedGraphics, {
|
|
93
|
-
svgWidth,
|
|
94
|
-
svgHeight,
|
|
95
|
-
})
|
|
96
|
-
await expect(svg).toMatchSvgSnapshot(import.meta.path)
|
|
97
|
-
})
|