@tscircuit/copper-pour-solver 0.0.13 → 0.0.15

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,18 @@
1
+ import { expect, test } from "bun:test"
2
+ import circuitJson from "./repro01-business-via-card.json"
3
+ import { runSolverAndRenderToSvg } from "../utils/run-solver-and-render-to-svg"
4
+ import type { AnyCircuitElement } from "circuit-json"
5
+
6
+ test("repro01-business-via-card", async () => {
7
+ const svg = runSolverAndRenderToSvg(circuitJson as AnyCircuitElement[], {
8
+ layer: "top",
9
+ net_name: "GND",
10
+ pad_margin: 0.2,
11
+ trace_margin: 0.2,
12
+ })
13
+
14
+ await expect(svg).toMatchSvgSnapshot(
15
+ import.meta.path,
16
+ "repro01-business-via-card",
17
+ )
18
+ })
@@ -8,6 +8,7 @@ import type {
8
8
  PcbCopperPourBRep,
9
9
  SourceNet,
10
10
  } from "circuit-json"
11
+ import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"
11
12
  import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
12
13
 
13
14
  export const runSolverAndRenderToSvg = (
@@ -29,11 +30,21 @@ export const runSolverAndRenderToSvg = (
29
30
  if (!source_net) {
30
31
  throw new Error(`Net with name "${pour_options.net_name}" not found`)
31
32
  }
32
- if (!source_net.subcircuit_connectivity_map_key) {
33
- throw new Error(`Net "${pour_options.net_name}" has no connectivity key`)
33
+
34
+ const connectivityMap = getFullConnectivityMapFromCircuitJson(circuitJson)
35
+ let pour_connectivity_key = connectivityMap.getNetConnectedToId(
36
+ source_net.source_net_id,
37
+ )
38
+
39
+ if (!pour_connectivity_key && source_net.subcircuit_connectivity_map_key) {
40
+ pour_connectivity_key = source_net.subcircuit_connectivity_map_key
34
41
  }
35
42
 
36
- const pour_connectivity_key = source_net.subcircuit_connectivity_map_key
43
+ if (!pour_connectivity_key) {
44
+ throw new Error(
45
+ `Net "${pour_options.net_name}" has no connectivity mapping`,
46
+ )
47
+ }
37
48
 
38
49
  const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
39
50
  ...pour_options,