@tscircuit/copper-pour-solver 0.0.33 → 0.0.35
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/README.md +148 -20
- package/cosmos.config.json +2 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +252 -8
- package/lib/circuit-json/ConvertCircuitJsonToInputProblemOptions.ts +19 -0
- package/lib/circuit-json/buildSubcircuitConnectivityLookup.ts +237 -0
- package/lib/circuit-json/convert-circuit-json-to-input-problem.ts +22 -22
- package/lib/circuit-json/getElementSubcircuitConnectivityKey.ts +8 -0
- package/lib/circuit-json/resolvePourConnectivityKey.ts +88 -0
- package/lib/index.ts +1 -0
- package/package.json +8 -3
- package/site/Welcome.page.tsx +214 -0
- package/tests/__snapshots__/tsx-subcircuit-connectivity01.snap.svg +1 -0
- package/tests/__snapshots__/tsx-subcircuit-connectivity02.snap.svg +1 -0
- package/tests/assets/subcircuit-connectivity-scope.json +126 -0
- package/tests/connectivity-key-api.test.ts +146 -0
- package/tests/pill-pad-copper-pour.test.ts +1 -1
- package/tests/repro01-business-via-card/__snapshots__/repro01-business-via-card.snap.svg +1 -1
- package/tests/tsx-subcircuit-connectivity.test.tsx +223 -0
- package/tests/utils/run-solver-and-render-to-svg.ts +5 -13
- package/vercel.json +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.988"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="66.66666666666669" y="66.6666666666666" width="666.6666666666667" height="466.66666666666663" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 66.66666666666669 533.3333333333333 L 733.3333333333335 533.3333333333333 L 733.3333333333335 66.6666666666666 L 66.66666666666669 66.6666666666666 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="6.666666666666668" data-type="pcb_board" data-pcb-layer="board"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 200.00000000000006 299.99999999999994 L 332.00000000000006 299.99999999999994" stroke-width="10.666666666666668" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-type="pcb_trace" data-pcb-layer="top"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 332.00000000000006 299.99999999999994 L 332.00000000000006 183.33333333333326" stroke-width="10.666666666666668" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-type="pcb_trace" data-pcb-layer="top"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 332.00000000000006 183.33333333333326 L 618.0000000000001 183.33333333333326" stroke-width="10.666666666666668" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-type="pcb_trace" data-pcb-layer="top"/><path class="pcb-trace" stroke="rgb(200, 52, 52)" fill="none" d="M 618.0000000000001 183.33333333333326 L 618.0000000000001 299.99999999999994" stroke-width="10.666666666666668" stroke-linecap="round" stroke-linejoin="round" shape-rendering="crispEdges" data-type="pcb_trace" data-pcb-layer="top"/><path class="pcb-copper-pour pcb-copper-pour-brep" d="M 733.3333333333335 533.3333333333333 L 66.66666666666669 533.3333333333333 L 66.66666666666669 66.6666666666666 L 733.3333333333335 66.6666666666666 L 733.3333333333335 533.3333333333333 Z M 382.00000000000006 366.66666666666663 L 515.3333333333334 366.66666666666663 L 515.3333333333334 233.33333333333326 L 382.00000000000006 233.33333333333326 L 382.00000000000006 366.66666666666663 Z" fill="rgb(200, 52, 52)" fill-rule="evenodd" fill-opacity="0.5" data-type="pcb_copper_pour" data-pcb-layer="top"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,200.00000000000006,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_0" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">A</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="46.666666666666664" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,200.00000000000006,130.6666666666666)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_1" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">J1</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,448.66666666666674,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_2" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">B</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,618.0000000000001,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_3" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">C</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="46.666666666666664" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,533.3333333333334,130.6666666666666)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_4" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">J2</text><g data-type="pcb_plated_hole" data-pcb-layer="through"><rect class="pcb-hole-outer-pad" fill="rgb(200, 52, 52)" x="150.00000000000006" y="249.99999999999994" width="100" height="100" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="200.00000000000006" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><g data-type="pcb_plated_hole" data-pcb-layer="through"><rect class="pcb-hole-outer-pad" fill="rgb(200, 52, 52)" x="398.66666666666674" y="249.99999999999994" width="100" height="100" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="448.66666666666674" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><g data-type="pcb_plated_hole" data-pcb-layer="through"><circle class="pcb-hole-outer" fill="rgb(200, 52, 52)" cx="618.0000000000001" cy="299.99999999999994" r="50" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="618.0000000000001" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><text x="400.00000000000006" y="9.999999999999943" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_0" data-pcb-layer="overlay">Expected: copper pour connects to A and C, but clears around B.</text><text x="400.00000000000006" y="29.999999999999943" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_1" data-pcb-layer="overlay">A is parent net.GND; C is child net.GND reached through the parent-to-child net.</text><text x="400.00000000000006" y="49.999999999999915" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_2" data-pcb-layer="overlay">B is a separate child pin, so the pour should clear around it.</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600" data-software-used-string="@tscircuit/core@0.0.988"><style></style><rect class="boundary" x="0" y="0" fill="#000" width="800" height="600" data-type="pcb_background" data-pcb-layer="global"/><rect class="pcb-boundary" fill="none" stroke="#fff" stroke-width="0.3" x="66.66666666666669" y="66.6666666666666" width="666.6666666666667" height="466.66666666666663" data-type="pcb_boundary" data-pcb-layer="global"/><path class="pcb-board" d="M 66.66666666666669 533.3333333333333 L 733.3333333333335 533.3333333333333 L 733.3333333333335 66.6666666666666 L 66.66666666666669 66.6666666666666 Z" fill="none" stroke="rgba(255, 255, 255, 0.5)" stroke-width="6.666666666666668" data-type="pcb_board" data-pcb-layer="board"/><path class="pcb-copper-pour pcb-copper-pour-brep" d="M 733.3333333333335 533.3333333333333 L 66.66666666666669 533.3333333333333 L 66.66666666666669 66.6666666666666 L 733.3333333333335 66.6666666666666 L 733.3333333333335 533.3333333333333 Z M 382.00000000000006 366.66666666666663 L 515.3333333333334 366.66666666666663 L 515.3333333333334 233.33333333333326 L 382.00000000000006 233.33333333333326 L 382.00000000000006 366.66666666666663 Z M 618.0000000000001 366.66666666666663 L 631.0060000000001 365.3856666666666 L 643.5122000000001 361.5919999999999 L 655.038 355.43133333333327 L 665.1404666666667 347.1404666666666 L 673.4313333333334 337.03799999999995 L 679.5920000000001 325.51219999999995 L 683.3856666666668 313.006 L 684.6666666666667 299.99999999999994 L 683.3856666666668 286.9939999999999 L 679.5920000000001 274.48779999999994 L 673.4313333333334 262.96199999999993 L 665.1404666666667 252.85953333333327 L 655.038 244.56866666666662 L 643.5122000000001 238.40799999999993 L 631.0060000000001 234.61433333333326 L 618.0000000000001 233.33333333333326 L 604.9940000000001 234.61433333333326 L 592.4878000000001 238.40799999999993 L 580.9620000000001 244.56866666666662 L 570.8595333333334 252.85953333333327 L 562.5686666666668 262.96199999999993 L 556.4080000000001 274.48779999999994 L 552.6143333333334 286.9939999999999 L 551.3333333333334 299.99999999999994 L 552.6143333333334 313.006 L 556.4080000000001 325.51219999999995 L 562.5686666666668 337.03799999999995 L 570.8595333333334 347.1404666666666 L 580.9620000000001 355.43133333333327 L 592.4878000000001 361.5919999999999 L 604.9940000000001 365.3856666666666 L 618.0000000000001 366.66666666666663 Z" fill="rgb(200, 52, 52)" fill-rule="evenodd" fill-opacity="0.5" data-type="pcb_copper_pour" data-pcb-layer="top"/><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,200.00000000000006,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_0" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">A</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="46.666666666666664" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,200.00000000000006,130.6666666666666)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_1" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">J1</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,448.66666666666674,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_2" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">B</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="33.333333333333336" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,618.0000000000001,224.99999999999994)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_3" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">C</text><text x="0" y="0" dx="0" dy="0" fill="#f2eda1" font-family="Arial, sans-serif" font-size="46.666666666666664" text-anchor="middle" dominant-baseline="central" transform="matrix(1,0,0,1,533.3333333333334,130.6666666666666)" class="pcb-silkscreen-text pcb-silkscreen-top" data-pcb-silkscreen-text-id="pcb_silkscreen_text_4" stroke="none" data-type="pcb_silkscreen_text" data-pcb-layer="top">J2</text><g data-type="pcb_plated_hole" data-pcb-layer="through"><rect class="pcb-hole-outer-pad" fill="rgb(200, 52, 52)" x="150.00000000000006" y="249.99999999999994" width="100" height="100" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="200.00000000000006" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><g data-type="pcb_plated_hole" data-pcb-layer="through"><rect class="pcb-hole-outer-pad" fill="rgb(200, 52, 52)" x="398.66666666666674" y="249.99999999999994" width="100" height="100" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="448.66666666666674" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><g data-type="pcb_plated_hole" data-pcb-layer="through"><circle class="pcb-hole-outer" fill="rgb(200, 52, 52)" cx="618.0000000000001" cy="299.99999999999994" r="50" data-type="pcb_plated_hole" data-pcb-layer="top"/><circle class="pcb-hole-inner" fill="#FF26E2" cx="618.0000000000001" cy="299.99999999999994" r="33.333333333333336" data-type="pcb_plated_hole_drill" data-pcb-layer="drill"/></g><text x="400.00000000000006" y="9.999999999999943" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_0" data-pcb-layer="overlay">Expected: copper pour connects to A, but clears around B and C.</text><text x="400.00000000000006" y="29.999999999999943" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_1" data-pcb-layer="overlay">A is parent net.GND; C is child net.GND with no parent-to-child net.</text><text x="400.00000000000006" y="49.999999999999915" fill="#ffffff" font-family="Arial, sans-serif" font-size="14.666666666666668" text-anchor="middle" dominant-baseline="central" class="pcb-note-text" data-type="pcb_note_text" data-pcb-note-text-id="pcb_note_text_2" data-pcb-layer="overlay">B is a separate child pin, so the pour should clear around it.</text></svg>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "pcb_board",
|
|
4
|
+
"pcb_board_id": "pcb_board_0",
|
|
5
|
+
"center": { "x": 0, "y": 0 },
|
|
6
|
+
"width": 8,
|
|
7
|
+
"height": 4,
|
|
8
|
+
"thickness": 1.4,
|
|
9
|
+
"num_layers": 2,
|
|
10
|
+
"material": "fr4"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "source_group",
|
|
14
|
+
"source_group_id": "source_group_parent",
|
|
15
|
+
"is_subcircuit": true,
|
|
16
|
+
"subcircuit_id": "subcircuit_parent"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "source_group",
|
|
20
|
+
"source_group_id": "source_group_child_a",
|
|
21
|
+
"is_subcircuit": true,
|
|
22
|
+
"subcircuit_id": "subcircuit_child_a",
|
|
23
|
+
"parent_subcircuit_id": "subcircuit_parent"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "source_group",
|
|
27
|
+
"source_group_id": "source_group_child_b",
|
|
28
|
+
"is_subcircuit": true,
|
|
29
|
+
"subcircuit_id": "subcircuit_child_b",
|
|
30
|
+
"parent_subcircuit_id": "subcircuit_parent"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "source_net",
|
|
34
|
+
"source_net_id": "source_net_child_a_gnd",
|
|
35
|
+
"name": "GND",
|
|
36
|
+
"member_source_group_ids": ["source_group_child_a"],
|
|
37
|
+
"subcircuit_id": "subcircuit_child_a",
|
|
38
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"type": "source_trace",
|
|
42
|
+
"source_trace_id": "source_trace_child_a_gnd",
|
|
43
|
+
"connected_source_net_ids": ["source_net_child_a_gnd"],
|
|
44
|
+
"connected_source_port_ids": ["source_port_child_a_gnd"],
|
|
45
|
+
"subcircuit_id": "subcircuit_child_a",
|
|
46
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"type": "source_port",
|
|
50
|
+
"source_port_id": "source_port_child_a_gnd",
|
|
51
|
+
"source_component_id": "source_component_child_a",
|
|
52
|
+
"name": "1",
|
|
53
|
+
"subcircuit_id": "subcircuit_child_a",
|
|
54
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "pcb_port",
|
|
58
|
+
"pcb_port_id": "pcb_port_child_a_gnd",
|
|
59
|
+
"pcb_component_id": "pcb_component_child_a",
|
|
60
|
+
"source_port_id": "source_port_child_a_gnd",
|
|
61
|
+
"x": -2,
|
|
62
|
+
"y": 0,
|
|
63
|
+
"layers": ["top"],
|
|
64
|
+
"subcircuit_id": "subcircuit_child_a"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "pcb_smtpad",
|
|
68
|
+
"pcb_smtpad_id": "pcb_smtpad_child_a_gnd",
|
|
69
|
+
"pcb_component_id": "pcb_component_child_a",
|
|
70
|
+
"pcb_port_id": "pcb_port_child_a_gnd",
|
|
71
|
+
"layer": "top",
|
|
72
|
+
"shape": "rect",
|
|
73
|
+
"x": -2,
|
|
74
|
+
"y": 0,
|
|
75
|
+
"width": 0.8,
|
|
76
|
+
"height": 0.8,
|
|
77
|
+
"subcircuit_id": "subcircuit_child_a"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "source_net",
|
|
81
|
+
"source_net_id": "source_net_child_b_gnd",
|
|
82
|
+
"name": "GND",
|
|
83
|
+
"member_source_group_ids": ["source_group_child_b"],
|
|
84
|
+
"subcircuit_id": "subcircuit_child_b",
|
|
85
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "source_trace",
|
|
89
|
+
"source_trace_id": "source_trace_child_b_gnd",
|
|
90
|
+
"connected_source_net_ids": ["source_net_child_b_gnd"],
|
|
91
|
+
"connected_source_port_ids": ["source_port_child_b_gnd"],
|
|
92
|
+
"subcircuit_id": "subcircuit_child_b",
|
|
93
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "source_port",
|
|
97
|
+
"source_port_id": "source_port_child_b_gnd",
|
|
98
|
+
"source_component_id": "source_component_child_b",
|
|
99
|
+
"name": "1",
|
|
100
|
+
"subcircuit_id": "subcircuit_child_b",
|
|
101
|
+
"subcircuit_connectivity_map_key": "net0"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "pcb_port",
|
|
105
|
+
"pcb_port_id": "pcb_port_child_b_gnd",
|
|
106
|
+
"pcb_component_id": "pcb_component_child_b",
|
|
107
|
+
"source_port_id": "source_port_child_b_gnd",
|
|
108
|
+
"x": 2,
|
|
109
|
+
"y": 0,
|
|
110
|
+
"layers": ["top"],
|
|
111
|
+
"subcircuit_id": "subcircuit_child_b"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "pcb_smtpad",
|
|
115
|
+
"pcb_smtpad_id": "pcb_smtpad_child_b_gnd",
|
|
116
|
+
"pcb_component_id": "pcb_component_child_b",
|
|
117
|
+
"pcb_port_id": "pcb_port_child_b_gnd",
|
|
118
|
+
"layer": "top",
|
|
119
|
+
"shape": "rect",
|
|
120
|
+
"x": 2,
|
|
121
|
+
"y": 0,
|
|
122
|
+
"width": 0.8,
|
|
123
|
+
"height": 0.8,
|
|
124
|
+
"subcircuit_id": "subcircuit_child_b"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { AnyCircuitElement } from "circuit-json"
|
|
3
|
+
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map"
|
|
4
|
+
import { convertCircuitJsonToInputProblem } from "lib/circuit-json/convert-circuit-json-to-input-problem"
|
|
5
|
+
import subcircuitConnectivityScopeCircuitJson from "./assets/subcircuit-connectivity-scope.json"
|
|
6
|
+
|
|
7
|
+
const circuitJson = [
|
|
8
|
+
{
|
|
9
|
+
type: "pcb_board",
|
|
10
|
+
pcb_board_id: "pcb_board_0",
|
|
11
|
+
center: { x: 0, y: 0 },
|
|
12
|
+
width: 10,
|
|
13
|
+
height: 10,
|
|
14
|
+
thickness: 1.4,
|
|
15
|
+
num_layers: 2,
|
|
16
|
+
material: "fr4",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "source_net",
|
|
20
|
+
source_net_id: "source_net_gnd",
|
|
21
|
+
name: "GND",
|
|
22
|
+
subcircuit_connectivity_map_key: "stable_subcircuit_net_gnd",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "source_trace",
|
|
26
|
+
source_trace_id: "source_trace_gnd",
|
|
27
|
+
connected_source_net_ids: ["source_net_gnd"],
|
|
28
|
+
connected_source_port_ids: ["source_port_gnd"],
|
|
29
|
+
subcircuit_connectivity_map_key: "stable_subcircuit_net_gnd",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "source_port",
|
|
33
|
+
source_port_id: "source_port_gnd",
|
|
34
|
+
source_component_id: "source_component_r1",
|
|
35
|
+
name: "1",
|
|
36
|
+
subcircuit_connectivity_map_key: "stable_subcircuit_net_gnd",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "pcb_port",
|
|
40
|
+
pcb_port_id: "pcb_port_gnd",
|
|
41
|
+
pcb_component_id: "pcb_component_r1",
|
|
42
|
+
source_port_id: "source_port_gnd",
|
|
43
|
+
x: 0,
|
|
44
|
+
y: 0,
|
|
45
|
+
layers: ["top"],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: "pcb_smtpad",
|
|
49
|
+
pcb_smtpad_id: "pcb_smtpad_gnd",
|
|
50
|
+
pcb_component_id: "pcb_component_r1",
|
|
51
|
+
pcb_port_id: "pcb_port_gnd",
|
|
52
|
+
layer: "top",
|
|
53
|
+
shape: "rect",
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0,
|
|
56
|
+
width: 1,
|
|
57
|
+
height: 1,
|
|
58
|
+
port_hints: ["1"],
|
|
59
|
+
},
|
|
60
|
+
] as AnyCircuitElement[]
|
|
61
|
+
|
|
62
|
+
test("circuit-json adapter resolves pours to subcircuit connectivity keys", () => {
|
|
63
|
+
const connectivityMap = getFullConnectivityMapFromCircuitJson(circuitJson)
|
|
64
|
+
const generatedConnectivityMapKey =
|
|
65
|
+
connectivityMap.getNetConnectedToId("source_net_gnd")
|
|
66
|
+
|
|
67
|
+
expect(generatedConnectivityMapKey).toBeDefined()
|
|
68
|
+
expect(generatedConnectivityMapKey).not.toBe("stable_subcircuit_net_gnd")
|
|
69
|
+
|
|
70
|
+
const inputProblem = convertCircuitJsonToInputProblem(circuitJson, {
|
|
71
|
+
layer: "top",
|
|
72
|
+
source_net_id: "source_net_gnd",
|
|
73
|
+
pad_margin: 0.2,
|
|
74
|
+
trace_margin: 0.2,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
expect(inputProblem.regionsForPour[0]?.connectivityKey).toBe(
|
|
78
|
+
"stable_subcircuit_net_gnd",
|
|
79
|
+
)
|
|
80
|
+
expect(
|
|
81
|
+
inputProblem.pads.find((pad) => pad.padId === "pcb_smtpad_gnd"),
|
|
82
|
+
).toMatchObject({
|
|
83
|
+
connectivityKey: "stable_subcircuit_net_gnd",
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test("circuit-json adapter rejects generated connectivity map keys", () => {
|
|
88
|
+
const generatedConnectivityMapKey =
|
|
89
|
+
getFullConnectivityMapFromCircuitJson(circuitJson).getNetConnectedToId(
|
|
90
|
+
"source_net_gnd",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
expect(() =>
|
|
94
|
+
convertCircuitJsonToInputProblem(circuitJson, {
|
|
95
|
+
layer: "top",
|
|
96
|
+
pour_connectivity_key: generatedConnectivityMapKey!,
|
|
97
|
+
pad_margin: 0.2,
|
|
98
|
+
trace_margin: 0.2,
|
|
99
|
+
}),
|
|
100
|
+
).toThrow(/subcircuit_connectivity_map_key/)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test("subcircuit_id scopes repeated subcircuit connectivity keys", () => {
|
|
104
|
+
const inputProblem = convertCircuitJsonToInputProblem(
|
|
105
|
+
subcircuitConnectivityScopeCircuitJson as AnyCircuitElement[],
|
|
106
|
+
{
|
|
107
|
+
layer: "top",
|
|
108
|
+
subcircuit_id: "subcircuit_child_a",
|
|
109
|
+
subcircuit_connectivity_map_key: "net0",
|
|
110
|
+
pad_margin: 0.2,
|
|
111
|
+
trace_margin: 0.2,
|
|
112
|
+
},
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
const childAPad = inputProblem.pads.find(
|
|
116
|
+
(pad) => pad.padId === "pcb_smtpad_child_a_gnd",
|
|
117
|
+
)
|
|
118
|
+
const childBPad = inputProblem.pads.find(
|
|
119
|
+
(pad) => pad.padId === "pcb_smtpad_child_b_gnd",
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
expect(inputProblem.regionsForPour[0]?.connectivityKey).toBe(
|
|
123
|
+
"subcircuit:subcircuit_child_a:connectivity:net0",
|
|
124
|
+
)
|
|
125
|
+
expect(childAPad?.connectivityKey).toBe(
|
|
126
|
+
inputProblem.regionsForPour[0]?.connectivityKey,
|
|
127
|
+
)
|
|
128
|
+
expect(childBPad?.connectivityKey).not.toBe(
|
|
129
|
+
inputProblem.regionsForPour[0]?.connectivityKey,
|
|
130
|
+
)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
test("parent subcircuit selection rejects ambiguous child connectivity keys", () => {
|
|
134
|
+
expect(() =>
|
|
135
|
+
convertCircuitJsonToInputProblem(
|
|
136
|
+
subcircuitConnectivityScopeCircuitJson as AnyCircuitElement[],
|
|
137
|
+
{
|
|
138
|
+
layer: "top",
|
|
139
|
+
subcircuit_id: "subcircuit_parent",
|
|
140
|
+
subcircuit_connectivity_map_key: "net0",
|
|
141
|
+
pad_margin: 0.2,
|
|
142
|
+
trace_margin: 0.2,
|
|
143
|
+
},
|
|
144
|
+
),
|
|
145
|
+
).toThrow(/multiple subcircuits/)
|
|
146
|
+
})
|
|
@@ -71,7 +71,7 @@ const circuitJson: AnyCircuitElement[] = [
|
|
|
71
71
|
const getInputProblem = () =>
|
|
72
72
|
convertCircuitJsonToInputProblem(circuitJson, {
|
|
73
73
|
layer: "top",
|
|
74
|
-
|
|
74
|
+
subcircuit_connectivity_map_key: "net:GND",
|
|
75
75
|
pad_margin: 0.15,
|
|
76
76
|
trace_margin: 0.15,
|
|
77
77
|
})
|