@tscircuit/copper-pour-solver 0.0.1

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.
Files changed (44) hide show
  1. package/.github/workflows/.replit +9 -0
  2. package/.github/workflows/bun-formatcheck.yml +26 -0
  3. package/.github/workflows/bun-pver-release.yml +71 -0
  4. package/.github/workflows/bun-test.yml +31 -0
  5. package/.github/workflows/bun-typecheck.yml +26 -0
  6. package/README.md +37 -0
  7. package/biome.json +93 -0
  8. package/bun.lock +164 -0
  9. package/bunfig.toml +5 -0
  10. package/cosmos.config.json +5 -0
  11. package/dist/index.d.ts +57 -0
  12. package/dist/index.js +368 -0
  13. package/lib/circuit-json/convert-circuit-json-to-input-problem.ts +208 -0
  14. package/lib/circuit-json/convertCircuitJsonToInputProblem.ts +0 -0
  15. package/lib/index.ts +3 -0
  16. package/lib/solvers/CopperPourPipelineSolver.ts +51 -0
  17. package/lib/solvers/copper-pour/circle-to-polygon.ts +15 -0
  18. package/lib/solvers/copper-pour/generate-brep.ts +60 -0
  19. package/lib/solvers/copper-pour/get-board-polygon.ts +19 -0
  20. package/lib/solvers/copper-pour/process-obstacles.ts +116 -0
  21. package/lib/types.ts +46 -0
  22. package/package.json +28 -0
  23. package/site/Welcome.page.tsx +0 -0
  24. package/tests/__snapshots__/circuit-1.snap.svg +1 -0
  25. package/tests/__snapshots__/circuit-2.snap.svg +1 -0
  26. package/tests/__snapshots__/circuit-3.snap.svg +1 -0
  27. package/tests/__snapshots__/circuit-4.snap.svg +1 -0
  28. package/tests/__snapshots__/circuit-5.snap.svg +1 -0
  29. package/tests/__snapshots__/circuit-6.snap.svg +1 -0
  30. package/tests/assets/circuit-1.json +592 -0
  31. package/tests/assets/circuit-2.json +1424 -0
  32. package/tests/assets/circuit-3.json +1424 -0
  33. package/tests/assets/circuit-4.json +631 -0
  34. package/tests/assets/circuit-5.json +631 -0
  35. package/tests/assets/circuit-6.json +806 -0
  36. package/tests/circuit-1.test.ts +14 -0
  37. package/tests/circuit-2.test.ts +15 -0
  38. package/tests/circuit-3.test.ts +15 -0
  39. package/tests/circuit-4.test.ts +15 -0
  40. package/tests/circuit-5.test.ts +15 -0
  41. package/tests/circuit-6.test.ts +15 -0
  42. package/tests/fixtures/preload.ts +1 -0
  43. package/tests/utils/run-solver-and-render-to-svg.ts +64 -0
  44. package/tsconfig.json +34 -0
