brepjs 8.8.2 → 8.8.3

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 (98) hide show
  1. package/dist/2d/curves.d.ts.map +1 -1
  2. package/dist/2d/lib/Curve2D.d.ts.map +1 -1
  3. package/dist/2d/lib/approximations.d.ts.map +1 -1
  4. package/dist/2d/lib/makeCurves.d.ts.map +1 -1
  5. package/dist/2d/lib/ocWrapper.d.ts.map +1 -1
  6. package/dist/2d.cjs +2 -2
  7. package/dist/2d.js +3 -3
  8. package/dist/Blueprint-BmFJ4caY.cjs +1439 -0
  9. package/dist/Blueprint-DsoGiJNJ.js +1440 -0
  10. package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BQk8LNmZ.cjs} +212 -127
  11. package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D5O0F3J8.js} +212 -127
  12. package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-CVM3dOTP.cjs} +210 -130
  13. package/dist/{booleanFns--Orezl-b.js → booleanFns-DOyKxL7q.js} +210 -130
  14. package/dist/brepjs.cjs +457 -304
  15. package/dist/brepjs.js +551 -398
  16. package/dist/core/disposal.d.ts +44 -3
  17. package/dist/core/disposal.d.ts.map +1 -1
  18. package/dist/core/geometryHelpers.d.ts.map +1 -1
  19. package/dist/core/kernelCall.d.ts +20 -0
  20. package/dist/core/kernelCall.d.ts.map +1 -1
  21. package/dist/core/memory.d.ts +1 -1
  22. package/dist/core/memory.d.ts.map +1 -1
  23. package/dist/core.cjs +4 -1
  24. package/dist/core.d.ts +1 -1
  25. package/dist/core.d.ts.map +1 -1
  26. package/dist/core.js +11 -8
  27. package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-DH6EwYfL.js} +1 -1
  28. package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-XAV2ywVS.cjs} +1 -1
  29. package/dist/curveFns-BHRYwxBM.js +281 -0
  30. package/dist/{curveFns-6ovDM_sR.cjs → curveFns-BsAHC3Qv.cjs} +137 -36
  31. package/dist/{drawFns-WgXeXHH1.cjs → drawFns-CsmUF97U.cjs} +181 -101
  32. package/dist/{drawFns-XwroLxdb.js → drawFns-hD05g0ZQ.js} +181 -101
  33. package/dist/faceFns-DNQss51F.cjs +358 -0
  34. package/dist/faceFns-q5CR9pOW.js +359 -0
  35. package/dist/{helpers-CRfqaW0Y.cjs → helpers-aylLv0_I.cjs} +13 -10
  36. package/dist/{helpers-CtBCzEqs.js → helpers-tNdaX01G.js} +13 -10
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/io/importFns.d.ts.map +1 -1
  40. package/dist/io.cjs +131 -63
  41. package/dist/io.js +131 -63
  42. package/dist/loft-CjEEqz2P.cjs +530 -0
  43. package/dist/loft-DTRcYrq2.js +531 -0
  44. package/dist/measurement-B6_cxjpw.cjs +200 -0
  45. package/dist/measurement-BXqFvcGh.js +201 -0
  46. package/dist/measurement.cjs +1 -1
  47. package/dist/measurement.js +1 -1
  48. package/dist/{meshFns-CPNNlpbw.cjs → meshFns-CTc1CRkF.cjs} +1 -1
  49. package/dist/{meshFns-DAmWVyEp.js → meshFns-DDFl7gLN.js} +1 -1
  50. package/dist/operations/exporterFns.d.ts.map +1 -1
  51. package/dist/operations/exporterUtils.d.ts +3 -3
  52. package/dist/operations/exporterUtils.d.ts.map +1 -1
  53. package/dist/operations/exporters.d.ts.map +1 -1
  54. package/dist/operations/extrude.d.ts.map +1 -1
  55. package/dist/operations/extrudeFns.d.ts.map +1 -1
  56. package/dist/operations/loft.d.ts.map +1 -1
  57. package/dist/operations/multiSweepFns.d.ts.map +1 -1
  58. package/dist/{operations-vN0tcoaU.js → operations-jRE2QbPo.js} +261 -166
  59. package/dist/{operations-BQ25CPI8.cjs → operations-pxjbW4Er.cjs} +261 -166
  60. package/dist/operations.cjs +2 -2
  61. package/dist/operations.js +2 -2
  62. package/dist/query/shapeDistanceFilter.d.ts.map +1 -1
  63. package/dist/query.cjs +66 -14
  64. package/dist/query.js +67 -15
  65. package/dist/{shapeFns-C785aeVn.cjs → shapeFns-D4CRxxmF.cjs} +61 -7
  66. package/dist/{shapeFns-ClpALED4.js → shapeFns-DNnBK8fG.js} +61 -7
  67. package/dist/{shapeTypes-DnwCo942.js → shapeTypes-Bi_9RZa2.js} +50 -19
  68. package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-CWuX602K.cjs} +32 -1
  69. package/dist/sketching/CompoundSketch.d.ts.map +1 -1
  70. package/dist/sketching/Sketch.d.ts.map +1 -1
  71. package/dist/sketching/Sketcher.d.ts.map +1 -1
  72. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  73. package/dist/sketching/cannedSketches.d.ts.map +1 -1
  74. package/dist/sketching/draw.d.ts.map +1 -1
  75. package/dist/sketching.cjs +2 -2
  76. package/dist/sketching.js +2 -2
  77. package/dist/surfaceBuilders-CLal3WlK.cjs +429 -0
  78. package/dist/surfaceBuilders-W9Y25CIb.js +430 -0
  79. package/dist/topology/curveBuilders.d.ts.map +1 -1
  80. package/dist/topology/shapeFns.d.ts.map +1 -1
  81. package/dist/topology/solidBuilders.d.ts.map +1 -1
  82. package/dist/topology/surfaceBuilders.d.ts.map +1 -1
  83. package/dist/{topology-CqyxpmEh.js → topology-CMM6vAzx.js} +6 -6
  84. package/dist/{topology-zG8maSDK.cjs → topology-CNw-wsmG.cjs} +6 -6
  85. package/dist/topology.cjs +6 -6
  86. package/dist/topology.js +6 -6
  87. package/package.json +4 -1
  88. package/dist/Blueprint-BmbNUnGI.cjs +0 -1185
  89. package/dist/Blueprint-C-JJkkwL.js +0 -1186
  90. package/dist/curveFns-BhQECv8e.js +0 -180
  91. package/dist/faceFns-3PDjBeW7.js +0 -272
  92. package/dist/faceFns-CxaLWOjc.cjs +0 -271
  93. package/dist/loft-CVb-IjEI.cjs +0 -372
  94. package/dist/loft-DMFjK6lk.js +0 -373
  95. package/dist/measurement-CecYIt3s.cjs +0 -134
  96. package/dist/measurement-DHDLAH7-.js +0 -135
  97. package/dist/surfaceBuilders-CC0ZQGix.cjs +0 -289
  98. package/dist/surfaceBuilders-CrJtFu2a.js +0 -290
