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,16 +1,61 @@
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 vectors = require("./vectors-CGLqemPY.cjs");
3
48
  const errors = require("./errors-NNmTtM5u.cjs");
4
- const faceFns = require("./faceFns-CxaLWOjc.cjs");
49
+ const faceFns = require("./faceFns-DNQss51F.cjs");
5
50
  const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
6
51
  const vecOps = require("./vecOps-CjRL1jau.cjs");
7
- const loft = require("./loft-CVb-IjEI.cjs");
8
- const shapeTypes = require("./shapeTypes-CIijJxCz.cjs");
9
- const curveFns = require("./curveFns-6ovDM_sR.cjs");
10
- const surfaceBuilders = require("./surfaceBuilders-CC0ZQGix.cjs");
52
+ const loft = require("./loft-CjEEqz2P.cjs");
53
+ const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
54
+ const curveFns = require("./curveFns-BsAHC3Qv.cjs");
55
+ const surfaceBuilders = require("./surfaceBuilders-CLal3WlK.cjs");
11
56
  const result = require("./result.cjs");
12
- const helpers = require("./helpers-CRfqaW0Y.cjs");
13
- const Blueprint = require("./Blueprint-BmbNUnGI.cjs");
57
+ const helpers = require("./helpers-aylLv0_I.cjs");
58
+ const Blueprint = require("./Blueprint-BmFJ4caY.cjs");
14
59
  function* pointsIteration(intersector) {
15
60
  const nPoints = intersector.NbPoints();
16
61
  if (!nPoints) return;
@@ -20,56 +65,77 @@ function* pointsIteration(intersector) {
20
65
  }
21
66
  }
