brepjs 8.8.2 → 8.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/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-C4Rx89oe.js +1440 -0
  9. package/dist/Blueprint-D1Dik12C.cjs +1439 -0
  10. package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BZnkU_aH.cjs} +215 -130
  11. package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D4j89vF_.js} +215 -130
  12. package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-Cf_0aWNe.cjs} +214 -133
  13. package/dist/{booleanFns--Orezl-b.js → booleanFns-D6SeHoCv.js} +214 -133
  14. package/dist/brepjs.cjs +478 -314
  15. package/dist/brepjs.js +574 -410
  16. package/dist/core/disposal.d.ts +44 -3
  17. package/dist/core/disposal.d.ts.map +1 -1
  18. package/dist/core/errors.d.ts +2 -0
  19. package/dist/core/errors.d.ts.map +1 -1
  20. package/dist/core/geometryHelpers.d.ts.map +1 -1
  21. package/dist/core/kernelCall.d.ts +20 -0
  22. package/dist/core/kernelCall.d.ts.map +1 -1
  23. package/dist/core/memory.d.ts +1 -1
  24. package/dist/core/memory.d.ts.map +1 -1
  25. package/dist/core.cjs +7 -4
  26. package/dist/core.d.ts +1 -1
  27. package/dist/core.d.ts.map +1 -1
  28. package/dist/core.js +14 -11
  29. package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-CypY3T_w.js} +1 -1
  30. package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-DbRL42YI.cjs} +1 -1
  31. package/dist/{curveFns-6ovDM_sR.cjs → curveFns-KDpL9iyo.cjs} +139 -38
  32. package/dist/curveFns-VDZEhY97.js +281 -0
  33. package/dist/{drawFns-WgXeXHH1.cjs → drawFns-B52K-9DJ.cjs} +184 -104
  34. package/dist/{drawFns-XwroLxdb.js → drawFns-CVPwl2No.js} +184 -104
  35. package/dist/{errors-NNmTtM5u.cjs → errors-BYb4tL5h.cjs} +3 -0
  36. package/dist/{errors-DJ92ermb.js → errors-CHfaHQSt.js} +3 -0
  37. package/dist/faceFns-B8xnZw-f.cjs +358 -0
  38. package/dist/faceFns-DG4bu-QB.js +359 -0
  39. package/dist/{helpers-CRfqaW0Y.cjs → helpers-Cfibxk7U.cjs} +15 -12
  40. package/dist/{helpers-CtBCzEqs.js → helpers-zsENdJlc.js} +15 -12
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/io/importFns.d.ts.map +1 -1
  44. package/dist/io.cjs +133 -65
  45. package/dist/io.js +133 -65
  46. package/dist/kernel/booleanOps.d.ts.map +1 -1
  47. package/dist/loft-Bhnw5Rfr.cjs +530 -0
  48. package/dist/loft-fSnlFn-j.js +531 -0
  49. package/dist/measurement-C4Ofuy_y.cjs +200 -0
  50. package/dist/measurement-DzRb6oYN.js +201 -0
  51. package/dist/measurement.cjs +1 -1
  52. package/dist/measurement.js +1 -1
  53. package/dist/{meshFns-CPNNlpbw.cjs → meshFns-C-6Cq3V-.cjs} +3 -3
  54. package/dist/{meshFns-DAmWVyEp.js → meshFns-Cw3IFJjg.js} +3 -3
  55. package/dist/{occtBoundary-Cqfsau2c.cjs → occtBoundary-CN_uQJtA.cjs} +4 -3
  56. package/dist/{occtBoundary-DvBywHyU.js → occtBoundary-Ct0tN8cs.js} +4 -3
  57. package/dist/operations/exporterFns.d.ts.map +1 -1
  58. package/dist/operations/exporterUtils.d.ts +3 -3
  59. package/dist/operations/exporterUtils.d.ts.map +1 -1
  60. package/dist/operations/exporters.d.ts.map +1 -1
  61. package/dist/operations/extrude.d.ts.map +1 -1
  62. package/dist/operations/extrudeFns.d.ts.map +1 -1
  63. package/dist/operations/loft.d.ts.map +1 -1
  64. package/dist/operations/multiSweepFns.d.ts.map +1 -1
  65. package/dist/{operations-BQ25CPI8.cjs → operations-DvwWDqIp.cjs} +263 -168
  66. package/dist/{operations-vN0tcoaU.js → operations-PYuj8GLd.js} +263 -168
  67. package/dist/operations.cjs +2 -2
  68. package/dist/operations.js +2 -2
  69. package/dist/query/shapeDistanceFilter.d.ts.map +1 -1
  70. package/dist/query.cjs +67 -15
  71. package/dist/query.js +68 -16
  72. package/dist/result.cjs +1 -1
  73. package/dist/result.js +1 -1
  74. package/dist/{shapeFns-C785aeVn.cjs → shapeFns-ByLUl6KE.cjs} +63 -9
  75. package/dist/{shapeFns-ClpALED4.js → shapeFns-QL3zx6uW.js} +63 -9
  76. package/dist/{shapeTypes-DnwCo942.js → shapeTypes-D34s68Xi.js} +51 -20
  77. package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-sXITvFkF.cjs} +33 -2
  78. package/dist/sketching/CompoundSketch.d.ts.map +1 -1
  79. package/dist/sketching/Sketch.d.ts.map +1 -1
  80. package/dist/sketching/Sketcher.d.ts.map +1 -1
  81. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  82. package/dist/sketching/cannedSketches.d.ts.map +1 -1
  83. package/dist/sketching/draw.d.ts.map +1 -1
  84. package/dist/sketching.cjs +2 -2
  85. package/dist/sketching.js +2 -2
  86. package/dist/surfaceBuilders-DYX6h68y.js +436 -0
  87. package/dist/surfaceBuilders-hupjYn0W.cjs +435 -0
  88. package/dist/topology/booleanFns.d.ts.map +1 -1
  89. package/dist/topology/compoundOpsFns.d.ts.map +1 -1
  90. package/dist/topology/curveBuilders.d.ts.map +1 -1
  91. package/dist/topology/shapeFns.d.ts.map +1 -1
  92. package/dist/topology/solidBuilders.d.ts.map +1 -1
  93. package/dist/topology/surfaceBuilders.d.ts.map +1 -1
  94. package/dist/{topology-zG8maSDK.cjs → topology-DWe9SYAy.cjs} +8 -8
  95. package/dist/{topology-CqyxpmEh.js → topology-psR8Hqiz.js} +8 -8
  96. package/dist/topology.cjs +6 -6
  97. package/dist/topology.js +6 -6
  98. package/dist/{vectors-CGLqemPY.cjs → vectors-9rrStq8t.cjs} +2 -2
  99. package/dist/{vectors-2lOjaa8N.js → vectors-Dp5Iu1KH.js} +2 -2
  100. package/dist/vectors.cjs +2 -2
  101. package/dist/vectors.js +2 -2
  102. package/package.json +4 -1
  103. package/dist/Blueprint-BmbNUnGI.cjs +0 -1185
  104. package/dist/Blueprint-C-JJkkwL.js +0 -1186
  105. package/dist/curveFns-BhQECv8e.js +0 -180
  106. package/dist/faceFns-3PDjBeW7.js +0 -272
  107. package/dist/faceFns-CxaLWOjc.cjs +0 -271
  108. package/dist/loft-CVb-IjEI.cjs +0 -372
  109. package/dist/loft-DMFjK6lk.js +0 -373
  110. package/dist/measurement-CecYIt3s.cjs +0 -134
  111. package/dist/measurement-DHDLAH7-.js +0 -135
  112. package/dist/surfaceBuilders-CC0ZQGix.cjs +0 -289
  113. package/dist/surfaceBuilders-CrJtFu2a.js +0 -290