@@ -1,6 +1,51 @@
1
1
  "use strict";
2
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
3
+ var __typeError = (msg) => {
4
+ throw TypeError(msg);
5
+ };
6
+ var __using = (stack, value, async) => {
7
+ if (value != null) {
8
+ if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
9
+ var dispose, inner;
10
+ if (async) dispose = value[__knownSymbol("asyncDispose")];
11
+ if (dispose === void 0) {
12
+ dispose = value[__knownSymbol("dispose")];
13
+ if (async) inner = dispose;
14
+ }
15
+ if (typeof dispose !== "function") __typeError("Object not disposable");
16
+ if (inner) dispose = function() {
17
+ try {
18
+ inner.call(this);
19
+ } catch (e) {
20
+ return Promise.reject(e);
21
+ }
22
+ };
23
+ stack.push([async, dispose, value]);
24
+ } else if (async) {
25
+ stack.push([async]);
26
+ }
27
+ return value;
28
+ };
29
+ var __callDispose = (stack, error, hasError) => {
30
+ var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
31
+ return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
32
+ };
33
+ var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
34
+ var next = (it) => {
35
+ while (it = stack.pop()) {
36
+ try {
37
+ var result = it[1] && it[1].call(it[2]);
38
+ if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
39
+ } catch (e) {
40
+ fail(e);
41
+ }
42
+ }
43
+ if (hasError) throw error;
44
+ };
45
+ return next();
46
+ };
2
47
  const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
