@tscircuit/copper-pour-solver 0.0.5 → 0.0.6

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.d.ts CHANGED
@@ -10,7 +10,7 @@ interface InputPourRegion {
10
10
  connectivityKey: string;
11
11
  padMargin: number;
12
12
  traceMargin: number;
13
- boardEdgeMargin?: number;
13
+ board_edge_margin?: number;
14
14
  }
15
15
  interface BaseInputPad {
16
16
  padId: string;
@@ -53,7 +53,7 @@ declare const convertCircuitJsonToInputProblem: (circuitJson: AnyCircuitElement[
53
53
  pour_connectivity_key: string;
54
54
  pad_margin: number;
55
55
  trace_margin: number;
56
- boardEdgeMargin?: number;
56
+ board_edge_margin?: number;
57
57
  }) => InputProblem;
58
58
 
59
59
  export { type BaseInputPad, CopperPourPipelineSolver, type InputCircularPad, type InputPad, type InputPourRegion, type InputProblem, type InputRectPad, type InputTracePad, type PipelineOutput, convertCircuitJsonToInputProblem };
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { BasePipelineSolver } from "@tscircuit/solver-utils";
4
4
  // lib/solvers/copper-pour/get-board-polygon.ts
5
5
  import Flatten from "@flatten-js/core";
6
6
  var getBoardPolygon = (region) => {
7
- const boardEdgeMargin = region.boardEdgeMargin ?? 0;
7
+ const board_edge_margin = region.board_edge_margin ?? 0;
8
8
  if (region.outline && region.outline.length > 0) {
9
9
  const polygon = new Flatten.Polygon(
10
10
  region.outline.map((p) => Flatten.point(p.x, p.y))
@@ -13,10 +13,10 @@ var getBoardPolygon = (region) => {
13
13
  }
14
14
  const { bounds } = region;
15
15
  const newBounds = {
16
- minX: bounds.minX + boardEdgeMargin,
17
- minY: bounds.minY + boardEdgeMargin,
18
- maxX: bounds.maxX - boardEdgeMargin,
19
- maxY: bounds.maxY - boardEdgeMargin
16
+ minX: bounds.minX + board_edge_margin,
17
+ minY: bounds.minY + board_edge_margin,
18
+ maxX: bounds.maxX - board_edge_margin,
19
+ maxY: bounds.maxY - board_edge_margin
20
20
  };
21
21
  if (newBounds.minX >= newBounds.maxX || newBounds.minY >= newBounds.maxY) {
22
22
  return new Flatten.Polygon();
@@ -59,8 +59,8 @@ var isTracePad = (pad) => pad.shape === "trace";
59
59
  var isCircularPad = (pad) => pad.shape === "circle";
60
60
  var processObstaclesForPour = (pads, pourConnectivityKey, margins, boardOutline) => {
61
61
  const polygonsToSubtract = [];
62
- const { padMargin, traceMargin, boardEdgeMargin } = margins;
63
- if (boardOutline && boardOutline.length > 0 && boardEdgeMargin && boardEdgeMargin > 0) {
62
+ const { padMargin, traceMargin, board_edge_margin } = margins;
63
+ if (boardOutline && boardOutline.length > 0 && board_edge_margin && board_edge_margin > 0) {
64
64
  const boardPoly = new Flatten3.Polygon(
65
65
  boardOutline.map((p) => Flatten3.point(p.x, p.y))
66
66
  );
@@ -76,14 +76,14 @@ var processObstaclesForPour = (pads, pourConnectivityKey, margins, boardOutline)
76
76
  const v1 = new Flatten3.Vector(p1, p2);
77
77
  const v2 = new Flatten3.Vector(p2, p3);
78
78
  const crossProduct = v1.cross(v2);
79
- const circle = new Flatten3.Circle(p2, boardEdgeMargin);
79
+ const circle = new Flatten3.Circle(p2, board_edge_margin);
80
80
  polygonsToSubtract.push(circleToPolygon(circle));
81
81
  if (crossProduct < 0) {
82
82
  const box = new Flatten3.Box(
83
- p2.x - boardEdgeMargin,
84
- p2.y - boardEdgeMargin,
85
- p2.x + boardEdgeMargin,
86
- p2.y + boardEdgeMargin
83
+ p2.x - board_edge_margin,
84
+ p2.y - board_edge_margin,
85
+ p2.x + board_edge_margin,
86
+ p2.y + board_edge_margin
87
87
  );
88
88
  polygonsToSubtract.push(new Flatten3.Polygon(box.toPoints()));
89
89
  }
@@ -94,7 +94,7 @@ var processObstaclesForPour = (pads, pourConnectivityKey, margins, boardOutline)
94
94
  if (!p1 || !p2) continue;
95
95
  const segmentLength = Math.hypot(p1.x - p2.x, p1.y - p2.y);
96
96
  if (segmentLength === 0) continue;
97
- const enlargedWidth = boardEdgeMargin * 2;
97
+ const enlargedWidth = board_edge_margin * 2;
98
98
  const centerX = (p1.x + p2.x) / 2;
99
99
  const centerY = (p1.y + p2.y) / 2;
100
100
  const rotationDeg = Math.atan2(p2.y - p1.y, p2.x - p1.x) * 180 / Math.PI;
@@ -254,7 +254,7 @@ var CopperPourPipelineSolver = class extends BasePipelineSolver {
254
254
  {
255
255
  padMargin: region.padMargin,
256
256
  traceMargin: region.traceMargin,
257
- boardEdgeMargin: region.boardEdgeMargin
257
+ board_edge_margin: region.board_edge_margin
258
258
  },
259
259
  region.outline
260
260
  );
@@ -435,7 +435,7 @@ var convertCircuitJsonToInputProblem = (circuitJson, options) => {
435
435
  connectivityKey: options.pour_connectivity_key,
436
436
  padMargin: options.pad_margin,
437
437
  traceMargin: options.trace_margin,
438
- boardEdgeMargin: options.boardEdgeMargin ?? 0
438
+ board_edge_margin: options.board_edge_margin ?? 0
439
439
  }
440
440
  ];
441
441
  return {
@@ -26,7 +26,7 @@ export const convertCircuitJsonToInputProblem = (
26
26
  pour_connectivity_key: string
27
27
  pad_margin: number
28
28
  trace_margin: number
29
- boardEdgeMargin?: number
29
+ board_edge_margin?: number
30
30
  },
31
31
  ): InputProblem => {
32
32
  const source_ports = circuitJson.filter(
@@ -199,7 +199,7 @@ export const convertCircuitJsonToInputProblem = (
199
199
  connectivityKey: options.pour_connectivity_key,
200
200
  padMargin: options.pad_margin,
201
201
  traceMargin: options.trace_margin,
202
- boardEdgeMargin: options.boardEdgeMargin ?? 0,
202
+ board_edge_margin: options.board_edge_margin ?? 0,
203
203
  },
204
204
  ]
205
205
 
@@ -28,7 +28,7 @@ export class CopperPourPipelineSolver extends BasePipelineSolver<InputProblem> {
28
28
  {
29
29
  padMargin: region.padMargin,
30
30
  traceMargin: region.traceMargin,
31
- boardEdgeMargin: region.boardEdgeMargin,
31
+ board_edge_margin: region.board_edge_margin,
32
32
  },
33
33
  region.outline,
34
34
  )
@@ -2,7 +2,7 @@ import type { InputPourRegion } from "lib/types"
2
2
  import Flatten from "@flatten-js/core"
3
3
 
4
4
  export const getBoardPolygon = (region: InputPourRegion): Flatten.Polygon => {
5
- const boardEdgeMargin = region.boardEdgeMargin ?? 0
5
+ const board_edge_margin = region.board_edge_margin ?? 0
6
6
 
7
7
  if (region.outline && region.outline.length > 0) {
8
8
  const polygon = new Flatten.Polygon(
@@ -13,10 +13,10 @@ export const getBoardPolygon = (region: InputPourRegion): Flatten.Polygon => {
13
13
 
14
14
  const { bounds } = region
15
15
  const newBounds = {
16
- minX: bounds.minX + boardEdgeMargin,
17
- minY: bounds.minY + boardEdgeMargin,
18
- maxX: bounds.maxX - boardEdgeMargin,
19
- maxY: bounds.maxY - boardEdgeMargin,
16
+ minX: bounds.minX + board_edge_margin,
17
+ minY: bounds.minY + board_edge_margin,
18
+ maxX: bounds.maxX - board_edge_margin,
19
+ maxY: bounds.maxY - board_edge_margin,
20
20
  }
21
21
 
22
22
  if (newBounds.minX >= newBounds.maxX || newBounds.minY >= newBounds.maxY) {
@@ -21,18 +21,22 @@ const isCircularPad = (pad: InputPad): pad is InputCircularPad =>
21
21
  export const processObstaclesForPour = (
22
22
  pads: InputPad[],
23
23
  pourConnectivityKey: string,
24
- margins: { padMargin: number; traceMargin: number; boardEdgeMargin?: number },
24
+ margins: {
25
+ padMargin: number
26
+ traceMargin: number
27
+ board_edge_margin?: number
28
+ },
25
29
  boardOutline?: Point[],
26
30
  ): ProcessedObstacles => {
27
31
  const polygonsToSubtract: Flatten.Polygon[] = []
28
32
 
29
- const { padMargin, traceMargin, boardEdgeMargin } = margins
33
+ const { padMargin, traceMargin, board_edge_margin } = margins
30
34
 
31
35
  if (
32
36
  boardOutline &&
33
37
  boardOutline.length > 0 &&
34
- boardEdgeMargin &&
35
- boardEdgeMargin > 0
38
+ board_edge_margin &&
39
+ board_edge_margin > 0
36
40
  ) {
37
41
  const boardPoly = new Flatten.Polygon(
38
42
  boardOutline.map((p) => Flatten.point(p.x, p.y)),
@@ -54,15 +58,15 @@ export const processObstaclesForPour = (
54
58
  const v2 = new Flatten.Vector(p2, p3)
55
59
  const crossProduct = v1.cross(v2)
56
60
 
57
- const circle = new Flatten.Circle(p2, boardEdgeMargin)
61
+ const circle = new Flatten.Circle(p2, board_edge_margin)
58
62
  polygonsToSubtract.push(circleToPolygon(circle))
59
63
 
60
64
  if (crossProduct < 0) {
61
65
  const box = new Flatten.Box(
62
- p2.x - boardEdgeMargin,
63
- p2.y - boardEdgeMargin,
64
- p2.x + boardEdgeMargin,
65
- p2.y + boardEdgeMargin,
66
+ p2.x - board_edge_margin,
67
+ p2.y - board_edge_margin,
68
+ p2.x + board_edge_margin,
69
+ p2.y + board_edge_margin,
66
70
  )
67
71
  polygonsToSubtract.push(new Flatten.Polygon(box.toPoints()))
68
72
  }
@@ -78,7 +82,7 @@ export const processObstaclesForPour = (
78
82
  const segmentLength = Math.hypot(p1.x - p2.x, p1.y - p2.y)
79
83
  if (segmentLength === 0) continue
80
84
 
81
- const enlargedWidth = boardEdgeMargin * 2
85
+ const enlargedWidth = board_edge_margin * 2
82
86
 
83
87
  const centerX = (p1.x + p2.x) / 2
84
88
  const centerY = (p1.y + p2.y) / 2
package/lib/types.ts CHANGED
@@ -9,7 +9,7 @@ export interface InputPourRegion {
9
9
  connectivityKey: string
10
10
  padMargin: number
11
11
  traceMargin: number
12
- boardEdgeMargin?: number
12
+ board_edge_margin?: number
13
13
  }
14
14
 
15
15
  export interface BaseInputPad {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/copper-pour-solver",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "scripts": {
6
6
  "format": "biome format . --write",
7
7
  "format:check": "biome format .",
@@ -9,7 +9,7 @@ test("board edge margin 2", async () => {
9
9
  net_name: "GND",
10
10
  pad_margin: 0.4,
11
11
  trace_margin: 0.2,
12
- boardEdgeMargin: 1,
12
+ board_edge_margin: 1,
13
13
  })
14
14
 
15
15
  await expect(svg).toMatchSvgSnapshot(import.meta.path, "board-edge-margin-2")
@@ -8,7 +8,7 @@ test("board edge margin", async () => {
8
8
  net_name: "GND",
9
9
  pad_margin: 0.4,
10
10
  trace_margin: 0.2,
11
- boardEdgeMargin: 1,
11
+ board_edge_margin: 1,
12
12
  })
13
13
 
14
14
  await expect(svg).toMatchSvgSnapshot(import.meta.path, "board-edge-margin")
@@ -17,7 +17,7 @@ export const runSolverAndRenderToSvg = (
17
17
  net_name: string
18
18
  pad_margin: number
19
19
  trace_margin: number
20
- boardEdgeMargin?: number
20
+ board_edge_margin?: number
21
21
  },
22
22
  ) => {
23
23
  const source_net = circuitJson.find(