@faicad/sheetmetal 0.13.0

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 (113) hide show
  1. package/dist/allowanceFns.d.ts +42 -0
  2. package/dist/allowanceFns.d.ts.map +1 -0
  3. package/dist/allowanceFns.js +63 -0
  4. package/dist/allowanceFns.js.map +1 -0
  5. package/dist/api.d.ts +312 -0
  6. package/dist/api.d.ts.map +1 -0
  7. package/dist/api.js +367 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/authorFns.d.ts +118 -0
  10. package/dist/authorFns.d.ts.map +1 -0
  11. package/dist/authorFns.js +562 -0
  12. package/dist/authorFns.js.map +1 -0
  13. package/dist/bendTableFns.d.ts +87 -0
  14. package/dist/bendTableFns.d.ts.map +1 -0
  15. package/dist/bendTableFns.js +345 -0
  16. package/dist/bendTableFns.js.map +1 -0
  17. package/dist/compat.d.ts +90 -0
  18. package/dist/compat.d.ts.map +1 -0
  19. package/dist/compat.js +99 -0
  20. package/dist/compat.js.map +1 -0
  21. package/dist/contourFlangeFns.d.ts +122 -0
  22. package/dist/contourFlangeFns.d.ts.map +1 -0
  23. package/dist/contourFlangeFns.js +403 -0
  24. package/dist/contourFlangeFns.js.map +1 -0
  25. package/dist/cutoutFns.d.ts +95 -0
  26. package/dist/cutoutFns.d.ts.map +1 -0
  27. package/dist/cutoutFns.js +300 -0
  28. package/dist/cutoutFns.js.map +1 -0
  29. package/dist/dxfFns.d.ts +48 -0
  30. package/dist/dxfFns.d.ts.map +1 -0
  31. package/dist/dxfFns.js +236 -0
  32. package/dist/dxfFns.js.map +1 -0
  33. package/dist/facade.d.ts +449 -0
  34. package/dist/facade.d.ts.map +1 -0
  35. package/dist/facade.js +535 -0
  36. package/dist/facade.js.map +1 -0
  37. package/dist/featureTreeFns.d.ts +76 -0
  38. package/dist/featureTreeFns.d.ts.map +1 -0
  39. package/dist/featureTreeFns.js +190 -0
  40. package/dist/featureTreeFns.js.map +1 -0
  41. package/dist/foldFns.d.ts +83 -0
  42. package/dist/foldFns.d.ts.map +1 -0
  43. package/dist/foldFns.js +744 -0
  44. package/dist/foldFns.js.map +1 -0
  45. package/dist/foreignUnfoldFns.d.ts +62 -0
  46. package/dist/foreignUnfoldFns.d.ts.map +1 -0
  47. package/dist/foreignUnfoldFns.js +854 -0
  48. package/dist/foreignUnfoldFns.js.map +1 -0
  49. package/dist/formFns.d.ts +58 -0
  50. package/dist/formFns.d.ts.map +1 -0
  51. package/dist/formFns.js +300 -0
  52. package/dist/formFns.js.map +1 -0
  53. package/dist/hemFns.d.ts +17 -0
  54. package/dist/hemFns.d.ts.map +1 -0
  55. package/dist/hemFns.js +212 -0
  56. package/dist/hemFns.js.map +1 -0
  57. package/dist/index.d.ts +43 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +32 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/internal.d.ts +27 -0
  62. package/dist/internal.d.ts.map +1 -0
  63. package/dist/internal.js +38 -0
  64. package/dist/internal.js.map +1 -0
  65. package/dist/jogFns.d.ts +18 -0
  66. package/dist/jogFns.d.ts.map +1 -0
  67. package/dist/jogFns.js +180 -0
  68. package/dist/jogFns.js.map +1 -0
  69. package/dist/loftedFlangeFns.d.ts +23 -0
  70. package/dist/loftedFlangeFns.d.ts.map +1 -0
  71. package/dist/loftedFlangeFns.js +306 -0
  72. package/dist/loftedFlangeFns.js.map +1 -0
  73. package/dist/materials.d.ts +16 -0
  74. package/dist/materials.d.ts.map +1 -0
  75. package/dist/materials.js +44 -0
  76. package/dist/materials.js.map +1 -0
  77. package/dist/miterFns.d.ts +31 -0
  78. package/dist/miterFns.d.ts.map +1 -0
  79. package/dist/miterFns.js +128 -0
  80. package/dist/miterFns.js.map +1 -0
  81. package/dist/nestFns.d.ts +116 -0
  82. package/dist/nestFns.d.ts.map +1 -0
  83. package/dist/nestFns.js +517 -0
  84. package/dist/nestFns.js.map +1 -0
  85. package/dist/polygonFns.d.ts +144 -0
  86. package/dist/polygonFns.d.ts.map +1 -0
  87. package/dist/polygonFns.js +324 -0
  88. package/dist/polygonFns.js.map +1 -0
  89. package/dist/reliefFns.d.ts +44 -0
  90. package/dist/reliefFns.d.ts.map +1 -0
  91. package/dist/reliefFns.js +367 -0
  92. package/dist/reliefFns.js.map +1 -0
  93. package/dist/reportFns.d.ts +33 -0
  94. package/dist/reportFns.d.ts.map +1 -0
  95. package/dist/reportFns.js +71 -0
  96. package/dist/reportFns.js.map +1 -0
  97. package/dist/tabFns.d.ts +43 -0
  98. package/dist/tabFns.d.ts.map +1 -0
  99. package/dist/tabFns.js +179 -0
  100. package/dist/tabFns.js.map +1 -0
  101. package/dist/types.d.ts +629 -0
  102. package/dist/types.d.ts.map +1 -0
  103. package/dist/types.js +2 -0
  104. package/dist/types.js.map +1 -0
  105. package/dist/unfoldFns.d.ts +120 -0
  106. package/dist/unfoldFns.d.ts.map +1 -0
  107. package/dist/unfoldFns.js +766 -0
  108. package/dist/unfoldFns.js.map +1 -0
  109. package/dist/validateFns.d.ts +18 -0
  110. package/dist/validateFns.d.ts.map +1 -0
  111. package/dist/validateFns.js +196 -0
  112. package/dist/validateFns.js.map +1 -0
  113. package/package.json +45 -0