3
- const shapeTypes = require("./shapeTypes-CIijJxCz.cjs");
48
+ const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
4
49
  const errors = require("./errors-NNmTtM5u.cjs");
5
50
  let CURVE_TYPES_MAP = null;
6
51
  const getCurveTypesMap = (refresh) => {
@@ -41,55 +86,111 @@ function mapParam(adaptor, t) {
41
86
  return first + (last - first) * t;
42
87
  }
43
88
  function getCurveType(shape) {
44
- const r = shapeTypes.gcWithScope();
45
- const adaptor = r(getAdaptor(shape));
46
- const technicalType = adaptor.GetType && adaptor.GetType();
47
- return errors.unwrap(findCurveType(technicalType));
89
+ var _stack = [];
90
+ try {
91
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
92
+ const adaptor = scope.register(getAdaptor(shape));
93
+ const technicalType = adaptor.GetType && adaptor.GetType();
94
+ return errors.unwrap(findCurveType(technicalType));
95
+ } catch (_) {
96
+ var _error = _, _hasError = true;
97
+ } finally {
98
+ __callDispose(_stack, _error, _hasError);
99
+ }
48
100
  }
49
101
  function curveStartPoint(shape) {
50
- const r = shapeTypes.gcWithScope();
51
- const adaptor = r(getAdaptor(shape));
52
- const pnt = r(adaptor.Value(adaptor.FirstParameter()));
53
- return [pnt.X(), pnt.Y(), pnt.Z()];
102
+ var _stack = [];
103
+ try {
104
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
105
+ const adaptor = scope.register(getAdaptor(shape));
106
+ const pnt = scope.register(adaptor.Value(adaptor.FirstParameter()));
107
+ return [pnt.X(), pnt.Y(), pnt.Z()];
108
+ } catch (_) {
109
+ var _error = _, _hasError = true;
110
+ } finally {
111
+ __callDispose(_stack, _error, _hasError);
112
+ }
54
113
  }
55
114
  function curveEndPoint(shape) {
56
- const r = shapeTypes.gcWithScope();
57
- const adaptor = r(getAdaptor(shape));
58
- const pnt = r(adaptor.Value(adaptor.LastParameter()));
59
- return [pnt.X(), pnt.Y(), pnt.Z()];
115
+ var _stack = [];
116
+ try {
117
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
118
+ const adaptor = scope.register(getAdaptor(shape));
119
+ const pnt = scope.register(adaptor.Value(adaptor.LastParameter()));
120
+ return [pnt.X(), pnt.Y(), pnt.Z()];
121
+ } catch (_) {
122
+ var _error = _, _hasError = true;
123
+ } finally {
124
+ __callDispose(_stack, _error, _hasError);
125
+ }
60
126
  }
61
127
  function curvePointAt(shape, position = 0.5) {
62
- const r = shapeTypes.gcWithScope();
63
- const adaptor = r(getAdaptor(shape));
64
- const pnt = r(adaptor.Value(mapParam(adaptor, position)));
65
- return [pnt.X(), pnt.Y(), pnt.Z()];
128
+ var _stack = [];
129
+ try {
130
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
131
+ const adaptor = scope.register(getAdaptor(shape));
132
+ const pnt = scope.register(adaptor.Value(mapParam(adaptor, position)));
133
+ return [pnt.X(), pnt.Y(), pnt.Z()];
134
+ } catch (_) {
135
+ var _error = _, _hasError = true;
136
+ } finally {
137
+ __callDispose(_stack, _error, _hasError);
138
+ }
66
139
  }
67
140
  function curveTangentAt(shape, position = 0.5) {
68
- const oc = occtBoundary.getKernel().oc;
69
- const r = shapeTypes.gcWithScope();
70
- const adaptor = r(getAdaptor(shape));
71
- const param = mapParam(adaptor, position);
72
- const tmpPnt = r(new oc.gp_Pnt_1());
73
- const tmpVec = r(new oc.gp_Vec_1());
74
- adaptor.D1(param, tmpPnt, tmpVec);
75
- return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
141
+ var _stack = [];
142
+ try {
143
+ const oc = occtBoundary.getKernel().oc;
144
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
145
+ const adaptor = scope.register(getAdaptor(shape));
146
+ const param = mapParam(adaptor, position);
147
+ const tmpPnt = scope.register(new oc.gp_Pnt_1());
148
+ const tmpVec = scope.register(new oc.gp_Vec_1());
149
+ adaptor.D1(param, tmpPnt, tmpVec);
150
+ return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
151
+ } catch (_) {
152
+ var _error = _, _hasError = true;
153
+ } finally {
154
+ __callDispose(_stack, _error, _hasError);
155
+ }
76
156
  }
77
157
  function curveLength(shape) {
78
- const oc = occtBoundary.getKernel().oc;
79
- const r = shapeTypes.gcWithScope();
80
- const props = r(new oc.GProp_GProps_1());
81
- oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
82
- return props.Mass();
158
+ var _stack = [];
159
+ try {
160
+ const oc = occtBoundary.getKernel().oc;
161
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
162
+ const props = scope.register(new oc.GProp_GProps_1());
163
+ oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
164
+ return props.Mass();
165
+ } catch (_) {
166
+ var _error = _, _hasError = true;
167
+ } finally {
168
+ __callDispose(_stack, _error, _hasError);
169
+ }
83
170
  }
84
171
  function curveIsClosed(shape) {
85
- const r = shapeTypes.gcWithScope();
86
- const adaptor = r(getAdaptor(shape));
87
- return adaptor.IsClosed();
172
+ var _stack = [];
173
+ try {
174
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
175
+ const adaptor = scope.register(getAdaptor(shape));
176
+ return adaptor.IsClosed();
177
+ } catch (_) {
178
+ var _error = _, _hasError = true;
179
+ } finally {
180
+ __callDispose(_stack, _error, _hasError);
181
+ }
88
182
  }
89
183
  function curveIsPeriodic(shape) {
90
- const r = shapeTypes.gcWithScope();
91
- const adaptor = r(getAdaptor(shape));
92
- return adaptor.IsPeriodic();
184
+ var _stack = [];
185
+ try {
186
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
187
+ const adaptor = scope.register(getAdaptor(shape));
188
+ return adaptor.IsPeriodic();
189
+ } catch (_) {
190
+ var _error = _, _hasError = true;
191
+ } finally {
192
+ __callDispose(_stack, _error, _hasError);
193
+ }
93
194
  }
94
195
  function curvePeriod(shape) {
95
196
  const adaptor = getAdaptor(shape);
@@ -1,20 +1,65 @@
1
1
  "use strict";
2
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
3
+ var __typeError = (msg) => {
4
+ throw TypeError(msg);
5
+ };
6
+ var __using = (stack, value, async) => {
7
+ if (value != null) {
8
+ if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
9
+ var dispose, inner;
10
+ if (async) dispose = value[__knownSymbol("asyncDispose")];
11
+ if (dispose === void 0) {
12
+ dispose = value[__knownSymbol("dispose")];
13
+ if (async) inner = dispose;
14
+ }
15
+ if (typeof dispose !== "function") __typeError("Object not disposable");
16
+ if (inner) dispose = function() {
17
+ try {
18
+ inner.call(this);
19
+ } catch (e) {
20
+ return Promise.reject(e);
21
+ }
22
+ };
23
+ stack.push([async, dispose, value]);
24
+ } else if (async) {
25
+ stack.push([async]);
26
+ }
27
+ return value;
28
+ };
29
+ var __callDispose = (stack, error, hasError) => {
30
+ var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
31
+ return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
32
+ };
33
+ var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
34
+ var next = (it) => {
35
+ while (it = stack.pop()) {
36
+ try {
37
+ var result2 = it[1] && it[1].call(it[2]);
38
+ if (it[0]) return Promise.resolve(result2).then(next, (e) => (fail(e), next()));
39
+ } catch (e) {
40
+ fail(e);
41
+ }
42
+ }
43
+ if (hasError) throw error;
44
+ };
45
+ return next();
46
+ };
2
47
  const errors = require("./errors-NNmTtM5u.cjs");
3
48
  const vectors = require("./vectors-CGLqemPY.cjs");
4
49
  const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
5
50
  const vecOps = require("./vecOps-CjRL1jau.cjs");
6
- const boolean2D = require("./boolean2D-q5FOdOQW.cjs");
7
- const faceFns = require("./faceFns-CxaLWOjc.cjs");
8
- const curveFns = require("./curveFns-6ovDM_sR.cjs");
9
- const surfaceBuilders = require("./surfaceBuilders-CC0ZQGix.cjs");
10
- const shapeTypes = require("./shapeTypes-CIijJxCz.cjs");
11
- const Blueprint = require("./Blueprint-BmbNUnGI.cjs");
51
+ const boolean2D = require("./boolean2D-BQk8LNmZ.cjs");
52
+ const faceFns = require("./faceFns-DNQss51F.cjs");
53
+ const curveFns = require("./curveFns-BsAHC3Qv.cjs");
54
+ const surfaceBuilders = require("./surfaceBuilders-CLal3WlK.cjs");
55
+ const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
56
+ const Blueprint = require("./Blueprint-BmFJ4caY.cjs");
12
57
  const result = require("./result.cjs");
13
- const helpers = require("./helpers-CRfqaW0Y.cjs");
14
- const shapeFns = require("./shapeFns-C785aeVn.cjs");
15
- const loft = require("./loft-CVb-IjEI.cjs");
58
+ const helpers = require("./helpers-aylLv0_I.cjs");
59
+ const shapeFns = require("./shapeFns-D4CRxxmF.cjs");
60
+ const loft = require("./loft-CjEEqz2P.cjs");
16
61
  const opentype = require("opentype.js");
17
- const cornerFinder = require("./cornerFinder-v4un1Fr9.cjs");
62
+ const cornerFinder = require("./cornerFinder-XAV2ywVS.cjs");
18
63
  const stitchCurves = (curves, precision = 1e-7) => {
19
64
  const startPoints = new boolean2D.Flatbush(curves.length);
20
65
  curves.forEach((c) => {
@@ -315,8 +360,9 @@ class Sketcher {
315
360
  }
316
361
  /** Draw a smooth cubic Bezier spline to an absolute end point, blending tangent with the previous edge. */
317
362
  smoothSplineTo(end, config) {
318
- const [r, gc] = shapeTypes.localGC();
363
+ var _stack = [];
319
364
  try {
365
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
320
366
  const { endTangent, startTangent, startFactor, endFactor } = boolean2D.defaultsSplineOptions(config);
321
367
  const endPoint = vectors.planeToWorld(this.plane, end);
322
368
  const previousEdge = this.pendingEdges.length ? this.pendingEdges[this.pendingEdges.length - 1] : null;
@@ -329,17 +375,14 @@ class Sketcher {
329
375
  startPoleDirection = vectors.planeToWorld(this.plane, [1, 0]);
330
376
  } else if (curveFns.getCurveType(previousEdge) === "BEZIER_CURVE") {
331
377
  const oc = occtBoundary.getKernel().oc;
332
- const adaptor = r(new oc.BRepAdaptor_Curve_2(previousEdge.wrapped));
378
+ const adaptor = scope.register(new oc.BRepAdaptor_Curve_2(previousEdge.wrapped));
333
379
  const rawCurve = adaptor.Bezier().get();
334
380
  const previousPole = occtBoundary.toVec3(rawCurve.Pole(rawCurve.NbPoles() - 1));
335
381
  startPoleDirection = vecOps.vecSub(this.pointer, previousPole);
336
382
  } else {
337
383
  startPoleDirection = curveFns.curveTangentAt(previousEdge, 1);
338
384
  }
339
- const poleDistance = vecOps.vecScale(
340
- vecOps.vecNormalize(startPoleDirection),
341
- startFactor * defaultDistance
342
- );
385
+ const poleDistance = vecOps.vecScale(vecOps.vecNormalize(startPoleDirection), startFactor * defaultDistance);
343
386
  const startControl = vecOps.vecAdd(this.pointer, poleDistance);
344
387
  let endPoleDirection;
345
388
  if (endTangent === "symmetric") {
@@ -354,8 +397,10 @@ class Sketcher {
354
397
  );
355
398
  this._updatePointer(endPoint);
356
399
  return this;
400
+ } catch (_) {
401
+ var _error = _, _hasError = true;
357
402
  } finally {
358
- gc();
403
+ __callDispose(_stack, _error, _hasError);
359
404
  }
360
405
  }
361
406
  /** Draw a smooth cubic Bezier spline to a relative end point, blending tangent with the previous edge. */
@@ -408,32 +453,44 @@ class Sketcher {
408
453
  }
409
454
  }
410
455
  const guessFaceFromWires = (wires) => {
411
- const oc = occtBoundary.getKernel().oc;
412
- const [r, gc] = shapeTypes.localGC();
413
- const faceBuilder = r(
414
- new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
415
- );
416
- wires.forEach((wire, wireIndex) => {
417
- shapeFns.getEdges(wire).forEach((edge) => {
418
- faceBuilder.Add_1(edge.wrapped, oc.GeomAbs_Shape.GeomAbs_C0, wireIndex === 0);
456
+ var _stack = [];
457
+ try {
458
+ const oc = occtBoundary.getKernel().oc;
459
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
460
+ const faceBuilder = scope.register(
461
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
462
+ );
463
+ wires.forEach((wire, wireIndex) => {
464
+ shapeFns.getEdges(wire).forEach((edge) => {
465
+ faceBuilder.Add_1(edge.wrapped, oc.GeomAbs_Shape.GeomAbs_C0, wireIndex === 0);
466
+ });
419
467
  });
420
- });
421
- const progress = r(new oc.Message_ProgressRange_1());
422
- faceBuilder.Build(progress);
423
- const newFace = errors.unwrap(faceFns.cast(faceBuilder.Shape()));
424
- gc();
425
- if (!shapeTypes.isFace(newFace)) {
426
- result.bug("guessFaceFromWires", "Failed to create a face");
427
- }
428
- return newFace;
468
+ const progress = scope.register(new oc.Message_ProgressRange_1());
469
+ faceBuilder.Build(progress);
470
+ const newFace = errors.unwrap(faceFns.cast(faceBuilder.Shape()));
471
+ if (!shapeTypes.isFace(newFace)) {
472
+ result.bug("guessFaceFromWires", "Failed to create a face");
473
+ }
474
+ return newFace;
475
+ } catch (_) {
476
+ var _error = _, _hasError = true;
477
+ } finally {
478
+ __callDispose(_stack, _error, _hasError);
479
+ }
429
480
  };
430
481
  const fixWire = (wire, baseFace) => {
431
- const oc = occtBoundary.getKernel().oc;
432
- const [r, gc] = shapeTypes.localGC();
433
- const wireFixer = r(new oc.ShapeFix_Wire_2(wire.wrapped, baseFace.wrapped, 1e-9));
434
- wireFixer.FixEdgeCurves();
435
- gc();
436
- return wire;
482
+ var _stack = [];
483
+ try {
484
+ const oc = occtBoundary.getKernel().oc;
485
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
486
+ const wireFixer = scope.register(new oc.ShapeFix_Wire_2(wire.wrapped, baseFace.wrapped, 1e-9));
487
+ wireFixer.FixEdgeCurves();
488
+ return wire;
489
+ } catch (_) {
490
+ var _error = _, _hasError = true;
491
+ } finally {
492
+ __callDispose(_stack, _error, _hasError);
493
+ }
437
494
  };
438
495
  const faceFromWires = (wires) => {
439
496
  let baseFace;
@@ -511,7 +568,6 @@ class CompoundSketch {
511
568
  twistAngle,
512
569
  origin
513
570
  } = {}) {
514
- const [, gc] = shapeTypes.localGC();
515
571
  const rawVec = extrusionDirection ? occtBoundary.toVec3(extrusionDirection) : this.outerSketch.defaultDirection;
516
572
  const normVec = vecOps.vecNormalize(rawVec);
517
573
  const extrusionVec = vecOps.vecScale(normVec, extrusionDistance);
@@ -542,7 +598,6 @@ class CompoundSketch {
542
598
  } else {
543
599
  result2 = loft.basicFaceExtrusion(this.face(), extrusionVec);
544
600
  }
545
- gc();
546
601
  return result2;
547
602
  }
548
603
  /**
@@ -686,22 +741,28 @@ const sketchFaceOffset = (face, offset2) => {
686
741
  return sketch;
687
742
  };
688
743
  const sketchParametricFunction = (func, planeConfig = {}, { pointsCount = 400, start = 0, stop = 1 } = {}, approximationConfig = {}) => {
689
- const [r, gc] = shapeTypes.localGC();
690
- const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : vectors.resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
691
- const stepSize = (stop - start) / pointsCount;
692
- const points = [...Array(pointsCount + 1).keys()].map((t) => {
693
- const point = func(start + t * stepSize);
694
- return vectors.planeToWorld(plane, point);
695
- });
696
- const wire = errors.unwrap(
697
- surfaceBuilders.assembleWire([r(errors.unwrap(surfaceBuilders.makeBSplineApproximation(points, approximationConfig)))])
698
- );
699
- const sketch = new boolean2D.Sketch(wire, {
700
- defaultOrigin: [...plane.origin],
701
- defaultDirection: [...plane.zDir]
702
- });
703
- gc();
704
- return sketch;
744
+ var _stack = [];
745
+ try {
746
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
747
+ const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : vectors.resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
748
+ const stepSize = (stop - start) / pointsCount;
749
+ const points = [...Array(pointsCount + 1).keys()].map((t) => {
750
+ const point = func(start + t * stepSize);
751
+ return vectors.planeToWorld(plane, point);
752
+ });
753
+ const wire = errors.unwrap(
754
+ surfaceBuilders.assembleWire([scope.register(errors.unwrap(surfaceBuilders.makeBSplineApproximation(points, approximationConfig)))])
755
+ );
756
+ const sketch = new boolean2D.Sketch(wire, {
757
+ defaultOrigin: [...plane.origin],
758
+ defaultDirection: [...plane.zDir]
759
+ });
760
+ return sketch;
761
+ } catch (_) {
762
+ var _error = _, _hasError = true;
763
+ } finally {
764
+ __callDispose(_stack, _error, _hasError);
765
+ }
705
766
  };
706
767
  const sketchHelix = (pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1], lefthand = false) => {
707
768
  const centerVec3 = occtBoundary.toVec3(center);
@@ -1150,31 +1211,38 @@ const getEdgesFromOc = (shape) => {
1150
1211
  return shapeFns.getEdges(shapeTypes.castShape(shape));
1151
1212
  };
1152
1213
  function makeProjectedEdges(shape, camera, withHiddenLines = true) {
1153
- const oc = occtBoundary.getKernel().oc;
1154
- const r = shapeTypes.gcWithScope();
1155
- const hiddenLineRemoval = r(new oc.HLRBRep_Algo_1());
1156
- hiddenLineRemoval.Add_2(shape.wrapped, 0);
1157
- const ax2 = r(occtBoundary.makeOcAx2(camera.position, camera.direction, camera.xAxis));
1158
- const projector = r(new oc.HLRAlgo_Projector_2(ax2));
1159
- hiddenLineRemoval.Projector_1(projector);
1160
- hiddenLineRemoval.Update();
1161
- hiddenLineRemoval.Hide_1();
1162
- const hlrShapes = r(
1163
- new oc.HLRBRep_HLRToShape(r(new oc.Handle_HLRBRep_Algo_2(hiddenLineRemoval)))
1164
- );
1165
- const visible = [
1166
- ...getEdgesFromOc(hlrShapes.VCompound_1()),
1167
- ...getEdgesFromOc(hlrShapes.Rg1LineVCompound_1()),
1168
- ...getEdgesFromOc(hlrShapes.OutLineVCompound_1())
1169
- ];
1170
- visible.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1171
- const hidden = withHiddenLines ? [
1172
- ...getEdgesFromOc(hlrShapes.HCompound_1()),
1173
- ...getEdgesFromOc(hlrShapes.Rg1LineHCompound_1()),
1174
- ...getEdgesFromOc(hlrShapes.OutLineHCompound_1())
1175
- ] : [];
1176
- hidden.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1177
- return { visible, hidden };
1214
+ var _stack = [];
1215
+ try {
1216
+ const oc = occtBoundary.getKernel().oc;
1217
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
1218
+ const hiddenLineRemoval = scope.register(new oc.HLRBRep_Algo_1());
1219
+ hiddenLineRemoval.Add_2(shape.wrapped, 0);
1220
+ const ax2 = scope.register(occtBoundary.makeOcAx2(camera.position, camera.direction, camera.xAxis));
1221
+ const projector = scope.register(new oc.HLRAlgo_Projector_2(ax2));
1222
+ hiddenLineRemoval.Projector_1(projector);
1223
+ hiddenLineRemoval.Update();
1224
+ hiddenLineRemoval.Hide_1();
1225
+ const hlrShapes = scope.register(
1226
+ new oc.HLRBRep_HLRToShape(scope.register(new oc.Handle_HLRBRep_Algo_2(hiddenLineRemoval)))
1227
+ );
1228
+ const visible = [
1229
+ ...getEdgesFromOc(hlrShapes.VCompound_1()),
1230
+ ...getEdgesFromOc(hlrShapes.Rg1LineVCompound_1()),
1231
+ ...getEdgesFromOc(hlrShapes.OutLineVCompound_1())
1232
+ ];
1233
+ visible.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1234
+ const hidden = withHiddenLines ? [
1235
+ ...getEdgesFromOc(hlrShapes.HCompound_1()),
1236
+ ...getEdgesFromOc(hlrShapes.Rg1LineHCompound_1()),
1237
+ ...getEdgesFromOc(hlrShapes.OutLineHCompound_1())
1238
+ ] : [];
1239
+ hidden.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1240
+ return { visible, hidden };
1241
+ } catch (_) {
1242
+ var _error = _, _hasError = true;
1243
+ } finally {
1244
+ __callDispose(_stack, _error, _hasError);
1245
+ }
1178
1246
  }
1179
1247
  function createCamera(position = [0, 0, 0], direction = [0, 0, 1], xAxis) {
1180
1248
  const dirLength = vecOps.vecLength(direction);
@@ -1498,15 +1566,21 @@ const drawParametricFunction = (func, { pointsCount = 400, start = 0, stop = 1,
1498
1566
  return drawPointsInterpolation(points, approximationConfig, { closeShape });
1499
1567
  };
1500
1568
  const edgesToDrawing = (edges) => {
1501
- const [r, gc] = shapeTypes.localGC();
1502
- const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
1503
- const planeFace = r(errors.unwrap(surfaceBuilders.makeFace(planeSketch.wire)));
1504
- const curves = edges.map((e) => Blueprint.edgeToCurve(e, planeFace));
1505
- gc();
1506
- const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
1507
- if (stitchedCurves.length === 0) return new Drawing();
1508
- if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1509
- return new Drawing(new boolean2D.Blueprints(stitchedCurves));
1569
+ var _stack = [];
1570
+ try {
1571
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
1572
+ const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
1573
+ const planeFace = scope.register(errors.unwrap(surfaceBuilders.makeFace(planeSketch.wire)));
1574
+ const curves = edges.map((e) => Blueprint.edgeToCurve(e, planeFace));
1575
+ const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
1576
+ if (stitchedCurves.length === 0) return new Drawing();
1577
+ if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1578
+ return new Drawing(new boolean2D.Blueprints(stitchedCurves));
1579
+ } catch (_) {
1580
+ var _error = _, _hasError = true;
1581
+ } finally {
1582
+ __callDispose(_stack, _error, _hasError);
1583
+ }
1510
1584
  };
1511
1585
  function drawProjection(shape, projectionCamera = "front") {
1512
1586
  let camera;
@@ -1522,15 +1596,21 @@ function drawProjection(shape, projectionCamera = "front") {
1522
1596
  };
1523
1597
  }
1524
1598
  function drawFaceOutline(face) {
1525
- const [r, gc] = shapeTypes.localGC();
1526
- const clonedFace = r(shapeTypes.createFace(errors.unwrap(faceFns.downcast(face.wrapped))));
1527
- const faceOuterWire = r(faceFns.outerWire(clonedFace));
1528
- const curves = shapeFns.getEdges(faceOuterWire).map((e) => Blueprint.edgeToCurve(e, face));
1529
- gc();
1530
- const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
1531
- if (stitchedCurves.length === 0) return new Drawing();
1532
- if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1533
- return new Drawing(new boolean2D.Blueprints(stitchedCurves));
1599
+ var _stack = [];
1600
+ try {
1601
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
1602
+ const clonedFace = scope.register(shapeTypes.createFace(errors.unwrap(faceFns.downcast(face.wrapped))));
1603
+ const faceOuterWire = scope.register(faceFns.outerWire(clonedFace));
1604
+ const curves = shapeFns.getEdges(faceOuterWire).map((e) => Blueprint.edgeToCurve(e, face));
1605
+ const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
1606
+ if (stitchedCurves.length === 0) return new Drawing();
1607
+ if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1608
+ return new Drawing(new boolean2D.Blueprints(stitchedCurves));
1609
+ } catch (_) {
1610
+ var _error = _, _hasError = true;
1611
+ } finally {
1612
+ __callDispose(_stack, _error, _hasError);
1613
+ }
1534
1614
  }
1535
1615
  function sketchExtrude(sketch, height, config) {
1536
1616
  return sketch.extrude(height, config);