brepjs 7.4.1 → 7.5.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 (78) hide show
  1. package/README.md +179 -17
  2. package/dist/2d.cjs +2 -2
  3. package/dist/2d.js +4 -4
  4. package/dist/{Blueprint-3Dyu0OL6.cjs → Blueprint-CVctc41Z.cjs} +4 -4
  5. package/dist/{Blueprint-DSHD89bZ.js → Blueprint-D3JfGJTz.js} +4 -4
  6. package/dist/{boolean2D-CtyE2hK5.js → boolean2D-Ba8TcVzC.js} +6 -6
  7. package/dist/{boolean2D-BwOpOv6L.cjs → boolean2D-BnuJdfDv.cjs} +6 -6
  8. package/dist/{booleanFns-5KSbtLBU.cjs → booleanFns-BBSVKhL2.cjs} +27 -31
  9. package/dist/{booleanFns-DcxqLQSG.js → booleanFns-CqehfzcK.js} +27 -31
  10. package/dist/brepjs.cjs +87 -79
  11. package/dist/brepjs.js +120 -112
  12. package/dist/{cast-D1s7Im9E.js → cast-DQaUibmm.js} +3 -3
  13. package/dist/{cast-DsxJk_F0.cjs → cast-DkB0GKmQ.cjs} +2 -2
  14. package/dist/{drawFns-CSbH7uoI.js → drawFns-D9qkvHgY.js} +8 -8
  15. package/dist/{drawFns-C6KQjmQj.cjs → drawFns-DWOskIp7.cjs} +8 -8
  16. package/dist/{faceFns-B9if-FPW.cjs → faceFns-BwK7FP7N.cjs} +1 -1
  17. package/dist/{faceFns-Bl6HHbqO.js → faceFns-DHu-2JpA.js} +1 -1
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/io.cjs +2 -2
  21. package/dist/io.js +2 -2
  22. package/dist/{loft-Cc5E5pAf.cjs → loft-BzWFokmC.cjs} +2 -2
  23. package/dist/{loft-BlNndTOR.js → loft-CtG5nMq5.js} +2 -2
  24. package/dist/{measurement-D75pyJi1.js → measurement-C5JGCuUP.js} +1 -1
  25. package/dist/{measurement-BVdZ9cG3.cjs → measurement-fxm_pW7x.cjs} +1 -1
  26. package/dist/measurement.cjs +1 -1
  27. package/dist/measurement.js +1 -1
  28. package/dist/{meshFns-p_kv--PW.js → meshFns-BY1fMF48.js} +7 -7
  29. package/dist/{meshFns-mVlogI3J.cjs → meshFns-Dbj_k5gq.cjs} +7 -7
  30. package/dist/operations/api.d.ts +2 -2
  31. package/dist/operations/api.d.ts.map +1 -1
  32. package/dist/operations/extrude.d.ts +2 -2
  33. package/dist/operations/extrudeFns.d.ts +3 -3
  34. package/dist/operations/extrudeFns.d.ts.map +1 -1
  35. package/dist/operations/loft.d.ts +1 -1
  36. package/dist/operations/loftFns.d.ts +2 -2
  37. package/dist/operations/loftFns.d.ts.map +1 -1
  38. package/dist/{operations-SRN-mfTx.cjs → operations-BP1wVDw0.cjs} +14 -20
  39. package/dist/{operations-CEV-gqkX.js → operations-C1rWoba2.js} +14 -20
  40. package/dist/operations.cjs +2 -2
  41. package/dist/operations.js +2 -2
  42. package/dist/{query-D7XclvBZ.js → query-V6nV-VfL.js} +4 -4
  43. package/dist/{query-DkcMfh6j.cjs → query-hMSmOWJP.cjs} +4 -4
  44. package/dist/query.cjs +1 -1
  45. package/dist/query.js +1 -1
  46. package/dist/{shapeFns-BpCPVHFT.js → shapeFns-BrF97sKt.js} +19 -19
  47. package/dist/{shapeFns-DjsWo98C.cjs → shapeFns-BvOndshS.cjs} +19 -19
  48. package/dist/{shapeHelpers-BBSVHPGk.cjs → shapeHelpers-B2SXz1p4.cjs} +2 -2
  49. package/dist/{shapeHelpers-C4QIp7u5.js → shapeHelpers-BcoZf2N9.js} +2 -2
  50. package/dist/sketching.cjs +2 -2
  51. package/dist/sketching.js +2 -2
  52. package/dist/topology/api.d.ts +11 -11
  53. package/dist/topology/api.d.ts.map +1 -1
  54. package/dist/topology/booleanFns.d.ts +9 -9
  55. package/dist/topology/booleanFns.d.ts.map +1 -1
  56. package/dist/topology/cast.d.ts +2 -2
  57. package/dist/topology/cast.d.ts.map +1 -1
  58. package/dist/topology/chamferAngleFns.d.ts +1 -1
  59. package/dist/topology/chamferAngleFns.d.ts.map +1 -1
  60. package/dist/topology/healingFns.d.ts +2 -2
  61. package/dist/topology/healingFns.d.ts.map +1 -1
  62. package/dist/topology/index.d.ts +1 -1
  63. package/dist/topology/index.d.ts.map +1 -1
  64. package/dist/topology/meshFns.d.ts +2 -2
  65. package/dist/topology/meshFns.d.ts.map +1 -1
  66. package/dist/topology/modifierFns.d.ts +5 -5
  67. package/dist/topology/modifierFns.d.ts.map +1 -1
  68. package/dist/topology/primitiveFns.d.ts +5 -1
  69. package/dist/topology/primitiveFns.d.ts.map +1 -1
  70. package/dist/topology/shapeFns.d.ts +9 -9
  71. package/dist/topology/shapeFns.d.ts.map +1 -1
  72. package/dist/{topology-BEMrS4WZ.js → topology-CJKeDGUb.js} +18 -18
  73. package/dist/{topology-Bb1W3SyF.cjs → topology-DoNKAKMt.cjs} +18 -18
  74. package/dist/topology.cjs +8 -8
  75. package/dist/topology.d.ts +1 -1
  76. package/dist/topology.d.ts.map +1 -1
  77. package/dist/topology.js +8 -8
  78. package/package.json +1 -1
