@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/api.js ADDED
@@ -0,0 +1,367 @@
1
+ /**
2
+ * Public API — short-named wrappers over the sheet-metal `*Fns` modules.
3
+ *
4
+ * These are the canonical entry points for the domain: they delegate to the
5
+ * underlying functional implementations without re-deriving any geometry, and
6
+ * preserve the `Result<T>` / warning-channel contract end to end. The fluent
7
+ * `sheetMetal()` facade in `./facade.js` is built on top of these.
8
+ */
9
+ import { ok, err, validationError } from '@faicad/faijs/brepjs-compat';
10
+ import { authorPart as authorPartFn, } from './authorFns.js';
11
+ import { unfold as unfoldFn } from './unfoldFns.js';
12
+ import { unfoldForeignSolid as unfoldForeignSolidFn } from './foreignUnfoldFns.js';
13
+ import { fold as foldFn } from './foldFns.js';
14
+ import { miterCut as miterCutFn, autoMiterCorner as autoMiterCornerFn, } from './miterFns.js';
15
+ import { addBendRelief as addBendReliefFn, autoBendReliefs as autoBendReliefsFn, cornerRelief as cornerReliefFn, } from './reliefFns.js';
16
+ import { addCutout as addCutoutFn, addHole as addHoleFn, addSlot as addSlotFn, addPolygonCutout as addPolygonCutoutFn, } from './cutoutFns.js';
17
+ import { addTab as addTabFn, tabAndSlot as tabAndSlotFn, } from './tabFns.js';
18
+ import { louver as louverFn, emboss as embossFn } from './formFns.js';
19
+ import { authorContourFlange as authorContourFlangeFn } from './contourFlangeFns.js';
20
+ import { authorLoftedFlange as authorLoftedFlangeFn } from './loftedFlangeFns.js';
21
+ import { hem as hemFn } from './hemFns.js';
22
+ import { jog as jogFn } from './jogFns.js';
23
+ import { flatPatternToDXF as flatPatternToDXFFn } from './dxfFns.js';
24
+ import { nest as nestFn, nestToDXF as nestToDXFFn, } from './nestFns.js';
25
+ import { buildReport as buildReportFn, reportFromUnfold as reportFromUnfoldFn, reportToJSON as reportToJSONFn, } from './reportFns.js';
26
+ import { validatePart as validatePartFn } from './validateFns.js';
27
+ import { bendAllowance as bendAllowanceFn, developedLength as developedLengthFn } from './allowanceFns.js';
28
+ import { registerBendTable as registerBendTableFn, getBendTable as getBendTableFn, resolveBendAllowance as resolveBendAllowanceFn, } from './bendTableFns.js';
29
+ /**
30
+ * Author a straight-bend part: a base flat plus folded-up flanges.
31
+ * @param spec - the part definition: base flat, material thickness, and the flange list to fold up.
32
+ * @returns a `Result<SheetMetalPart>` carrying the authored part, or the first error encountered.
33
+ */
34
+ export function author(spec) {
35
+ return authorPartFn(spec);
36
+ }
37
+ /**
38
+ * Extract the lone 3D solid of an authored part as its own `Result` terminal.
39
+ *
40
+ * `author`/`fold`/`hem` return the data model `SheetMetalPart`; its `.solid`
41
+ * field is the authored BREP solid. `.fai.js` statements cannot read nested
42
+ * member expressions (`p1.solid`), so this explicit terminal is the sanctioned
43
+ * way to pull the geometry out of a part.
44
+ * @param part - the sheet-metal part carrying the authored solid.
45
+ * @returns `Ok` with the part's surface, or `Err` (`NO_SOLID`) when the part
46
+ * has no authored solid yet (e.g. it was only built by `flatPattern`).
47
+ */
48
+ export function solidOf(part) {
49
+ return part.solid ? ok(part.solid) : err(validationError('NO_SOLID', 'part has no authored solid'));
50
+ }
51
+ /**
52
+ * Flatten an authored part into a developed flat pattern + bend report + warnings.
53
+ * @param part - the authored sheet-metal part to flatten.
54
+ * @returns a `Result<UnfoldResult>` with the flat pattern, bend report, and any warnings.
55
+ */
56
+ export function unfold(part) {
57
+ return unfoldFn(part);
58
+ }
59
+ /**
60
+ * Unfold an imported sheet-metal solid that has no feature tree, by detecting its
61
+ * geometry (planar panels + cylindrical bends) numerically. `kFactor` defaults to
62
+ * the mid-surface neutral axis (0.5); supply a known material's K-factor to match
63
+ * its development.
64
+ * @param solid - the imported solid (B-rep) to unfold.
65
+ * @param opts - optional overrides; `opts.kFactor` sets the K-factor used for the bend allowance.
66
+ * @returns a `Result<UnfoldResult>` with the detected flat pattern, report, and any warnings.
67
+ */
68
+ export function unfoldSolid(solid, opts) {
69
+ return unfoldForeignSolidFn(solid, opts);
70
+ }
71
+ /**
72
+ * Fold a flat pattern (region-tree) up into a 3D part — the inverse of {@link unfold}.
73
+ * @param input - the flat pattern (region tree) to fold up.
74
+ * @returns a `Result<SheetMetalPart>` carrying the folded 3D part, or the first error.
75
+ */
76
+ export function fold(input) {
77
+ return foldFn(input);
78
+ }
79
+ /**
80
+ * Cut a part by an oriented plane, removing material on the `+normal` side.
81
+ * @param part - the sheet-metal part to cut.
82
+ * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.
83
+ * @returns a `Result<SheetMetalPart>` carrying the mitered part, or the first error.
84
+ */
85
+ export function miter(part, plane) {
86
+ return miterCutFn(part, plane);
87
+ }
88
+ /**
89
+ * Auto-miter the shared corner of two flanges with an optional gap.
90
+ * @param part - the sheet-metal part whose corner is to be mitered.
91
+ * @param flangeIdA - id of the first flange meeting at the corner.
92
+ * @param flangeIdB - id of the second flange meeting at the corner.
93
+ * @param gap - optional gap (in millimetres) left between the two mitered edges; defaults to 0.
94
+ * @returns a `Result<SheetMetalPart>` carrying the mitered part, or the first error.
95
+ */
96
+ export function miterCorner(part, flangeIdA, flangeIdB, gap = 0) {
97
+ return autoMiterCornerFn(part, flangeIdA, flangeIdB, gap);
98
+ }
99
+ /**
100
+ * Add a bend relief slot at each mid-edge end of a partial flange's bend line.
101
+ * @param part - the sheet-metal part to modify.
102
+ * @param flangeId - id of the partial flange whose bend-line ends get the relief.
103
+ * @param spec - optional relief specification overriding the defaults.
104
+ * @returns a `Result<SheetMetalPart>` carrying the part with the relief added, or the first error.
105
+ */
106
+ export function bendRelief(part, flangeId, spec) {
107
+ return addBendReliefFn(part, flangeId, spec);
108
+ }
109
+ /**
110
+ * Add a bend relief to every partial-span bend in the part.
111
+ * @param part - the sheet-metal part to modify.
112
+ * @param spec - optional relief specification applied to every partial bend.
113
+ * @returns a `Result<SheetMetalPart>` carrying the part with all reliefs added, or the first error.
114
+ */
115
+ export function autoReliefs(part, spec) {
116
+ return autoBendReliefsFn(part, spec);
117
+ }
118
+ /**
119
+ * Cut a corner relief notch at the shared corner of two adjacent flanges.
120
+ * @param part - the sheet-metal part to modify.
121
+ * @param flangeIdA - id of the first flange forming the corner.
122
+ * @param flangeIdB - id of the second flange forming the corner.
123
+ * @param spec - optional relief specification overriding the defaults.
124
+ * @returns a `Result<SheetMetalPart>` carrying the part with the corner relief added, or the first error.
125
+ */
126
+ export function relieveCorner(part, flangeIdA, flangeIdB, spec) {
127
+ return cornerReliefFn(part, flangeIdA, flangeIdB, spec);
128
+ }
129
+ /**
130
+ * Punch a cutout (hole / slot / polygon) through a named flat region's thickness.
131
+ * @param part - the sheet-metal part to modify.
132
+ * @param spec - the cutout definition (kind, geometry, and target region).
133
+ * @returns a `Result<SheetMetalPart>` carrying the part with the cutout punched, or the first error.
134
+ */
135
+ export function addCutout(part, spec) {
136
+ return addCutoutFn(part, spec);
137
+ }
138
+ /**
139
+ * Punch a circular hole of `diameter` centred at region-local `(x, y)`.
140
+ * @param part - the sheet-metal part to modify.
141
+ * @param region - name of the flat region the hole is punched through.
142
+ * @param x - region-local X of the hole centre.
143
+ * @param y - region-local Y of the hole centre.
144
+ * @param diameter - hole diameter.
145
+ * @returns a `Result<SheetMetalPart>` carrying the part with the hole punched, or the first error.
146
+ */
147
+ export function addHole(part, region, x, y, diameter) {
148
+ return addHoleFn(part, region, x, y, diameter);
149
+ }
150
+ /**
151
+ * Punch a slot (rectangular or obround) centred at region-local `(x, y)`.
152
+ * @param part - the sheet-metal part to modify.
153
+ * @param region - name of the flat region the slot is punched through.
154
+ * @param opts - slot geometry: centre `(x, y)`, `length`, `width`, optional `angleDeg` rotation, and `round` ends flag.
155
+ * @returns a `Result<SheetMetalPart>` carrying the part with the slot punched, or the first error.
156
+ */
157
+ export function addSlot(part, region, opts) {
158
+ return addSlotFn(part, region, opts);
159
+ }
160
+ /**
161
+ * Punch an arbitrary polygon cutout from its region-local `points`.
162
+ * @param part - the sheet-metal part to modify.
163
+ * @param region - name of the flat region the polygon is punched through.
164
+ * @param points - region-local polygon vertices as `[x, y]` pairs.
165
+ * @returns a `Result<SheetMetalPart>` carrying the part with the polygon cutout, or the first error.
166
+ */
167
+ export function addPolygonCutout(part, region, points) {
168
+ return addPolygonCutoutFn(part, region, points);
169
+ }
170
+ /**
171
+ * Fuse a rectangular tab (additive protrusion) onto a region's edge.
172
+ * @param part - the sheet-metal part to modify.
173
+ * @param spec - tab definition: edge, width, and length.
174
+ * @returns a `Result<SheetMetalPart>` carrying the part with the tab added, or the first error.
175
+ */
176
+ export function addTab(part, spec) {
177
+ return addTabFn(part, spec);
178
+ }
179
+ /**
180
+ * Self-fixturing tab-and-slot joint: a tab on one region + a matching slot on another.
181
+ * @param part - the sheet-metal part to modify.
182
+ * @param tab - the tab to add to the first region.
183
+ * @param slot - placement of the matching slot on the second region.
184
+ * @returns a `Result<SheetMetalPart>` carrying the part with the joint added, or the first error.
185
+ */
186
+ export function tabAndSlot(part, tab, slot) {
187
+ return tabAndSlotFn(part, tab, slot);
188
+ }
189
+ /**
190
+ * Form a louver (vent flap cut on 3 sides, formed up along the hinge) on a region.
191
+ * @param part - the sheet-metal part to modify.
192
+ * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.
193
+ * @returns a `Result<SheetMetalPart>` carrying the part with the louver formed, or the first error.
194
+ */
195
+ export function louver(part, opts) {
196
+ return louverFn(part, opts);
197
+ }
198
+ /**
199
+ * Form a round emboss (raised) or dimple (recessed) on a region.
200
+ * @param part - the sheet-metal part to modify.
201
+ * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).
202
+ * @returns a `Result<SheetMetalPart>` carrying the part with the form added, or the first error.
203
+ */
204
+ export function emboss(part, opts) {
205
+ return embossFn(part, opts);
206
+ }
207
+ /**
208
+ * Author a contour flange: an open line/arc profile swept along a base edge into a
209
+ * multi-bend cross-section. The development is exact (Σ segment developed lengths).
210
+ * @param part - the sheet-metal part the flange is added to.
211
+ * @param spec - contour flange definition: profile, base edge, and bend parameters.
212
+ * @returns a `Result<SheetMetalPart>` carrying the part with the contour flange added, or the first error.
213
+ */
214
+ export function contourFlange(part, spec) {
215
+ return authorContourFlangeFn(part, spec);
216
+ }
217
+ /**
218
+ * Author a lofted / ruled transition flange between two parallel open profiles. The
219
+ * development is by triangulation — exact for a developable transition, an
220
+ * approximation (with a `DEVELOPMENT_APPROXIMATE` unfold warning) otherwise.
221
+ * @param part - the sheet-metal part the flange is added to.
222
+ * @param spec - lofted flange definition: the two open profiles and their alignment.
223
+ * @returns a `Result<SheetMetalPart>` carrying the part with the lofted flange added, or the first error.
224
+ */
225
+ export function loftedFlange(part, spec) {
226
+ return authorLoftedFlangeFn(part, spec);
227
+ }
228
+ /**
229
+ * Author a hem: fold a region edge back ~180°+ onto its parent and run a short
230
+ * return leg. The development is exact (Σ curl bend allowances + return length).
231
+ * @param part - the sheet-metal part the hem is added to.
232
+ * @param spec - hem definition: edge, curl radius, and return leg length.
233
+ * @returns a `Result<SheetMetalPart>` carrying the part with the hem added, or the first error.
234
+ */
235
+ export function hem(part, spec) {
236
+ return hemFn(part, spec);
237
+ }
238
+ /**
239
+ * Author a jog (joggle): two opposite bends stepping the flat by `offsetHeight`
240
+ * perpendicular to its plane, then continuing parallel. Development is exact.
241
+ * @param part - the sheet-metal part the jog is added to.
242
+ * @param spec - jog definition: bend line, offset height, and radii.
243
+ * @returns a `Result<SheetMetalPart>` carrying the part with the jog added, or the first error.
244
+ */
245
+ export function jog(part, spec) {
246
+ return jogFn(part, spec);
247
+ }
248
+ /**
249
+ * Emit an annotated multi-layer DXF string for a flat pattern.
250
+ * @param pattern - the flat pattern to serialize.
251
+ * @param options - optional DXF output options (layers, precision, units).
252
+ * @returns a `Result<string>` carrying the DXF text, or the first error.
253
+ */
254
+ export function toDXF(pattern, options) {
255
+ return flatPatternToDXFFn(pattern, options);
256
+ }
257
+ /**
258
+ * Nest developed flat patterns onto stock sheets to reduce waste. The default
259
+ * `strategy: "bbox"` packs each part as its outline bounding box (fast, no
260
+ * interlocking). `strategy: "nfp"` is true-shape / no-fit-polygon nesting: the actual
261
+ * outline polygons are packed so concave (L-shaped) parts interlock for higher
262
+ * utilization. The NFP packer is a HEURISTIC (bottom-left-fill) — not provably
263
+ * optimal — but never overlaps parts and never drops a part silently.
264
+ * @param patterns - the flat patterns to place onto stock sheets.
265
+ * @param options - nesting configuration: stock sheet size, strategy, and spacing.
266
+ * @returns a `Result<NestResult>` carrying the placed sheets and part transforms, or the first error.
267
+ */
268
+ export function nest(patterns, options) {
269
+ return nestFn(patterns, options);
270
+ }
271
+ /**
272
+ * Emit one fabrication-ready DXF for a single nested sheet (all parts placed).
273
+ * @param result - the nesting result containing the sheet to render.
274
+ * @param patterns - the original flat patterns referenced by `result`.
275
+ * @param sheetIndex - index of the nested sheet to emit.
276
+ * @param options - optional DXF output options (layers, precision, units).
277
+ * @returns a `Result<string>` carrying the DXF text, or the first error.
278
+ */
279
+ export function nestToDXF(result, patterns, sheetIndex, options) {
280
+ return nestToDXFFn(result, patterns, sheetIndex, options);
281
+ }
282
+ /**
283
+ * Build a bend report by walking the part's feature tree.
284
+ * @param part - the sheet-metal part to report on.
285
+ * @returns a `Result<BendReport>` carrying the computed bend report, or the first error.
286
+ */
287
+ export function report(part) {
288
+ return buildReportFn(part);
289
+ }
290
+ /**
291
+ * Project the report already computed by {@link unfold} without re-walking the tree.
292
+ * @param result - the unfold result whose bend report is to be projected.
293
+ * @returns a `Result<BendReport>` carrying the projected bend report, or the first error.
294
+ */
295
+ export function reportFrom(result) {
296
+ return reportFromUnfoldFn(result);
297
+ }
298
+ /**
299
+ * Serialize a bend report to stable pretty-printed JSON.
300
+ * @param report - the bend report to serialize.
301
+ * @returns the stable pretty-printed JSON string.
302
+ */
303
+ export function reportJSON(report) {
304
+ return reportToJSONFn(report);
305
+ }
306
+ /**
307
+ * Manufacturability checks — advisory warnings, never errors.
308
+ * @param part - the sheet-metal part to check.
309
+ * @returns the list of manufacturability warnings (empty when the part is clean).
310
+ */
311
+ export function validate(part) {
312
+ return validatePartFn(part);
313
+ }
314
+ /**
315
+ * Bend allowance `BA = (π/180)·|angle|·(R + K·T)` for a single bend.
316
+ * @param angleDeg - the bend angle in degrees.
317
+ * @param thickness - the material thickness, in the same units as the rule radii.
318
+ * @param rule - the bend rule (K-factor, inner radius, or a bend-table reference) to apply.
319
+ * @param onWarning - optional callback invoked for non-fatal warnings during the computation.
320
+ * @returns a `Result<number>` carrying the bend allowance, or the first error.
321
+ */
322
+ export function allowance(angleDeg, thickness, rule, onWarning) {
323
+ return bendAllowanceFn(angleDeg, thickness, rule, onWarning);
324
+ }
325
+ /**
326
+ * Neutral-axis developed length of a bend region (numerically equal to the allowance).
327
+ * @param angleDeg - the bend angle in degrees.
328
+ * @param thickness - the material thickness, in the same units as the rule radii.
329
+ * @param rule - the bend rule (K-factor, inner radius, or a bend-table reference) to apply.
330
+ * @param onWarning - optional callback invoked for non-fatal warnings during the computation.
331
+ * @returns a `Result<number>` carrying the developed length, or the first error.
332
+ */
333
+ export function developed(angleDeg, thickness, rule, onWarning) {
334
+ return developedLengthFn(angleDeg, thickness, rule, onWarning);
335
+ }
336
+ /**
337
+ * Register (or replace) a shop bend table so rules can reference it by id.
338
+ * @param table - the bend table to register.
339
+ * @returns a `Result<BendTable>` carrying the registered table, or the first error.
340
+ */
341
+ export function addBendTable(table) {
342
+ return registerBendTableFn(table);
343
+ }
344
+ /**
345
+ * Look up a registered bend table by id (starter tables included).
346
+ * @param id - the bend table id to look up.
347
+ * @returns the matching `BendTable`, or `undefined` when no such table is registered.
348
+ */
349
+ export function bendTable(id) {
350
+ return getBendTableFn(id);
351
+ }
352
+ /**
353
+ * Resolve a bend's developed allowance through the single resolution point:
354
+ * a referenced bend table, then an explicit `rule.allowance`, then the K-factor
355
+ * formula. This is what {@link developed} delegates to.
356
+ * @param rule - the bend rule (bend-table reference, explicit allowance, or K-factor) to resolve.
357
+ * @param angleDeg - the bend angle in degrees.
358
+ * @param thickness - the material thickness, in the same units as the rule radii.
359
+ * @param onWarning - optional callback invoked for non-fatal warnings during the computation.
360
+ * @returns a `Result<number>` carrying the resolved allowance, or the first error.
361
+ */
362
+ export function resolveAllowance(rule, angleDeg, thickness, onWarning) {
363
+ return resolveBendAllowanceFn(rule, angleDeg, thickness, onWarning);
364
+ }
365
+ /** The live bend-table registry (shared resource, §7.3). */
366
+ export { bendTables } from './bendTableFns.js';
367
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,eAAe,EAA2B,MAAM,6BAA6B,CAAC;AAChG,OAAO,EACL,UAAU,IAAI,YAAY,GAG3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,IA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O,cAAc,CAAC,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAc,EACd,QAAgB,EAChB,SAAiB,EACjB,SAAgD;IAEhD,OAAO,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACtE,CAAC;AAID,4DAA4D;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["/**\n * Public API — short-named wrappers over the sheet-metal `*Fns` modules.\n *\n * These are the canonical entry points for the domain: they delegate to the\n * underlying functional implementations without re-deriving any geometry, and\n * preserve the `Result<T>` / warning-channel contract end to end. The fluent\n * `sheetMetal()` facade in `./facade.js` is built on top of these.\n */\n\nimport { ok, err, validationError, type Result, type Solid } from '@faicad/faijs/brepjs-compat';\nimport {\n authorPart as authorPartFn,\n type AuthorSpec,\n type FlangeSpec,\n} from './authorFns.js';\nimport { unfold as unfoldFn } from './unfoldFns.js';\nimport { unfoldForeignSolid as unfoldForeignSolidFn } from './foreignUnfoldFns.js';\nimport { fold as foldFn } from './foldFns.js';\nimport {\n miterCut as miterCutFn,\n autoMiterCorner as autoMiterCornerFn,\n type MiterPlane,\n} from './miterFns.js';\nimport {\n addBendRelief as addBendReliefFn,\n autoBendReliefs as autoBendReliefsFn,\n cornerRelief as cornerReliefFn,\n} from './reliefFns.js';\nimport {\n addCutout as addCutoutFn,\n addHole as addHoleFn,\n addSlot as addSlotFn,\n addPolygonCutout as addPolygonCutoutFn,\n} from './cutoutFns.js';\nimport {\n addTab as addTabFn,\n tabAndSlot as tabAndSlotFn,\n type SlotPlacement,\n} from './tabFns.js';\nimport { louver as louverFn, emboss as embossFn } from './formFns.js';\nimport { authorContourFlange as authorContourFlangeFn } from './contourFlangeFns.js';\nimport { authorLoftedFlange as authorLoftedFlangeFn } from './loftedFlangeFns.js';\nimport { hem as hemFn } from './hemFns.js';\nimport { jog as jogFn } from './jogFns.js';\nimport { flatPatternToDXF as flatPatternToDXFFn, type DxfOptions } from './dxfFns.js';\nimport {\n nest as nestFn,\n nestToDXF as nestToDXFFn,\n type NestOptions,\n type NestResult,\n} from './nestFns.js';\nimport {\n buildReport as buildReportFn,\n reportFromUnfold as reportFromUnfoldFn,\n reportToJSON as reportToJSONFn,\n} from './reportFns.js';\nimport { validatePart as validatePartFn } from './validateFns.js';\nimport { bendAllowance as bendAllowanceFn, developedLength as developedLengthFn } from './allowanceFns.js';\nimport {\n registerBendTable as registerBendTableFn,\n getBendTable as getBendTableFn,\n resolveBendAllowance as resolveBendAllowanceFn,\n type BendTable,\n} from './bendTableFns.js';\nimport type {\n SheetMetalPart,\n FlatPattern,\n FlatInput,\n BendReport,\n BendRule,\n ReliefSpec,\n CutoutSpec,\n TabSpec,\n ContourFlangeSpec,\n LoftedFlangeSpec,\n HemSpec,\n JogSpec,\n UnfoldResult,\n SheetMetalWarning,\n} from './types.js';\n\n/**\n * Author a straight-bend part: a base flat plus folded-up flanges.\n * @param spec - the part definition: base flat, material thickness, and the flange list to fold up.\n * @returns a `Result<SheetMetalPart>` carrying the authored part, or the first error encountered.\n */\nexport function author(spec: AuthorSpec): Result<SheetMetalPart> {\n return authorPartFn(spec);\n}\n\n/**\n * Extract the lone 3D solid of an authored part as its own `Result` terminal.\n *\n * `author`/`fold`/`hem` return the data model `SheetMetalPart`; its `.solid`\n * field is the authored BREP solid. `.fai.js` statements cannot read nested\n * member expressions (`p1.solid`), so this explicit terminal is the sanctioned\n * way to pull the geometry out of a part.\n * @param part - the sheet-metal part carrying the authored solid.\n * @returns `Ok` with the part's surface, or `Err` (`NO_SOLID`) when the part\n * has no authored solid yet (e.g. it was only built by `flatPattern`).\n */\nexport function solidOf(part: SheetMetalPart): Result<Solid> {\n return part.solid ? ok(part.solid) : err(validationError('NO_SOLID', 'part has no authored solid'));\n}\n\n/**\n * Flatten an authored part into a developed flat pattern + bend report + warnings.\n * @param part - the authored sheet-metal part to flatten.\n * @returns a `Result<UnfoldResult>` with the flat pattern, bend report, and any warnings.\n */\nexport function unfold(part: SheetMetalPart): Result<UnfoldResult> {\n return unfoldFn(part);\n}\n\n/**\n * Unfold an imported sheet-metal solid that has no feature tree, by detecting its\n * geometry (planar panels + cylindrical bends) numerically. `kFactor` defaults to\n * the mid-surface neutral axis (0.5); supply a known material's K-factor to match\n * its development.\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 `Result<UnfoldResult>` with the detected flat pattern, report, and any warnings.\n */\nexport function unfoldSolid(solid: Solid, opts?: { kFactor?: number }): Result<UnfoldResult> {\n return unfoldForeignSolidFn(solid, opts);\n}\n\n/**\n * Fold a flat pattern (region-tree) up into a 3D part — the inverse of {@link unfold}.\n * @param input - the flat pattern (region tree) to fold up.\n * @returns a `Result<SheetMetalPart>` carrying the folded 3D part, or the first error.\n */\nexport function fold(input: FlatInput): Result<SheetMetalPart> {\n return foldFn(input);\n}\n\n/**\n * Cut a part by an oriented plane, removing material on the `+normal` side.\n * @param part - the sheet-metal part to cut.\n * @param plane - the oriented cutting plane; material on the plane's `+normal` side is removed.\n * @returns a `Result<SheetMetalPart>` carrying the mitered part, or the first error.\n */\nexport function miter(part: SheetMetalPart, plane: MiterPlane): Result<SheetMetalPart> {\n return miterCutFn(part, plane);\n}\n\n/**\n * Auto-miter the shared corner of two flanges with an optional gap.\n * @param part - the sheet-metal part whose corner is to be mitered.\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 `Result<SheetMetalPart>` carrying the mitered part, or the first error.\n */\nexport function miterCorner(\n part: SheetMetalPart,\n flangeIdA: string,\n flangeIdB: string,\n gap = 0\n): Result<SheetMetalPart> {\n return autoMiterCornerFn(part, flangeIdA, flangeIdB, gap);\n}\n\n/**\n * Add a bend relief slot at each mid-edge end of a partial flange's bend line.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the relief added, or the first error.\n */\nexport function bendRelief(\n part: SheetMetalPart,\n flangeId: string,\n spec?: ReliefSpec\n): Result<SheetMetalPart> {\n return addBendReliefFn(part, flangeId, spec);\n}\n\n/**\n * Add a bend relief to every partial-span bend in the part.\n * @param part - the sheet-metal part to modify.\n * @param spec - optional relief specification applied to every partial bend.\n * @returns a `Result<SheetMetalPart>` carrying the part with all reliefs added, or the first error.\n */\nexport function autoReliefs(part: SheetMetalPart, spec?: ReliefSpec): Result<SheetMetalPart> {\n return autoBendReliefsFn(part, spec);\n}\n\n/**\n * Cut a corner relief notch at the shared corner of two adjacent flanges.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the corner relief added, or the first error.\n */\nexport function relieveCorner(\n part: SheetMetalPart,\n flangeIdA: string,\n flangeIdB: string,\n spec?: ReliefSpec\n): Result<SheetMetalPart> {\n return cornerReliefFn(part, flangeIdA, flangeIdB, spec);\n}\n\n/**\n * Punch a cutout (hole / slot / polygon) through a named flat region's thickness.\n * @param part - the sheet-metal part to modify.\n * @param spec - the cutout definition (kind, geometry, and target region).\n * @returns a `Result<SheetMetalPart>` carrying the part with the cutout punched, or the first error.\n */\nexport function addCutout(part: SheetMetalPart, spec: CutoutSpec): Result<SheetMetalPart> {\n return addCutoutFn(part, spec);\n}\n\n/**\n * Punch a circular hole of `diameter` centred at region-local `(x, y)`.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the hole punched, or the first error.\n */\nexport function addHole(\n part: SheetMetalPart,\n region: string,\n x: number,\n y: number,\n diameter: number\n): Result<SheetMetalPart> {\n return addHoleFn(part, region, x, y, diameter);\n}\n\n/**\n * Punch a slot (rectangular or obround) centred at region-local `(x, y)`.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the slot punched, or the first error.\n */\nexport function addSlot(\n part: SheetMetalPart,\n region: string,\n opts: { x: number; y: number; length: number; width: number; angleDeg?: number; round?: boolean }\n): Result<SheetMetalPart> {\n return addSlotFn(part, region, opts);\n}\n\n/**\n * Punch an arbitrary polygon cutout from its region-local `points`.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the polygon cutout, or the first error.\n */\nexport function addPolygonCutout(\n part: SheetMetalPart,\n region: string,\n points: [number, number][]\n): Result<SheetMetalPart> {\n return addPolygonCutoutFn(part, region, points);\n}\n\n/**\n * Fuse a rectangular tab (additive protrusion) onto a region's edge.\n * @param part - the sheet-metal part to modify.\n * @param spec - tab definition: edge, width, and length.\n * @returns a `Result<SheetMetalPart>` carrying the part with the tab added, or the first error.\n */\nexport function addTab(part: SheetMetalPart, spec: TabSpec): Result<SheetMetalPart> {\n return addTabFn(part, spec);\n}\n\n/**\n * Self-fixturing tab-and-slot joint: a tab on one region + a matching slot on another.\n * @param part - the sheet-metal part to modify.\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 `Result<SheetMetalPart>` carrying the part with the joint added, or the first error.\n */\nexport function tabAndSlot(\n part: SheetMetalPart,\n tab: TabSpec,\n slot: SlotPlacement\n): Result<SheetMetalPart> {\n return tabAndSlotFn(part, tab, slot);\n}\n\n/**\n * Form a louver (vent flap cut on 3 sides, formed up along the hinge) on a region.\n * @param part - the sheet-metal part to modify.\n * @param opts - louver geometry: target `region`, centre `(x, y)`, `length`, `width`, `height`, and optional `direction`.\n * @returns a `Result<SheetMetalPart>` carrying the part with the louver formed, or the first error.\n */\nexport function louver(\n part: SheetMetalPart,\n opts: {\n region: string;\n x: number;\n y: number;\n length: number;\n width: number;\n height: number;\n direction?: 'up' | 'down';\n }\n): Result<SheetMetalPart> {\n return louverFn(part, opts);\n}\n\n/**\n * Form a round emboss (raised) or dimple (recessed) on a region.\n * @param part - the sheet-metal part to modify.\n * @param opts - emboss geometry: target `region`, centre `(x, y)`, `diameter`, `height`, and `kind` (`dimple` or `emboss`).\n * @returns a `Result<SheetMetalPart>` carrying the part with the form added, or the first error.\n */\nexport function emboss(\n part: SheetMetalPart,\n opts: { region: string; x: number; y: number; diameter: number; height: number; kind: 'dimple' | 'emboss' }\n): Result<SheetMetalPart> {\n return embossFn(part, opts);\n}\n\n/**\n * Author a contour flange: an open line/arc profile swept along a base edge into a\n * multi-bend cross-section. The development is exact (Σ segment developed lengths).\n * @param part - the sheet-metal part the flange is added to.\n * @param spec - contour flange definition: profile, base edge, and bend parameters.\n * @returns a `Result<SheetMetalPart>` carrying the part with the contour flange added, or the first error.\n */\nexport function contourFlange(part: SheetMetalPart, spec: ContourFlangeSpec): Result<SheetMetalPart> {\n return authorContourFlangeFn(part, spec);\n}\n\n/**\n * Author a lofted / ruled transition flange between two parallel open profiles. The\n * development is by triangulation — exact for a developable transition, an\n * approximation (with a `DEVELOPMENT_APPROXIMATE` unfold warning) otherwise.\n * @param part - the sheet-metal part the flange is added to.\n * @param spec - lofted flange definition: the two open profiles and their alignment.\n * @returns a `Result<SheetMetalPart>` carrying the part with the lofted flange added, or the first error.\n */\nexport function loftedFlange(part: SheetMetalPart, spec: LoftedFlangeSpec): Result<SheetMetalPart> {\n return authorLoftedFlangeFn(part, spec);\n}\n\n/**\n * Author a hem: fold a region edge back ~180°+ onto its parent and run a short\n * return leg. The development is exact (Σ curl bend allowances + return length).\n * @param part - the sheet-metal part the hem is added to.\n * @param spec - hem definition: edge, curl radius, and return leg length.\n * @returns a `Result<SheetMetalPart>` carrying the part with the hem added, or the first error.\n */\nexport function hem(part: SheetMetalPart, spec: HemSpec): Result<SheetMetalPart> {\n return hemFn(part, spec);\n}\n\n/**\n * Author a jog (joggle): two opposite bends stepping the flat by `offsetHeight`\n * perpendicular to its plane, then continuing parallel. Development is exact.\n * @param part - the sheet-metal part the jog is added to.\n * @param spec - jog definition: bend line, offset height, and radii.\n * @returns a `Result<SheetMetalPart>` carrying the part with the jog added, or the first error.\n */\nexport function jog(part: SheetMetalPart, spec: JogSpec): Result<SheetMetalPart> {\n return jogFn(part, spec);\n}\n\n/**\n * Emit an annotated multi-layer DXF string for a flat pattern.\n * @param pattern - the flat pattern to serialize.\n * @param options - optional DXF output options (layers, precision, units).\n * @returns a `Result<string>` carrying the DXF text, or the first error.\n */\nexport function toDXF(pattern: FlatPattern, options?: DxfOptions): Result<string> {\n return flatPatternToDXFFn(pattern, options);\n}\n\n/**\n * Nest developed flat patterns onto stock sheets to reduce waste. The default\n * `strategy: \"bbox\"` packs each part as its outline bounding box (fast, no\n * interlocking). `strategy: \"nfp\"` is true-shape / no-fit-polygon nesting: the actual\n * outline polygons are packed so concave (L-shaped) parts interlock for higher\n * utilization. The NFP packer is a HEURISTIC (bottom-left-fill) — not provably\n * optimal — but never overlaps parts and never drops a part silently.\n * @param patterns - the flat patterns to place onto stock sheets.\n * @param options - nesting configuration: stock sheet size, strategy, and spacing.\n * @returns a `Result<NestResult>` carrying the placed sheets and part transforms, or the first error.\n */\nexport function nest(patterns: FlatPattern[], options: NestOptions): Result<NestResult> {\n return nestFn(patterns, options);\n}\n\n/**\n * Emit one fabrication-ready DXF for a single nested sheet (all parts placed).\n * @param result - the nesting result containing the sheet to render.\n * @param patterns - the original flat patterns referenced by `result`.\n * @param sheetIndex - index of the nested sheet to emit.\n * @param options - optional DXF output options (layers, precision, units).\n * @returns a `Result<string>` carrying the DXF text, or the first error.\n */\nexport function nestToDXF(\n result: NestResult,\n patterns: FlatPattern[],\n sheetIndex: number,\n options?: DxfOptions\n): Result<string> {\n return nestToDXFFn(result, patterns, sheetIndex, options);\n}\n\n/**\n * Build a bend report by walking the part's feature tree.\n * @param part - the sheet-metal part to report on.\n * @returns a `Result<BendReport>` carrying the computed bend report, or the first error.\n */\nexport function report(part: SheetMetalPart): Result<BendReport> {\n return buildReportFn(part);\n}\n\n/**\n * Project the report already computed by {@link unfold} without re-walking the tree.\n * @param result - the unfold result whose bend report is to be projected.\n * @returns a `Result<BendReport>` carrying the projected bend report, or the first error.\n */\nexport function reportFrom(result: UnfoldResult): Result<BendReport> {\n return reportFromUnfoldFn(result);\n}\n\n/**\n * Serialize a bend report to stable pretty-printed JSON.\n * @param report - the bend report to serialize.\n * @returns the stable pretty-printed JSON string.\n */\nexport function reportJSON(report: BendReport): string {\n return reportToJSONFn(report);\n}\n\n/**\n * Manufacturability checks — advisory warnings, never errors.\n * @param part - the sheet-metal part to check.\n * @returns the list of manufacturability warnings (empty when the part is clean).\n */\nexport function validate(part: SheetMetalPart): SheetMetalWarning[] {\n return validatePartFn(part);\n}\n\n/**\n * Bend allowance `BA = (π/180)·|angle|·(R + K·T)` for a single bend.\n * @param angleDeg - the bend angle in degrees.\n * @param thickness - the material thickness, in the same units as the rule radii.\n * @param rule - the bend rule (K-factor, inner radius, or a bend-table reference) to apply.\n * @param onWarning - optional callback invoked for non-fatal warnings during the computation.\n * @returns a `Result<number>` carrying the bend allowance, or the first error.\n */\nexport function allowance(\n angleDeg: number,\n thickness: number,\n rule: BendRule,\n onWarning?: (warning: SheetMetalWarning) => void\n): Result<number> {\n return bendAllowanceFn(angleDeg, thickness, rule, onWarning);\n}\n\n/**\n * Neutral-axis developed length of a bend region (numerically equal to the allowance).\n * @param angleDeg - the bend angle in degrees.\n * @param thickness - the material thickness, in the same units as the rule radii.\n * @param rule - the bend rule (K-factor, inner radius, or a bend-table reference) to apply.\n * @param onWarning - optional callback invoked for non-fatal warnings during the computation.\n * @returns a `Result<number>` carrying the developed length, or the first error.\n */\nexport function developed(\n angleDeg: number,\n thickness: number,\n rule: BendRule,\n onWarning?: (warning: SheetMetalWarning) => void\n): Result<number> {\n return developedLengthFn(angleDeg, thickness, rule, onWarning);\n}\n\n/**\n * Register (or replace) a shop bend table so rules can reference it by id.\n * @param table - the bend table to register.\n * @returns a `Result<BendTable>` carrying the registered table, or the first error.\n */\nexport function addBendTable(table: BendTable): Result<BendTable> {\n return registerBendTableFn(table);\n}\n\n/**\n * Look up a registered bend table by id (starter tables included).\n * @param id - the bend table id to look up.\n * @returns the matching `BendTable`, or `undefined` when no such table is registered.\n */\nexport function bendTable(id: string): BendTable | undefined {\n return getBendTableFn(id);\n}\n\n/**\n * Resolve a bend's developed allowance through the single resolution point:\n * a referenced bend table, then an explicit `rule.allowance`, then the K-factor\n * formula. This is what {@link developed} delegates to.\n * @param rule - the bend rule (bend-table reference, explicit allowance, or K-factor) to resolve.\n * @param angleDeg - the bend angle in degrees.\n * @param thickness - the material thickness, in the same units as the rule radii.\n * @param onWarning - optional callback invoked for non-fatal warnings during the computation.\n * @returns a `Result<number>` carrying the resolved allowance, or the first error.\n */\nexport function resolveAllowance(\n rule: BendRule,\n angleDeg: number,\n thickness: number,\n onWarning?: (warning: SheetMetalWarning) => void\n): Result<number> {\n return resolveBendAllowanceFn(rule, angleDeg, thickness, onWarning);\n}\n\nexport type { AuthorSpec, FlangeSpec, MiterPlane, DxfOptions, SlotPlacement, NestOptions, NestResult };\n\n/** The live bend-table registry (shared resource, §7.3). */\nexport { bendTables } from './bendTableFns.js';\n"]}
@@ -0,0 +1,118 @@
1
+ import { type Result, type Vec3 } from '@faicad/faijs/brepjs-compat';
2
+ import type { BendRule, EdgeRef, FlatSide, MaterialSpec, MiterSpec, SheetMetalPart } from './types.js';
3
+ import { type FeatureTree } from './featureTreeFns.js';
4
+ /** Authoring options for the base flat the flanges attach to. */
5
+ export interface BaseFlatSpec {
6
+ /** Extent along the run (+X) axis. */
7
+ length: number;
8
+ /** Extent along the width (+Y) axis. */
9
+ width: number;
10
+ }
11
+ /** Which edge a flange folds off (of the base, or of its parent flange). */
12
+ export type FlangeSide = FlatSide;
13
+ /** A single flange to author off an edge of its parent flat. */
14
+ export interface FlangeSpec {
15
+ id: string;
16
+ /** Flat length measured from the end of the bend along the flange plane. */
17
+ length: number;
18
+ /** Signed fold angle in degrees. */
19
+ angleDeg: number;
20
+ rule: BendRule;
21
+ /** Parent edge to attach to. Default `'xmax'` (the leading +X edge). */
22
+ side?: FlangeSide | undefined;
23
+ /** Fold direction relative to the parent face normal. Default `'up'`. */
24
+ direction?: 'up' | 'down' | undefined;
25
+ /** Id of another flange this flange folds off (its distal edge). Default = base flat. */
26
+ parent?: string | undefined;
27
+ /** Start position along the parent edge. Default `0`. */
28
+ offset?: number | undefined;
29
+ /** Extent along the parent edge. Default = full parent-edge length. */
30
+ width?: number | undefined;
31
+ miter?: MiterSpec | undefined;
32
+ }
33
+ /**
34
+ * A seam: a bend connecting two already-authored flats that is intentionally left
35
+ * unfolded (a free edge). Closing the last wall of a box/tube back onto an earlier
36
+ * flat produces a cyclic feature graph; the feature tree turns this edge into a
37
+ * SEAM_CUT, and the unfold leaves the flats connected through the spanning tree.
38
+ */
39
+ export interface SeamSpec {
40
+ /** Flat id the seam folds from (an authored flange, or `'root'`/`'face-0'` for the base). */
41
+ parent: string;
42
+ /** Flat id the seam meets (must already be authored; `'root'`/`'face-0'` = base). */
43
+ child: string;
44
+ angleDeg: number;
45
+ rule: BendRule;
46
+ }
47
+ /** Inputs for {@link authorPart}. */
48
+ export interface AuthorSpec {
49
+ thickness: number;
50
+ base: BaseFlatSpec;
51
+ flanges: FlangeSpec[];
52
+ material?: MaterialSpec | undefined;
53
+ /** Optional seams that close a profile into a tube/box (left unfolded). */
54
+ seams?: SeamSpec[] | undefined;
55
+ }
56
+ /**
57
+ * Stable edge reference for flange attachment. The base flat is `face-0`; every
58
+ * flange face is `face-<n+1>` in authoring order. The leading edge of a flat is
59
+ * `edgeIndex 0`. The reference also carries `parentId`/`side`/`offset`/`extent`
60
+ * so the feature tree and recursive unfold can resolve the exact parent edge a
61
+ * flange folds from without reading topology back out of the B-rep.
62
+ *
63
+ * @param faceIndex - the face index of the flat: `0` for the base, `n+1` for the
64
+ * flange authored in the `n`-th position.
65
+ * @returns an {@link EdgeRef} pointing at the flat's leading edge (`edgeIndex 0`).
66
+ */
67
+ export declare function baseEdgeRef(faceIndex: number): EdgeRef;
68
+ /**
69
+ * A flat in the part: the base, or a placed flange face. Each carries the world
70
+ * frame (origin + orthonormal axes) of its top surface so a child flange can be
71
+ * built directly off any of its four edges, at any fold direction.
72
+ */
73
+ export interface FlatFrame {
74
+ id: string;
75
+ /** Near corner of the flat on its −normal (bottom) surface; the flat spans
76
+ * `thickness` along +n. Local `(x, y)` maps to `origin + x·u + y·v`. */
77
+ origin: Vec3;
78
+ /** In-plane direction; the flat spans `[0, uLen]` along it. */
79
+ u: Vec3;
80
+ /** In-plane direction; the flat spans `[0, vLen]` along it. */
81
+ v: Vec3;
82
+ /** Outward face normal of the top surface (n = u × v). */
83
+ n: Vec3;
84
+ uLen: number;
85
+ vLen: number;
86
+ }
87
+ /**
88
+ * Author a sheet-metal part: a base flat plus an arbitrary tree of flanges. Each
89
+ * flange folds off one of the four edges of its parent flat (the base by default,
90
+ * or another flange via `parent`), in the requested direction (up/down), over an
91
+ * optional sub-span of that edge (`offset`/`width`). Returns a {@link SheetMetalPart}
92
+ * carrying the folded 3D solid and the recorded bend feature tree the unfold
93
+ * consumes. All construction stays on the public, OCCT-WASM-safe API.
94
+ *
95
+ * @param spec - the authoring spec: sheet thickness, base flat dimensions, the
96
+ * flange list, optional material, and optional closing seams.
97
+ * @returns a `Result<SheetMetalPart>` — `ok` with the folded part on success, or
98
+ * `err` with a `validationError` for an invalid thickness / base / flange /
99
+ * seam specification.
100
+ */
101
+ export declare function authorPart(spec: AuthorSpec): Result<SheetMetalPart>;
102
+ /**
103
+ * World {@link FlatFrame} of every flat region of an authored part, keyed by region
104
+ * id (`'root'` for the base). Reconstructed from the recorded bend/flange feature
105
+ * tree using the exact same edge/transform/child-frame math {@link authorPart} uses
106
+ * to place the geometry, so a cutout authored in a region's local `(x, y)` lands on
107
+ * the matching folded face. Walks the feature tree in BFS order so a chained
108
+ * flange's parent frame is always known first.
109
+ *
110
+ * @param part - the authored sheet-metal part whose flat regions to resolve.
111
+ * @param tree - optional pre-built {@link FeatureTree}; when omitted the tree is
112
+ * reconstructed from `part` via {@link featureTree}.
113
+ * @returns a `Result<Map<string, FlatFrame>>` — `ok` with a map of region id
114
+ * (`'root'` for the base, otherwise the flange id) to its world {@link FlatFrame},
115
+ * or `err` when a flange's parent frame is missing from the tree.
116
+ */
117
+ export declare function worldFrames(part: SheetMetalPart, tree?: FeatureTree): Result<Map<string, FlatFrame>>;
118
+ //# sourceMappingURL=authorFns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorFns.d.ts","sourceRoot":"","sources":["../src/authorFns.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,IAAI,EAoBV,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAEV,QAAQ,EAER,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElF,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;AAElC,gEAAgE;AAChE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,oCA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