@tscircuit/copper-pour-solver 0.0.28 → 0.0.30
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
CHANGED
|
@@ -179,6 +179,7 @@ var runManifoldOperation = (operation, polygons, callback) => {
|
|
|
179
179
|
|
|
180
180
|
// lib/solvers/copper-pour/manifold-geometry-adapter.ts
|
|
181
181
|
var DEFAULT_MIN_ISLAND_AREA = 1e-8;
|
|
182
|
+
var emptyCrossSection = () => getCrossSection().square([0, 0]);
|
|
182
183
|
var crossSectionFromPolygon = (polygon, fillRule = "Positive") => {
|
|
183
184
|
const scaledPolygons = toScaledManifoldPolygons(
|
|
184
185
|
[polygon],
|
|
@@ -186,7 +187,7 @@ var crossSectionFromPolygon = (polygon, fillRule = "Positive") => {
|
|
|
186
187
|
);
|
|
187
188
|
const CrossSection = getCrossSection();
|
|
188
189
|
if (scaledPolygons.length === 0) {
|
|
189
|
-
return
|
|
190
|
+
return emptyCrossSection();
|
|
190
191
|
}
|
|
191
192
|
return runManifoldOperation(
|
|
192
193
|
"crossSectionFromPolygon",
|
|
@@ -201,7 +202,7 @@ var crossSectionFromPolygons = (polygons, fillRule = "Positive") => {
|
|
|
201
202
|
);
|
|
202
203
|
const CrossSection = getCrossSection();
|
|
203
204
|
if (scaledPolygons.length === 0) {
|
|
204
|
-
return
|
|
205
|
+
return emptyCrossSection();
|
|
205
206
|
}
|
|
206
207
|
return runManifoldOperation(
|
|
207
208
|
"crossSectionFromPolygons",
|
|
@@ -213,7 +214,7 @@ var composeCrossSections = (sections) => {
|
|
|
213
214
|
const nonEmptySections = sections.filter((section) => !section.isEmpty());
|
|
214
215
|
const CrossSection = getCrossSection();
|
|
215
216
|
if (nonEmptySections.length === 0) {
|
|
216
|
-
return
|
|
217
|
+
return emptyCrossSection();
|
|
217
218
|
}
|
|
218
219
|
return runManifoldOperation(
|
|
219
220
|
"composeCrossSections",
|
|
@@ -20,6 +20,8 @@ export type CopperPourIsland = {
|
|
|
20
20
|
innerRings: PolygonRing[]
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const emptyCrossSection = (): CrossSection => getCrossSection().square([0, 0])
|
|
24
|
+
|
|
23
25
|
export const crossSectionFromPolygon = (
|
|
24
26
|
polygon: PolygonRing,
|
|
25
27
|
fillRule: FillRule = "Positive",
|
|
@@ -30,7 +32,7 @@ export const crossSectionFromPolygon = (
|
|
|
30
32
|
)
|
|
31
33
|
const CrossSection = getCrossSection()
|
|
32
34
|
if (scaledPolygons.length === 0) {
|
|
33
|
-
return
|
|
35
|
+
return emptyCrossSection()
|
|
34
36
|
}
|
|
35
37
|
return runManifoldOperation("crossSectionFromPolygon", scaledPolygons, () =>
|
|
36
38
|
CrossSection.ofPolygons(scaledPolygons, fillRule),
|
|
@@ -47,7 +49,7 @@ export const crossSectionFromPolygons = (
|
|
|
47
49
|
)
|
|
48
50
|
const CrossSection = getCrossSection()
|
|
49
51
|
if (scaledPolygons.length === 0) {
|
|
50
|
-
return
|
|
52
|
+
return emptyCrossSection()
|
|
51
53
|
}
|
|
52
54
|
return runManifoldOperation("crossSectionFromPolygons", scaledPolygons, () =>
|
|
53
55
|
CrossSection.ofPolygons(scaledPolygons, fillRule),
|
|
@@ -60,7 +62,7 @@ export const composeCrossSections = (
|
|
|
60
62
|
const nonEmptySections = sections.filter((section) => !section.isEmpty())
|
|
61
63
|
const CrossSection = getCrossSection()
|
|
62
64
|
if (nonEmptySections.length === 0) {
|
|
63
|
-
return
|
|
65
|
+
return emptyCrossSection()
|
|
64
66
|
}
|
|
65
67
|
return runManifoldOperation("composeCrossSections", [], () =>
|
|
66
68
|
CrossSection.compose(nonEmptySections),
|
package/package.json
CHANGED
|
@@ -60,6 +60,15 @@ const assertValidRings = (shapes: BRepShape[]) => {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
test("empty blocker list still returns full pour", () => {
|
|
64
|
+
const shapes = solve([])
|
|
65
|
+
|
|
66
|
+
expect(shapes).toHaveLength(1)
|
|
67
|
+
expect(shapes[0]!.inner_rings).toHaveLength(0)
|
|
68
|
+
expect(totalArea(shapes)).toBe(100)
|
|
69
|
+
assertValidRings(shapes)
|
|
70
|
+
})
|
|
71
|
+
|
|
63
72
|
test("trace clearance subtracts from rectangular pour", () => {
|
|
64
73
|
const shapes = solve([
|
|
65
74
|
{
|