package/README.md CHANGED
@@ -79,8 +79,16 @@ A flanged pipe with bolt holes — showing booleans, shelling, fillets, and find
79
79
 
80
80
  ```typescript
81
81
  import {
82
- cylinder, fuse, cut, shell, fillet, rotate,
83
- faceFinder, edgeFinder, measureVolume, unwrap,
82
+ cylinder,
83
+ fuse,
84
+ cut,
85
+ shell,
86
+ fillet,
87
+ rotate,
88
+ faceFinder,
89
+ edgeFinder,
90
+ measureVolume,
91
+ unwrap,
84
92
  } from 'brepjs/quick';
85
93
 
86
94
  // Tube + flanges
@@ -92,7 +100,10 @@ const topFaces = faceFinder().parallelTo('XY').atDistance(100, [0, 0, 0]).findAl
92
100
  const hollowed = unwrap(shell(body, topFaces, 2));
93
101
 
94
102
  // Fillet the tube-to-flange transitions
95
- const filletEdges = edgeFinder().ofCurveType('CIRCLE').ofLength(2 * Math.PI * 15).findAll(hollowed);
103
+ const filletEdges = edgeFinder()
104
+ .ofCurveType('CIRCLE')
105
+ .ofLength(2 * Math.PI * 15)
106
+ .findAll(hollowed);
96
107
  let result = unwrap(fillet(hollowed, filletEdges, 3));
97
108
 
98
109
  // Bolt holes around each flange
@@ -105,23 +116,174 @@ for (let i = 0; i < 6; i++) {
105
116
  console.log('Volume:', measureVolume(result), 'mm³');
106
117
  ```
107
118
 