package/dist/facade.js ADDED
@@ -0,0 +1,535 @@
1
+ /**
2
+ * Fluent facade — `sheetMetal(base).flange(...).miter(...).unfold()`.
3
+ *
4
+ * A lightweight immutable builder over the {@link ./api.js} wrappers. Authoring
5
+ * steps (`flange`, `material`) accumulate into a spec; part-consuming steps
6
+ * (`miter`, `miterCorner`, `unfold`, `report`, `dxf`, `validate`, `part`)
7
+ * materialize the folded part once and thread it through, auto-unwrapping the
8
+ * underlying `Result<T>` and throwing {@link SheetMetalError} on failure so the
9
+ * chain stays terminal-free. Use the `Result`-returning functions in `./api.js`
10
+ * directly when explicit error handling is preferred over throwing.
11
+ */
12
+ import { isErr } from '@faicad/faijs/brepjs-compat';
13
+ import { author, unfold, unfoldSolid, fold, miter, miterCorner, bendRelief, autoReliefs, relieveCorner, addCutout, addHole, addSlot, addPolygonCutout, addTab, tabAndSlot, louver, emboss, contourFlange, loftedFlange, hem, jog, toDXF, report, validate, } from './api.js';
14
+ /** Thrown by the fluent facade when an underlying `Result<T>` is an `Err`. */
15
+ export class SheetMetalError extends Error {
16
+ /** The machine-readable error code from the underlying `BrepError`. */
17
+ code;
18
+ /** The error kind/category from the underlying `BrepError`. */
19
+ kind;
20
+ constructor(brepError) {
21
+ super(brepError.suggestion
22
+ ? `${brepError.message}\nSuggestion: ${brepError.suggestion}`
23
+ : brepError.message);
24
+ this.name = 'SheetMetalError';
25
+ this.code = brepError.code;
26
+ this.kind = brepError.kind;
27
+ }
28
+ }
29
+ function unwrapOrThrow(result) {
30
+ if (isErr(result)) {
31
+ throw new SheetMetalError(result.error);
32
+ }
33
+ return result.value;
34
+ }
35
+ /** A built part already mitered/operated on, re-entering the fluent chain. */
36
+ class SheetMetalPartHandle {
37
+ part;
38
+ constructor(part) {
39
+ this.part = part;
40
+ }
41
+ /**
42
+ * Cut by an oriented plane, removing material on the `+normal` side.
43
+ * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.
44
+ * @returns a new `SheetMetalPartHandle` carrying the mitered part.
45
+ */
46
+ miter(plane) {
47
+ return new SheetMetalPartHandle(unwrapOrThrow(miter(this.part, plane)));
48
+ }
49
+ /**
50
+ * Auto-miter the shared corner of two flanges with an optional gap.
51
+ * @param flangeIdA - id of the first flange meeting at the corner.
52
+ * @param flangeIdB - id of the second flange meeting at the corner.
53
+ * @param gap - optional gap (in millimetres) left between the two mitered edges; defaults to 0.
54
+ * @returns a new `SheetMetalPartHandle` carrying the part with the corner mitered.
55
+ */
56
+ miterCorner(flangeIdA, flangeIdB, gap = 0) {
57
+ return new SheetMetalPartHandle(unwrapOrThrow(miterCorner(this.part, flangeIdA, flangeIdB, gap)));
58
+ }
59
+ /**
60
+ * Add a bend relief at each mid-edge end of a partial flange's bend line.
61
+ * @param flangeId - id of the partial flange whose bend-line ends get the relief.
62
+ * @param spec - optional relief specification overriding the defaults.
63
+ * @returns a new `SheetMetalPartHandle` carrying the part with the relief added.
64
+ */
65
+ bendRelief(flangeId, spec) {
66
+ return new SheetMetalPartHandle(unwrapOrThrow(bendRelief(this.part, flangeId, spec)));
67
+ }
68
+ /**
69
+ * Add a bend relief to every partial-span bend in the part.
70
+ * @param spec - optional relief specification applied to every partial bend.
71
+ * @returns a new `SheetMetalPartHandle` carrying the part with all reliefs added.
72
+ */
73
+ autoReliefs(spec) {
74
+ return new SheetMetalPartHandle(unwrapOrThrow(autoReliefs(this.part, spec)));
75
+ }
76
+ /**
77
+ * Cut a corner relief notch at the shared corner of two adjacent flanges.
78
+ * @param flangeIdA - id of the first flange forming the corner.
79
+ * @param flangeIdB - id of the second flange forming the corner.
80
+ * @param spec - optional relief specification overriding the defaults.
81
+ * @returns a new `SheetMetalPartHandle` carrying the part with the corner relief added.
82
+ */
83
+ cornerRelief(flangeIdA, flangeIdB, spec) {
84
+ return new SheetMetalPartHandle(unwrapOrThrow(relieveCorner(this.part, flangeIdA, flangeIdB, spec)));
85
+ }
86
+ /**
87
+ * Punch a cutout (hole / slot / polygon) through a named flat region.
88
+ * @param spec - the cutout definition (kind, geometry, and target region).
89
+ * @returns a new `SheetMetalPartHandle` carrying the part with the cutout punched.
90
+ */
91
+ cutout(spec) {
92
+ return new SheetMetalPartHandle(unwrapOrThrow(addCutout(this.part, spec)));
93
+ }
94
+ /**
95
+ * Punch a circular hole of `diameter` centred at region-local `(x, y)`.
96
+ * @param region - name of the flat region the hole is punched through.
97
+ * @param x - region-local X of the hole centre.
98
+ * @param y - region-local Y of the hole centre.
99
+ * @param diameter - hole diameter.
100
+ * @returns a new `SheetMetalPartHandle` carrying the part with the hole punched.
101
+ */
102
+ hole(region, x, y, diameter) {
103
+ return new SheetMetalPartHandle(unwrapOrThrow(addHole(this.part, region, x, y, diameter)));
104
+ }
105
+ /**
106
+ * Punch a slot (rectangular or obround) centred at region-local `(x, y)`.
107
+ * @param region - name of the flat region the slot is punched through.
108
+ * @param opts - slot geometry: centre `(x, y)`, `length`, `width`, optional `angleDeg` rotation, and `round` ends flag.
109
+ * @returns a new `SheetMetalPartHandle` carrying the part with the slot punched.
110
+ */
111
+ slot(region, opts) {
112
+ return new SheetMetalPartHandle(unwrapOrThrow(addSlot(this.part, region, opts)));
113
+ }
114
+ /**
115
+ * Punch an arbitrary polygon cutout from its region-local `points`.
116
+ * @param region - name of the flat region the polygon is punched through.
117
+ * @param points - region-local polygon vertices as `[x, y]` pairs.
118
+ * @returns a new `SheetMetalPartHandle` carrying the part with the polygon cutout.
119
+ */
120
+ polygonCutout(region, points) {
121
+ return new SheetMetalPartHandle(unwrapOrThrow(addPolygonCutout(this.part, region, points)));
122
+ }
123
+ /**
124
+ * Fuse a rectangular tab (additive protrusion) onto a region's edge.
125
+ * @param spec - tab definition: edge, width, and length.
126
+ * @returns a new `SheetMetalPartHandle` carrying the part with the tab added.
127
+ */
128
+ tab(spec) {
129
+ return new SheetMetalPartHandle(unwrapOrThrow(addTab(this.part, spec)));
130
+ }
131
+ /**
132
+ * Self-fixturing tab-and-slot joint: a tab on one region + a matching slot on another.
133
+ * @param tab - the tab to add to the first region.
134
+ * @param slot - placement of the matching slot on the second region.
135
+ * @returns a new `SheetMetalPartHandle` carrying the part with the joint added.
136
+ */
137
+ tabAndSlot(tab, slot) {
138
+ return new SheetMetalPartHandle(unwrapOrThrow(tabAndSlot(this.part, tab, slot)));
139
+ }
140
+ /**
141
+ * Form a louver (vent flap) on a region.
142
+ * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.
143
+ * @returns a new `SheetMetalPartHandle` carrying the part with the louver formed.
144
+ */
145
+ louver(opts) {
146
+ return new SheetMetalPartHandle(unwrapOrThrow(louver(this.part, opts)));
147
+ }
148
+ /**
149
+ * Form a round emboss (raised) or dimple (recessed) on a region.
150
+ * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).
151
+ * @returns a new `SheetMetalPartHandle` carrying the part with the form added.
152
+ */
153
+ emboss(opts) {
154
+ return new SheetMetalPartHandle(unwrapOrThrow(emboss(this.part, opts)));
155
+ }
156
+ /**
157
+ * Author a contour flange (open line/arc profile swept along a base edge).
158
+ * @param spec - contour flange definition: profile, base edge, and bend parameters.
159
+ * @returns a new `SheetMetalPartHandle` carrying the part with the contour flange added.
160
+ */
161
+ contourFlange(spec) {
162
+ return new SheetMetalPartHandle(unwrapOrThrow(contourFlange(this.part, spec)));
163
+ }
164
+ /**
165
+ * Author a lofted / ruled transition flange between two parallel open profiles.
166
+ * @param spec - lofted flange definition: the two open profiles and their alignment.
167
+ * @returns a new `SheetMetalPartHandle` carrying the part with the lofted flange added.
168
+ */
169
+ loftedFlange(spec) {
170
+ return new SheetMetalPartHandle(unwrapOrThrow(loftedFlange(this.part, spec)));
171
+ }
172
+ /**
173
+ * Fold a region edge back ~180°+ onto its parent as a hem (closed/open/teardrop/rolled).
174
+ * @param spec - hem definition: edge, curl radius, and return leg length.
175
+ * @returns a new `SheetMetalPartHandle` carrying the part with the hem added.
176
+ */
177
+ hem(spec) {
178
+ return new SheetMetalPartHandle(unwrapOrThrow(hem(this.part, spec)));
179
+ }
180
+ /**
181
+ * Step a region's flat by `offsetHeight` with two opposite bends (a jog/joggle).
182
+ * @param spec - jog definition: bend line, offset height, and radii.
183
+ * @returns a new `SheetMetalPartHandle` carrying the part with the jog added.
184
+ */
185
+ jog(spec) {
186
+ return new SheetMetalPartHandle(unwrapOrThrow(jog(this.part, spec)));
187
+ }
188
+ /**
189
+ * Flatten into a developed flat pattern + bend report + warnings.
190
+ * @returns the `UnfoldResult` with the flat pattern, bend report, and any warnings.
191
+ */
192
+ unfold() {
193
+ return unwrapOrThrow(unfold(this.part));
194
+ }
195
+ /**
196
+ * Just the flat pattern from the unfold.
197
+ * @returns the developed `FlatPattern`.
198
+ */
199
+ flatPattern() {
200
+ return this.unfold().pattern;
201
+ }
202
+ /**
203
+ * Bend report built from the feature tree.
204
+ * @returns the `BendReport` describing every bend in the part.
205
+ */
206
+ report() {
207
+ return unwrapOrThrow(report(this.part));
208
+ }
209
+ /**
210
+ * Annotated multi-layer DXF of the developed flat pattern.
211
+ * @param options - optional DXF output options (layers, precision, units).
212
+ * @returns the DXF text of the developed flat pattern.
213
+ */
214
+ dxf(options) {
215
+ return unwrapOrThrow(toDXF(this.flatPattern(), options));
216
+ }
217
+ /**
218
+ * Manufacturability warnings (advisory, never throws).
219
+ * @returns the list of `SheetMetalWarning`s (empty when the part is manufacturable).
220
+ */
221
+ validate() {
222
+ return validate(this.part);
223
+ }
224
+ /**
225
+ * The materialized part (escape hatch back to the functional API).
226
+ * @returns the underlying `SheetMetalPart`.
227
+ */
228
+ get() {
229
+ return this.part;
230
+ }
231
+ }
232
+ /**
233
+ * An imported foreign solid (no feature tree) re-entering the fluent chain: detect
234
+ * its geometry and unfold it. `kFactor` defaults to the mid-surface neutral axis.
235
+ */
236
+ class ForeignSolidHandle {
237
+ solid;
238
+ opts;
239
+ constructor(solid, opts) {
240
+ this.solid = solid;
241
+ this.opts = opts;
242
+ }
243
+ /**
244
+ * Override the neutral-axis K-factor (default 0.5, the mid-surface).
245
+ * @param kFactor - the K-factor to use for the bend allowance.
246
+ * @returns a new `ForeignSolidHandle` with the K-factor applied.
247
+ */
248
+ kFactor(kFactor) {
249
+ return new ForeignSolidHandle(this.solid, { ...this.opts, kFactor });
250
+ }
251
+ /**
252
+ * Detect geometry and flatten into a developed flat pattern + report + warnings.
253
+ * @returns the `UnfoldResult` with the detected flat pattern, report, and any warnings.
254
+ */
255
+ unfold() {
256
+ return unwrapOrThrow(unfoldSolid(this.solid, this.opts));
257
+ }
258
+ /**
259
+ * Just the flat pattern from the detected unfold.
260
+ * @returns the developed `FlatPattern`.
261
+ */
262
+ flatPattern() {
263
+ return this.unfold().pattern;
264
+ }
265
+ /**
266
+ * Annotated multi-layer DXF of the developed flat pattern.
267
+ * @param options - optional DXF output options (layers, precision, units).
268
+ * @returns the DXF text of the developed flat pattern.
269
+ */
270
+ dxf(options) {
271
+ return unwrapOrThrow(toDXF(this.flatPattern(), options));
272
+ }
273
+ }
274
+ /** Authoring builder — accumulates the base/flanges/material spec, then folds. */
275
+ class SheetMetalBuilder {
276
+ spec;
277
+ built;
278
+ constructor(spec) {
279
+ this.spec = spec;
280
+ }
281
+ /**
282
+ * Add a flange folded off its parent edge (the base by default).
283
+ * @param flange - the flange definition to add.
284
+ * @returns a new `SheetMetalBuilder` with the flange appended to the spec.
285
+ */
286
+ flange(flange) {
287
+ return new SheetMetalBuilder({ ...this.spec, flanges: [...this.spec.flanges, flange] });
288
+ }
289
+ /**
290
+ * Add a seam closing a profile into a tube/box (left unfolded).
291
+ * @param seam - the seam definition to add.
292
+ * @returns a new `SheetMetalBuilder` with the seam appended to the spec.
293
+ */
294
+ seam(seam) {
295
+ return new SheetMetalBuilder({ ...this.spec, seams: [...(this.spec.seams ?? []), seam] });
296
+ }
297
+ /**
298
+ * Set the part material (its thickness/default rule).
299
+ * @param material - the material definition (thickness / default rule).
300
+ * @returns a new `SheetMetalBuilder` with the material set.
301
+ */
302
+ material(material) {
303
+ return new SheetMetalBuilder({ ...this.spec, material });
304
+ }
305
+ /**
306
+ * Fold the accumulated spec into a 3D part, re-entering the fluent chain.
307
+ * Memoized so chaining multiple terminal shortcuts (e.g. `unfold()` then
308
+ * `report()`) authors the solid only once.
309
+ * @returns a `SheetMetalPartHandle` for the folded part, memoized across calls.
310
+ */
311
+ build() {
312
+ this.built ??= new SheetMetalPartHandle(unwrapOrThrow(author(this.spec)));
313
+ return this.built;
314
+ }
315
+ // ----- part-consuming shortcuts (build then delegate) -----
316
+ /**
317
+ * Build the part and cut it by an oriented plane, removing material on the `+normal` side.
318
+ * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.
319
+ * @returns a `SheetMetalPartHandle` carrying the mitered part.
320
+ */
321
+ miter(plane) {
322
+ return this.build().miter(plane);
323
+ }
324
+ /**
325
+ * Build the part and auto-miter the shared corner of two flanges with an optional gap.
326
+ * @param flangeIdA - id of the first flange meeting at the corner.
327
+ * @param flangeIdB - id of the second flange meeting at the corner.
328
+ * @param gap - optional gap (in millimetres) left between the two mitered edges; defaults to 0.
329
+ * @returns a `SheetMetalPartHandle` carrying the part with the corner mitered.
330
+ */
331
+ miterCorner(flangeIdA, flangeIdB, gap = 0) {
332
+ return this.build().miterCorner(flangeIdA, flangeIdB, gap);
333
+ }
334
+ /**
335
+ * Build the part and add a bend relief at each mid-edge end of a partial flange's bend line.
336
+ * @param flangeId - id of the partial flange whose bend-line ends get the relief.
337
+ * @param spec - optional relief specification overriding the defaults.
338
+ * @returns a `SheetMetalPartHandle` carrying the part with the relief added.
339
+ */
340
+ bendRelief(flangeId, spec) {
341
+ return this.build().bendRelief(flangeId, spec);
342
+ }
343
+ /**
344
+ * Build the part and add a bend relief to every partial-span bend.
345
+ * @param spec - optional relief specification applied to every partial bend.
346
+ * @returns a `SheetMetalPartHandle` carrying the part with all reliefs added.
347
+ */
348
+ autoReliefs(spec) {
349
+ return this.build().autoReliefs(spec);
350
+ }
351
+ /**
352
+ * Build the part and cut a corner relief notch at the shared corner of two adjacent flanges.
353
+ * @param flangeIdA - id of the first flange forming the corner.
354
+ * @param flangeIdB - id of the second flange forming the corner.
355
+ * @param spec - optional relief specification overriding the defaults.
356
+ * @returns a `SheetMetalPartHandle` carrying the part with the corner relief added.
357
+ */
358
+ cornerRelief(flangeIdA, flangeIdB, spec) {
359
+ return this.build().cornerRelief(flangeIdA, flangeIdB, spec);
360
+ }
361
+ /**
362
+ * Build the part and punch a cutout (hole / slot / polygon) through a named flat region.
363
+ * @param spec - the cutout definition (kind, geometry, and target region).
364
+ * @returns a `SheetMetalPartHandle` carrying the part with the cutout punched.
365
+ */
366
+ cutout(spec) {
367
+ return this.build().cutout(spec);
368
+ }
369
+ /**
370
+ * Build the part and punch a circular hole of `diameter` centred at region-local `(x, y)`.
371
+ * @param region - name of the flat region the hole is punched through.
372
+ * @param x - region-local X of the hole centre.
373
+ * @param y - region-local Y of the hole centre.
374
+ * @param diameter - hole diameter.
375
+ * @returns a `SheetMetalPartHandle` carrying the part with the hole punched.
376
+ */
377
+ hole(region, x, y, diameter) {
378
+ return this.build().hole(region, x, y, diameter);
379
+ }
380
+ /**
381
+ * Build the part and punch a slot (rectangular or obround) centred at region-local `(x, y)`.
382
+ * @param region - name of the flat region the slot is punched through.
383
+ * @param opts - slot geometry: centre `(x, y)`, `length`, `width`, optional `angleDeg` rotation, and `round` ends flag.
384
+ * @returns a `SheetMetalPartHandle` carrying the part with the slot punched.
385
+ */
386
+ slot(region, opts) {
387
+ return this.build().slot(region, opts);
388
+ }
389
+ /**
390
+ * Build the part and punch an arbitrary polygon cutout from its region-local `points`.
391
+ * @param region - name of the flat region the polygon is punched through.
392
+ * @param points - region-local polygon vertices as `[x, y]` pairs.
393
+ * @returns a `SheetMetalPartHandle` carrying the part with the polygon cutout.
394
+ */
395
+ polygonCutout(region, points) {
396
+ return this.build().polygonCutout(region, points);
397
+ }
398
+ /**
399
+ * Build the part and fuse a rectangular tab (additive protrusion) onto a region's edge.
400
+ * @param spec - tab definition: edge, width, and length.
401
+ * @returns a `SheetMetalPartHandle` carrying the part with the tab added.
402
+ */
403
+ tab(spec) {
404
+ return this.build().tab(spec);
405
+ }
406
+ /**
407
+ * Build the part and add a self-fixturing tab-and-slot joint across two regions.
408
+ * @param tab - the tab to add to the first region.
409
+ * @param slot - placement of the matching slot on the second region.
410
+ * @returns a `SheetMetalPartHandle` carrying the part with the joint added.
411
+ */
412
+ tabAndSlot(tab, slot) {
413
+ return this.build().tabAndSlot(tab, slot);
414
+ }
415
+ /**
416
+ * Build the part and form a louver (vent flap) on a region.
417
+ * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.
418
+ * @returns a `SheetMetalPartHandle` carrying the part with the louver formed.
419
+ */
420
+ louver(opts) {
421
+ return this.build().louver(opts);
422
+ }
423
+ /**
424
+ * Build the part and form a round emboss (raised) or dimple (recessed) on a region.
425
+ * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).
426
+ * @returns a `SheetMetalPartHandle` carrying the part with the form added.
427
+ */
428
+ emboss(opts) {
429
+ return this.build().emboss(opts);
430
+ }
431
+ /**
432
+ * Build the part and author a contour flange (open line/arc profile swept along a base edge).
433
+ * @param spec - contour flange definition: profile, base edge, and bend parameters.
434
+ * @returns a `SheetMetalPartHandle` carrying the part with the contour flange added.
435
+ */
436
+ contourFlange(spec) {
437
+ return this.build().contourFlange(spec);
438
+ }
439
+ /**
440
+ * Build the part and author a lofted / ruled transition flange between two parallel open profiles.
441
+ * @param spec - lofted flange definition: the two open profiles and their alignment.
442
+ * @returns a `SheetMetalPartHandle` carrying the part with the lofted flange added.
443
+ */
444
+ loftedFlange(spec) {
445
+ return this.build().loftedFlange(spec);
446
+ }
447
+ /**
448
+ * Build the part and fold a region edge back ~180°+ onto its parent as a hem.
449
+ * @param spec - hem definition: edge, curl radius, and return leg length.
450
+ * @returns a `SheetMetalPartHandle` carrying the part with the hem added.
451
+ */
452
+ hem(spec) {
453
+ return this.build().hem(spec);
454
+ }
455
+ /**
456
+ * Build the part and step a region's flat by `offsetHeight` with two opposite bends (a jog/joggle).
457
+ * @param spec - jog definition: bend line, offset height, and radii.
458
+ * @returns a `SheetMetalPartHandle` carrying the part with the jog added.
459
+ */
460
+ jog(spec) {
461
+ return this.build().jog(spec);
462
+ }
463
+ /**
464
+ * Build the part and flatten it into a developed flat pattern + bend report + warnings.
465
+ * @returns the `UnfoldResult` with the flat pattern, bend report, and any warnings.
466
+ */
467
+ unfold() {
468
+ return this.build().unfold();
469
+ }
470
+ /**
471
+ * Build the part and produce the bend report from its feature tree.
472
+ * @returns the `BendReport` describing every bend in the part.
473
+ */
474
+ report() {
475
+ return this.build().report();
476
+ }
477
+ /**
478
+ * Build the part and emit an annotated multi-layer DXF of its developed flat pattern.
479
+ * @param options - optional DXF output options (layers, precision, units).
480
+ * @returns the DXF text of the developed flat pattern.
481
+ */
482
+ dxf(options) {
483
+ return this.build().dxf(options);
484
+ }
485
+ /**
486
+ * Build the part and run manufacturability checks (advisory, never throws).
487
+ * @returns the list of `SheetMetalWarning`s (empty when the part is manufacturable).
488
+ */
489
+ validate() {
490
+ return this.build().validate();
491
+ }
492
+ /**
493
+ * Build the part and return it (escape hatch back to the functional API).
494
+ * @returns the underlying `SheetMetalPart`.
495
+ */
496
+ get() {
497
+ return this.build().get();
498
+ }
499
+ }
500
+ /**
501
+ * Start a fluent sheet-metal chain from a base flat (`length × width`).
502
+ * @param base - the base flat definition (length × width).
503
+ * @param thickness - the sheet material thickness in millimetres.
504
+ * @returns a `SheetMetalBuilder` ready for authoring steps like `flange`/`seam`/`material`.
505
+ */
506
+ export function sheetMetal(base, thickness) {
507
+ return new SheetMetalBuilder({ thickness, base, flanges: [] });
508
+ }
509
+ /**
510
+ * Re-enter the fluent chain from an already-authored part.
511
+ * @param part - an authored sheet-metal part to operate on.
512
+ * @returns a `SheetMetalPartHandle` wrapping the part.
513
+ */
514
+ export function fromPart(part) {
515
+ return new SheetMetalPartHandle(part);
516
+ }
517
+ /**
518
+ * Fold a flat pattern up into a part and re-enter the fluent chain.
519
+ * @param input - the flat pattern (region tree) to fold up.
520
+ * @returns a `SheetMetalPartHandle` carrying the folded part.
521
+ */
522
+ export function foldFlat(input) {
523
+ return new SheetMetalPartHandle(unwrapOrThrow(fold(input)));
524
+ }
525
+ /**
526
+ * Detect and unfold an imported foreign sheet-metal solid (no feature tree).
527
+ * @param solid - the imported solid (B-rep) to unfold.
528
+ * @param opts - optional overrides; `opts.kFactor` sets the K-factor used for the bend allowance.
529
+ * @returns a `ForeignSolidHandle` for detecting and unfolding the solid.
530
+ */
531
+ export function fromSolid(solid, opts) {
532
+ return new ForeignSolidHandle(solid, opts);
533
+ }
534
+ export { SheetMetalBuilder, SheetMetalPartHandle, ForeignSolidHandle };
535
+ //# sourceMappingURL=facade.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facade.js","sourceRoot":"","sources":["../src/facade.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EACL,MAAM,EACN,MAAM,EACN,WAAW,EACX,IAAI,EACJ,KAAK,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,MAAM,EACN,MAAM,EACN,aAAa,EACb,YAAY,EACZ,GAAG,EACH,GAAG,EACH,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,UAAU,CAAC;AAkBlB,8EAA8E;AAC9E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,uEAAuE;IAC9D,IAAI,CAAS;IACtB,+DAA+D;IACtD,IAAI,CAAS;IAEtB,YAAY,SAAoB;QAC9B,KAAK,CACH,SAAS,CAAC,UAAU;YAClB,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,iBAAiB,SAAS,CAAC,UAAU,EAAE;YAC7D,CAAC,CAAC,SAAS,CAAC,OAAO,CACtB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;CACF;AAED,SAAS,aAAa,CAAI,MAAiB;IACzC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC;AAED,8EAA8E;AAC9E,MAAM,oBAAoB;IACH;IAArB,YAAqB,IAAoB;QA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AAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAY,EAAE,IAA2B;IACjE,OAAO,IAAI,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["/**\n * Fluent facade — `sheetMetal(base).flange(...).miter(...).unfold()`.\n *\n * A lightweight immutable builder over the {@link ./api.js} wrappers. Authoring\n * steps (`flange`, `material`) accumulate into a spec; part-consuming steps\n * (`miter`, `miterCorner`, `unfold`, `report`, `dxf`, `validate`, `part`)\n * materialize the folded part once and thread it through, auto-unwrapping the\n * underlying `Result<T>` and throwing {@link SheetMetalError} on failure so the\n * chain stays terminal-free. Use the `Result`-returning functions in `./api.js`\n * directly when explicit error handling is preferred over throwing.\n */\n\nimport type { BrepError, Result, Solid } from '@faicad/faijs/brepjs-compat';\nimport { isErr } from '@faicad/faijs/brepjs-compat';\nimport type { AuthorSpec, BaseFlatSpec, FlangeSpec, SeamSpec } from './authorFns.js';\nimport type { MiterPlane, DxfOptions, SlotPlacement } from './api.js';\nimport {\n author,\n unfold,\n unfoldSolid,\n fold,\n miter,\n miterCorner,\n bendRelief,\n autoReliefs,\n relieveCorner,\n addCutout,\n addHole,\n addSlot,\n addPolygonCutout,\n addTab,\n tabAndSlot,\n louver,\n emboss,\n contourFlange,\n loftedFlange,\n hem,\n jog,\n toDXF,\n report,\n validate,\n} from './api.js';\nimport type {\n SheetMetalPart,\n FlatPattern,\n FlatInput,\n BendReport,\n MaterialSpec,\n ReliefSpec,\n CutoutSpec,\n TabSpec,\n ContourFlangeSpec,\n LoftedFlangeSpec,\n HemSpec,\n JogSpec,\n SheetMetalWarning,\n UnfoldResult,\n} from './types.js';\n\n/** Thrown by the fluent facade when an underlying `Result<T>` is an `Err`. */\nexport class SheetMetalError extends Error {\n /** The machine-readable error code from the underlying `BrepError`. */\n readonly code: string;\n /** The error kind/category from the underlying `BrepError`. */\n readonly kind: string;\n\n constructor(brepError: BrepError) {\n super(\n brepError.suggestion\n ? `${brepError.message}\\nSuggestion: ${brepError.suggestion}`\n : brepError.message\n );\n this.name = 'SheetMetalError';\n this.code = brepError.code;\n this.kind = brepError.kind;\n }\n}\n\nfunction unwrapOrThrow<T>(result: Result<T>): T {\n if (isErr(result)) {\n throw new SheetMetalError(result.error);\n }\n return result.value;\n}\n\n/** A built part already mitered/operated on, re-entering the fluent chain. */\nclass SheetMetalPartHandle {\n constructor(readonly part: SheetMetalPart) {}\n\n /**\n * Cut by an oriented plane, removing material on the `+normal` side.\n * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.\n * @returns a new `SheetMetalPartHandle` carrying the mitered part.\n */\n miter(plane: MiterPlane): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(miter(this.part, plane)));\n }\n\n /**\n * Auto-miter the shared corner of two flanges with an optional gap.\n * @param flangeIdA - id of the first flange meeting at the corner.\n * @param flangeIdB - id of the second flange meeting at the corner.\n * @param gap - optional gap (in millimetres) left between the two mitered edges; defaults to 0.\n * @returns a new `SheetMetalPartHandle` carrying the part with the corner mitered.\n */\n miterCorner(flangeIdA: string, flangeIdB: string, gap = 0): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(miterCorner(this.part, flangeIdA, flangeIdB, gap)));\n }\n\n /**\n * Add a bend relief at each mid-edge end of a partial flange's bend line.\n * @param flangeId - id of the partial flange whose bend-line ends get the relief.\n * @param spec - optional relief specification overriding the defaults.\n * @returns a new `SheetMetalPartHandle` carrying the part with the relief added.\n */\n bendRelief(flangeId: string, spec?: ReliefSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(bendRelief(this.part, flangeId, spec)));\n }\n\n /**\n * Add a bend relief to every partial-span bend in the part.\n * @param spec - optional relief specification applied to every partial bend.\n * @returns a new `SheetMetalPartHandle` carrying the part with all reliefs added.\n */\n autoReliefs(spec?: ReliefSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(autoReliefs(this.part, spec)));\n }\n\n /**\n * Cut a corner relief notch at the shared corner of two adjacent flanges.\n * @param flangeIdA - id of the first flange forming the corner.\n * @param flangeIdB - id of the second flange forming the corner.\n * @param spec - optional relief specification overriding the defaults.\n * @returns a new `SheetMetalPartHandle` carrying the part with the corner relief added.\n */\n cornerRelief(flangeIdA: string, flangeIdB: string, spec?: ReliefSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(relieveCorner(this.part, flangeIdA, flangeIdB, spec)));\n }\n\n /**\n * Punch a cutout (hole / slot / polygon) through a named flat region.\n * @param spec - the cutout definition (kind, geometry, and target region).\n * @returns a new `SheetMetalPartHandle` carrying the part with the cutout punched.\n */\n cutout(spec: CutoutSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(addCutout(this.part, spec)));\n }\n\n /**\n * Punch a circular hole of `diameter` centred at region-local `(x, y)`.\n * @param region - name of the flat region the hole is punched through.\n * @param x - region-local X of the hole centre.\n * @param y - region-local Y of the hole centre.\n * @param diameter - hole diameter.\n * @returns a new `SheetMetalPartHandle` carrying the part with the hole punched.\n */\n hole(region: string, x: number, y: number, diameter: number): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(addHole(this.part, region, x, y, diameter)));\n }\n\n /**\n * Punch a slot (rectangular or obround) centred at region-local `(x, y)`.\n * @param region - name of the flat region the slot is punched through.\n * @param opts - slot geometry: centre `(x, y)`, `length`, `width`, optional `angleDeg` rotation, and `round` ends flag.\n * @returns a new `SheetMetalPartHandle` carrying the part with the slot punched.\n */\n slot(\n region: string,\n opts: { x: number; y: number; length: number; width: number; angleDeg?: number; round?: boolean }\n ): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(addSlot(this.part, region, opts)));\n }\n\n /**\n * Punch an arbitrary polygon cutout from its region-local `points`.\n * @param region - name of the flat region the polygon is punched through.\n * @param points - region-local polygon vertices as `[x, y]` pairs.\n * @returns a new `SheetMetalPartHandle` carrying the part with the polygon cutout.\n */\n polygonCutout(region: string, points: [number, number][]): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(addPolygonCutout(this.part, region, points)));\n }\n\n /**\n * Fuse a rectangular tab (additive protrusion) onto a region's edge.\n * @param spec - tab definition: edge, width, and length.\n * @returns a new `SheetMetalPartHandle` carrying the part with the tab added.\n */\n tab(spec: TabSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(addTab(this.part, spec)));\n }\n\n /**\n * Self-fixturing tab-and-slot joint: a tab on one region + a matching slot on another.\n * @param tab - the tab to add to the first region.\n * @param slot - placement of the matching slot on the second region.\n * @returns a new `SheetMetalPartHandle` carrying the part with the joint added.\n */\n tabAndSlot(tab: TabSpec, slot: SlotPlacement): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(tabAndSlot(this.part, tab, slot)));\n }\n\n /**\n * Form a louver (vent flap) on a region.\n * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.\n * @returns a new `SheetMetalPartHandle` carrying the part with the louver formed.\n */\n louver(opts: {\n region: string;\n x: number;\n y: number;\n length: number;\n width: number;\n height: number;\n direction?: 'up' | 'down';\n }): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(louver(this.part, opts)));\n }\n\n /**\n * Form a round emboss (raised) or dimple (recessed) on a region.\n * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).\n * @returns a new `SheetMetalPartHandle` carrying the part with the form added.\n */\n emboss(opts: {\n region: string;\n x: number;\n y: number;\n diameter: number;\n height: number;\n kind: 'dimple' | 'emboss';\n }): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(emboss(this.part, opts)));\n }\n\n /**\n * Author a contour flange (open line/arc profile swept along a base edge).\n * @param spec - contour flange definition: profile, base edge, and bend parameters.\n * @returns a new `SheetMetalPartHandle` carrying the part with the contour flange added.\n */\n contourFlange(spec: ContourFlangeSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(contourFlange(this.part, spec)));\n }\n\n /**\n * Author a lofted / ruled transition flange between two parallel open profiles.\n * @param spec - lofted flange definition: the two open profiles and their alignment.\n * @returns a new `SheetMetalPartHandle` carrying the part with the lofted flange added.\n */\n loftedFlange(spec: LoftedFlangeSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(loftedFlange(this.part, spec)));\n }\n\n /**\n * Fold a region edge back ~180°+ onto its parent as a hem (closed/open/teardrop/rolled).\n * @param spec - hem definition: edge, curl radius, and return leg length.\n * @returns a new `SheetMetalPartHandle` carrying the part with the hem added.\n */\n hem(spec: HemSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(hem(this.part, spec)));\n }\n\n /**\n * Step a region's flat by `offsetHeight` with two opposite bends (a jog/joggle).\n * @param spec - jog definition: bend line, offset height, and radii.\n * @returns a new `SheetMetalPartHandle` carrying the part with the jog added.\n */\n jog(spec: JogSpec): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(jog(this.part, spec)));\n }\n\n /**\n * Flatten into a developed flat pattern + bend report + warnings.\n * @returns the `UnfoldResult` with the flat pattern, bend report, and any warnings.\n */\n unfold(): UnfoldResult {\n return unwrapOrThrow(unfold(this.part));\n }\n\n /**\n * Just the flat pattern from the unfold.\n * @returns the developed `FlatPattern`.\n */\n flatPattern(): FlatPattern {\n return this.unfold().pattern;\n }\n\n /**\n * Bend report built from the feature tree.\n * @returns the `BendReport` describing every bend in the part.\n */\n report(): BendReport {\n return unwrapOrThrow(report(this.part));\n }\n\n /**\n * Annotated multi-layer DXF of the developed flat pattern.\n * @param options - optional DXF output options (layers, precision, units).\n * @returns the DXF text of the developed flat pattern.\n */\n dxf(options?: DxfOptions): string {\n return unwrapOrThrow(toDXF(this.flatPattern(), options));\n }\n\n /**\n * Manufacturability warnings (advisory, never throws).\n * @returns the list of `SheetMetalWarning`s (empty when the part is manufacturable).\n */\n validate(): SheetMetalWarning[] {\n return validate(this.part);\n }\n\n /**\n * The materialized part (escape hatch back to the functional API).\n * @returns the underlying `SheetMetalPart`.\n */\n get(): SheetMetalPart {\n return this.part;\n }\n}\n\n/**\n * An imported foreign solid (no feature tree) re-entering the fluent chain: detect\n * its geometry and unfold it. `kFactor` defaults to the mid-surface neutral axis.\n */\nclass ForeignSolidHandle {\n constructor(\n private readonly solid: Solid,\n private readonly opts?: { kFactor?: number }\n ) {}\n\n /**\n * Override the neutral-axis K-factor (default 0.5, the mid-surface).\n * @param kFactor - the K-factor to use for the bend allowance.\n * @returns a new `ForeignSolidHandle` with the K-factor applied.\n */\n kFactor(kFactor: number): ForeignSolidHandle {\n return new ForeignSolidHandle(this.solid, { ...this.opts, kFactor });\n }\n\n /**\n * Detect geometry and flatten into a developed flat pattern + report + warnings.\n * @returns the `UnfoldResult` with the detected flat pattern, report, and any warnings.\n */\n unfold(): UnfoldResult {\n return unwrapOrThrow(unfoldSolid(this.solid, this.opts));\n }\n\n /**\n * Just the flat pattern from the detected unfold.\n * @returns the developed `FlatPattern`.\n */\n flatPattern(): FlatPattern {\n return this.unfold().pattern;\n }\n\n /**\n * Annotated multi-layer DXF of the developed flat pattern.\n * @param options - optional DXF output options (layers, precision, units).\n * @returns the DXF text of the developed flat pattern.\n */\n dxf(options?: DxfOptions): string {\n return unwrapOrThrow(toDXF(this.flatPattern(), options));\n }\n}\n\n/** Authoring builder — accumulates the base/flanges/material spec, then folds. */\nclass SheetMetalBuilder {\n private built?: SheetMetalPartHandle;\n\n constructor(private readonly spec: AuthorSpec) {}\n\n /**\n * Add a flange folded off its parent edge (the base by default).\n * @param flange - the flange definition to add.\n * @returns a new `SheetMetalBuilder` with the flange appended to the spec.\n */\n flange(flange: FlangeSpec): SheetMetalBuilder {\n return new SheetMetalBuilder({ ...this.spec, flanges: [...this.spec.flanges, flange] });\n }\n\n /**\n * Add a seam closing a profile into a tube/box (left unfolded).\n * @param seam - the seam definition to add.\n * @returns a new `SheetMetalBuilder` with the seam appended to the spec.\n */\n seam(seam: SeamSpec): SheetMetalBuilder {\n return new SheetMetalBuilder({ ...this.spec, seams: [...(this.spec.seams ?? []), seam] });\n }\n\n /**\n * Set the part material (its thickness/default rule).\n * @param material - the material definition (thickness / default rule).\n * @returns a new `SheetMetalBuilder` with the material set.\n */\n material(material: MaterialSpec): SheetMetalBuilder {\n return new SheetMetalBuilder({ ...this.spec, material });\n }\n\n /**\n * Fold the accumulated spec into a 3D part, re-entering the fluent chain.\n * Memoized so chaining multiple terminal shortcuts (e.g. `unfold()` then\n * `report()`) authors the solid only once.\n * @returns a `SheetMetalPartHandle` for the folded part, memoized across calls.\n */\n build(): SheetMetalPartHandle {\n this.built ??= new SheetMetalPartHandle(unwrapOrThrow(author(this.spec)));\n return this.built;\n }\n\n // ----- part-consuming shortcuts (build then delegate) -----\n\n /**\n * Build the part and cut it by an oriented plane, removing material on the `+normal` side.\n * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.\n * @returns a `SheetMetalPartHandle` carrying the mitered part.\n */\n miter(plane: MiterPlane): SheetMetalPartHandle {\n return this.build().miter(plane);\n }\n\n /**\n * Build the part and auto-miter the shared corner of two flanges with an optional gap.\n * @param flangeIdA - id of the first flange meeting at the corner.\n * @param flangeIdB - id of the second flange meeting at the corner.\n * @param gap - optional gap (in millimetres) left between the two mitered edges; defaults to 0.\n * @returns a `SheetMetalPartHandle` carrying the part with the corner mitered.\n */\n miterCorner(flangeIdA: string, flangeIdB: string, gap = 0): SheetMetalPartHandle {\n return this.build().miterCorner(flangeIdA, flangeIdB, gap);\n }\n\n /**\n * Build the part and add a bend relief at each mid-edge end of a partial flange's bend line.\n * @param flangeId - id of the partial flange whose bend-line ends get the relief.\n * @param spec - optional relief specification overriding the defaults.\n * @returns a `SheetMetalPartHandle` carrying the part with the relief added.\n */\n bendRelief(flangeId: string, spec?: ReliefSpec): SheetMetalPartHandle {\n return this.build().bendRelief(flangeId, spec);\n }\n\n /**\n * Build the part and add a bend relief to every partial-span bend.\n * @param spec - optional relief specification applied to every partial bend.\n * @returns a `SheetMetalPartHandle` carrying the part with all reliefs added.\n */\n autoReliefs(spec?: ReliefSpec): SheetMetalPartHandle {\n return this.build().autoReliefs(spec);\n }\n\n /**\n * Build the part and cut a corner relief notch at the shared corner of two adjacent flanges.\n * @param flangeIdA - id of the first flange forming the corner.\n * @param flangeIdB - id of the second flange forming the corner.\n * @param spec - optional relief specification overriding the defaults.\n * @returns a `SheetMetalPartHandle` carrying the part with the corner relief added.\n */\n cornerRelief(flangeIdA: string, flangeIdB: string, spec?: ReliefSpec): SheetMetalPartHandle {\n return this.build().cornerRelief(flangeIdA, flangeIdB, spec);\n }\n\n /**\n * Build the part and punch a cutout (hole / slot / polygon) through a named flat region.\n * @param spec - the cutout definition (kind, geometry, and target region).\n * @returns a `SheetMetalPartHandle` carrying the part with the cutout punched.\n */\n cutout(spec: CutoutSpec): SheetMetalPartHandle {\n return this.build().cutout(spec);\n }\n\n /**\n * Build the part and punch a circular hole of `diameter` centred at region-local `(x, y)`.\n * @param region - name of the flat region the hole is punched through.\n * @param x - region-local X of the hole centre.\n * @param y - region-local Y of the hole centre.\n * @param diameter - hole diameter.\n * @returns a `SheetMetalPartHandle` carrying the part with the hole punched.\n */\n hole(region: string, x: number, y: number, diameter: number): SheetMetalPartHandle {\n return this.build().hole(region, x, y, diameter);\n }\n\n /**\n * Build the part and punch a slot (rectangular or obround) centred at region-local `(x, y)`.\n * @param region - name of the flat region the slot is punched through.\n * @param opts - slot geometry: centre `(x, y)`, `length`, `width`, optional `angleDeg` rotation, and `round` ends flag.\n * @returns a `SheetMetalPartHandle` carrying the part with the slot punched.\n */\n slot(\n region: string,\n opts: { x: number; y: number; length: number; width: number; angleDeg?: number; round?: boolean }\n ): SheetMetalPartHandle {\n return this.build().slot(region, opts);\n }\n\n /**\n * Build the part and punch an arbitrary polygon cutout from its region-local `points`.\n * @param region - name of the flat region the polygon is punched through.\n * @param points - region-local polygon vertices as `[x, y]` pairs.\n * @returns a `SheetMetalPartHandle` carrying the part with the polygon cutout.\n */\n polygonCutout(region: string, points: [number, number][]): SheetMetalPartHandle {\n return this.build().polygonCutout(region, points);\n }\n\n /**\n * Build the part and fuse a rectangular tab (additive protrusion) onto a region's edge.\n * @param spec - tab definition: edge, width, and length.\n * @returns a `SheetMetalPartHandle` carrying the part with the tab added.\n */\n tab(spec: TabSpec): SheetMetalPartHandle {\n return this.build().tab(spec);\n }\n\n /**\n * Build the part and add a self-fixturing tab-and-slot joint across two regions.\n * @param tab - the tab to add to the first region.\n * @param slot - placement of the matching slot on the second region.\n * @returns a `SheetMetalPartHandle` carrying the part with the joint added.\n */\n tabAndSlot(tab: TabSpec, slot: SlotPlacement): SheetMetalPartHandle {\n return this.build().tabAndSlot(tab, slot);\n }\n\n /**\n * Build the part and form a louver (vent flap) on a region.\n * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.\n * @returns a `SheetMetalPartHandle` carrying the part with the louver formed.\n */\n louver(opts: {\n region: string;\n x: number;\n y: number;\n length: number;\n width: number;\n height: number;\n direction?: 'up' | 'down';\n }): SheetMetalPartHandle {\n return this.build().louver(opts);\n }\n\n /**\n * Build the part and form a round emboss (raised) or dimple (recessed) on a region.\n * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).\n * @returns a `SheetMetalPartHandle` carrying the part with the form added.\n */\n emboss(opts: {\n region: string;\n x: number;\n y: number;\n diameter: number;\n height: number;\n kind: 'dimple' | 'emboss';\n }): SheetMetalPartHandle {\n return this.build().emboss(opts);\n }\n\n /**\n * Build the part and author a contour flange (open line/arc profile swept along a base edge).\n * @param spec - contour flange definition: profile, base edge, and bend parameters.\n * @returns a `SheetMetalPartHandle` carrying the part with the contour flange added.\n */\n contourFlange(spec: ContourFlangeSpec): SheetMetalPartHandle {\n return this.build().contourFlange(spec);\n }\n\n /**\n * Build the part and author a lofted / ruled transition flange between two parallel open profiles.\n * @param spec - lofted flange definition: the two open profiles and their alignment.\n * @returns a `SheetMetalPartHandle` carrying the part with the lofted flange added.\n */\n loftedFlange(spec: LoftedFlangeSpec): SheetMetalPartHandle {\n return this.build().loftedFlange(spec);\n }\n\n /**\n * Build the part and fold a region edge back ~180°+ onto its parent as a hem.\n * @param spec - hem definition: edge, curl radius, and return leg length.\n * @returns a `SheetMetalPartHandle` carrying the part with the hem added.\n */\n hem(spec: HemSpec): SheetMetalPartHandle {\n return this.build().hem(spec);\n }\n\n /**\n * Build the part and step a region's flat by `offsetHeight` with two opposite bends (a jog/joggle).\n * @param spec - jog definition: bend line, offset height, and radii.\n * @returns a `SheetMetalPartHandle` carrying the part with the jog added.\n */\n jog(spec: JogSpec): SheetMetalPartHandle {\n return this.build().jog(spec);\n }\n\n /**\n * Build the part and flatten it into a developed flat pattern + bend report + warnings.\n * @returns the `UnfoldResult` with the flat pattern, bend report, and any warnings.\n */\n unfold(): UnfoldResult {\n return this.build().unfold();\n }\n\n /**\n * Build the part and produce the bend report from its feature tree.\n * @returns the `BendReport` describing every bend in the part.\n */\n report(): BendReport {\n return this.build().report();\n }\n\n /**\n * Build the part and emit an annotated multi-layer DXF of its developed flat pattern.\n * @param options - optional DXF output options (layers, precision, units).\n * @returns the DXF text of the developed flat pattern.\n */\n dxf(options?: DxfOptions): string {\n return this.build().dxf(options);\n }\n\n /**\n * Build the part and run manufacturability checks (advisory, never throws).\n * @returns the list of `SheetMetalWarning`s (empty when the part is manufacturable).\n */\n validate(): SheetMetalWarning[] {\n return this.build().validate();\n }\n\n /**\n * Build the part and return it (escape hatch back to the functional API).\n * @returns the underlying `SheetMetalPart`.\n */\n get(): SheetMetalPart {\n return this.build().get();\n }\n}\n\n/**\n * Start a fluent sheet-metal chain from a base flat (`length × width`).\n * @param base - the base flat definition (length × width).\n * @param thickness - the sheet material thickness in millimetres.\n * @returns a `SheetMetalBuilder` ready for authoring steps like `flange`/`seam`/`material`.\n */\nexport function sheetMetal(base: BaseFlatSpec, thickness: number): SheetMetalBuilder {\n return new SheetMetalBuilder({ thickness, base, flanges: [] });\n}\n\n/**\n * Re-enter the fluent chain from an already-authored part.\n * @param part - an authored sheet-metal part to operate on.\n * @returns a `SheetMetalPartHandle` wrapping the part.\n */\nexport function fromPart(part: SheetMetalPart): SheetMetalPartHandle {\n return new SheetMetalPartHandle(part);\n}\n\n/**\n * Fold a flat pattern up into a part and re-enter the fluent chain.\n * @param input - the flat pattern (region tree) to fold up.\n * @returns a `SheetMetalPartHandle` carrying the folded part.\n */\nexport function foldFlat(input: FlatInput): SheetMetalPartHandle {\n return new SheetMetalPartHandle(unwrapOrThrow(fold(input)));\n}\n\n/**\n * Detect and unfold an imported foreign sheet-metal solid (no feature tree).\n * @param solid - the imported solid (B-rep) to unfold.\n * @param opts - optional overrides; `opts.kFactor` sets the K-factor used for the bend allowance.\n * @returns a `ForeignSolidHandle` for detecting and unfolding the solid.\n */\nexport function fromSolid(solid: Solid, opts?: { kFactor?: number }): ForeignSolidHandle {\n return new ForeignSolidHandle(solid, opts);\n}\n\nexport { SheetMetalBuilder, SheetMetalPartHandle, ForeignSolidHandle };\n"]}