brepjs 4.25.0 → 4.26.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 (63) hide show
  1. package/dist/2d.cjs +2 -2
  2. package/dist/2d.js +4 -4
  3. package/dist/{Blueprint-CBvm7PL1.js → Blueprint-CVJ9l3MQ.js} +10 -8
  4. package/dist/{Blueprint-Cf2bQx9i.cjs → Blueprint-CtN6uibs.cjs} +85 -83
  5. package/dist/{boolean2D-Dsb7_zFc.js → boolean2D-SQMo7XtV.js} +12 -10
  6. package/dist/{boolean2D-DZz6fNbS.cjs → boolean2D-eL2leqtU.cjs} +100 -98
  7. package/dist/{booleanFns-DgLLOoeg.cjs → booleanFns-B9kEhspU.cjs} +55 -53
  8. package/dist/{booleanFns-u4DnXrX3.js → booleanFns-CTaavqtA.js} +4 -2
  9. package/dist/brepjs.cjs +107 -105
  10. package/dist/brepjs.js +305 -302
  11. package/dist/{cast-Au_UYuDI.cjs → cast-CQ7SKb6A.cjs} +12 -10
  12. package/dist/{cast-De1fNfOB.js → cast-EtXm4_Ni.js} +3 -1
  13. package/dist/core.cjs +71 -79
  14. package/dist/core.js +68 -76
  15. package/dist/{curveFns-DnXGH3Rw.js → curveFns-CBqqsuTX.js} +3 -1
  16. package/dist/{curveFns-hiIFupBR.cjs → curveFns-DqT7DqLQ.cjs} +25 -23
  17. package/dist/{drawFns-DlNydgox.cjs → drawFns-0aIWJNlZ.cjs} +165 -163
  18. package/dist/{drawFns-CQxs0Sz2.js → drawFns-DKoThDRX.js} +15 -13
  19. package/dist/errors-C7Inmd1n.cjs +221 -0
  20. package/dist/errors-EPHOk9hi.js +222 -0
  21. package/dist/{faceFns-BiADk4Ys.cjs → faceFns-BOc1QawY.cjs} +21 -19
  22. package/dist/{faceFns-DcvflSoj.js → faceFns-DJsu6nUY.js} +4 -2
  23. package/dist/{finderFns-ti3qUFpJ.js → finderFns-BRHoTSM7.js} +10 -8
  24. package/dist/{finderFns-DptGRbGA.cjs → finderFns-BUC9hZU9.cjs} +33 -31
  25. package/dist/{helpers-CYQYjKFu.js → helpers-CU9dnrkT.js} +8 -6
  26. package/dist/{helpers-GNF_mnAY.cjs → helpers-D6spKAz4.cjs} +20 -18
  27. package/dist/io.cjs +24 -22
  28. package/dist/io.js +4 -2
  29. package/dist/{loft-sFeoEebW.cjs → loft-B1NuMnJJ.cjs} +42 -40
  30. package/dist/{loft-ByF6QLtd.js → loft-D1_u9YgM.js} +6 -4
  31. package/dist/{measurement-NbK46U6B.cjs → measurement-DqiOwyhS.cjs} +6 -5
  32. package/dist/{measurement-CrsEV5Tg.js → measurement-VmVnUc-w.js} +3 -2
  33. package/dist/measurement.cjs +1 -1
  34. package/dist/measurement.js +1 -1
  35. package/dist/{occtBoundary-DBs4sGzK.js → occtBoundary-BdGtXEUi.js} +22 -551
  36. package/dist/{occtBoundary-DRn81X_r.cjs → occtBoundary-du8_ex-p.cjs} +5 -534
  37. package/dist/operations.cjs +82 -80
  38. package/dist/operations.js +9 -7
  39. package/dist/query.cjs +2 -2
  40. package/dist/query.js +2 -2
  41. package/dist/result.cjs +43 -0
  42. package/dist/result.d.ts +7 -0
  43. package/dist/result.d.ts.map +1 -0
  44. package/dist/result.js +43 -0
  45. package/dist/{shapeFns-VyO-9N-6.js → shapeFns-CbJ15k3S.js} +5 -3
  46. package/dist/{shapeFns-4yZh4lqz.cjs → shapeFns-DdAGaJP-.cjs} +22 -20
  47. package/dist/{shapeHelpers-OCwPIfRh.cjs → shapeHelpers-CNv5JX--.cjs} +88 -86
  48. package/dist/{shapeHelpers-CUd1Cw8j.js → shapeHelpers-jBD0w9FP.js} +5 -3
  49. package/dist/shapeTypes-DKhwEnUM.cjs +311 -0
  50. package/dist/shapeTypes-Drjbf_Uu.js +312 -0
  51. package/dist/sketching.cjs +2 -2
  52. package/dist/sketching.js +2 -2
  53. package/dist/{topology-CH3GPRNk.cjs → topology-CZIqVE5K.cjs} +120 -118
  54. package/dist/{topology-BP9i1Anq.js → topology-DHdqcRsT.js} +10 -8
  55. package/dist/topology.cjs +7 -7
  56. package/dist/topology.js +7 -7
  57. package/dist/{planeOps-B5oUs8oF.cjs → vectors-CVRXEGfA.cjs} +4 -3
  58. package/dist/{planeOps-0MoExrYA.js → vectors-QAJQy2Yy.js} +19 -18
  59. package/dist/vectors.cjs +30 -0
  60. package/dist/vectors.d.ts +11 -0
  61. package/dist/vectors.d.ts.map +1 -0
  62. package/dist/vectors.js +30 -0
  63. package/package.json +21 -1
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-Cf2bQx9i.cjs");
4
- const boolean2D = require("./boolean2D-DZz6fNbS.cjs");
3
+ const Blueprint = require("./Blueprint-CtN6uibs.cjs");
4
+ const boolean2D = require("./boolean2D-eL2leqtU.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-CBvm7PL1.js";
2
- import { a, C, b } from "./Blueprint-CBvm7PL1.js";
3
- import { c as cut2D, f as fuse2D, i as intersect2D } from "./boolean2D-Dsb7_zFc.js";
4
- import { b as b2, C as C2, d, e, g, o, p, r } from "./boolean2D-Dsb7_zFc.js";
1
+ import { B as Blueprint } from "./Blueprint-CVJ9l3MQ.js";
2
+ import { a, C, b } from "./Blueprint-CVJ9l3MQ.js";
3
+ import { c as cut2D, f as fuse2D, i as intersect2D } from "./boolean2D-SQMo7XtV.js";
4
+ import { b as b2, C as C2, d, e, g, o, p, r } from "./boolean2D-SQMo7XtV.js";
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
@@ -1,11 +1,13 @@
1
- import { r as resolvePlane, h as vecCross, k as vecLength, v as vecNormalize, f as createPlane, D as DEG2RAD, R as RAD2DEG } from "./planeOps-0MoExrYA.js";
2
- import { g as getKernel, X as localGC, h as toVec3, m as makeOcAx2, d as makeOcAx1, t as toOcPnt, f as toOcVec, ae as registerForCleanup, af as unregisterFromCleanup, a as gcWithScope, u as unwrap, o as ok, e as err, w as computationError, y as createEdge, v as validationError, H as createWire } from "./occtBoundary-DBs4sGzK.js";
3
- import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-DcvflSoj.js";
4
- import { k as findCurveType, m as getOrientation } from "./curveFns-DnXGH3Rw.js";
5
- import { A as zip, l as makeFace } from "./shapeHelpers-CUd1Cw8j.js";
6
- import { d as distance2d, s as samePoint, f as scalarMultiply2d, c as add2d, n as normalize2d, b as subtract2d, g as getSingleFace } from "./helpers-CYQYjKFu.js";
7
- import { c as cast } from "./cast-De1fNfOB.js";
8
- import { bug } from "./core.js";
1
+ import { r as resolvePlane, d as vecCross, i as vecLength, l as vecNormalize, a as createPlane, D as DEG2RAD, R as RAD2DEG } from "./vectors-QAJQy2Yy.js";
2
+ import { g as getKernel, a as toVec3, m as makeOcAx2, c as makeOcAx1, b as toOcPnt, d as toOcVec } from "./occtBoundary-BdGtXEUi.js";
3
+ import { x as localGC, y as registerForCleanup, z as unregisterFromCleanup, n as gcWithScope, p as createEdge, u as createWire } from "./shapeTypes-Drjbf_Uu.js";
4
+ import { u as uvBounds, a as faceGeomType, f as faceCenter, h as uvCoordinates } from "./faceFns-DJsu6nUY.js";
5
+ import { k as findCurveType, m as getOrientation } from "./curveFns-CBqqsuTX.js";
6
+ import { u as unwrap, l as ok, e as err, b as computationError, x as validationError } from "./errors-EPHOk9hi.js";
7
+ import { A as zip, l as makeFace } from "./shapeHelpers-jBD0w9FP.js";
8
+ import { d as distance2d, s as samePoint, f as scalarMultiply2d, c as add2d, n as normalize2d, b as subtract2d, g as getSingleFace } from "./helpers-CU9dnrkT.js";
9
+ import { c as cast } from "./cast-EtXm4_Ni.js";
10
+ import { bug } from "./result.js";
9
11
  const makePlaneFromFace = (face, originOnSurface = [0, 0]) => {
10
12
  const originPoint = face.pointOnSurface(...originOnSurface);
11
13
  const normal = face.normalAt(originPoint);
@@ -1,38 +1,40 @@
1
1
  "use strict";
2
- const planeOps = require("./planeOps-B5oUs8oF.cjs");
3
- const occtBoundary = require("./occtBoundary-DRn81X_r.cjs");
4
- const faceFns = require("./faceFns-BiADk4Ys.cjs");
5
- const curveFns = require("./curveFns-hiIFupBR.cjs");
6
- const shapeHelpers = require("./shapeHelpers-OCwPIfRh.cjs");
7
- const helpers = require("./helpers-GNF_mnAY.cjs");
8
- const cast = require("./cast-Au_UYuDI.cjs");
9
- const core = require("./core.cjs");
2
+ const vectors = require("./vectors-CVRXEGfA.cjs");
3
+ const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
4
+ const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
5
+ const faceFns = require("./faceFns-BOc1QawY.cjs");
6
+ const curveFns = require("./curveFns-DqT7DqLQ.cjs");
7
+ const errors = require("./errors-C7Inmd1n.cjs");
8
+ const shapeHelpers = require("./shapeHelpers-CNv5JX--.cjs");
9
+ const helpers = require("./helpers-D6spKAz4.cjs");
10
+ const cast = require("./cast-CQ7SKb6A.cjs");
11
+ const result = require("./result.cjs");
10
12
  const makePlaneFromFace = (face, originOnSurface = [0, 0]) => {
11
13
  const originPoint = face.pointOnSurface(...originOnSurface);
12
14
  const normal = face.normalAt(originPoint);
13
15
  const ref = [0, 0, 1];
14
- let xd = planeOps.vecCross(ref, normal);
15
- if (planeOps.vecLength(xd) < 1e-8) {
16
+ let xd = vectors.vecCross(ref, normal);
17
+ if (vectors.vecLength(xd) < 1e-8) {
16
18
  xd = [1, 0, 0];
17
19
  }
18
- xd = planeOps.vecNormalize(xd);
19
- return planeOps.createPlane(originPoint, xd, normal);
20
+ xd = vectors.vecNormalize(xd);
21
+ return vectors.createPlane(originPoint, xd, normal);
20
22
  };
21
23
  function makePlane(plane, origin) {
22
24
  if (plane && typeof plane !== "string") {
23
25
  return { ...plane };
24
26
  } else {
25
- return planeOps.resolvePlane(plane ?? "XY", origin);
27
+ return vectors.resolvePlane(plane ?? "XY", origin);
26
28
  }
27
29
  }
28
30
  function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
29
31
  const oc = occtBoundary.getKernel().oc;
30
- const [r, gc] = occtBoundary.localGC();
32
+ const [r, gc] = shapeTypes.localGC();
31
33
  const posVec = occtBoundary.toVec3(position);
32
34
  const dirVec = occtBoundary.toVec3(direction);
33
35
  const ax = r(occtBoundary.makeOcAx1(posVec, dirVec));
34
36
  const trsf = r(new oc.gp_Trsf_1());
35
- trsf.SetRotation_1(ax, angle * planeOps.DEG2RAD);
37
+ trsf.SetRotation_1(ax, angle * vectors.DEG2RAD);
36
38
  const transformer = r(new oc.BRepBuilderAPI_Transform_2(shape, trsf, true));
37
39
  const newShape = transformer.ModifiedShape(shape);
38
40
  gc();
@@ -40,7 +42,7 @@ function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
40
42
  }
41
43
  function translate(shape, vector) {
42
44
  const oc = occtBoundary.getKernel().oc;
43
- const [r, gc] = occtBoundary.localGC();
45
+ const [r, gc] = shapeTypes.localGC();
44
46
  const vecArr = occtBoundary.toVec3(vector);
45
47
  const ocVec = r(occtBoundary.toOcVec(vecArr));
46
48
  const trsf = r(new oc.gp_Trsf_1());
@@ -52,11 +54,11 @@ function translate(shape, vector) {
52
54
  }
53
55
  function mirror(shape, inputPlane, origin) {
54
56
  const oc = occtBoundary.getKernel().oc;
55
- const [r, gc] = occtBoundary.localGC();
57
+ const [r, gc] = shapeTypes.localGC();
56
58
  let originVec;
57
59
  let directionVec;
58
60
  if (typeof inputPlane === "string") {
59
- const plane = planeOps.resolvePlane(inputPlane, origin);
61
+ const plane = vectors.resolvePlane(inputPlane, origin);
60
62
  originVec = plane.origin;
61
63
  directionVec = plane.zDir;
62
64
  } else if (inputPlane && typeof inputPlane === "object" && "origin" in inputPlane && "zDir" in inputPlane) {
@@ -66,7 +68,7 @@ function mirror(shape, inputPlane, origin) {
66
68
  originVec = origin ? occtBoundary.toVec3(origin) : [0, 0, 0];
67
69
  directionVec = occtBoundary.toVec3(inputPlane);
68
70
  } else {
69
- const plane = planeOps.resolvePlane("YZ", origin);
71
+ const plane = vectors.resolvePlane("YZ", origin);
70
72
  originVec = plane.origin;
71
73
  directionVec = plane.zDir;
72
74
  }
@@ -80,7 +82,7 @@ function mirror(shape, inputPlane, origin) {
80
82
  }
81
83
  function scale(shape, center, scaleFactor) {
82
84
  const oc = occtBoundary.getKernel().oc;
83
- const [r, gc] = occtBoundary.localGC();
85
+ const [r, gc] = shapeTypes.localGC();
84
86
  const centerVec = occtBoundary.toVec3(center);
85
87
  const pnt2 = r(occtBoundary.toOcPnt(centerVec));
86
88
  const trsf = r(new oc.gp_Trsf_1());
@@ -133,7 +135,7 @@ const vec = ([x, y]) => {
133
135
  };
134
136
  const axis2d = (point, direction) => {
135
137
  const oc = occtBoundary.getKernel().oc;
136
- const [r, gc] = occtBoundary.localGC();
138
+ const [r, gc] = shapeTypes.localGC();
137
139
  const axis = new oc.gp_Ax2d_2(r(pnt(point)), r(direction2d(direction)));
138
140
  gc();
139
141
  return axis;
@@ -144,7 +146,7 @@ class BoundingBox2d {
144
146
  constructor(wrapped) {
145
147
  const oc = occtBoundary.getKernel().oc;
146
148
  this._wrapped = wrapped ?? new oc.Bnd_Box2d();
147
- occtBoundary.registerForCleanup(this, this._wrapped);
149
+ shapeTypes.registerForCleanup(this, this._wrapped);
148
150
  }
149
151
  get wrapped() {
150
152
  if (this._deleted) throw new Error("This object has been deleted");
@@ -153,7 +155,7 @@ class BoundingBox2d {
153
155
  delete() {
154
156
  if (!this._deleted) {
155
157
  this._deleted = true;
156
- occtBoundary.unregisterFromCleanup(this._wrapped);
158
+ shapeTypes.unregisterFromCleanup(this._wrapped);
157
159
  this._wrapped.delete();
158
160
  }
159
161
  }
@@ -213,7 +215,7 @@ class BoundingBox2d {
213
215
  }
214
216
  /** Test whether the given point lies inside (or on the boundary of) this box. */
215
217
  containsPoint(other) {
216
- const r = occtBoundary.gcWithScope();
218
+ const r = shapeTypes.gcWithScope();
217
219
  const point = r(pnt(other));
218
220
  return !this.wrapped.IsOut_1(point);
219
221
  }
@@ -234,7 +236,7 @@ class Curve2D {
234
236
  const inner = handle.get();
235
237
  this._wrapped = new oc.Handle_Geom2d_Curve_2(inner);
236
238
  this._boundingBox = null;
237
- occtBoundary.registerForCleanup(this, this._wrapped);
239
+ shapeTypes.registerForCleanup(this, this._wrapped);
238
240
  }
239
241
  get wrapped() {
240
242
  if (this._deleted) throw new Error("This object has been deleted");
@@ -243,7 +245,7 @@ class Curve2D {
243
245
  delete() {
244
246
  if (!this._deleted) {
245
247
  this._deleted = true;
246
- occtBoundary.unregisterFromCleanup(this._wrapped);
248
+ shapeTypes.unregisterFromCleanup(this._wrapped);
247
249
  this._wrapped.delete();
248
250
  }
249
251
  }
@@ -306,7 +308,7 @@ class Curve2D {
306
308
  /** Return the geometric type of this curve (e.g. `LINE`, `CIRCLE`, `BSPLINE_CURVE`). */
307
309
  get geomType() {
308
310
  const adaptor = this.adaptor();
309
- const curveType = occtBoundary.unwrap(curveFns.findCurveType(adaptor.GetType()));
311
+ const curveType = errors.unwrap(curveFns.findCurveType(adaptor.GetType()));
310
312
  adaptor.delete();
311
313
  return curveType;
312
314
  }
@@ -326,7 +328,7 @@ class Curve2D {
326
328
  }
327
329
  distanceFromPoint(point) {
328
330
  const oc = occtBoundary.getKernel().oc;
329
- const r = occtBoundary.gcWithScope();
331
+ const r = shapeTypes.gcWithScope();
330
332
  const projector = r(new oc.Geom2dAPI_ProjectPointOnCurve_2(r(pnt(point)), this.wrapped));
331
333
  let curveToPoint = Infinity;
332
334
  try {
@@ -342,7 +344,7 @@ class Curve2D {
342
344
  }
343
345
  distanceFromCurve(curve) {
344
346
  const oc = occtBoundary.getKernel().oc;
345
- const r = occtBoundary.gcWithScope();
347
+ const r = shapeTypes.gcWithScope();
346
348
  let curveDistance = Infinity;
347
349
  const projector = r(
348
350
  new oc.Geom2dAPI_ExtremaCurveCurve(
@@ -385,7 +387,7 @@ class Curve2D {
385
387
  */
386
388
  parameter(point, precision = 1e-9) {
387
389
  const oc = occtBoundary.getKernel().oc;
388
- const r = occtBoundary.gcWithScope();
390
+ const r = shapeTypes.gcWithScope();
389
391
  let lowerDistance;
390
392
  let lowerDistanceParameter;
391
393
  try {
@@ -393,19 +395,19 @@ class Curve2D {
393
395
  lowerDistance = projector.LowerDistance();
394
396
  lowerDistanceParameter = projector.LowerDistanceParameter();
395
397
  } catch {
396
- if (helpers.samePoint(point, this.firstPoint, precision)) return occtBoundary.ok(this.firstParameter);
397
- if (helpers.samePoint(point, this.lastPoint, precision)) return occtBoundary.ok(this.lastParameter);
398
- return occtBoundary.err(occtBoundary.computationError("PARAMETER_NOT_FOUND", "Failed to find parameter"));
398
+ if (helpers.samePoint(point, this.firstPoint, precision)) return errors.ok(this.firstParameter);
399
+ if (helpers.samePoint(point, this.lastPoint, precision)) return errors.ok(this.lastParameter);
400
+ return errors.err(errors.computationError("PARAMETER_NOT_FOUND", "Failed to find parameter"));
399
401
  }
400
402
  if (lowerDistance > precision) {
401
- return occtBoundary.err(
402
- occtBoundary.computationError(
403
+ return errors.err(
404
+ errors.computationError(
403
405
  "POINT_NOT_ON_CURVE",
404
406
  `Point ${reprPnt(point)} not on curve ${this.repr}, ${lowerDistance.toFixed(9)}`
405
407
  )
406
408
  );
407
409
  }
408
- return occtBoundary.ok(lowerDistanceParameter);
410
+ return errors.ok(lowerDistanceParameter);
409
411
  }
410
412
  /**
411
413
  * Compute the tangent vector at a parameter position or at the projection of a point.
@@ -414,10 +416,10 @@ class Curve2D {
414
416
  */
415
417
  tangentAt(index) {
416
418
  const oc = occtBoundary.getKernel().oc;
417
- const [r, gc] = occtBoundary.localGC();
419
+ const [r, gc] = shapeTypes.localGC();
418
420
  let param;
419
421
  if (Array.isArray(index)) {
420
- param = occtBoundary.unwrap(this.parameter(index));
422
+ param = errors.unwrap(this.parameter(index));
421
423
  } else {
422
424
  const paramLength = this.innerCurve.LastParameter() - this.innerCurve.FirstParameter();
423
425
  param = paramLength * index + Number(this.innerCurve.FirstParameter());
@@ -436,9 +438,9 @@ class Curve2D {
436
438
  */
437
439
  splitAt(points, precision = 1e-9) {
438
440
  const oc = occtBoundary.getKernel().oc;
439
- const r = occtBoundary.gcWithScope();
441
+ const r = shapeTypes.gcWithScope();
440
442
  let parameters = points.map((point) => {
441
- if (isPoint2D(point)) return occtBoundary.unwrap(this.parameter(point, precision));
443
+ if (isPoint2D(point)) return errors.unwrap(this.parameter(point, precision));
442
444
  return point;
443
445
  });
444
446
  parameters = Array.from(
@@ -489,7 +491,7 @@ class Curve2D {
489
491
  }
490
492
  const approximateAsBSpline = (adaptor, tolerance = 1e-4, continuity = "C0", maxSegments = 200) => {
491
493
  const oc = occtBoundary.getKernel().oc;
492
- const r = occtBoundary.gcWithScope();
494
+ const r = shapeTypes.gcWithScope();
493
495
  const continuities = {
494
496
  C0: oc.GeomAbs_Shape.GeomAbs_C0,
495
497
  C1: oc.GeomAbs_Shape.GeomAbs_C1,
@@ -508,8 +510,8 @@ const approximateAsBSpline = (adaptor, tolerance = 1e-4, continuity = "C0", maxS
508
510
  return new Curve2D(convert.Curve());
509
511
  };
510
512
  const BSplineToBezier = (adaptor) => {
511
- if (occtBoundary.unwrap(curveFns.findCurveType(adaptor.GetType())) !== "BSPLINE_CURVE")
512
- core.bug("BSplineToBezier", "You can only convert a Bspline");
513
+ if (errors.unwrap(curveFns.findCurveType(adaptor.GetType())) !== "BSPLINE_CURVE")
514
+ result.bug("BSplineToBezier", "You can only convert a Bspline");
513
515
  const handle = adaptor.BSpline();
514
516
  const oc = occtBoundary.getKernel().oc;
515
517
  const convert = new oc.Geom2dConvert_BSplineCurveToBezierCurve_1(handle);
@@ -530,10 +532,10 @@ function approximateAsSvgCompatibleCurve(curves, options = {
530
532
  continuity: "C0",
531
533
  maxSegments: 300
532
534
  }) {
533
- const r = occtBoundary.gcWithScope();
535
+ const r = shapeTypes.gcWithScope();
534
536
  return curves.flatMap((curve) => {
535
537
  const adaptor = r(curve.adaptor());
536
- const curveType = occtBoundary.unwrap(curveFns.findCurveType(adaptor.GetType()));
538
+ const curveType = errors.unwrap(curveFns.findCurveType(adaptor.GetType()));
537
539
  if (curveType === "ELLIPSE" || curveType === "CIRCLE" && helpers.samePoint(curve.firstPoint, curve.lastPoint)) {
538
540
  return curve.splitAt([0.5]);
539
541
  }
@@ -562,7 +564,7 @@ function approximateAsSvgCompatibleCurve(curves, options = {
562
564
  }
563
565
  const make2dSegmentCurve = (startPoint, endPoint) => {
564
566
  const oc = occtBoundary.getKernel().oc;
565
- const [r, gc] = occtBoundary.localGC();
567
+ const [r, gc] = shapeTypes.localGC();
566
568
  const segment = r(new oc.GCE2d_MakeSegment_1(r(pnt(startPoint)), r(pnt(endPoint)))).Value();
567
569
  const curve = new Curve2D(segment);
568
570
  if (!helpers.samePoint(curve.firstPoint, startPoint)) {
@@ -573,7 +575,7 @@ const make2dSegmentCurve = (startPoint, endPoint) => {
573
575
  };
574
576
  const make2dThreePointArc = (startPoint, midPoint, endPoint) => {
575
577
  const oc = occtBoundary.getKernel().oc;
576
- const [r, gc] = occtBoundary.localGC();
578
+ const [r, gc] = shapeTypes.localGC();
577
579
  const segment = r(
578
580
  new oc.GCE2d_MakeArcOfCircle_4(r(pnt(startPoint)), r(pnt(midPoint)), r(pnt(endPoint)))
579
581
  ).Value();
@@ -586,7 +588,7 @@ const make2dThreePointArc = (startPoint, midPoint, endPoint) => {
586
588
  };
587
589
  const make2dTangentArc = (startPoint, tangent, endPoint) => {
588
590
  const oc = occtBoundary.getKernel().oc;
589
- const [r, gc] = occtBoundary.localGC();
591
+ const [r, gc] = shapeTypes.localGC();
590
592
  const segment = r(
591
593
  new oc.GCE2d_MakeArcOfCircle_5(r(pnt(startPoint)), r(vec(tangent)), r(pnt(endPoint)))
592
594
  ).Value();
@@ -599,14 +601,14 @@ const make2dTangentArc = (startPoint, tangent, endPoint) => {
599
601
  };
600
602
  const make2dCircle = (radius, center = [0, 0]) => {
601
603
  const oc = occtBoundary.getKernel().oc;
602
- const [r, gc] = occtBoundary.localGC();
604
+ const [r, gc] = shapeTypes.localGC();
603
605
  const segment = r(new oc.GCE2d_MakeCircle_7(r(pnt(center)), radius, true)).Value();
604
606
  gc();
605
607
  return new Curve2D(segment);
606
608
  };
607
609
  const make2dEllipse = (majorRadius, minorRadius, xDir = [1, 0], center = [0, 0], direct = true) => {
608
610
  const oc = occtBoundary.getKernel().oc;
609
- const [r, gc] = occtBoundary.localGC();
611
+ const [r, gc] = shapeTypes.localGC();
610
612
  const ellipse = r(new oc.gp_Elips2d_2(r(axis2d(center, xDir)), majorRadius, minorRadius, direct));
611
613
  const segment = r(new oc.GCE2d_MakeEllipse_1(ellipse)).Value();
612
614
  gc();
@@ -614,7 +616,7 @@ const make2dEllipse = (majorRadius, minorRadius, xDir = [1, 0], center = [0, 0],
614
616
  };
615
617
  const make2dEllipseArc = (majorRadius, minorRadius, startAngle, endAngle, center = [0, 0], xDir, direct = true) => {
616
618
  const oc = occtBoundary.getKernel().oc;
617
- const [r, gc] = occtBoundary.localGC();
619
+ const [r, gc] = shapeTypes.localGC();
618
620
  const ellipse = r(new oc.gp_Elips2d_2(r(axis2d(center, xDir)), majorRadius, minorRadius, true));
619
621
  const segment = r(new oc.GCE2d_MakeArcOfEllipse_1(ellipse, startAngle, endAngle, direct)).Value();
620
622
  gc();
@@ -622,7 +624,7 @@ const make2dEllipseArc = (majorRadius, minorRadius, startAngle, endAngle, center
622
624
  };
623
625
  const make2dBezierCurve = (startPoint, controls, endPoint) => {
624
626
  const oc = occtBoundary.getKernel().oc;
625
- const [r, gc] = occtBoundary.localGC();
627
+ const [r, gc] = shapeTypes.localGC();
626
628
  const arrayOfPoints = r(new oc.TColgp_Array1OfPnt2d_2(1, controls.length + 2));
627
629
  arrayOfPoints.SetValue(1, r(pnt(startPoint)));
628
630
  controls.forEach((p, i) => {
@@ -639,7 +641,7 @@ function make2dInerpolatedBSplineCurve(points, {
639
641
  degMax = 3,
640
642
  degMin = 1
641
643
  } = {}) {
642
- const r = occtBoundary.gcWithScope();
644
+ const r = shapeTypes.gcWithScope();
643
645
  const oc = occtBoundary.getKernel().oc;
644
646
  const pnts = r(new oc.TColgp_Array1OfPnt2d_2(1, points.length));
645
647
  points.forEach((point, index) => {
@@ -670,9 +672,9 @@ function make2dInerpolatedBSplineCurve(points, {
670
672
  );
671
673
  }
672
674
  if (!splineBuilder.IsDone()) {
673
- return occtBoundary.err(occtBoundary.computationError("BSPLINE_2D_FAILED", "B-spline approximation failed"));
675
+ return errors.err(errors.computationError("BSPLINE_2D_FAILED", "B-spline approximation failed"));
674
676
  }
675
- return occtBoundary.ok(new Curve2D(splineBuilder.Curve()));
677
+ return errors.ok(new Curve2D(splineBuilder.Curve()));
676
678
  }
677
679
  const make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
678
680
  const midChord = helpers.scalarMultiply2d(helpers.add2d(startPoint, endPoint), 0.5);
@@ -690,8 +692,8 @@ function round5(v) {
690
692
  const fromPnt = (pnt2) => `${round2(pnt2.X())} ${round2(pnt2.Y())}`;
691
693
  const adaptedCurveToPathElem = (adaptor, lastPoint) => {
692
694
  const oc = occtBoundary.getKernel().oc;
693
- const r = occtBoundary.gcWithScope();
694
- const curveType = occtBoundary.unwrap(curveFns.findCurveType(adaptor.GetType()));
695
+ const r = shapeTypes.gcWithScope();
696
+ const curveType = errors.unwrap(curveFns.findCurveType(adaptor.GetType()));
695
697
  const [endX, endY] = lastPoint;
696
698
  const endpoint = `${round5(endX)} ${round5(endY)}`;
697
699
  if (curveType === "LINE") {
@@ -721,7 +723,7 @@ const adaptedCurveToPathElem = (adaptor, lastPoint) => {
721
723
  const radius = curve.Radius();
722
724
  const p1 = adaptor.FirstParameter();
723
725
  const p2 = adaptor.LastParameter();
724
- const paramAngle = (p2 - p1) * planeOps.RAD2DEG;
726
+ const paramAngle = (p2 - p1) * vectors.RAD2DEG;
725
727
  const end = paramAngle !== 360 ? endpoint : `${round5(endX)} ${round5(endY + 1e-4)}`;
726
728
  return `A ${radius} ${radius} 0 ${Math.abs(paramAngle) > 180 ? "1" : "0"} ${curve.IsDirect() ? "1" : "0"} ${end}`;
727
729
  }
@@ -731,15 +733,15 @@ const adaptedCurveToPathElem = (adaptor, lastPoint) => {
731
733
  const ry = curve.MinorRadius();
732
734
  const p1 = adaptor.FirstParameter();
733
735
  const p2 = adaptor.LastParameter();
734
- const paramAngle = (p2 - p1) * planeOps.RAD2DEG;
736
+ const paramAngle = (p2 - p1) * vectors.RAD2DEG;
735
737
  const end = paramAngle !== 360 ? endpoint : `${round5(endX)} ${round5(endY + 1e-4)}`;
736
738
  const dir0 = r(new oc.gp_Dir2d_1());
737
739
  const xAxis = r(curve.XAxis());
738
740
  const xDir = r(xAxis.Direction());
739
- const angle = 180 - xDir.Angle(dir0) * planeOps.RAD2DEG;
741
+ const angle = 180 - xDir.Angle(dir0) * vectors.RAD2DEG;
740
742
  return `A ${round5(rx)} ${round5(ry)} ${round5(angle)} ${Math.abs(paramAngle) > 180 ? "1" : "0"} ${curve.IsDirect() ? "1" : "0"} ${end}`;
741
743
  }
742
- core.bug("adaptedCurveToPathElem", `Unsupported curve type: ${curveType}`);
744
+ result.bug("adaptedCurveToPathElem", `Unsupported curve type: ${curveType}`);
743
745
  };
744
746
  const curvesBoundingBox = (curves) => {
745
747
  const oc = occtBoundary.getKernel().oc;
@@ -750,23 +752,23 @@ const curvesBoundingBox = (curves) => {
750
752
  return new BoundingBox2d(boundBox);
751
753
  };
752
754
  function curvesAsEdgesOnPlane(curves, plane) {
753
- const [r, gc] = occtBoundary.localGC();
755
+ const [r, gc] = shapeTypes.localGC();
754
756
  const ax = r(occtBoundary.makeOcAx2(plane.origin, plane.zDir, plane.xDir));
755
757
  const oc = occtBoundary.getKernel().oc;
756
758
  const edges = curves.map((curve) => {
757
759
  const curve3d = r(oc.GeomLib.To3d(ax, curve.wrapped));
758
760
  const edgeBuilder = r(new oc.BRepBuilderAPI_MakeEdge_24(curve3d));
759
- return occtBoundary.createEdge(edgeBuilder.Edge());
761
+ return shapeTypes.createEdge(edgeBuilder.Edge());
760
762
  });
761
763
  gc();
762
764
  return edges;
763
765
  }
764
766
  const curvesAsEdgesOnSurface = (curves, geomSurf) => {
765
- const [r, gc] = occtBoundary.localGC();
767
+ const [r, gc] = shapeTypes.localGC();
766
768
  const oc = occtBoundary.getKernel().oc;
767
769
  const modifiedCurves = curves.map((curve) => {
768
770
  const edgeBuilder = r(new oc.BRepBuilderAPI_MakeEdge_30(curve.wrapped, geomSurf));
769
- return occtBoundary.createEdge(edgeBuilder.Edge());
771
+ return shapeTypes.createEdge(edgeBuilder.Edge());
770
772
  });
771
773
  gc();
772
774
  return modifiedCurves;
@@ -789,7 +791,7 @@ const stretchTransform2d = (ratio, direction, origin = [0, 0]) => {
789
791
  };
790
792
  const translationTransform2d = (translation) => {
791
793
  const oc = occtBoundary.getKernel().oc;
792
- const [r, gc] = occtBoundary.localGC();
794
+ const [r, gc] = shapeTypes.localGC();
793
795
  const rotation = new oc.gp_Trsf2d_1();
794
796
  rotation.SetTranslation_1(r(vec(translation)));
795
797
  const transform = new oc.gp_GTrsf2d_2(rotation);
@@ -798,7 +800,7 @@ const translationTransform2d = (translation) => {
798
800
  };
799
801
  const mirrorTransform2d = (centerOrDirection, origin = [0, 0], mode = "center") => {
800
802
  const oc = occtBoundary.getKernel().oc;
801
- const [r, gc] = occtBoundary.localGC();
803
+ const [r, gc] = shapeTypes.localGC();
802
804
  const rotation = new oc.gp_Trsf2d_1();
803
805
  if (mode === "center") {
804
806
  rotation.SetMirror_1(r(pnt(centerOrDirection)));
@@ -811,7 +813,7 @@ const mirrorTransform2d = (centerOrDirection, origin = [0, 0], mode = "center")
811
813
  };
812
814
  const rotateTransform2d = (angle, center = [0, 0]) => {
813
815
  const oc = occtBoundary.getKernel().oc;
814
- const [r, gc] = occtBoundary.localGC();
816
+ const [r, gc] = shapeTypes.localGC();
815
817
  const rotation = new oc.gp_Trsf2d_1();
816
818
  rotation.SetRotation(r(pnt(center)), angle);
817
819
  const transform = new oc.gp_GTrsf2d_2(rotation);
@@ -820,7 +822,7 @@ const rotateTransform2d = (angle, center = [0, 0]) => {
820
822
  };
821
823
  const scaleTransform2d = (scaleFactor, center = [0, 0]) => {
822
824
  const oc = occtBoundary.getKernel().oc;
823
- const [r, gc] = occtBoundary.localGC();
825
+ const [r, gc] = shapeTypes.localGC();
824
826
  const scaling = new oc.gp_Trsf2d_1();
825
827
  scaling.SetScale(r(pnt(center)), scaleFactor);
826
828
  const transform = new oc.gp_GTrsf2d_2(scaling);
@@ -828,7 +830,7 @@ const scaleTransform2d = (scaleFactor, center = [0, 0]) => {
828
830
  return transform;
829
831
  };
830
832
  function curvesAsEdgesOnFace(curves, face, scale2 = "original") {
831
- const [r, gc] = occtBoundary.localGC();
833
+ const [r, gc] = shapeTypes.localGC();
832
834
  const oc = occtBoundary.getKernel().oc;
833
835
  let geomSurf = r(oc.BRep_Tool.Surface_2(face.wrapped));
834
836
  const bounds = faceFns.uvBounds(face);
@@ -837,8 +839,8 @@ function curvesAsEdgesOnFace(curves, face, scale2 = "original") {
837
839
  const _vAxis = r(axis2d([0, 0], [1, 0]));
838
840
  if (scale2 === "original" && faceFns.faceGeomType(face) !== "PLANE") {
839
841
  if (faceFns.faceGeomType(face) !== "CYLINDRE")
840
- return occtBoundary.err(
841
- occtBoundary.validationError(
842
+ return errors.err(
843
+ errors.validationError(
842
844
  "UNSUPPORTED_FACE_TYPE",
843
845
  "Only planar and cylindrical faces can be unwrapped for sketching"
844
846
  )
@@ -870,11 +872,11 @@ function curvesAsEdgesOnFace(curves, face, scale2 = "original") {
870
872
  const modifiedCurves = transformCurves(curves, transformation);
871
873
  const edges = curvesAsEdgesOnSurface(modifiedCurves, geomSurf);
872
874
  gc();
873
- return occtBoundary.ok(edges);
875
+ return errors.ok(edges);
874
876
  }
875
877
  function edgeToCurve(e, face) {
876
878
  const oc = occtBoundary.getKernel().oc;
877
- const r = occtBoundary.gcWithScope();
879
+ const r = shapeTypes.gcWithScope();
878
880
  const adaptor = r(new oc.BRepAdaptor_Curve2d_2(e.wrapped, face.wrapped));
879
881
  const trimmed = new oc.Geom2d_TrimmedCurve(
880
882
  adaptor.Curve(),
@@ -905,7 +907,7 @@ function assembleWire(listOfEdges) {
905
907
  listOfEdges.forEach((e) => {
906
908
  builder.Add_1(e.wrapped);
907
909
  });
908
- return occtBoundary.createWire(builder.Wire());
910
+ return shapeTypes.createWire(builder.Wire());
909
911
  }
910
912
  class Blueprint {
911
913
  /** Ordered 2D curve segments that compose this blueprint. */
@@ -1001,7 +1003,7 @@ class Blueprint {
1001
1003
  * @returns A new rotated Blueprint.
1002
1004
  */
1003
1005
  rotate(angle, center) {
1004
- const curves = transformCurves(this.curves, rotateTransform2d(angle * planeOps.DEG2RAD, center));
1006
+ const curves = transformCurves(this.curves, rotateTransform2d(angle * vectors.DEG2RAD, center));
1005
1007
  return new Blueprint(curves);
1006
1008
  }
1007
1009
  translate(xDistOrPoint, yDist = 0) {
@@ -1047,7 +1049,7 @@ class Blueprint {
1047
1049
  */
1048
1050
  sketchOnFace(face, scaleMode) {
1049
1051
  const oc = occtBoundary.getKernel().oc;
1050
- const edges = occtBoundary.unwrap(curvesAsEdgesOnFace(this.curves, face, scaleMode));
1052
+ const edges = errors.unwrap(curvesAsEdgesOnFace(this.curves, face, scaleMode));
1051
1053
  const wire = assembleWire(edges);
1052
1054
  oc.BRepLib.BuildCurves3d_2(wire.wrapped);
1053
1055
  const wireFixer = new oc.ShapeFix_Wire_2(wire.wrapped, face.wrapped, 1e-9);
@@ -1066,7 +1068,7 @@ class Blueprint {
1066
1068
  const originPoint = origin || [...faceFns.faceCenter(face)];
1067
1069
  const originVec3 = occtBoundary.toVec3(originPoint);
1068
1070
  const sketch = this.translate(faceFns.uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
1069
- return occtBoundary.unwrap(shapeHelpers.makeFace(sketch.wire));
1071
+ return errors.unwrap(shapeHelpers.makeFace(sketch.wire));
1070
1072
  }
1071
1073
  /**
1072
1074
  * Cut a prism-shaped hole through a solid along a face using this blueprint.
@@ -1085,15 +1087,15 @@ class Blueprint {
1085
1087
  draftAngle = 0
1086
1088
  } = {}) {
1087
1089
  const oc = occtBoundary.getKernel().oc;
1088
- const gc = occtBoundary.gcWithScope();
1089
- const foundFace = occtBoundary.unwrap(helpers.getSingleFace(face, shape));
1090
+ const gc = shapeTypes.gcWithScope();
1091
+ const foundFace = errors.unwrap(helpers.getSingleFace(face, shape));
1090
1092
  const hole = this.subFace(foundFace, origin);
1091
1093
  const maker = gc(
1092
1094
  new oc.BRepFeat_MakeDPrism_1(
1093
1095
  shape.wrapped,
1094
1096
  hole.wrapped,
1095
1097
  foundFace.wrapped,
1096
- draftAngle * planeOps.DEG2RAD,
1098
+ draftAngle * vectors.DEG2RAD,
1097
1099
  0,
1098
1100
  false
1099
1101
  )
@@ -1103,11 +1105,11 @@ class Blueprint {
1103
1105
  } else {
1104
1106
  maker.PerformThruAll();
1105
1107
  }
1106
- return occtBoundary.unwrap(cast.cast(maker.Shape()));
1108
+ return errors.unwrap(cast.cast(maker.Shape()));
1107
1109
  }
1108
1110
  /** Convert the blueprint to an SVG path `d` attribute string. */
1109
1111
  toSVGPathD() {
1110
- const r = occtBoundary.gcWithScope();
1112
+ const r = shapeTypes.gcWithScope();
1111
1113
  const bp = this.clone().mirror([1, 0], [0, 0], "plane");
1112
1114
  const compatibleCurves = approximateAsSvgCompatibleCurve(bp.curves);
1113
1115
  const path = compatibleCurves.flatMap((c) => {
@@ -1,13 +1,15 @@
1
- import { c as vecScale, v as vecNormalize, h as vecCross, f as createPlane, D as DEG2RAD, R as RAD2DEG } from "./planeOps-0MoExrYA.js";
2
- import { l as makeFace, p as makeNewFaceWithinFace, b as assembleWire, A as zip } from "./shapeHelpers-CUd1Cw8j.js";
3
- import { o as ok, g as getKernel, e as err, w as computationError, a as gcWithScope, u as unwrap, S as isOk, h as toVec3, z as createFace, H as createWire, X as localGC, y as createEdge } from "./occtBoundary-DBs4sGzK.js";
4
- import { d as downcast } from "./cast-De1fNfOB.js";
5
- import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-ByF6QLtd.js";
6
- import { i as curveStartPoint, j as curveTangentAt, a as curveIsClosed } from "./curveFns-DnXGH3Rw.js";
7
- import { u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-DcvflSoj.js";
8
- import { bug } from "./core.js";
9
- import { s as samePoint$1, n as normalize2d, b as subtract2d, c as add2d, e as crossProduct2d, f as scalarMultiply2d, p as polarToCartesian, d as distance2d, r as rotate2d, h as cartesianToPolar, i as polarAngle2d, P as PRECISION_INTERSECTION } from "./helpers-CYQYjKFu.js";
10
- import { C as Curve2D, e as make2dSegmentCurve, f as approximateAsBSpline, i as isPoint2D, g as make2dCircle, h as make2dThreePointArc, j as make2dArcFromCenter, a as BoundingBox2d, v as viewbox, k as asSVG, B as Blueprint, l as make2dTangentArc, n as make2dEllipseArc, o as make2dBezierCurve, b as axis2d, p as removeDuplicatePoints } from "./Blueprint-CBvm7PL1.js";
1
+ import { q as vecScale, l as vecNormalize, d as vecCross, a as createPlane, D as DEG2RAD, R as RAD2DEG } from "./vectors-QAJQy2Yy.js";
2
+ import { l as makeFace, p as makeNewFaceWithinFace, b as assembleWire, A as zip } from "./shapeHelpers-jBD0w9FP.js";
3
+ import { l as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-EPHOk9hi.js";
4
+ import { d as downcast } from "./cast-EtXm4_Ni.js";
5
+ import { g as getKernel, a as toVec3 } from "./occtBoundary-BdGtXEUi.js";
6
+ import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-D1_u9YgM.js";
7
+ import { n as gcWithScope, q as createFace, u as createWire, x as localGC, p as createEdge } from "./shapeTypes-Drjbf_Uu.js";
8
+ import { i as curveStartPoint, j as curveTangentAt, a as curveIsClosed } from "./curveFns-CBqqsuTX.js";
9
+ import { u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-DJsu6nUY.js";
10
+ import { bug } from "./result.js";
11
+ import { s as samePoint$1, n as normalize2d, b as subtract2d, c as add2d, e as crossProduct2d, f as scalarMultiply2d, p as polarToCartesian, d as distance2d, r as rotate2d, h as cartesianToPolar, i as polarAngle2d, P as PRECISION_INTERSECTION } from "./helpers-CU9dnrkT.js";
12
+ import { C as Curve2D, e as make2dSegmentCurve, f as approximateAsBSpline, i as isPoint2D, g as make2dCircle, h as make2dThreePointArc, j as make2dArcFromCenter, a as BoundingBox2d, v as viewbox, k as asSVG, B as Blueprint, l as make2dTangentArc, n as make2dEllipseArc, o as make2dBezierCurve, b as axis2d, p as removeDuplicatePoints } from "./Blueprint-CVJ9l3MQ.js";
11
13
  function* pointsIteration(intersector) {
12
14
  const nPoints = intersector.NbPoints();
13
15
  if (!nPoints) return;