119
+ ## Common Patterns
120
+
121
+ ### Memory cleanup
122
+
123
+ WASM objects aren't garbage-collected. Use `using` (TS 5.9+) for automatic cleanup, or `gcWithScope()`/`localGC()` for explicit control:
124
+
125
+ ```typescript
126
+ import { box, cylinder, cut, unwrap, gcWithScope, localGC } from 'brepjs/quick';
127
+
128
+ // Option 1: using keyword — auto-disposed at block end
129
+ {
130
+ using temp = box(10, 10, 10);
131
+ using hole = cylinder(3, 15);
132
+ const result = unwrap(cut(temp, hole));
133
+ // temp and hole freed here; result survives
134
+ }
135
+
136
+ // Option 2: gcWithScope — GC-based cleanup
137
+ function buildPart() {
138
+ const r = gcWithScope();
139
+ const b = r(box(10, 10, 10));
140
+ const hole = r(cylinder(3, 15));
141
+ return unwrap(cut(b, hole)); // b and hole cleaned up when r is GC'd
142
+ }
143
+
144
+ // Option 3: localGC — deterministic cleanup
145
+ const [register, cleanup] = localGC();
146
+ try {
147
+ const b = register(box(10, 10, 10));
148
+ return unwrap(cut(b, register(cylinder(3, 15))));
149
+ } finally {
150
+ cleanup(); // immediate disposal
151
+ }
152
+ ```
153
+
154
+ ### Immutability
155
+
156
+ All operations return new shapes — the original is never modified:
157
+
158
+ ```typescript
159
+ import { box, translate, rotate, measureVolume } from 'brepjs/quick';
160
+
161
+ const original = box(30, 20, 10);
162
+ const moved = translate(original, [100, 0, 0]);
163
+ const rotated = rotate(moved, 45, { axis: [0, 0, 1] });
164
+
165
+ // original is unchanged
166
+ console.log(measureVolume(original) === measureVolume(moved)); // true — same geometry, different position
167
+ ```
168
+
169
+ ### Chaining transforms
170
+
171
+ Apply translation then rotation (functional or wrapper style):
172
+
173
+ ```typescript
174
+ import { box, translate, rotate, shape } from 'brepjs/quick';
175
+
176
+ // Functional — each call returns a new shape
177
+ const b = box(30, 20, 10);
178
+ const moved = translate(b, [50, 0, 0]);
179
+ const result = rotate(moved, 45, { axis: [0, 0, 1] });
180
+
181
+ // Wrapper — fluent chaining
182
+ const same = shape(box(30, 20, 10))
183
+ .translate([50, 0, 0])
184
+ .rotate(45, { axis: [0, 0, 1] }).val;
185
+ ```
186
+
187
+ ### 2D sketch to 3D extrusion
188
+
189
+ Draw a 2D profile, then extrude it to create a solid:
190
+
191
+ ```typescript
192
+ import { drawRectangle, drawCircle, drawingCut, drawingToSketchOnPlane, shape } from 'brepjs/quick';
193
+
194
+ // Draw 2D rectangle with a hole
195
+ const profile = drawingCut(drawRectangle(50, 30), drawCircle(8).translate([25, 15]));
196
+
197
+ // Convert to sketch on XY plane, extrude 20mm
198
+ const sketch = drawingToSketchOnPlane(profile, 'XY');
199
+ const solid = shape(sketch.face()).extrude(20).val;
200
+
201
+ // Or use the sketch shortcut directly
202
+ import { sketchRectangle } from 'brepjs/quick';
203
+ const quickBox = sketchRectangle(50, 30).extrude(20);
204
+ ```
205
+
206
+ ### STEP import and export
207
+
208
+ Load a STEP file, modify it, and re-export:
209
+
210
+ ```typescript
211
+ import { importSTEP, exportSTEP, shape, unwrap } from 'brepjs/quick';
212
+
213
+ // Import from Blob (e.g., from file input or fs.readFileSync)
214
+ const imported = unwrap(await importSTEP(stepBlob));
215
+
216
+ // Modify the imported shape
217
+ const modified = shape(imported).fillet(2).translate([0, 0, 10]).val;
218
+
219
+ // Export back to STEP
220
+ const outputBlob = unwrap(exportSTEP(modified));
221
+
222
+ // Save to disk (Node.js)
223
+ import { writeFileSync } from 'fs';
224
+ writeFileSync('output.step', Buffer.from(await outputBlob.arrayBuffer()));
225
+ ```
226
+
227
+ ### Custom WASM kernel
228
+
229
+ `initFromOC()` accepts any OpenCascade WASM instance, enabling custom builds:
230
+
231
+ ```typescript
232
+ import { initFromOC, box } from 'brepjs';
233
+
234
+ // Standard build
235
+ import opencascade from 'brepjs-opencascade';
236
+ const oc = await opencascade();
237
+ initFromOC(oc);
238
+
239
+ // Or use a custom/alternative OpenCascade WASM build
240
+ import customOC from 'my-custom-opencascade';
241
+ const customKernel = await customOC({ locateFile: (f) => `/wasm/${f}` });
242
+ initFromOC(customKernel); // same API — any compatible OC instance works
243
+ ```
244
+
245
+ The kernel abstraction layer in `src/kernel/` translates brepjs calls to OCCT operations, so any WASM build exposing the standard OpenCascade API is compatible.
246
+
247
+ ### Parametric variations
248
+
249
+ Generate multiple part variations by iterating over dimensions:
250
+
251
+ ```typescript
252
+ import { box, cylinder, cut, fillet, edgeFinder, unwrap, exportSTEP } from 'brepjs/quick';
253
+
254
+ function makeBracket(width: number, holeRadius: number) {
255
+ const base = box(width, 20, 10);
256
+ const hole = cylinder(holeRadius, 15, { at: [width / 2, 10, -2] });
257
+ const drilled = unwrap(cut(base, hole));
258
+ const edges = edgeFinder().inDirection('Z').findAll(drilled);
259
+ return unwrap(fillet(drilled, edges, 1.5));
260
+ }
261
+
262
+ // Generate variants
263
+ for (const width of [30, 40, 50, 60]) {
264
+ const part = makeBracket(width, width / 10);
265
+ const step = unwrap(exportSTEP(part));
266
+ console.log(`${width}mm bracket: ${step.size} bytes`);
267
+ }
268
+ ```
269
+
108
270
  ## Examples
109
271
 
110
272
  ```bash
111
273
  npm run example examples/hello-world.ts
112
274
  ```
113
275
 
