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,10 +1,55 @@
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
+ };
1
46
  import { g as getKernel, b as toOcVec, d as toOcPnt, e as makeOcAx3, u as uniqueIOFilename } from "./occtBoundary-DvBywHyU.js";
2
47
  import { g as vecLength, v as vecAdd, D as DEG2RAD, f as vecIsZero, j as vecNormalize, n as vecScale } from "./vecOps-ZDdZWbwT.js";
3
- import { b as createOcHandle, c as castShape, h as isShape3D, m as isWire, n as gcWithScope, u as createSolid } from "./shapeTypes-DnwCo942.js";
4
- import { d as downcast } from "./faceFns-3PDjBeW7.js";
48
+ import { b as createOcHandle, c as castShape, j as isShape3D, D as DisposalScope, n as isWire, v as createSolid } from "./shapeTypes-Bi_9RZa2.js";
49
+ import { d as downcast } from "./faceFns-q5CR9pOW.js";
5
50
  import { e as err, x as validationError, u as unwrap, p as typeCastError, l as ok, B as BrepErrorCode, d as isErr, o as occtError, i as ioError, b as computationError } from "./errors-DJ92ermb.js";
6
- import { n as buildLawFromProfile } from "./loft-DMFjK6lk.js";
7
- import { g as fuseAll } from "./booleanFns--Orezl-b.js";
51
+ import { n as buildLawFromProfile } from "./loft-DTRcYrq2.js";
52
+ import { g as fuseAll } from "./booleanFns-DOyKxL7q.js";
8
53
  function uuidv() {
9
54
  return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
10
55
  /[018]/g,
@@ -32,10 +77,10 @@ function wrapColor(hex, alpha = 1) {
32
77
  const [red, green, blue] = colorFromHex(hex);
33
78
  return new oc.Quantity_ColorRGBA_5(red / 255, green / 255, blue / 255, alpha);
34
79
  }
35
- function configureStepUnits(unit, modelUnit, r) {
80
+ function configureStepUnits(unit, modelUnit, scope) {
36
81
  if (!unit && !modelUnit) return;
37
82
  const oc = getKernel().oc;
38
- r(new oc.STEPCAFControl_Writer_1());
83
+ scope.register(new oc.STEPCAFControl_Writer_1());
39
84
  oc.Interface_Static.SetCVal("xstep.cascade.unit", (modelUnit || unit || "MM").toUpperCase());
40
85
  oc.Interface_Static.SetCVal("write.step.unit", (unit || modelUnit || "MM").toUpperCase());
41
86
  }
@@ -70,38 +115,55 @@ function createAssembly(shapes = []) {
70
115
  return createOcHandle(doc);
71
116
  }
72
117
  function makeSpineWire(start, end) {
73
- const oc = getKernel().oc;
74
- const r = gcWithScope();
75
- const pnt1 = r(toOcPnt(start));
76
- const pnt2 = r(toOcPnt(end));
77
- const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_3(pnt1, pnt2));
78
- const wireMaker = r(new oc.BRepBuilderAPI_MakeWire_2(edgeMaker.Edge()));
79
- return castShape(wireMaker.Wire());
118
+ var _stack = [];
119
+ try {
120
+ const oc = getKernel().oc;
121
+ const scope = __using(_stack, new DisposalScope());
122
+ const pnt1 = scope.register(toOcPnt(start));
123
+ const pnt2 = scope.register(toOcPnt(end));
124
+ const edgeMaker = scope.register(new oc.BRepBuilderAPI_MakeEdge_3(pnt1, pnt2));
125
+ const wireMaker = scope.register(new oc.BRepBuilderAPI_MakeWire_2(edgeMaker.Edge()));
126
+ return castShape(wireMaker.Wire());
127
+ } catch (_) {
128
+ var _error = _, _hasError = true;
129
+ } finally {
130
+ __callDispose(_stack, _error, _hasError);
131
+ }
80
132
  }
81
133
  function makeHelixWire(pitch, height, radius, center, dir, lefthand = false) {
82
- const oc = getKernel().oc;
83
- const r = gcWithScope();
84
- let myDir = 2 * Math.PI;
85
- if (lefthand) myDir = -2 * Math.PI;
86
- const geomLine = r(
87
- new oc.Geom2d_Line_3(r(new oc.gp_Pnt2d_3(0, 0)), r(new oc.gp_Dir2d_4(myDir, pitch)))
88
- );
89
- const nTurns = height / pitch;
90
- const uStart = r(geomLine.Value(0));
91
- const uStop = r(geomLine.Value(nTurns * Math.sqrt((2 * Math.PI) ** 2 + pitch ** 2)));
92
- const geomSeg = r(new oc.GCE2d_MakeSegment_1(uStart, uStop));
93
- const ax3 = makeOcAx3(center, dir);
94
- const geomSurf = new oc.Geom_CylindricalSurface_1(ax3, radius);
95
- ax3.delete();
96
- const e = r(
97
- new oc.BRepBuilderAPI_MakeEdge_30(
98
- r(new oc.Handle_Geom2d_Curve_2(geomSeg.Value().get())),
99
- r(new oc.Handle_Geom_Surface_2(geomSurf))
100
- )
101
- ).Edge();
102
- const w = r(new oc.BRepBuilderAPI_MakeWire_2(e)).Wire();
103
- oc.BRepLib.BuildCurves3d_2(w);
104
- return castShape(w);
134
+ var _stack = [];
135
+ try {
136
+ const oc = getKernel().oc;
137
+ const scope = __using(_stack, new DisposalScope());
138
+ let myDir = 2 * Math.PI;
139
+ if (lefthand) myDir = -2 * Math.PI;
140
+ const geomLine = scope.register(
141
+ new oc.Geom2d_Line_3(
142
+ scope.register(new oc.gp_Pnt2d_3(0, 0)),
143
+ scope.register(new oc.gp_Dir2d_4(myDir, pitch))
144
+ )
145
+ );
146
+ const nTurns = height / pitch;
147
+ const uStart = scope.register(geomLine.Value(0));
148
+ const uStop = scope.register(geomLine.Value(nTurns * Math.sqrt((2 * Math.PI) ** 2 + pitch ** 2)));
149
+ const geomSeg = scope.register(new oc.GCE2d_MakeSegment_1(uStart, uStop));
150
+ const ax3 = makeOcAx3(center, dir);
151
+ const geomSurf = new oc.Geom_CylindricalSurface_1(ax3, radius);
152
+ ax3.delete();
153
+ const e = scope.register(
154
+ new oc.BRepBuilderAPI_MakeEdge_30(
155
+ scope.register(new oc.Handle_Geom2d_Curve_2(geomSeg.Value().get())),
156
+ scope.register(new oc.Handle_Geom_Surface_2(geomSurf))
157
+ )
158
+ ).Edge();
159
+ const w = scope.register(new oc.BRepBuilderAPI_MakeWire_2(e)).Wire();
160
+ oc.BRepLib.BuildCurves3d_2(w);
161
+ return castShape(w);
162
+ } catch (_) {
163
+ var _error = _, _hasError = true;
164
+ } finally {
165
+ __callDispose(_stack, _error, _hasError);
166
+ }
105
167
  }
106
168
  function extrude(face, extrusionVec) {
107
169
  if (face.wrapped.IsNull()) {
@@ -111,17 +173,24 @@ function extrude(face, extrusionVec) {
111
173
  return err(validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
112
174
  }
113
175
  try {
114
- const oc = getKernel().oc;
115
- const r = gcWithScope();
116
- const vec = r(toOcVec(extrusionVec));
117
- const builder = r(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, vec, false, true));
118
- const shape = builder.Shape();
119
- const downcastResult = downcast(shape);
120
- if (isErr(downcastResult)) {
121
- return downcastResult;
176
+ var _stack = [];
177
+ try {
178
+ const oc = getKernel().oc;
179
+ const scope = __using(_stack, new DisposalScope());
180
+ const vec = scope.register(toOcVec(extrusionVec));
181
+ const builder = scope.register(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, vec, false, true));
182
+ const shape = builder.Shape();
183
+ const downcastResult = downcast(shape);
184
+ if (isErr(downcastResult)) {
185
+ return downcastResult;
186
+ }
187
+ const solid = createSolid(downcastResult.value);
188
+ return ok(solid);
189
+ } catch (_) {
190
+ var _error = _, _hasError = true;
191
+ } finally {
192
+ __callDispose(_stack, _error, _hasError);
122
193
  }
123
- const solid = createSolid(downcastResult.value);
124
- return ok(solid);
125
194
  } catch (e) {
126
195
  return err(
127
196
  occtError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
@@ -132,95 +201,111 @@ function extrude(face, extrusionVec) {
132
201
  }
133
202
  }
134
203
  function revolve(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
135
- if (face.wrapped.IsNull()) {
136
- return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
137
- }
138
- const oc = getKernel().oc;
139
- const r = gcWithScope();
140
- const pnt = r(new oc.gp_Pnt_3(center[0], center[1], center[2]));
141
- const dir = r(new oc.gp_Dir_4(direction[0], direction[1], direction[2]));
142
- const ax = r(new oc.gp_Ax1_2(pnt, dir));
143
- const builder = r(new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * DEG2RAD, false));
144
- const result = castShape(builder.Shape());
145
- if (!isShape3D(result)) {
146
- return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
204
+ var _stack = [];
205
+ try {
206
+ if (face.wrapped.IsNull()) {
207
+ return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
208
+ }
209
+ const oc = getKernel().oc;
210
+ const scope = __using(_stack, new DisposalScope());
211
+ const pnt = scope.register(new oc.gp_Pnt_3(center[0], center[1], center[2]));
212
+ const dir = scope.register(new oc.gp_Dir_4(direction[0], direction[1], direction[2]));
213
+ const ax = scope.register(new oc.gp_Ax1_2(pnt, dir));
214
+ const builder = scope.register(
215
+ new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * DEG2RAD, false)
216
+ );
217
+ const result = castShape(builder.Shape());
218
+ if (!isShape3D(result)) {
219
+ return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
220
+ }
221
+ return ok(result);
222
+ } catch (_) {
223
+ var _error = _, _hasError = true;
224
+ } finally {
225
+ __callDispose(_stack, _error, _hasError);
147
226
  }
148
- return ok(result);
149
227
  }
150
228
  function sweep(wire, spine, config = {}, shellMode = false) {
151
- if (config.mode === "simple" && !shellMode) {
152
- const kernel = getKernel();
153
- const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
154
- const shape2 = castShape(resultOc);
155
- if (!isShape3D(shape2)) {
156
- return err(typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
229
+ var _stack = [];
230
+ try {
231
+ if (config.mode === "simple" && !shellMode) {
232
+ const kernel = getKernel();
233
+ const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
234
+ const shape2 = castShape(resultOc);
235
+ if (!isShape3D(shape2)) {
236
+ return err(typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
237
+ }
238
+ return ok(shape2);
157
239
  }
158
- return ok(shape2);
159
- }
160
- const oc = getKernel().oc;
161
- const r = gcWithScope();
162
- const {
163
- frenet = false,
164
- auxiliarySpine,
165
- law = null,
166
- transitionMode = "right",
167
- withContact,
168
- support,
169
- forceProfileSpineOthogonality,
170
- tolerance,
171
- boundTolerance,
172
- angularTolerance,
173
- maxDegree,
174
- maxSegments
175
- } = config;
176
- const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
177
- const builder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
178
- if (tolerance !== void 0) {
179
- builder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
180
- }
181
- if (maxDegree !== void 0) {
182
- builder.SetMaxDegree(maxDegree);
183
- }
184
- if (maxSegments !== void 0) {
185
- builder.SetMaxSegments(maxSegments);
186
- }
187
- {
188
- const mode = {
189
- transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
190
- round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
191
- right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
192
- }[transitionMode];
193
- if (mode) builder.SetTransitionMode(mode);
194
- }
195
- if (support) {
196
- builder.SetMode_4(support);
197
- } else if (frenet) {
198
- builder.SetMode_1(frenet);
199
- }
200
- if (auxiliarySpine) {
201
- builder.SetMode_5(auxiliarySpine.wrapped, false, oc.BRepFill_TypeOfContact.BRepFill_NoContact);
202
- }
203
- if (!law) builder.Add_1(wire.wrapped, !!withContact, withCorrection);
204
- else builder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
205
- const progress = r(new oc.Message_ProgressRange_1());
206
- builder.Build(progress);
207
- if (!shellMode) builder.MakeSolid();
208
- const shape = castShape(builder.Shape());
209
- if (!isShape3D(shape)) {
210
- return err(typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
211
- }
212
- if (shellMode) {
213
- const startWire = castShape(builder.FirstShape());
214
- const endWire = castShape(builder.LastShape());
215
- if (!isWire(startWire)) {
216
- return err(typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
240
+ const oc = getKernel().oc;
241
+ const scope = __using(_stack, new DisposalScope());
242
+ const {
243
+ frenet = false,
244
+ auxiliarySpine,
245
+ law = null,
246
+ transitionMode = "right",
247
+ withContact,
248
+ support,
249
+ forceProfileSpineOthogonality,
250
+ tolerance,
251
+ boundTolerance,
252
+ angularTolerance,
253
+ maxDegree,
254
+ maxSegments
255
+ } = config;
256
+ const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
257
+ const builder = scope.register(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
258
+ if (tolerance !== void 0) {
259
+ builder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
260
+ }
261
+ if (maxDegree !== void 0) {
262
+ builder.SetMaxDegree(maxDegree);
263
+ }
264
+ if (maxSegments !== void 0) {
265
+ builder.SetMaxSegments(maxSegments);
266
+ }
267
+ {
268
+ const mode = {
269
+ transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
270
+ round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
271
+ right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
272
+ }[transitionMode];
273
+ if (mode) builder.SetTransitionMode(mode);
274
+ }
275
+ if (support) {
276
+ builder.SetMode_4(support);
277
+ } else if (frenet) {
278
+ builder.SetMode_1(frenet);
279
+ }
280
+ if (auxiliarySpine) {
281
+ builder.SetMode_5(auxiliarySpine.wrapped, false, oc.BRepFill_TypeOfContact.BRepFill_NoContact);
217
282
  }
218
- if (!isWire(endWire)) {
219
- return err(typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
283
+ if (!law) builder.Add_1(wire.wrapped, !!withContact, withCorrection);
284
+ else builder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
285
+ const progress = scope.register(new oc.Message_ProgressRange_1());
286
+ builder.Build(progress);
287
+ if (!shellMode) builder.MakeSolid();
288
+ const shape = castShape(builder.Shape());
289
+ if (!isShape3D(shape)) {
290
+ return err(typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
220
291
  }
221
- return ok([shape, startWire, endWire]);
292
+ if (shellMode) {
293
+ const startWire = castShape(builder.FirstShape());
294
+ const endWire = castShape(builder.LastShape());
295
+ if (!isWire(startWire)) {
296
+ return err(typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
297
+ }
298
+ if (!isWire(endWire)) {
299
+ return err(typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
300
+ }
301
+ return ok([shape, startWire, endWire]);
302
+ }
303
+ return ok(shape);
304
+ } catch (_) {
305
+ var _error = _, _hasError = true;
306
+ } finally {
307
+ __callDispose(_stack, _error, _hasError);
222
308
  }
223
- return ok(shape);
224
309
  }
225
310
  function supportExtrude(wire, center, normal, support) {
226
311
  const endPoint = vecAdd(center, normal);
@@ -257,48 +342,58 @@ function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMod
257
342
  return sweep(wire, spine, { auxiliarySpine, law }, shellMode);
258
343
  }
259
344
  function exportAssemblySTEP(shapes = [], { unit, modelUnit } = {}) {
260
- const oc = getKernel().oc;
261
- const r = gcWithScope();
262
- const doc = new oc.TDocStd_Document(wrapString("XmlOcaf"));
345
+ var _stack = [];
263
346
  try {
264
- oc.XCAFDoc_ShapeTool.SetAutoNaming(false);
265
- const mainLabel = doc.Main();
266
- const tool = oc.XCAFDoc_DocumentTool.ShapeTool(mainLabel).get();
267
- const ctool = oc.XCAFDoc_DocumentTool.ColorTool(mainLabel).get();
268
- for (const { shape, name, color, alpha } of shapes) {
269
- const shapeNode = tool.NewShape();
270
- tool.SetShape(shapeNode, shape.wrapped);
271
- oc.TDataStd_Name.Set_1(shapeNode, wrapString(name || uuidv()));
272
- ctool.SetColor_3(
273
- shapeNode,
274
- wrapColor(color || "#f00", alpha ?? 1),
275
- oc.XCAFDoc_ColorType.XCAFDoc_ColorSurf
347
+ const oc = getKernel().oc;
348
+ const scope = __using(_stack, new DisposalScope());
349
+ const doc = new oc.TDocStd_Document(wrapString("XmlOcaf"));
350
+ try {
351
+ oc.XCAFDoc_ShapeTool.SetAutoNaming(false);
352
+ const mainLabel = doc.Main();
353
+ const tool = oc.XCAFDoc_DocumentTool.ShapeTool(mainLabel).get();
354
+ const ctool = oc.XCAFDoc_DocumentTool.ColorTool(mainLabel).get();
355
+ for (const { shape, name, color, alpha } of shapes) {
356
+ const shapeNode = tool.NewShape();
357
+ tool.SetShape(shapeNode, shape.wrapped);
358
+ oc.TDataStd_Name.Set_1(shapeNode, wrapString(name || uuidv()));
359
+ ctool.SetColor_3(
360
+ shapeNode,
361
+ wrapColor(color || "#f00", alpha ?? 1),
362
+ oc.XCAFDoc_ColorType.XCAFDoc_ColorSurf
363
+ );
364
+ }
365
+ tool.UpdateAssemblies();
366
+ configureStepUnits(unit, modelUnit, scope);
367
+ const session = scope.register(new oc.XSControl_WorkSession());
368
+ const writer = scope.register(
369
+ new oc.STEPCAFControl_Writer_2(
370
+ scope.register(new oc.Handle_XSControl_WorkSession_2(session)),
371
+ false
372
+ )
276
373
  );
374
+ configureStepWriter(writer);
375
+ const progress = scope.register(new oc.Message_ProgressRange_1());
376
+ writer.Transfer_1(
377
+ new oc.Handle_TDocStd_Document_2(doc),
378
+ oc.STEPControl_StepModelType.STEPControl_AsIs,
379
+ null,
380
+ progress
381
+ );
382
+ const filename = uniqueIOFilename("_export", "step");
383
+ const done = writer.Write(filename);
384
+ if (done === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
385
+ const file = oc.FS.readFile("/" + filename);
386
+ oc.FS.unlink("/" + filename);
387
+ return ok(new Blob([file], { type: "application/STEP" }));
388
+ }
389
+ return err(ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
390
+ } finally {
391
+ doc.delete();
277
392
  }
278
- tool.UpdateAssemblies();
279
- configureStepUnits(unit, modelUnit, r);
280
- const session = r(new oc.XSControl_WorkSession());
281
- const writer = r(
282
- new oc.STEPCAFControl_Writer_2(r(new oc.Handle_XSControl_WorkSession_2(session)), false)
283
- );
284
- configureStepWriter(writer);
285
- const progress = r(new oc.Message_ProgressRange_1());
286
- writer.Transfer_1(
287
- new oc.Handle_TDocStd_Document_2(doc),
288
- oc.STEPControl_StepModelType.STEPControl_AsIs,
289
- null,
290
- progress
291
- );
292
- const filename = uniqueIOFilename("_export", "step");
293
- const done = writer.Write(filename);
294
- if (done === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
295
- const file = oc.FS.readFile("/" + filename);
296
- oc.FS.unlink("/" + filename);
297
- return ok(new Blob([file], { type: "application/STEP" }));
298
- }
299
- return err(ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
393
+ } catch (_) {
394
+ var _error = _, _hasError = true;
300
395
  } finally {
301
- doc.delete();
396
+ __callDispose(_stack, _error, _hasError);
302
397
  }
303
398
  }
304
399
  function linearPattern(shape, direction, count, spacing, options) {