@@ -0,0 +1,592 @@
1
+ [
2
+ {
3
+ "type": "source_project_metadata",
4
+ "source_project_metadata_id": "source_project_metadata_0",
5
+ "software_used_string": "@tscircuit/core@0.0.844"
6
+ },
7
+ {
8
+ "type": "source_group",
9
+ "source_group_id": "source_group_0",
10
+ "is_subcircuit": true,
11
+ "was_automatically_named": true,
12
+ "subcircuit_id": "subcircuit_source_group_0"
13
+ },
14
+ {
15
+ "type": "source_net",
16
+ "source_net_id": "source_net_0",
17
+ "name": "GND",
18
+ "member_source_group_ids": [],
19
+ "is_ground": true,
20
+ "is_power": false,
21
+ "is_positive_voltage_source": false,
22
+ "subcircuit_id": "subcircuit_source_group_0",
23
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net1"
24
+ },
25
+ {
26
+ "type": "source_net",
27
+ "source_net_id": "source_net_1",
28
+ "name": "VCC",
29
+ "member_source_group_ids": [],
30
+ "is_ground": false,
31
+ "is_power": true,
32
+ "is_positive_voltage_source": true,
33
+ "subcircuit_id": "subcircuit_source_group_0",
34
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net0"
35
+ },
36
+ {
37
+ "type": "source_port",
38
+ "source_port_id": "source_port_0",
39
+ "name": "pin1",
40
+ "pin_number": 1,
41
+ "port_hints": ["pin1", "anode", "pos", "left", "1"],
42
+ "source_component_id": "source_component_0",
43
+ "subcircuit_id": "subcircuit_source_group_0",
44
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net0"
45
+ },
46
+ {
47
+ "type": "source_port",
48
+ "source_port_id": "source_port_1",
49
+ "name": "pin2",
50
+ "pin_number": 2,
51
+ "port_hints": ["pin2", "cathode", "neg", "right", "2"],
52
+ "source_component_id": "source_component_0",
53
+ "subcircuit_id": "subcircuit_source_group_0",
54
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net2"
55
+ },
56
+ {
57
+ "type": "source_component",
58
+ "source_component_id": "source_component_0",
59
+ "ftype": "simple_resistor",
60
+ "name": "R1",
61
+ "resistance": 10000,
62
+ "display_resistance": "10kΩ",
63
+ "are_pins_interchangeable": true,
64
+ "source_group_id": "source_group_0"
65
+ },
66
+ {
67
+ "type": "source_port",
68
+ "source_port_id": "source_port_2",
69
+ "name": "pin1",
70
+ "pin_number": 1,
71
+ "port_hints": ["pin1", "anode", "pos", "left", "1"],
72
+ "source_component_id": "source_component_1",
73
+ "subcircuit_id": "subcircuit_source_group_0",
74
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net2"
75
+ },
76
+ {
77
+ "type": "source_port",
78
+ "source_port_id": "source_port_3",
79
+ "name": "pin2",
80
+ "pin_number": 2,
81
+ "port_hints": ["pin2", "cathode", "neg", "right", "2"],
82
+ "source_component_id": "source_component_1",
83
+ "subcircuit_id": "subcircuit_source_group_0",
84
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net1"
85
+ },
86
+ {
87
+ "type": "source_component",
88
+ "source_component_id": "source_component_1",
89
+ "ftype": "simple_resistor",
90
+ "name": "R2",
91
+ "resistance": 1000,
92
+ "display_resistance": "1kΩ",
93
+ "are_pins_interchangeable": true,
94
+ "source_group_id": "source_group_0"
95
+ },
96
+ {
97
+ "type": "source_board",
98
+ "source_board_id": "source_board_0",
99
+ "source_group_id": "source_group_0"
100
+ },
101
+ {
102
+ "type": "source_trace",
103
+ "source_trace_id": "source_trace_0",
104
+ "connected_source_port_ids": ["source_port_0"],
105
+ "connected_source_net_ids": ["source_net_1"],
106
+ "subcircuit_id": "subcircuit_source_group_0",
107
+ "display_name": ".R1 > .pin1 to net.VCC",
108
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net0"
109
+ },
110
+ {
111
+ "type": "source_trace",
112
+ "source_trace_id": "source_trace_1",
113
+ "connected_source_port_ids": ["source_port_3"],
114
+ "connected_source_net_ids": ["source_net_0"],
115
+ "subcircuit_id": "subcircuit_source_group_0",
116
+ "display_name": ".R2 > .pin2 to net.GND",
117
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net1"
118
+ },
119
+ {
120
+ "type": "source_trace",
121
+ "source_trace_id": "source_trace_2",
122
+ "connected_source_port_ids": ["source_port_1", "source_port_2"],
123
+ "connected_source_net_ids": [],
124
+ "subcircuit_id": "subcircuit_source_group_0",
125
+ "display_name": ".R1 > .pin2 to .R2 > .pin1",
126
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net2"
127
+ },
128
+ {
129
+ "type": "schematic_component",
130
+ "schematic_component_id": "schematic_component_0",
131
+ "center": {
132
+ "x": 0,
133
+ "y": 0
134
+ },
135
+ "size": {
136
+ "width": 1.1,
137
+ "height": 0.388910699999999
138
+ },
139
+ "source_component_id": "source_component_0",
140
+ "is_box_with_pins": true,
141
+ "symbol_name": "boxresistor_right",
142
+ "symbol_display_value": "10kΩ",
143
+ "schematic_group_id": "schematic_group_0"
144
+ },
145
+ {
146
+ "type": "schematic_component",
147
+ "schematic_component_id": "schematic_component_1",
148
+ "center": {
149
+ "x": 1.8000000000000003,
150
+ "y": 0
151
+ },
152
+ "size": {
153
+ "width": 1.1,
154
+ "height": 0.388910699999999
155
+ },
156
+ "source_component_id": "source_component_1",
157
+ "is_box_with_pins": true,
158
+ "symbol_name": "boxresistor_right",
159
+ "symbol_display_value": "1kΩ",
160
+ "schematic_group_id": "schematic_group_0"
161
+ },
162
+ {
163
+ "type": "schematic_group",
164
+ "schematic_group_id": "schematic_group_0",
165
+ "is_subcircuit": true,
166
+ "subcircuit_id": "subcircuit_source_group_0",
167
+ "name": "unnamed_board1",
168
+ "center": {
169
+ "x": 0,
170
+ "y": 0
171
+ },
172
+ "width": 0,
173
+ "height": 0,
174
+ "schematic_component_ids": [],
175
+ "source_group_id": "source_group_0"
176
+ },
177
+ {
178
+ "type": "schematic_port",
179
+ "schematic_port_id": "schematic_port_0",
180
+ "schematic_component_id": "schematic_component_0",
181
+ "center": {
182
+ "x": -0.55,
183
+ "y": 0
184
+ },
185
+ "source_port_id": "source_port_0",
186
+ "facing_direction": "left",
187
+ "distance_from_component_edge": 0.4,
188
+ "pin_number": 1,
189
+ "display_pin_label": "anode",
190
+ "is_connected": false
191
+ },
192
+ {
193
+ "type": "schematic_port",
194
+ "schematic_port_id": "schematic_port_1",
195
+ "schematic_component_id": "schematic_component_0",
196
+ "center": {
197
+ "x": 0.55,
198
+ "y": 0
199
+ },
200
+ "source_port_id": "source_port_1",
201
+ "facing_direction": "right",
202
+ "distance_from_component_edge": 0.4,
203
+ "pin_number": 2,
204
+ "display_pin_label": "cathode",
205
+ "is_connected": true
206
+ },
207
+ {
208
+ "type": "schematic_port",
209
+ "schematic_port_id": "schematic_port_2",
210
+ "schematic_component_id": "schematic_component_1",
211
+ "center": {
212
+ "x": 1.2500000000000002,
213
+ "y": 0
214
+ },
215
+ "source_port_id": "source_port_2",
216
+ "facing_direction": "left",
217
+ "distance_from_component_edge": 0.4,
218
+ "pin_number": 1,
219
+ "display_pin_label": "anode",
220
+ "is_connected": true
221
+ },
222
+ {
223
+ "type": "schematic_port",
224
+ "schematic_port_id": "schematic_port_3",
225
+ "schematic_component_id": "schematic_component_1",
226
+ "center": {
227
+ "x": 2.3500000000000005,
228
+ "y": 0
229
+ },
230
+ "source_port_id": "source_port_3",
231
+ "facing_direction": "right",
232
+ "distance_from_component_edge": 0.4,
233
+ "pin_number": 2,
234
+ "display_pin_label": "cathode",
235
+ "is_connected": false
236
+ },
237
+ {
238
+ "type": "schematic_trace",
239
+ "schematic_trace_id": "schematic_trace_0",
240
+ "source_trace_id": "solver_R1.2-R2.1",
241
+ "edges": [
242
+ {
243
+ "from": {
244
+ "x": 0.55,
245
+ "y": 0
246
+ },
247
+ "to": {
248
+ "x": 1.25,
249
+ "y": 0
250
+ }
251
+ }
252
+ ],
253
+ "junctions": [],
254
+ "subcircuit_connectivity_map_key": "unnamedsubcircuit111_connectivity_net2"
255
+ },
256
+ {
257
+ "type": "schematic_net_label",
258
+ "schematic_net_label_id": "schematic_net_label_0",
259
+ "text": "VCC",
260
+ "anchor_position": {
261
+ "x": -0.55,
262
+ "y": 0
263
+ },
264
+ "center": {
265
+ "x": -0.7000000000000001,
266
+ "y": 0
267
+ },
268
+ "anchor_side": "right",
269
+ "source_net_id": "source_net_1"
270
+ },
271
+ {
272
+ "type": "schematic_net_label",
273
+ "schematic_net_label_id": "schematic_net_label_1",
274
+ "text": "GND",
275
+ "anchor_position": {
276
+ "x": 2.3500000000000005,
277
+ "y": 0
278
+ },
279
+ "center": {
280
+ "x": 2.5000000000000004,
281
+ "y": 0
282
+ },
283
+ "anchor_side": "left",
284
+ "source_net_id": "source_net_0"
285
+ },
286
+ {
287
+ "type": "pcb_component",
288
+ "pcb_component_id": "pcb_component_0",
289
+ "center": {
290
+ "x": -5,
291
+ "y": 0
292
+ },
293
+ "width": 2.8499999999999996,
294
+ "height": 1.4,
295
+ "layer": "top",
296
+ "rotation": 0,
297
+ "source_component_id": "source_component_0",
298
+ "subcircuit_id": "subcircuit_source_group_0",
299
+ "do_not_place": false,
300
+ "obstructs_within_bounds": true
301
+ },
302
+ {
303
+ "type": "pcb_component",
304
+ "pcb_component_id": "pcb_component_1",
305
+ "center": {
306
+ "x": 5,
307
+ "y": 0
308
+ },
309
+ "width": 2.8499999999999996,
310
+ "height": 1.4,
311
+ "layer": "top",
312
+ "rotation": 0,
313
+ "source_component_id": "source_component_1",
314
+ "subcircuit_id": "subcircuit_source_group_0",
315
+ "do_not_place": false,
316
+ "obstructs_within_bounds": true
317
+ },
318
+ {
319
+ "type": "pcb_board",
320
+ "pcb_board_id": "pcb_board_0",
321
+ "center": {
322
+ "x": 0,
323
+ "y": 0
324
+ },
325
+ "thickness": 1.4,
326
+ "num_layers": 2,
327
+ "width": 20,
328
+ "height": 20,
329
+ "material": "fr4"
330
+ },
331
+ {
332
+ "type": "pcb_smtpad",
333
+ "pcb_smtpad_id": "pcb_smtpad_0",
334
+ "pcb_component_id": "pcb_component_0",
335
+ "pcb_port_id": "pcb_port_0",
336
+ "layer": "top",
337
+ "shape": "rect",
338
+ "width": 1.025,
339
+ "height": 1.4,
340
+ "port_hints": ["1", "left"],
341
+ "is_covered_with_solder_mask": false,
342
+ "x": -5.9125,
343
+ "y": 0,
344
+ "subcircuit_id": "subcircuit_source_group_0"
345
+ },
346
+ {
347
+ "type": "pcb_solder_paste",
348
+ "pcb_solder_paste_id": "pcb_solder_paste_0",
349
+ "layer": "top",
350
+ "shape": "rect",
351
+ "width": 0.7174999999999999,
352
+ "height": 0.9799999999999999,
353
+ "x": -5.9125,
354
+ "y": 0,
355
+ "pcb_component_id": "pcb_component_0",
356
+ "pcb_smtpad_id": "pcb_smtpad_0",
357
+ "subcircuit_id": "subcircuit_source_group_0"
358
+ },
359
+ {
360
+ "type": "pcb_smtpad",
361
+ "pcb_smtpad_id": "pcb_smtpad_1",
362
+ "pcb_component_id": "pcb_component_0",
363
+ "pcb_port_id": "pcb_port_1",
364
+ "layer": "top",
365
+ "shape": "rect",
366
+ "width": 1.025,
367
+ "height": 1.4,
368
+ "port_hints": ["2", "right"],
369
+ "is_covered_with_solder_mask": false,
370
+ "x": -4.0875,
371
+ "y": 0,
372
+ "subcircuit_id": "subcircuit_source_group_0"
373
+ },
374
+ {
375
+ "type": "pcb_solder_paste",
376
+ "pcb_solder_paste_id": "pcb_solder_paste_1",
377
+ "layer": "top",
378
+ "shape": "rect",
379
+ "width": 0.7174999999999999,
380
+ "height": 0.9799999999999999,
381
+ "x": -4.0875,
382
+ "y": 0,
383
+ "pcb_component_id": "pcb_component_0",
384
+ "pcb_smtpad_id": "pcb_smtpad_1",
385
+ "subcircuit_id": "subcircuit_source_group_0"
386
+ },
387
+ {
388
+ "type": "pcb_silkscreen_path",
389
+ "pcb_silkscreen_path_id": "pcb_silkscreen_path_0",
390
+ "pcb_component_id": "pcb_component_0",
391
+ "layer": "top",
392
+ "route": [
393
+ {
394
+ "x": -4.0875,
395
+ "y": 1.1
396
+ },
397
+ {
398
+ "x": -6.625,
399
+ "y": 1.1
400
+ },
401
+ {
402
+ "x": -6.625,
403
+ "y": -1.1
404
+ },
405
+ {
406
+ "x": -4.0875,
407
+ "y": -1.1
408
+ }
409
+ ],
410
+ "stroke_width": 0.1,
411
+ "subcircuit_id": "subcircuit_source_group_0"
412
+ },
413
+ {
414
+ "type": "pcb_silkscreen_text",
415
+ "pcb_silkscreen_text_id": "pcb_silkscreen_text_0",
416
+ "anchor_alignment": "center",
417
+ "anchor_position": {
418
+ "x": -5,
419
+ "y": 1.6
420
+ },
421
+ "font": "tscircuit2024",
422
+ "font_size": 0.4,
423
+ "layer": "top",
424
+ "text": "R1",
425
+ "ccw_rotation": 0,
426
+ "pcb_component_id": "pcb_component_0",
427
+ "subcircuit_id": "subcircuit_source_group_0"
428
+ },
429
+ {
430
+ "type": "pcb_smtpad",
431
+ "pcb_smtpad_id": "pcb_smtpad_2",
432
+ "pcb_component_id": "pcb_component_1",
433
+ "pcb_port_id": "pcb_port_2",
434
+ "layer": "top",
435
+ "shape": "rect",
436
+ "width": 1.025,
437
+ "height": 1.4,
438
+ "port_hints": ["1", "left"],
439
+ "is_covered_with_solder_mask": false,
440
+ "x": 4.0875,
441
+ "y": 0,
442
+ "subcircuit_id": "subcircuit_source_group_0"
443
+ },
444
+ {
445
+ "type": "pcb_solder_paste",
446
+ "pcb_solder_paste_id": "pcb_solder_paste_2",
447
+ "layer": "top",
448
+ "shape": "rect",
449
+ "width": 0.7174999999999999,
450
+ "height": 0.9799999999999999,
451
+ "x": 4.0875,
452
+ "y": 0,
453
+ "pcb_component_id": "pcb_component_1",
454
+ "pcb_smtpad_id": "pcb_smtpad_2",
455
+ "subcircuit_id": "subcircuit_source_group_0"
456
+ },
457
+ {
458
+ "type": "pcb_smtpad",
459
+ "pcb_smtpad_id": "pcb_smtpad_3",
460
+ "pcb_component_id": "pcb_component_1",
461
+ "pcb_port_id": "pcb_port_3",
462
+ "layer": "top",
463
+ "shape": "rect",
464
+ "width": 1.025,
465
+ "height": 1.4,
466
+ "port_hints": ["2", "right"],
467
+ "is_covered_with_solder_mask": false,
468
+ "x": 5.9125,
469
+ "y": 0,
470
+ "subcircuit_id": "subcircuit_source_group_0"
471
+ },
472
+ {
473
+ "type": "pcb_solder_paste",
474
+ "pcb_solder_paste_id": "pcb_solder_paste_3",
475
+ "layer": "top",
476
+ "shape": "rect",
477
+ "width": 0.7174999999999999,
478
+ "height": 0.9799999999999999,
479
+ "x": 5.9125,
480
+ "y": 0,
481
+ "pcb_component_id": "pcb_component_1",
482
+ "pcb_smtpad_id": "pcb_smtpad_3",
483
+ "subcircuit_id": "subcircuit_source_group_0"
484
+ },
485
+ {
486
+ "type": "pcb_silkscreen_path",
487
+ "pcb_silkscreen_path_id": "pcb_silkscreen_path_1",
488
+ "pcb_component_id": "pcb_component_1",
489
+ "layer": "top",
490
+ "route": [
491
+ {
492
+ "x": 5.9125,
493
+ "y": 1.1
494
+ },
495
+ {
496
+ "x": 3.375,
497
+ "y": 1.1
498
+ },
499
+ {
500
+ "x": 3.375,
501
+ "y": -1.1
502
+ },
503
+ {
504
+ "x": 5.9125,
505
+ "y": -1.1
506
+ }
507
+ ],
508
+ "stroke_width": 0.1,
509
+ "subcircuit_id": "subcircuit_source_group_0"
510
+ },
511
+ {
512
+ "type": "pcb_silkscreen_text",
513
+ "pcb_silkscreen_text_id": "pcb_silkscreen_text_1",
514
+ "anchor_alignment": "center",
515
+ "anchor_position": {
516
+ "x": 5,
517
+ "y": 1.6
518
+ },
519
+ "font": "tscircuit2024",
520
+ "font_size": 0.4,
521
+ "layer": "top",
522
+ "text": "R2",
523
+ "ccw_rotation": 0,
524
+ "pcb_component_id": "pcb_component_1",
525
+ "subcircuit_id": "subcircuit_source_group_0"
526
+ },
527
+ {
528
+ "type": "pcb_port",
529
+ "pcb_port_id": "pcb_port_0",
530
+ "pcb_component_id": "pcb_component_0",
531
+ "layers": ["top"],
532
+ "subcircuit_id": "subcircuit_source_group_0",
533
+ "x": -5.9125,
534
+ "y": 0,
535
+ "source_port_id": "source_port_0"
536
+ },
537
+ {
538
+ "type": "pcb_port",
539
+ "pcb_port_id": "pcb_port_1",
540
+ "pcb_component_id": "pcb_component_0",
541
+ "layers": ["top"],
542
+ "subcircuit_id": "subcircuit_source_group_0",
543
+ "x": -4.0875,
544
+ "y": 0,
545
+ "source_port_id": "source_port_1"
546
+ },
547
+ {
548
+ "type": "pcb_port",
549
+ "pcb_port_id": "pcb_port_2",
550
+ "pcb_component_id": "pcb_component_1",
551
+ "layers": ["top"],
552
+ "subcircuit_id": "subcircuit_source_group_0",
553
+ "x": 4.0875,
554
+ "y": 0,
555
+ "source_port_id": "source_port_2"
556
+ },
557
+ {
558
+ "type": "pcb_port",
559
+ "pcb_port_id": "pcb_port_3",
560
+ "pcb_component_id": "pcb_component_1",
561
+ "layers": ["top"],
562
+ "subcircuit_id": "subcircuit_source_group_0",
563
+ "x": 5.9125,
564
+ "y": 0,
565
+ "source_port_id": "source_port_3"
566
+ },
567
+ {
568
+ "type": "pcb_trace",
569
+ "pcb_trace_id": "pcb_trace_0",
570
+ "route": [
571
+ {
572
+ "route_type": "wire",
573
+ "x": -4.0875,
574
+ "y": 0,
575
+ "width": 0.16,
576
+ "layer": "top",
577
+ "start_pcb_port_id": "pcb_port_1"
578
+ },
579
+ {
580
+ "route_type": "wire",
581
+ "x": 4.0875,
582
+ "y": 0,
583
+ "width": 0.16,
584
+ "layer": "top",
585
+ "end_pcb_port_id": "pcb_port_2"
586
+ }
587
+ ],
588
+ "source_trace_id": "source_trace_2",
589
+ "subcircuit_id": "subcircuit_source_group_0",
590
+ "trace_length": 8.175
591
+ }
592
+ ]