114
- | Example | What it does |
115
- |---|---|
116
- | [hello-world.ts](./examples/hello-world.ts) | Create a box, measure it, export it |
117
- | [basic-primitives.ts](./examples/basic-primitives.ts) | Primitives and boolean operations |
118
- | [mechanical-part.ts](./examples/mechanical-part.ts) | Bracket with holes, slots, and SVG drawings |
119
- | [2d-to-3d.ts](./examples/2d-to-3d.ts) | Sketch a profile, extrude to 3D |
120
- | [parametric-part.ts](./examples/parametric-part.ts) | Configurable flanged pipe fitting |
121
- | [threejs-rendering.ts](./examples/threejs-rendering.ts) | Generate mesh data for Three.js |
122
- | [browser-viewer.ts](./examples/browser-viewer.ts) | Standalone HTML viewer with orbit controls |
123
- | [import-export.ts](./examples/import-export.ts) | Load, modify, and re-export STEP files |
124
- | [text-engraving.ts](./examples/text-engraving.ts) | Engrave text on a solid shape |
276
+ | Example | What it does |
277
+ | ------------------------------------------------------- | ------------------------------------------- |
278
+ | [hello-world.ts](./examples/hello-world.ts) | Create a box, measure it, export it |
279
+ | [basic-primitives.ts](./examples/basic-primitives.ts) | Primitives and boolean operations |
280
+ | [mechanical-part.ts](./examples/mechanical-part.ts) | Bracket with holes, slots, and SVG drawings |
281
+ | [2d-to-3d.ts](./examples/2d-to-3d.ts) | Sketch a profile, extrude to 3D |
282
+ | [parametric-part.ts](./examples/parametric-part.ts) | Configurable flanged pipe fitting |
283
+ | [threejs-rendering.ts](./examples/threejs-rendering.ts) | Generate mesh data for Three.js |
284
+ | [browser-viewer.ts](./examples/browser-viewer.ts) | Standalone HTML viewer with orbit controls |
285
+ | [import-export.ts](./examples/import-export.ts) | Load, modify, and re-export STEP files |
286
+ | [text-engraving.ts](./examples/text-engraving.ts) | Engrave text on a solid shape |
125
287
 
126
288
  ## Imports
127
289
 
@@ -184,9 +346,9 @@ Layer 0 kernel/, utils/ WASM bindings
184
346
 
185
347
  ## Packages
186
348
 