22
67
  function* commonSegmentsIteration(intersector) {
23
- const nSegments = intersector.NbSegments();
24
- if (!nSegments) return;
25
- const oc = occtBoundary.getKernel().oc;
26
- const r = shapeTypes.gcWithScope();
27
- for (let i = 1; i <= nSegments; i++) {
28
- const h1 = new oc.Handle_Geom2d_Curve_1();
29
- const h2 = r(new oc.Handle_Geom2d_Curve_1());
30
- try {
31
- intersector.Segment(i, h1, h2);
32
- } catch {
33
- continue;
68
+ var _stack = [];
69
+ try {
70
+ const nSegments = intersector.NbSegments();
71
+ if (!nSegments) return;
72
+ const oc = occtBoundary.getKernel().oc;
73
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
74
+ for (let i = 1; i <= nSegments; i++) {
75
+ const h1 = new oc.Handle_Geom2d_Curve_1();
76
+ const h2 = scope.register(new oc.Handle_Geom2d_Curve_1());
77
+ try {
78
+ intersector.Segment(i, h1, h2);
79
+ } catch {
80
+ continue;
81
+ }
82
+ yield new Blueprint.Curve2D(h1);
34
83
  }
35
- yield new Blueprint.Curve2D(h1);
84
+ } catch (_) {
85
+ var _error = _, _hasError = true;
86
+ } finally {
87
+ __callDispose(_stack, _error, _hasError);
36
88
  }
37
89
  }
38
90
  const intersectCurves = (first, second, precision = 1e-9) => {
39
- if (first.boundingBox.isOut(second.boundingBox))
40
- return errors.ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
41
- const oc = occtBoundary.getKernel().oc;
42
- const r = shapeTypes.gcWithScope();
43
- const intersector = r(new oc.Geom2dAPI_InterCurveCurve_1());
44
- let intersections;
45
- let commonSegments;
91
+ var _stack = [];
46
92
  try {
47
- intersector.Init_1(first.wrapped, second.wrapped, precision);
48
- intersections = Array.from(pointsIteration(intersector));
49
- commonSegments = Array.from(commonSegmentsIteration(intersector));
50
- } catch (e) {
51
- return errors.err(errors.computationError("INTERSECTION_FAILED", "Intersections failed between curves", e));
52
- }
53
- const segmentsAsPoints = commonSegments.filter((c) => helpers.samePoint(c.firstPoint, c.lastPoint, precision)).map((c) => c.firstPoint);
54
- if (segmentsAsPoints.length) {
55
- intersections.push(...segmentsAsPoints);
56
- commonSegments = commonSegments.filter((c) => !helpers.samePoint(c.firstPoint, c.lastPoint, precision));
57
- }
58
- const commonSegmentsPoints = commonSegments.flatMap((c) => [c.firstPoint, c.lastPoint]);
59
- return errors.ok({ intersections, commonSegments, commonSegmentsPoints });
93
+ if (first.boundingBox.isOut(second.boundingBox))
94
+ return errors.ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
95
+ const oc = occtBoundary.getKernel().oc;
96
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
97
+ const intersector = scope.register(new oc.Geom2dAPI_InterCurveCurve_1());
98
+ let intersections;
99
+ let commonSegments;
100
+ try {
101
+ intersector.Init_1(first.wrapped, second.wrapped, precision);
102
+ intersections = Array.from(pointsIteration(intersector));
103
+ commonSegments = Array.from(commonSegmentsIteration(intersector));
104
+ } catch (e) {
105
+ return errors.err(errors.computationError("INTERSECTION_FAILED", "Intersections failed between curves", e));
106
+ }
107
+ const segmentsAsPoints = commonSegments.filter((c) => helpers.samePoint(c.firstPoint, c.lastPoint, precision)).map((c) => c.firstPoint);
108
+ if (segmentsAsPoints.length) {
109
+ intersections.push(...segmentsAsPoints);
110
+ commonSegments = commonSegments.filter((c) => !helpers.samePoint(c.firstPoint, c.lastPoint, precision));
111
+ }
112
+ const commonSegmentsPoints = commonSegments.flatMap((c) => [c.firstPoint, c.lastPoint]);
113
+ return errors.ok({ intersections, commonSegments, commonSegmentsPoints });
114
+ } catch (_) {
115
+ var _error = _, _hasError = true;
116
+ } finally {
117
+ __callDispose(_stack, _error, _hasError);
118
+ }
60
119
  };
61
120
  const selfIntersections = (curve, precision = 1e-9) => {
62
- const oc = occtBoundary.getKernel().oc;
63
- const r = shapeTypes.gcWithScope();
64
- const intersector = r(new oc.Geom2dAPI_InterCurveCurve_1());
65
- let intersections;
121
+ var _stack = [];
66
122
  try {
67
- intersector.Init_1(curve.wrapped, curve.wrapped, precision);
68
- intersections = Array.from(pointsIteration(intersector));
69
- } catch (e) {
70
- return errors.err(errors.computationError("SELF_INTERSECTION_FAILED", "Self intersection failed", e));
123
+ const oc = occtBoundary.getKernel().oc;
124
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
125
+ const intersector = scope.register(new oc.Geom2dAPI_InterCurveCurve_1());
126
+ let intersections;
127
+ try {
128
+ intersector.Init_1(curve.wrapped, curve.wrapped, precision);
129
+ intersections = Array.from(pointsIteration(intersector));
130
+ } catch (e) {
131
+ return errors.err(errors.computationError("SELF_INTERSECTION_FAILED", "Self intersection failed", e));
132
+ }
133
+ return errors.ok(intersections);
134
+ } catch (_) {
135
+ var _error = _, _hasError = true;
136
+ } finally {
137
+ __callDispose(_stack, _error, _hasError);
71
138
  }
72
- return errors.ok(intersections);
73
139
  };
74
140
  const offsetEndPoints = (firstPoint, lastPoint, offset) => {
75
141
  const tangent = helpers.normalize2d(helpers.subtract2d(lastPoint, firstPoint));
@@ -81,58 +147,65 @@ const offsetEndPoints = (firstPoint, lastPoint, offset) => {
81
147
  };
82
148
  };
83
149
  const make2dOffset = (curve, offset) => {
84
- const r = shapeTypes.gcWithScope();
85
- const curveType = curve.geomType;
86
- if (curveType === "CIRCLE") {
87
- const circle = r(r(curve.adaptor()).Circle());
88
- const radius = circle.Radius();
89
- const orientationCorrection = circle.IsDirect() ? 1 : -1;
90
- const orientedOffset = offset * orientationCorrection;
91
- const newRadius = Number(radius) + orientedOffset;
92
- if (newRadius < 1e-10) {
93
- const centerPos = r(circle.Location());
94
- const center = [centerPos.X(), centerPos.Y()];
95
- const offsetViaCenter = (point) => {
96
- const [x, y] = helpers.normalize2d(helpers.subtract2d(point, center));
97
- return helpers.add2d(point, [orientedOffset * x, orientedOffset * y]);
98
- };
150
+ var _stack = [];
151
+ try {
152
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
153
+ const curveType = curve.geomType;
154
+ if (curveType === "CIRCLE") {
155
+ const circle = scope.register(scope.register(curve.adaptor()).Circle());
156
+ const radius = circle.Radius();
157
+ const orientationCorrection = circle.IsDirect() ? 1 : -1;
158
+ const orientedOffset = offset * orientationCorrection;
159
+ const newRadius = Number(radius) + orientedOffset;
160
+ if (newRadius < 1e-10) {
161
+ const centerPos = scope.register(circle.Location());
162
+ const center = [centerPos.X(), centerPos.Y()];
163
+ const offsetViaCenter = (point) => {
164
+ const [x, y] = helpers.normalize2d(helpers.subtract2d(point, center));
165
+ return helpers.add2d(point, [orientedOffset * x, orientedOffset * y]);
166
+ };
167
+ return {
168
+ collapsed: true,
169
+ firstPoint: offsetViaCenter(curve.firstPoint),
170
+ lastPoint: offsetViaCenter(curve.lastPoint)
171
+ };
172
+ }
173
+ const oc2 = occtBoundary.getKernel().oc;
174
+ const newCircle = new oc2.gp_Circ2d_3(circle.Axis(), newRadius);
175
+ const newInnerCurve = new oc2.Geom2d_Circle_1(newCircle);
176
+ newCircle.delete();
177
+ const newCurve = new oc2.Geom2d_TrimmedCurve(
178
+ new oc2.Handle_Geom2d_Curve_2(newInnerCurve),
179
+ curve.firstParameter,
180
+ curve.lastParameter,
181
+ true,
182
+ true
183
+ );
184
+ return new Blueprint.Curve2D(new oc2.Handle_Geom2d_Curve_2(newCurve));
185
+ }
186
+ if (curveType === "LINE") {
187
+ const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
188
+ return Blueprint.make2dSegmentCurve(firstPoint, lastPoint);
189
+ }
190
+ const oc = occtBoundary.getKernel().oc;
191
+ const offsetCurve = new Blueprint.Curve2D(
192
+ new oc.Handle_Geom2d_Curve_2(new oc.Geom2d_OffsetCurve(curve.wrapped, offset, true))
193
+ );
194
+ const approximation = Blueprint.approximateAsBSpline(offsetCurve.adaptor());
195
+ const selfIntersects = errors.unwrap(selfIntersections(approximation));
196
+ if (selfIntersects.length) {
99
197
  return {
100
198
  collapsed: true,
101
- firstPoint: offsetViaCenter(curve.firstPoint),
102
- lastPoint: offsetViaCenter(curve.lastPoint)
199
+ firstPoint: approximation.firstPoint,
200
+ lastPoint: approximation.lastPoint
103
201
  };
104
202
  }
105
- const oc2 = occtBoundary.getKernel().oc;
106
- const newCircle = new oc2.gp_Circ2d_3(circle.Axis(), newRadius);
107
- const newInnerCurve = new oc2.Geom2d_Circle_1(newCircle);
108
- newCircle.delete();
109
- const newCurve = new oc2.Geom2d_TrimmedCurve(
110
- new oc2.Handle_Geom2d_Curve_2(newInnerCurve),
111
- curve.firstParameter,
112
- curve.lastParameter,
113
- true,
114
- true
115
- );
116
- return new Blueprint.Curve2D(new oc2.Handle_Geom2d_Curve_2(newCurve));
117
- }
118
- if (curveType === "LINE") {
119
- const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
120
- return Blueprint.make2dSegmentCurve(firstPoint, lastPoint);
121
- }
122
- const oc = occtBoundary.getKernel().oc;
123
- const offsetCurve = new Blueprint.Curve2D(
124
- new oc.Handle_Geom2d_Curve_2(new oc.Geom2d_OffsetCurve(curve.wrapped, offset, true))
125
- );
126
- const approximation = Blueprint.approximateAsBSpline(offsetCurve.adaptor());
127
- const selfIntersects = errors.unwrap(selfIntersections(approximation));
128
- if (selfIntersects.length) {
129
- return {
130
- collapsed: true,
131
- firstPoint: approximation.firstPoint,
132
- lastPoint: approximation.lastPoint
133
- };
203
+ return approximation;
204
+ } catch (_) {
205
+ var _error = _, _hasError = true;
206
+ } finally {
207
+ __callDispose(_stack, _error, _hasError);
134
208
  }
135
- return approximation;
136
209
  };
137
210
  function removeCorner(firstCurve, secondCurve, radius) {
138
211
  const sinAngle = helpers.crossProduct2d(firstCurve.tangentAt(1), secondCurve.tangentAt(0));
@@ -1037,7 +1110,6 @@ class Sketch {
1037
1110
  twistAngle,
1038
1111
  origin
1039
1112
  } = {}) {
1040
- const gc = shapeTypes.localGC()[1];
1041
1113
  const direction = extrusionDirection ? occtBoundary.toVec3(extrusionDirection) : this.defaultDirection;
1042
1114
  const extrusionVec = vecOps.vecScale(vecOps.vecNormalize(direction), extrusionDistance);
1043
1115
  const originVec = origin ? occtBoundary.toVec3(origin) : this.defaultOrigin;
@@ -1045,7 +1117,6 @@ class Sketch {
1045
1117
  const solid2 = errors.unwrap(
1046
1118
  loft.complexExtrude(this.wire, [...originVec], [...extrusionVec], extrusionProfile)
1047
1119
  );
1048
- gc();
1049
1120
  this.delete();
1050
1121
  return solid2;
1051
1122
  }
@@ -1053,13 +1124,11 @@ class Sketch {
1053
1124
  const solid2 = errors.unwrap(
1054
1125
  loft.twistExtrude(this.wire, twistAngle, [...originVec], [...extrusionVec], extrusionProfile)
1055
1126
  );
1056
- gc();
1057
1127
  this.delete();
1058
1128
  return solid2;
1059
1129
  }
1060
1130
  const face = errors.unwrap(surfaceBuilders.makeFace(this.wire));
1061
1131
  const solid = loft.basicFaceExtrusion(face, [...extrusionVec]);
1062
- gc();
1063
1132
  this.delete();
1064
1133
  return solid;
1065
1134
  }
@@ -1649,38 +1718,54 @@ class FaceSketcher extends BaseSketcher2d {
1649
1718
  * @ignore
1650
1719
  */
1651
1720
  buildWire() {
1652
- const [r, gc] = shapeTypes.localGC();
1653
- const oc = occtBoundary.getKernel().oc;
1654
- const geomSurf = r(this._adaptSurface());
1655
- const edges = this.pendingCurves.map((curve) => {
1656
- return r(shapeTypes.createEdge(r(new oc.BRepBuilderAPI_MakeEdge_30(curve.wrapped, geomSurf)).Edge()));
1657
- });
1658
- const wire = errors.unwrap(surfaceBuilders.assembleWire(edges));
1659
- oc.BRepLib.BuildCurves3d_2(wire.wrapped);
1660
- gc();
1661
- return wire;
1721
+ var _stack = [];
1722
+ try {
1723
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
1724
+ const oc = occtBoundary.getKernel().oc;
1725
+ const geomSurf = scope.register(this._adaptSurface());
1726
+ const edges = this.pendingCurves.map((curve) => {
1727
+ return scope.register(
1728
+ shapeTypes.createEdge(
1729
+ scope.register(new oc.BRepBuilderAPI_MakeEdge_30(curve.wrapped, geomSurf)).Edge()
1730
+ )
1731
+ );
1732
+ });
1733
+ const wire = errors.unwrap(surfaceBuilders.assembleWire(edges));
1734
+ oc.BRepLib.BuildCurves3d_2(wire.wrapped);
1735
+ return wire;
1736
+ } catch (_) {
1737
+ var _error = _, _hasError = true;
1738
+ } finally {
1739
+ __callDispose(_stack, _error, _hasError);
1740
+ }
1662
1741
  }
1663
1742
  /** Finish drawing and return the resulting {@link Sketch} (does not close the path). */
1664
1743
  done() {
1665
- const [r, gc] = shapeTypes.localGC();
1666
- const wire = this.buildWire();
1667
- const sketch = new Sketch(wire);
1668
- if (curveFns.curveIsClosed(wire)) {
1669
- const face = r(sketch.clone().face());
1670
- const origin = faceFns.pointOnSurface(face, 0.5, 0.5);
1671
- const normal = faceFns.normalAt(face);
1672
- const direction = vecOps.vecScale(normal, -1);
1673
- sketch.defaultOrigin = [origin[0], origin[1], origin[2]];
1674
- sketch.defaultDirection = [direction[0], direction[1], direction[2]];
1675
- } else {
1676
- const startPoint = curveFns.curveStartPoint(wire);
1677
- const normal = faceFns.normalAt(this.face, [startPoint[0], startPoint[1], startPoint[2]]);
1678
- sketch.defaultOrigin = [startPoint[0], startPoint[1], startPoint[2]];
1679
- sketch.defaultDirection = [normal[0], normal[1], normal[2]];
1744
+ var _stack = [];
1745
+ try {
1746
+ const scope = __using(_stack, new shapeTypes.DisposalScope());
1747
+ const wire = this.buildWire();
1748
+ const sketch = new Sketch(wire);
1749
+ if (curveFns.curveIsClosed(wire)) {
1750
+ const face = scope.register(sketch.clone().face());
1751
+ const origin = faceFns.pointOnSurface(face, 0.5, 0.5);
1752
+ const normal = faceFns.normalAt(face);
1753
+ const direction = vecOps.vecScale(normal, -1);
1754
+ sketch.defaultOrigin = [origin[0], origin[1], origin[2]];
1755
+ sketch.defaultDirection = [direction[0], direction[1], direction[2]];
1756
+ } else {
1757
+ const startPoint = curveFns.curveStartPoint(wire);
1758
+ const normal = faceFns.normalAt(this.face, [startPoint[0], startPoint[1], startPoint[2]]);
1759
+ sketch.defaultOrigin = [startPoint[0], startPoint[1], startPoint[2]];
1760
+ sketch.defaultDirection = [normal[0], normal[1], normal[2]];
1761
+ }
1762
+ sketch.baseFace = this.face;
1763
+ return sketch;
1764
+ } catch (_) {
1765
+ var _error = _, _hasError = true;
1766
+ } finally {
1767
+ __callDispose(_stack, _error, _hasError);
1680
1768
  }
1681
- sketch.baseFace = this.face;
1682
- gc();
1683
- return sketch;
1684
1769
  }
1685
1770
  /** Close the path with a straight line to the start point and return the Sketch. */
1686
1771
  close() {