@@ -0,0 +1,281 @@
1
+ var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
5
+ var __using = (stack, value, async) => {
6
+ if (value != null) {
7
+ if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
8
+ var dispose, inner;
9
+ if (async) dispose = value[__knownSymbol("asyncDispose")];
10
+ if (dispose === void 0) {
11
+ dispose = value[__knownSymbol("dispose")];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") __typeError("Object not disposable");
15
+ if (inner) dispose = function() {
16
+ try {
17
+ inner.call(this);
18
+ } catch (e) {
19
+ return Promise.reject(e);
20
+ }
21
+ };
22
+ stack.push([async, dispose, value]);
23
+ } else if (async) {
24
+ stack.push([async]);
25
+ }
26
+ return value;
27
+ };
28
+ var __callDispose = (stack, error, hasError) => {
29
+ var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
30
+ return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
31
+ };
32
+ var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
33
+ var next = (it) => {
34
+ while (it = stack.pop()) {
35
+ try {
36
+ var result = it[1] && it[1].call(it[2]);
37
+ if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
38
+ } catch (e) {
39
+ fail(e);
40
+ }
41
+ }
42
+ if (hasError) throw error;
43
+ };
44
+ return next();
45
+ };
46
+ import { g as getKernel } from "./occtBoundary-Ct0tN8cs.js";
47
+ import { D as DisposalScope, c as castShape, d as isEdge, n as isWire } from "./shapeTypes-D34s68Xi.js";
48
+ import { e as err, p as typeCastError, l as ok, u as unwrap } from "./errors-CHfaHQSt.js";
49
+ let CURVE_TYPES_MAP = null;
50
+ const getCurveTypesMap = (refresh) => {
51
+ if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
52
+ const oc = getKernel().oc;
53
+ const ga = oc.GeomAbs_CurveType;
54
+ CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
55
+ [ga.GeomAbs_Line, "LINE"],
56
+ [ga.GeomAbs_Circle, "CIRCLE"],
57
+ [ga.GeomAbs_Ellipse, "ELLIPSE"],
58
+ [ga.GeomAbs_Hyperbola, "HYPERBOLA"],
59
+ [ga.GeomAbs_Parabola, "PARABOLA"],
60
+ [ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
61
+ [ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
62
+ [ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
63
+ [ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
64
+ ]);
65
+ return CURVE_TYPES_MAP;
66
+ };
67
+ const findCurveType = (type) => {
68
+ let shapeType = getCurveTypesMap().get(type);
69
+ if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
70
+ if (!shapeType) return err(typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
71
+ return ok(shapeType);
72
+ };
73
+ function getAdaptor(shape) {
74
+ const oc = getKernel().oc;
75
+ const st = shape.wrapped.ShapeType();
76
+ const e = oc.TopAbs_ShapeEnum;
77
+ if (st === e.TopAbs_WIRE) {
78
+ return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
79
+ }
80
+ return new oc.BRepAdaptor_Curve_2(shape.wrapped);
81
+ }
82
+ function mapParam(adaptor, t) {
83
+ const first = Number(adaptor.FirstParameter());
84
+ const last = Number(adaptor.LastParameter());
85
+ return first + (last - first) * t;
86
+ }
87
+ function getCurveType(shape) {
88
+ var _stack = [];
89
+ try {
90
+ const scope = __using(_stack, new DisposalScope());
91
+ const adaptor = scope.register(getAdaptor(shape));
92
+ const technicalType = adaptor.GetType && adaptor.GetType();
93
+ return unwrap(findCurveType(technicalType));
94
+ } catch (_) {
95
+ var _error = _, _hasError = true;
96
+ } finally {
97
+ __callDispose(_stack, _error, _hasError);
98
+ }
99
+ }
100
+ function curveStartPoint(shape) {
101
+ var _stack = [];
102
+ try {
103
+ const scope = __using(_stack, new DisposalScope());
104
+ const adaptor = scope.register(getAdaptor(shape));
105
+ const pnt = scope.register(adaptor.Value(adaptor.FirstParameter()));
106
+ return [pnt.X(), pnt.Y(), pnt.Z()];
107
+ } catch (_) {
108
+ var _error = _, _hasError = true;
109
+ } finally {
110
+ __callDispose(_stack, _error, _hasError);
111
+ }
112
+ }
113
+ function curveEndPoint(shape) {
114
+ var _stack = [];
115
+ try {
116
+ const scope = __using(_stack, new DisposalScope());
117
+ const adaptor = scope.register(getAdaptor(shape));
118
+ const pnt = scope.register(adaptor.Value(adaptor.LastParameter()));
119
+ return [pnt.X(), pnt.Y(), pnt.Z()];
120
+ } catch (_) {
121
+ var _error = _, _hasError = true;
122
+ } finally {
123
+ __callDispose(_stack, _error, _hasError);
124
+ }
125
+ }
126
+ function curvePointAt(shape, position = 0.5) {
127
+ var _stack = [];
128
+ try {
129
+ const scope = __using(_stack, new DisposalScope());
130
+ const adaptor = scope.register(getAdaptor(shape));
131
+ const pnt = scope.register(adaptor.Value(mapParam(adaptor, position)));
132
+ return [pnt.X(), pnt.Y(), pnt.Z()];
133
+ } catch (_) {
134
+ var _error = _, _hasError = true;
135
+ } finally {
136
+ __callDispose(_stack, _error, _hasError);
137
+ }
138
+ }
139
+ function curveTangentAt(shape, position = 0.5) {
140
+ var _stack = [];
141
+ try {
142
+ const oc = getKernel().oc;
143
+ const scope = __using(_stack, new DisposalScope());
144
+ const adaptor = scope.register(getAdaptor(shape));
145
+ const param = mapParam(adaptor, position);
146
+ const tmpPnt = scope.register(new oc.gp_Pnt_1());
147
+ const tmpVec = scope.register(new oc.gp_Vec_1());
148
+ adaptor.D1(param, tmpPnt, tmpVec);
149
+ return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
150
+ } catch (_) {
151
+ var _error = _, _hasError = true;
152
+ } finally {
153
+ __callDispose(_stack, _error, _hasError);
154
+ }
155
+ }
156
+ function curveLength(shape) {
157
+ var _stack = [];
158
+ try {
159
+ const oc = getKernel().oc;
160
+ const scope = __using(_stack, new DisposalScope());
161
+ const props = scope.register(new oc.GProp_GProps_1());
162
+ oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
163
+ return props.Mass();
164
+ } catch (_) {
165
+ var _error = _, _hasError = true;
166
+ } finally {
167
+ __callDispose(_stack, _error, _hasError);
168
+ }
169
+ }
170
+ function curveIsClosed(shape) {
171
+ var _stack = [];
172
+ try {
173
+ const scope = __using(_stack, new DisposalScope());
174
+ const adaptor = scope.register(getAdaptor(shape));
175
+ return adaptor.IsClosed();
176
+ } catch (_) {
177
+ var _error = _, _hasError = true;
178
+ } finally {
179
+ __callDispose(_stack, _error, _hasError);
180
+ }
181
+ }
182
+ function curveIsPeriodic(shape) {
183
+ var _stack = [];
184
+ try {
185
+ const scope = __using(_stack, new DisposalScope());
186
+ const adaptor = scope.register(getAdaptor(shape));
187
+ return adaptor.IsPeriodic();
188
+ } catch (_) {
189
+ var _error = _, _hasError = true;
190
+ } finally {
191
+ __callDispose(_stack, _error, _hasError);
192
+ }
193
+ }
194
+ function curvePeriod(shape) {
195
+ const adaptor = getAdaptor(shape);
196
+ const result = adaptor.Period();
197
+ adaptor.delete();
198
+ return result;
199
+ }
200
+ function getOrientation(shape) {
201
+ const oc = getKernel().oc;
202
+ const orient = shape.wrapped.Orientation_1();
203
+ return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
204
+ }
205
+ function flipOrientation(shape) {
206
+ return castShape(shape.wrapped.Reversed());
207
+ }
208
+ function interpolateCurve(points, options = {}) {
209
+ if (points.length < 2) {
210
+ return err(typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
211
+ }
212
+ try {
213
+ const result = getKernel().interpolatePoints(points, options);
214
+ const cast = castShape(result);
215
+ if (!isEdge(cast)) {
216
+ return err(typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
217
+ }
218
+ return ok(cast);
219
+ } catch (e) {
220
+ return err(
221
+ typeCastError(
222
+ "INTERPOLATE_FAILED",
223
+ `Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
224
+ )
225
+ );
226
+ }
227
+ }
228
+ function approximateCurve(points, options = {}) {
229
+ if (points.length < 2) {
230
+ return err(typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
231
+ }
232
+ try {
233
+ const result = getKernel().approximatePoints(points, options);
234
+ const cast = castShape(result);
235
+ if (!isEdge(cast)) {
236
+ return err(typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
237
+ }
238
+ return ok(cast);
239
+ } catch (e) {
240
+ return err(
241
+ typeCastError(
242
+ "APPROXIMATE_FAILED",
243
+ `Approximation failed: ${e instanceof Error ? e.message : String(e)}`
244
+ )
245
+ );
246
+ }
247
+ }
248
+ function offsetWire2D(wire, offset, kind = "arc") {
249
+ const oc = getKernel().oc;
250
+ const joinTypes = {
251
+ arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
252
+ intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
253
+ tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent,
254
+ chamfer: oc.GeomAbs_JoinType.GeomAbs_Intersection
255
+ // sharp/miter corners
256
+ };
257
+ const resultShape = getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
258
+ const wrapped = castShape(resultShape);
259
+ if (!isWire(wrapped)) {
260
+ wrapped[Symbol.dispose]();
261
+ return err(typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
262
+ }
263
+ return ok(wrapped);
264
+ }
265
+ export {
266
+ curveEndPoint as a,
267
+ getCurveType as b,
268
+ curveTangentAt as c,
269
+ curveStartPoint as d,
270
+ curveIsClosed as e,
271
+ findCurveType as f,
272
+ getOrientation as g,
273
+ curvePointAt as h,
274
+ curveLength as i,
275
+ approximateCurve as j,
276
+ curveIsPeriodic as k,
277
+ curvePeriod as l,
278
+ flipOrientation as m,
279
+ interpolateCurve as n,
280
+ offsetWire2D as o
281
+ };
@@ -1,20 +1,65 @@
1
1
  "use strict";
2
- const errors = require("./errors-NNmTtM5u.cjs");
3
- const vectors = require("./vectors-CGLqemPY.cjs");
4
- const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
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
+ };
47
+ const errors = require("./errors-BYb4tL5h.cjs");
48
+ const vectors = require("./vectors-9rrStq8t.cjs");
49
+ const occtBoundary = require("./occtBoundary-CN_uQJtA.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-BZnkU_aH.cjs");
52
+ const faceFns = require("./faceFns-B8xnZw-f.cjs");
53
+ const curveFns = require("./curveFns-KDpL9iyo.cjs");
54
+ const surfaceBuilders = require("./surfaceBuilders-hupjYn0W.cjs");
55
+ const shapeTypes = require("./shapeTypes-sXITvFkF.cjs");
56
+ const Blueprint = require("./Blueprint-D1Dik12C.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-Cfibxk7U.cjs");
59
+ const shapeFns = require("./shapeFns-ByLUl6KE.cjs");
60
+ const loft = require("./loft-Bhnw5Rfr.cjs");
16
61
  const opentype = require("opentype.js");
17
- const cornerFinder = require("./cornerFinder-v4un1Fr9.cjs");
62
+ const cornerFinder = require("./cornerFinder-DbRL42YI.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);