187
- | Package | Description |
188
- |---|---|
189
- | [brepjs](https://www.npmjs.com/package/brepjs) | Core library |
349
+ | Package | Description |
350
+ | ---------------------------------------------------------------------- | ---------------------- |
351
+ | [brepjs](https://www.npmjs.com/package/brepjs) | Core library |
190
352
  | [brepjs-opencascade](https://www.npmjs.com/package/brepjs-opencascade) | OpenCascade WASM build |
191
353
 
192
354
  ## Projects Using brepjs
package/dist/2d.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Blueprint = require("./Blueprint-3Dyu0OL6.cjs");
4
- const boolean2D = require("./boolean2D-BwOpOv6L.cjs");
3
+ const Blueprint = require("./Blueprint-CVctc41Z.cjs");
4
+ const boolean2D = require("./boolean2D-BnuJdfDv.cjs");
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
package/dist/2d.js CHANGED
@@ -1,7 +1,7 @@
1
- import { B as Blueprint } from "./Blueprint-DSHD89bZ.js";
2
- import { a, C, b } from "./Blueprint-DSHD89bZ.js";
3
- import { c as cut2D, f as fuse2D, i as intersect2D } from "./boolean2D-CtyE2hK5.js";
4
- import { b as b2, C as C2, d, e, g, o, p, r } from "./boolean2D-CtyE2hK5.js";
1
+ import { B as Blueprint } from "./Blueprint-D3JfGJTz.js";
2
+ import { a, C, b } from "./Blueprint-D3JfGJTz.js";
3
+ import { c as cut2D, f as fuse2D, i as intersect2D } from "./boolean2D-Ba8TcVzC.js";
4
+ import { b as b2, C as C2, d, e, g, o, p, r } from "./boolean2D-Ba8TcVzC.js";
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
@@ -2,12 +2,12 @@
2
2
  const vectors = require("./vectors-ChWEZPwy.cjs");
3
3
  const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
4
4
  const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
5
- const faceFns = require("./faceFns-B9if-FPW.cjs");
5
+ const faceFns = require("./faceFns-BwK7FP7N.cjs");
6
6
  const curveFns = require("./curveFns-BilyYL_s.cjs");
7
7
  const errors = require("./errors-DK1VAdP4.cjs");
8
- const shapeHelpers = require("./shapeHelpers-BBSVHPGk.cjs");
9
- const query = require("./query-DkcMfh6j.cjs");
10
- const cast = require("./cast-DsxJk_F0.cjs");
8
+ const shapeHelpers = require("./shapeHelpers-B2SXz1p4.cjs");
9
+ const query = require("./query-hMSmOWJP.cjs");
10
+ const cast = require("./cast-DkB0GKmQ.cjs");
11
11
  const vecOps = require("./vecOps-CjRL1jau.cjs");
12
12
  const result = require("./result.cjs");
13
13
  function makePlane(plane, origin) {
@@ -1,12 +1,12 @@
1
1
  import { r as resolvePlane } from "./vectors-CBuaMeZv.js";
2
2
  import { g as getKernel, a as toVec3, c as makeOcAx2 } from "./occtBoundary-CwegMzqc.js";
3
3
  import { o as localGC, y as registerForCleanup, z as unregisterFromCleanup, n as gcWithScope, t as createEdge, s as createWire } from "./shapeTypes-BlSElW8z.js";
4
- import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-Bl6HHbqO.js";
4
+ import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-DHu-2JpA.js";
5
5
  import { j as findCurveType, m as getOrientation } from "./curveFns-CdVE4da7.js";
6
6
  import { u as unwrap, l as ok, e as err, b as computationError, x as validationError } from "./errors-wGhcJMpB.js";
7
- import { z as zip, o as makeFace } from "./shapeHelpers-C4QIp7u5.js";
8
- import { i as distance2d, s as samePoint, h as scalarMultiply2d, b as add2d, n as normalize2d, a as subtract2d, g as getSingleFace } from "./query-D7XclvBZ.js";
9
- import { c as cast } from "./cast-D1s7Im9E.js";
7
+ import { z as zip, o as makeFace } from "./shapeHelpers-BcoZf2N9.js";
8
+ import { i as distance2d, s as samePoint, h as scalarMultiply2d, b as add2d, n as normalize2d, a as subtract2d, g as getSingleFace } from "./query-V6nV-VfL.js";
9
+ import { c as cast } from "./cast-DQaUibmm.js";
10
10
  import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
11
11
  import { bug } from "./result.js";
12
12
  function makePlane(plane, origin) {
@@ -1,16 +1,16 @@
1
1
  import { a as createPlane } from "./vectors-CBuaMeZv.js";
2
- import { o as makeFace, u as makeNewFaceWithinFace, a as assembleWire, z as zip } from "./shapeHelpers-C4QIp7u5.js";
2
+ import { o as makeFace, u as makeNewFaceWithinFace, a as assembleWire, z as zip } from "./shapeHelpers-BcoZf2N9.js";
3
3
  import { l as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-wGhcJMpB.js";
4
- import { d as downcast } from "./cast-D1s7Im9E.js";
4
+ import { d as downcast } from "./cast-DQaUibmm.js";
5
5
  import { g as getKernel, a as toVec3 } from "./occtBoundary-CwegMzqc.js";
6
6
  import { n as vecScale, j as vecNormalize, b as vecCross, D as DEG2RAD, R as RAD2DEG } from "./vecOps-ZDdZWbwT.js";
7
- import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-BlNndTOR.js";
7
+ import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-CtG5nMq5.js";
8
8
  import { n as gcWithScope, q as createFace, s as createWire, o as localGC, t as createEdge } from "./shapeTypes-BlSElW8z.js";
9
9
  import { e as curveStartPoint, a as curveTangentAt, c as curveIsClosed } from "./curveFns-CdVE4da7.js";
10
- import { u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-Bl6HHbqO.js";
10
+ import { u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-DHu-2JpA.js";
11
11
  import { bug } from "./result.js";
12
- import { s as samePoint$1, n as normalize2d, a as subtract2d, b as add2d, d as crossProduct2d, h as scalarMultiply2d, p as polarToCartesian, i as distance2d, r as rotate2d, j as cartesianToPolar, k as polarAngle2d, P as PRECISION_INTERSECTION } from "./query-D7XclvBZ.js";
13
- import { C as Curve2D, c as make2dSegmentCurve, d as approximateAsBSpline, i as isPoint2D, e as make2dCircle, f as make2dThreePointArc, g as make2dArcFromCenter, a as BoundingBox2d, v as viewbox, h as asSVG, B as Blueprint, j as make2dTangentArc, k as make2dEllipseArc, l as make2dBezierCurve, b as axis2d, r as removeDuplicatePoints } from "./Blueprint-DSHD89bZ.js";
12
+ import { s as samePoint$1, n as normalize2d, a as subtract2d, b as add2d, d as crossProduct2d, h as scalarMultiply2d, p as polarToCartesian, i as distance2d, r as rotate2d, j as cartesianToPolar, k as polarAngle2d, P as PRECISION_INTERSECTION } from "./query-V6nV-VfL.js";
13
+ import { C as Curve2D, c as make2dSegmentCurve, d as approximateAsBSpline, i as isPoint2D, e as make2dCircle, f as make2dThreePointArc, g as make2dArcFromCenter, a as BoundingBox2d, v as viewbox, h as asSVG, B as Blueprint, j as make2dTangentArc, k as make2dEllipseArc, l as make2dBezierCurve, b as axis2d, r as removeDuplicatePoints } from "./Blueprint-D3JfGJTz.js";
14
14
  function* pointsIteration(intersector) {
15
15
  const nPoints = intersector.NbPoints();
16
16
  if (!nPoints) return;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  const vectors = require("./vectors-ChWEZPwy.cjs");
3
- const shapeHelpers = require("./shapeHelpers-BBSVHPGk.cjs");
3
+ const shapeHelpers = require("./shapeHelpers-B2SXz1p4.cjs");
4
4
  const errors = require("./errors-DK1VAdP4.cjs");
5
- const cast = require("./cast-DsxJk_F0.cjs");
5
+ const cast = require("./cast-DkB0GKmQ.cjs");
6
6
  const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
7
7
  const vecOps = require("./vecOps-CjRL1jau.cjs");
8
- const loft = require("./loft-Cc5E5pAf.cjs");
8
+ const loft = require("./loft-BzWFokmC.cjs");
9
9
  const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
10
10
  const curveFns = require("./curveFns-BilyYL_s.cjs");
11
- const faceFns = require("./faceFns-B9if-FPW.cjs");
11
+ const faceFns = require("./faceFns-BwK7FP7N.cjs");
12
12
  const result = require("./result.cjs");
13
- const query = require("./query-DkcMfh6j.cjs");
14
- const Blueprint = require("./Blueprint-3Dyu0OL6.cjs");
13
+ const query = require("./query-hMSmOWJP.cjs");
14
+ const Blueprint = require("./Blueprint-CVctc41Z.cjs");
15
15
  function* pointsIteration(intersector) {
16
16
  const nPoints = intersector.NbPoints();
17
17
  if (!nPoints) return;
@@ -51,11 +51,11 @@ function castToShape3D(shape, errorCode, errorMsg) {
51
51
  }
52
52
  return errors.ok(wrapped);
53
53
  }
54
- function fuseShape(a, b, { optimisation = "none", simplify = false, signal } = {}) {
54
+ function fuse(a, b, { optimisation = "none", simplify = false, signal } = {}) {
55
55
  if (signal?.aborted) throw signal.reason;
56
- const checkA = validateShape3D(a, "fuseShape: first operand");
56
+ const checkA = validateShape3D(a, "fuse: first operand");
57
57
  if (errors.isErr(checkA)) return checkA;
58
- const checkB = validateShape3D(b, "fuseShape: second operand");
58
+ const checkB = validateShape3D(b, "fuse: second operand");
59
59
  if (errors.isErr(checkB)) return checkB;
60
60
  const oc = occtBoundary.getKernel().oc;
61
61
  const r = shapeTypes.gcWithScope();
@@ -66,11 +66,11 @@ function fuseShape(a, b, { optimisation = "none", simplify = false, signal } = {
66
66
  if (simplify) fuseOp.SimplifyResult(true, true, 1e-3);
67
67
  return castToShape3D(fuseOp.Shape(), "FUSE_NOT_3D", "Fuse did not produce a 3D shape");
68
68
  }
69
- function cutShape(base, tool, { optimisation = "none", simplify = false, signal } = {}) {
69
+ function cut(base, tool, { optimisation = "none", simplify = false, signal } = {}) {
70
70
  if (signal?.aborted) throw signal.reason;
71
- const checkBase = validateShape3D(base, "cutShape: base");
71
+ const checkBase = validateShape3D(base, "cut: base");
72
72
  if (errors.isErr(checkBase)) return checkBase;
73
- const checkTool = validateShape3D(tool, "cutShape: tool");
73
+ const checkTool = validateShape3D(tool, "cut: tool");
74
74
  if (errors.isErr(checkTool)) return checkTool;
75
75
  const oc = occtBoundary.getKernel().oc;
76
76
  const r = shapeTypes.gcWithScope();
@@ -81,11 +81,11 @@ function cutShape(base, tool, { optimisation = "none", simplify = false, signal
81
81
  if (simplify) cutOp.SimplifyResult(true, true, 1e-3);
82
82
  return castToShape3D(cutOp.Shape(), "CUT_NOT_3D", "Cut did not produce a 3D shape");
83
83
  }
84
- function intersectShape(a, b, { simplify = false, signal } = {}) {
84
+ function intersect(a, b, { simplify = false, signal } = {}) {
85
85
  if (signal?.aborted) throw signal.reason;
86
- const checkA = validateShape3D(a, "intersectShape: first operand");
86
+ const checkA = validateShape3D(a, "intersect: first operand");
87
87
  if (errors.isErr(checkA)) return checkA;
88
- const checkB = validateShape3D(b, "intersectShape: second operand");
88
+ const checkB = validateShape3D(b, "intersect: second operand");
89
89
  if (errors.isErr(checkB)) return checkB;
90
90
  const oc = occtBoundary.getKernel().oc;
91
91
  const r = shapeTypes.gcWithScope();
@@ -100,7 +100,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
100
100
  const count = end - start;
101
101
  if (count === 1) return errors.ok(shapes[start]);
102
102
  if (count === 2) {
103
- return fuseShape(shapes[start], shapes[start + 1], {
103
+ return fuse(shapes[start], shapes[start + 1], {
104
104
  optimisation,
105
105
  simplify: isTopLevel ? simplify : false,
106
106
  ...signal ? { signal } : {}
@@ -111,7 +111,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
111
111
  if (errors.isErr(leftResult)) return leftResult;
112
112
  const rightResult = fuseAllPairwise(shapes, mid, end, optimisation, simplify, false, signal);
113
113
  if (errors.isErr(rightResult)) return rightResult;
114
- return fuseShape(leftResult.value, rightResult.value, {
114
+ return fuse(leftResult.value, rightResult.value, {
115
115
  optimisation,
116
116
  simplify: isTopLevel ? simplify : false,
117
117
  ...signal ? { signal } : {}
@@ -193,11 +193,9 @@ function makeSectionFace(plane, size) {
193
193
  for (const p of pts) p.delete();
194
194
  return face;
195
195
  }
196
- function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
196
+ function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
197
197
  if (shape.wrapped.IsNull()) {
198
- return errors.err(
199
- errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "sectionShape: shape is a null shape")
200
- );
198
+ return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "section: shape is a null shape"));
201
199
  }
202
200
  const resolvedPlane = typeof plane === "string" ? vectors.resolvePlane(plane) : plane;
203
201
  const sectionFace = makeSectionFace(resolvedPlane, planeSize);
@@ -211,7 +209,7 @@ function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } =
211
209
  const planeName = typeof plane === "string" ? plane : "custom";
212
210
  return errors.err(
213
211
  errors.occtError("SECTION_FAILED", `Section with ${planeName} plane failed: ${raw}`, e, {
214
- operation: "sectionShape",
212
+ operation: "section",
215
213
  plane: planeName
216
214
  })
217
215
  );
@@ -219,12 +217,10 @@ function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } =
219
217
  sectionFace.delete();
220
218
  }
221
219
  }
222
- function splitShape(shape, tools) {
220
+ function split(shape, tools) {
223
221
  if (tools.length === 0) return errors.ok(shape);
224
222
  if (shape.wrapped.IsNull()) {
225
- return errors.err(
226
- errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "splitShape: shape is a null shape")
227
- );
223
+ return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "split: shape is a null shape"));
228
224
  }
229
225
  for (let i = 0; i < tools.length; i++) {
230
226
  if (tools[i].wrapped.IsNull()) {
@@ -246,27 +242,27 @@ function splitShape(shape, tools) {
246
242
  const raw = e instanceof Error ? e.message : String(e);
247
243
  return errors.err(
248
244
  errors.occtError("SPLIT_FAILED", `Split operation failed on ${tools.length} tool(s): ${raw}`, e, {
249
- operation: "splitShape",
245
+ operation: "split",
250
246
  toolCount: tools.length
251
247
  })
252
248
  );
253
249
  }
254
250
  }
255
- function sliceShape(shape, planes, options = {}) {
251
+ function slice(shape, planes, options = {}) {
256
252
  const results = [];
257
253
  for (const plane of planes) {
258
- const section = sectionShape(shape, plane, options);
259
- if (errors.isErr(section)) return section;
260
- results.push(section.value);
254
+ const result = section(shape, plane, options);
255
+ if (errors.isErr(result)) return result;
256
+ results.push(result.value);
261
257
  }
262
258
  return errors.ok(results);
263
259
  }
264
260
  exports.applyGlue = applyGlue;
261
+ exports.cut = cut;
265
262
  exports.cutAll = cutAll;
266
- exports.cutShape = cutShape;
263
+ exports.fuse = fuse;
267
264
  exports.fuseAll = fuseAll;
268
- exports.fuseShape = fuseShape;
269
- exports.intersectShape = intersectShape;
270
- exports.sectionShape = sectionShape;
271
- exports.sliceShape = sliceShape;
272
- exports.splitShape = splitShape;
265
+ exports.intersect = intersect;
266
+ exports.section = section;
267
+ exports.slice = slice;
268
+ exports.split = split;
@@ -50,11 +50,11 @@ function castToShape3D(shape, errorCode, errorMsg) {
50
50
  }
51
51
  return ok(wrapped);
52
52
  }
53
- function fuseShape(a, b, { optimisation = "none", simplify = false, signal } = {}) {
53
+ function fuse(a, b, { optimisation = "none", simplify = false, signal } = {}) {
54
54
  if (signal?.aborted) throw signal.reason;
55
- const checkA = validateShape3D(a, "fuseShape: first operand");
55
+ const checkA = validateShape3D(a, "fuse: first operand");
56
56
  if (isErr(checkA)) return checkA;
57
- const checkB = validateShape3D(b, "fuseShape: second operand");
57
+ const checkB = validateShape3D(b, "fuse: second operand");
58
58
  if (isErr(checkB)) return checkB;
59
59
  const oc = getKernel().oc;
60
60
  const r = gcWithScope();
@@ -65,11 +65,11 @@ function fuseShape(a, b, { optimisation = "none", simplify = false, signal } = {
65
65
  if (simplify) fuseOp.SimplifyResult(true, true, 1e-3);
66
66
  return castToShape3D(fuseOp.Shape(), "FUSE_NOT_3D", "Fuse did not produce a 3D shape");
67
67
  }
68
- function cutShape(base, tool, { optimisation = "none", simplify = false, signal } = {}) {
68
+ function cut(base, tool, { optimisation = "none", simplify = false, signal } = {}) {
69
69
  if (signal?.aborted) throw signal.reason;
70
- const checkBase = validateShape3D(base, "cutShape: base");
70
+ const checkBase = validateShape3D(base, "cut: base");
71
71
  if (isErr(checkBase)) return checkBase;
72
- const checkTool = validateShape3D(tool, "cutShape: tool");
72
+ const checkTool = validateShape3D(tool, "cut: tool");
73
73
  if (isErr(checkTool)) return checkTool;
74
74
  const oc = getKernel().oc;
75
75
  const r = gcWithScope();
@@ -80,11 +80,11 @@ function cutShape(base, tool, { optimisation = "none", simplify = false, signal
80
80
  if (simplify) cutOp.SimplifyResult(true, true, 1e-3);
81
81
  return castToShape3D(cutOp.Shape(), "CUT_NOT_3D", "Cut did not produce a 3D shape");
82
82
  }
83
- function intersectShape(a, b, { simplify = false, signal } = {}) {
83
+ function intersect(a, b, { simplify = false, signal } = {}) {
84
84
  if (signal?.aborted) throw signal.reason;
85
- const checkA = validateShape3D(a, "intersectShape: first operand");
85
+ const checkA = validateShape3D(a, "intersect: first operand");
86
86
  if (isErr(checkA)) return checkA;
87
- const checkB = validateShape3D(b, "intersectShape: second operand");
87
+ const checkB = validateShape3D(b, "intersect: second operand");
88
88
  if (isErr(checkB)) return checkB;
89
89
  const oc = getKernel().oc;
90
90
  const r = gcWithScope();
@@ -99,7 +99,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
99
99
  const count = end - start;
100
100
  if (count === 1) return ok(shapes[start]);
101
101
  if (count === 2) {
102
- return fuseShape(shapes[start], shapes[start + 1], {
102
+ return fuse(shapes[start], shapes[start + 1], {
103
103
  optimisation,
104
104
  simplify: isTopLevel ? simplify : false,
105
105
  ...signal ? { signal } : {}
@@ -110,7 +110,7 @@ function fuseAllPairwise(shapes, start, end, optimisation, simplify, isTopLevel,
110
110
  if (isErr(leftResult)) return leftResult;
111
111
  const rightResult = fuseAllPairwise(shapes, mid, end, optimisation, simplify, false, signal);
112
112
  if (isErr(rightResult)) return rightResult;
113
- return fuseShape(leftResult.value, rightResult.value, {
113
+ return fuse(leftResult.value, rightResult.value, {
114
114
  optimisation,
115
115
  simplify: isTopLevel ? simplify : false,
116
116
  ...signal ? { signal } : {}
@@ -192,11 +192,9 @@ function makeSectionFace(plane, size) {
192
192
  for (const p of pts) p.delete();
193
193
  return face;
194
194
  }
195
- function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
195
+ function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
196
196
  if (shape.wrapped.IsNull()) {
197
- return err(
198
- validationError(BrepErrorCode.NULL_SHAPE_INPUT, "sectionShape: shape is a null shape")
199
- );
197
+ return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "section: shape is a null shape"));
200
198
  }
201
199
  const resolvedPlane = typeof plane === "string" ? resolvePlane(plane) : plane;
202
200
  const sectionFace = makeSectionFace(resolvedPlane, planeSize);
@@ -210,7 +208,7 @@ function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } =
210
208
  const planeName = typeof plane === "string" ? plane : "custom";
211
209
  return err(
212
210
  occtError("SECTION_FAILED", `Section with ${planeName} plane failed: ${raw}`, e, {
213
- operation: "sectionShape",
211
+ operation: "section",
214
212
  plane: planeName
215
213
  })
216
214
  );
@@ -218,12 +216,10 @@ function sectionShape(shape, plane, { approximation = true, planeSize = 1e4 } =
218
216
  sectionFace.delete();
219
217
  }
220
218
  }
221
- function splitShape(shape, tools) {
219
+ function split(shape, tools) {
222
220
  if (tools.length === 0) return ok(shape);
223
221
  if (shape.wrapped.IsNull()) {
224
- return err(
225
- validationError(BrepErrorCode.NULL_SHAPE_INPUT, "splitShape: shape is a null shape")
226
- );
222
+ return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "split: shape is a null shape"));
227
223
  }
228
224
  for (let i = 0; i < tools.length; i++) {
229
225
  if (tools[i].wrapped.IsNull()) {
@@ -245,29 +241,29 @@ function splitShape(shape, tools) {
245
241
  const raw = e instanceof Error ? e.message : String(e);
246
242
  return err(
247
243
  occtError("SPLIT_FAILED", `Split operation failed on ${tools.length} tool(s): ${raw}`, e, {
248
- operation: "splitShape",
244
+ operation: "split",
249
245
  toolCount: tools.length
250
246
  })
251
247
  );
252
248
  }
253
249
  }
254
- function sliceShape(shape, planes, options = {}) {
250
+ function slice(shape, planes, options = {}) {
255
251
  const results = [];
256
252
  for (const plane of planes) {
257
- const section = sectionShape(shape, plane, options);
258
- if (isErr(section)) return section;
259
- results.push(section.value);
253
+ const result = section(shape, plane, options);
254
+ if (isErr(result)) return result;
255
+ results.push(result.value);
260
256
  }
261
257
  return ok(results);
262
258
  }
263
259
  export {
264
- sliceShape as a,
265
- splitShape as b,
266
- cutShape as c,
260
+ slice as a,
261
+ split as b,
262
+ cut as c,
267
263
  cutAll as d,
268
264
  applyGlue as e,
269
- fuseShape as f,
265
+ fuse as f,
270
266
  fuseAll as g,
271
- intersectShape as i,
272
- sectionShape as s
267
+ intersect as i,
268
+ section as s
273
269
  };