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,19 +1,64 @@
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 { u as unwrap, g as isOk, e as err, x as validationError, l as ok } from "./errors-DJ92ermb.js";
2
47
  import { r as resolvePlane, b as planeToWorld, d as planeToLocal } from "./vectors-2lOjaa8N.js";
3
48
  import { g as getKernel, a as toVec3, c as makeOcAx2 } from "./occtBoundary-DvBywHyU.js";
4
49
  import { n as vecScale, j as vecNormalize, v as vecAdd, o as vecSub, b as vecCross, m as vecRotate, R as RAD2DEG, g as vecLength, e as vecEquals, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
5
- import { b as Flatbush, c as convertSvgEllipseParams, d as defaultsSplineOptions, S as Sketch, r as roundedRectangleBlueprint, e as Blueprints, C as CompoundBlueprint, f as cut2D, i as intersectCurves, g as fuse2D, m as make2dOffset, h as filletCurves, j as chamferCurves, o as organiseBlueprints, a as BlueprintSketcher, k as intersect2D, B as BaseSketcher2d, p as polysidesBlueprint } from "./boolean2D-Dgnuy63w.js";
6
- import { d as downcast, c as cast, e as faceCenter, n as normalAt, o as outerWire } from "./faceFns-3PDjBeW7.js";
7
- import { c as curveTangentAt, a as curveEndPoint, b as getCurveType, o as offsetWire2D } from "./curveFns-BhQECv8e.js";
8
- import { a as makeLine, d as makeThreePointArc, e as makeTangentArc, f as makeEllipseArc, g as makeBezierCurve, b as assembleWire, h as addHolesInFace, m as makeFace, i as makeCircle, j as makeEllipse, c as makeHelix, k as makeBSplineApproximation } from "./surfaceBuilders-CrJtFu2a.js";
9
- import { o as createWire, r as localGC, q as createFace, e as isFace, n as gcWithScope, c as castShape } from "./shapeTypes-DnwCo942.js";
10
- import { m as mirror, B as Blueprint, C as Curve2D, a as make2dSegmentCurve, b as make2dArcFromCenter, c as approximateAsSvgCompatibleCurve, d as BoundingBox2d, e as edgeToCurve, f as make2dInerpolatedBSplineCurve, g as make2dCircle, h as make2dEllipse, i as deserializeCurve2D } from "./Blueprint-C-JJkkwL.js";
50
+ import { b as Flatbush, c as convertSvgEllipseParams, d as defaultsSplineOptions, S as Sketch, r as roundedRectangleBlueprint, e as Blueprints, C as CompoundBlueprint, f as cut2D, i as intersectCurves, g as fuse2D, m as make2dOffset, h as filletCurves, j as chamferCurves, o as organiseBlueprints, a as BlueprintSketcher, k as intersect2D, B as BaseSketcher2d, p as polysidesBlueprint } from "./boolean2D-D5O0F3J8.js";
51
+ import { d as downcast, c as cast, e as faceCenter, n as normalAt, o as outerWire } from "./faceFns-q5CR9pOW.js";
52
+ import { c as curveTangentAt, a as curveEndPoint, b as getCurveType, o as offsetWire2D } from "./curveFns-BHRYwxBM.js";
53
+ import { a as makeLine, d as makeThreePointArc, e as makeTangentArc, f as makeEllipseArc, g as makeBezierCurve, b as assembleWire, h as addHolesInFace, m as makeFace, i as makeCircle, j as makeEllipse, c as makeHelix, k as makeBSplineApproximation } from "./surfaceBuilders-W9Y25CIb.js";
54
+ import { D as DisposalScope, q as createWire, s as createFace, e as isFace, c as castShape } from "./shapeTypes-Bi_9RZa2.js";
55
+ import { m as mirror, B as Blueprint, C as Curve2D, a as make2dSegmentCurve, b as make2dArcFromCenter, c as approximateAsSvgCompatibleCurve, d as BoundingBox2d, e as edgeToCurve, f as make2dInerpolatedBSplineCurve, g as make2dCircle, h as make2dEllipse, i as deserializeCurve2D } from "./Blueprint-DsoGiJNJ.js";
11
56
  import { bug } from "./result.js";
12
- import { d as distance2d, p as polarAngle2d, f as polarToCartesian, P as PRECISION_OFFSET, h as squareDistance2d, s as samePoint$1, e as subtract2d, c as add2d } from "./helpers-CtBCzEqs.js";
13
- import { d as getEdges } from "./shapeFns-ClpALED4.js";
14
- import { m as makeCompound, b as basicFaceExtrusion, r as revolution, a as makeSolid, c as complexExtrude, t as twistExtrude } from "./loft-DMFjK6lk.js";
57
+ import { d as distance2d, p as polarAngle2d, f as polarToCartesian, P as PRECISION_OFFSET, h as squareDistance2d, s as samePoint$1, e as subtract2d, c as add2d } from "./helpers-tNdaX01G.js";
58
+ import { d as getEdges } from "./shapeFns-DNnBK8fG.js";
59
+ import { m as makeCompound, b as basicFaceExtrusion, r as revolution, a as makeSolid, c as complexExtrude, t as twistExtrude } from "./loft-DTRcYrq2.js";
15
60
  import opentype from "opentype.js";
16
- import { c as cornerFinder } from "./cornerFinder-KNTFoGrm.js";
61
+ import { c as cornerFinder } from "./cornerFinder-DH6EwYfL.js";
17
62
  const stitchCurves = (curves, precision = 1e-7) => {
18
63
  const startPoints = new Flatbush(curves.length);
19
64
  curves.forEach((c) => {
@@ -314,8 +359,9 @@ class Sketcher {
314
359
  }
315
360
  /** Draw a smooth cubic Bezier spline to an absolute end point, blending tangent with the previous edge. */
316
361
  smoothSplineTo(end, config) {
317
- const [r, gc] = localGC();
362
+ var _stack = [];
318
363
  try {
364
+ const scope = __using(_stack, new DisposalScope());
319
365
  const { endTangent, startTangent, startFactor, endFactor } = defaultsSplineOptions(config);
320
366
  const endPoint = planeToWorld(this.plane, end);
321
367
  const previousEdge = this.pendingEdges.length ? this.pendingEdges[this.pendingEdges.length - 1] : null;
@@ -328,17 +374,14 @@ class Sketcher {
328
374
  startPoleDirection = planeToWorld(this.plane, [1, 0]);
329
375
  } else if (getCurveType(previousEdge) === "BEZIER_CURVE") {
330
376
  const oc = getKernel().oc;
331
- const adaptor = r(new oc.BRepAdaptor_Curve_2(previousEdge.wrapped));
377
+ const adaptor = scope.register(new oc.BRepAdaptor_Curve_2(previousEdge.wrapped));
332
378
  const rawCurve = adaptor.Bezier().get();
333
379
  const previousPole = toVec3(rawCurve.Pole(rawCurve.NbPoles() - 1));
334
380
  startPoleDirection = vecSub(this.pointer, previousPole);
335
381
  } else {
336
382
  startPoleDirection = curveTangentAt(previousEdge, 1);
337
383
  }
338
- const poleDistance = vecScale(
339
- vecNormalize(startPoleDirection),
340
- startFactor * defaultDistance
341
- );
384
+ const poleDistance = vecScale(vecNormalize(startPoleDirection), startFactor * defaultDistance);
342
385
  const startControl = vecAdd(this.pointer, poleDistance);
343
386
  let endPoleDirection;
344
387
  if (endTangent === "symmetric") {
@@ -353,8 +396,10 @@ class Sketcher {
353
396
  );
354
397
  this._updatePointer(endPoint);
355
398
  return this;
399
+ } catch (_) {
400
+ var _error = _, _hasError = true;
356
401
  } finally {
357
- gc();
402
+ __callDispose(_stack, _error, _hasError);
358
403
  }
359
404
  }
360
405
  /** Draw a smooth cubic Bezier spline to a relative end point, blending tangent with the previous edge. */
@@ -407,32 +452,44 @@ class Sketcher {
407
452
  }
408
453
  }
409
454
  const guessFaceFromWires = (wires) => {
410
- const oc = getKernel().oc;
411
- const [r, gc] = localGC();
412
- const faceBuilder = r(
413
- new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
414
- );
415
- wires.forEach((wire, wireIndex) => {
416
- getEdges(wire).forEach((edge) => {
417
- faceBuilder.Add_1(edge.wrapped, oc.GeomAbs_Shape.GeomAbs_C0, wireIndex === 0);
455
+ var _stack = [];
456
+ try {
457
+ const oc = getKernel().oc;
458
+ const scope = __using(_stack, new DisposalScope());
459
+ const faceBuilder = scope.register(
460
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
461
+ );
462
+ wires.forEach((wire, wireIndex) => {
463
+ getEdges(wire).forEach((edge) => {
464
+ faceBuilder.Add_1(edge.wrapped, oc.GeomAbs_Shape.GeomAbs_C0, wireIndex === 0);
465
+ });
418
466
  });
419
- });
420
- const progress = r(new oc.Message_ProgressRange_1());
421
- faceBuilder.Build(progress);
422
- const newFace = unwrap(cast(faceBuilder.Shape()));
423
- gc();
424
- if (!isFace(newFace)) {
425
- bug("guessFaceFromWires", "Failed to create a face");
426
- }
427
- return newFace;
467
+ const progress = scope.register(new oc.Message_ProgressRange_1());
468
+ faceBuilder.Build(progress);
469
+ const newFace = unwrap(cast(faceBuilder.Shape()));
470
+ if (!isFace(newFace)) {
471
+ bug("guessFaceFromWires", "Failed to create a face");
472
+ }
473
+ return newFace;
474
+ } catch (_) {
475
+ var _error = _, _hasError = true;
476
+ } finally {
477
+ __callDispose(_stack, _error, _hasError);
478
+ }
428
479
  };
429
480
  const fixWire = (wire, baseFace) => {
430
- const oc = getKernel().oc;
431
- const [r, gc] = localGC();
432
- const wireFixer = r(new oc.ShapeFix_Wire_2(wire.wrapped, baseFace.wrapped, 1e-9));
433
- wireFixer.FixEdgeCurves();
434
- gc();
435
- return wire;
481
+ var _stack = [];
482
+ try {
483
+ const oc = getKernel().oc;
484
+ const scope = __using(_stack, new DisposalScope());
485
+ const wireFixer = scope.register(new oc.ShapeFix_Wire_2(wire.wrapped, baseFace.wrapped, 1e-9));
486
+ wireFixer.FixEdgeCurves();
487
+ return wire;
488
+ } catch (_) {
489
+ var _error = _, _hasError = true;
490
+ } finally {
491
+ __callDispose(_stack, _error, _hasError);
492
+ }
436
493
  };
437
494
  const faceFromWires = (wires) => {
438
495
  let baseFace;
@@ -510,7 +567,6 @@ class CompoundSketch {
510
567
  twistAngle,
511
568
  origin
512
569
  } = {}) {
513
- const [, gc] = localGC();
514
570
  const rawVec = extrusionDirection ? toVec3(extrusionDirection) : this.outerSketch.defaultDirection;
515
571
  const normVec = vecNormalize(rawVec);
516
572
  const extrusionVec = vecScale(normVec, extrusionDistance);
@@ -541,7 +597,6 @@ class CompoundSketch {
541
597
  } else {
542
598
  result = basicFaceExtrusion(this.face(), extrusionVec);
543
599
  }
544
- gc();
545
600
  return result;
546
601
  }
547
602
  /**
@@ -685,22 +740,28 @@ const sketchFaceOffset = (face, offset2) => {
685
740
  return sketch;
686
741
  };
687
742
  const sketchParametricFunction = (func, planeConfig = {}, { pointsCount = 400, start = 0, stop = 1 } = {}, approximationConfig = {}) => {
688
- const [r, gc] = localGC();
689
- const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
690
- const stepSize = (stop - start) / pointsCount;
691
- const points = [...Array(pointsCount + 1).keys()].map((t) => {
692
- const point = func(start + t * stepSize);
693
- return planeToWorld(plane, point);
694
- });
695
- const wire = unwrap(
696
- assembleWire([r(unwrap(makeBSplineApproximation(points, approximationConfig)))])
697
- );
698
- const sketch = new Sketch(wire, {
699
- defaultOrigin: [...plane.origin],
700
- defaultDirection: [...plane.zDir]
701
- });
702
- gc();
703
- return sketch;
743
+ var _stack = [];
744
+ try {
745
+ const scope = __using(_stack, new DisposalScope());
746
+ const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
747
+ const stepSize = (stop - start) / pointsCount;
748
+ const points = [...Array(pointsCount + 1).keys()].map((t) => {
749
+ const point = func(start + t * stepSize);
750
+ return planeToWorld(plane, point);
751
+ });
752
+ const wire = unwrap(
753
+ assembleWire([scope.register(unwrap(makeBSplineApproximation(points, approximationConfig)))])
754
+ );
755
+ const sketch = new Sketch(wire, {
756
+ defaultOrigin: [...plane.origin],
757
+ defaultDirection: [...plane.zDir]
758
+ });
759
+ return sketch;
760
+ } catch (_) {
761
+ var _error = _, _hasError = true;
762
+ } finally {
763
+ __callDispose(_stack, _error, _hasError);
764
+ }
704
765
  };
705
766
  const sketchHelix = (pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1], lefthand = false) => {
706
767
  const centerVec3 = toVec3(center);
@@ -1149,31 +1210,38 @@ const getEdgesFromOc = (shape) => {
1149
1210
  return getEdges(castShape(shape));
1150
1211
  };
1151
1212
  function makeProjectedEdges(shape, camera, withHiddenLines = true) {
1152
- const oc = getKernel().oc;
1153
- const r = gcWithScope();
1154
- const hiddenLineRemoval = r(new oc.HLRBRep_Algo_1());
1155
- hiddenLineRemoval.Add_2(shape.wrapped, 0);
1156
- const ax2 = r(makeOcAx2(camera.position, camera.direction, camera.xAxis));
1157
- const projector = r(new oc.HLRAlgo_Projector_2(ax2));
1158
- hiddenLineRemoval.Projector_1(projector);
1159
- hiddenLineRemoval.Update();
1160
- hiddenLineRemoval.Hide_1();
1161
- const hlrShapes = r(
1162
- new oc.HLRBRep_HLRToShape(r(new oc.Handle_HLRBRep_Algo_2(hiddenLineRemoval)))
1163
- );
1164
- const visible = [
1165
- ...getEdgesFromOc(hlrShapes.VCompound_1()),
1166
- ...getEdgesFromOc(hlrShapes.Rg1LineVCompound_1()),
1167
- ...getEdgesFromOc(hlrShapes.OutLineVCompound_1())
1168
- ];
1169
- visible.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1170
- const hidden = withHiddenLines ? [
1171
- ...getEdgesFromOc(hlrShapes.HCompound_1()),
1172
- ...getEdgesFromOc(hlrShapes.Rg1LineHCompound_1()),
1173
- ...getEdgesFromOc(hlrShapes.OutLineHCompound_1())
1174
- ] : [];
1175
- hidden.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1176
- return { visible, hidden };
1213
+ var _stack = [];
1214
+ try {
1215
+ const oc = getKernel().oc;
1216
+ const scope = __using(_stack, new DisposalScope());
1217
+ const hiddenLineRemoval = scope.register(new oc.HLRBRep_Algo_1());
1218
+ hiddenLineRemoval.Add_2(shape.wrapped, 0);
1219
+ const ax2 = scope.register(makeOcAx2(camera.position, camera.direction, camera.xAxis));
1220
+ const projector = scope.register(new oc.HLRAlgo_Projector_2(ax2));
1221
+ hiddenLineRemoval.Projector_1(projector);
1222
+ hiddenLineRemoval.Update();
1223
+ hiddenLineRemoval.Hide_1();
1224
+ const hlrShapes = scope.register(
1225
+ new oc.HLRBRep_HLRToShape(scope.register(new oc.Handle_HLRBRep_Algo_2(hiddenLineRemoval)))
1226
+ );
1227
+ const visible = [
1228
+ ...getEdgesFromOc(hlrShapes.VCompound_1()),
1229
+ ...getEdgesFromOc(hlrShapes.Rg1LineVCompound_1()),
1230
+ ...getEdgesFromOc(hlrShapes.OutLineVCompound_1())
1231
+ ];
1232
+ visible.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1233
+ const hidden = withHiddenLines ? [
1234
+ ...getEdgesFromOc(hlrShapes.HCompound_1()),
1235
+ ...getEdgesFromOc(hlrShapes.Rg1LineHCompound_1()),
1236
+ ...getEdgesFromOc(hlrShapes.OutLineHCompound_1())
1237
+ ] : [];
1238
+ hidden.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
1239
+ return { visible, hidden };
1240
+ } catch (_) {
1241
+ var _error = _, _hasError = true;
1242
+ } finally {
1243
+ __callDispose(_stack, _error, _hasError);
1244
+ }
1177
1245
  }
1178
1246
  function createCamera(position = [0, 0, 0], direction = [0, 0, 1], xAxis) {
1179
1247
  const dirLength = vecLength(direction);
@@ -1497,15 +1565,21 @@ const drawParametricFunction = (func, { pointsCount = 400, start = 0, stop = 1,
1497
1565
  return drawPointsInterpolation(points, approximationConfig, { closeShape });
1498
1566
  };
1499
1567
  const edgesToDrawing = (edges) => {
1500
- const [r, gc] = localGC();
1501
- const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
1502
- const planeFace = r(unwrap(makeFace(planeSketch.wire)));
1503
- const curves = edges.map((e) => edgeToCurve(e, planeFace));
1504
- gc();
1505
- const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint(s));
1506
- if (stitchedCurves.length === 0) return new Drawing();
1507
- if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1508
- return new Drawing(new Blueprints(stitchedCurves));
1568
+ var _stack = [];
1569
+ try {
1570
+ const scope = __using(_stack, new DisposalScope());
1571
+ const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
1572
+ const planeFace = scope.register(unwrap(makeFace(planeSketch.wire)));
1573
+ const curves = edges.map((e) => edgeToCurve(e, planeFace));
1574
+ const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint(s));
1575
+ if (stitchedCurves.length === 0) return new Drawing();
1576
+ if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1577
+ return new Drawing(new Blueprints(stitchedCurves));
1578
+ } catch (_) {
1579
+ var _error = _, _hasError = true;
1580
+ } finally {
1581
+ __callDispose(_stack, _error, _hasError);
1582
+ }
1509
1583
  };
1510
1584
  function drawProjection(shape, projectionCamera = "front") {
1511
1585
  let camera;
@@ -1521,15 +1595,21 @@ function drawProjection(shape, projectionCamera = "front") {
1521
1595
  };
1522
1596
  }
1523
1597
  function drawFaceOutline(face) {
1524
- const [r, gc] = localGC();
1525
- const clonedFace = r(createFace(unwrap(downcast(face.wrapped))));
1526
- const faceOuterWire = r(outerWire(clonedFace));
1527
- const curves = getEdges(faceOuterWire).map((e) => edgeToCurve(e, face));
1528
- gc();
1529
- const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint(s));
1530
- if (stitchedCurves.length === 0) return new Drawing();
1531
- if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1532
- return new Drawing(new Blueprints(stitchedCurves));
1598
+ var _stack = [];
1599
+ try {
1600
+ const scope = __using(_stack, new DisposalScope());
1601
+ const clonedFace = scope.register(createFace(unwrap(downcast(face.wrapped))));
1602
+ const faceOuterWire = scope.register(outerWire(clonedFace));
1603
+ const curves = getEdges(faceOuterWire).map((e) => edgeToCurve(e, face));
1604
+ const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint(s));
1605
+ if (stitchedCurves.length === 0) return new Drawing();
1606
+ if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
1607
+ return new Drawing(new Blueprints(stitchedCurves));
1608
+ } catch (_) {
1609
+ var _error = _, _hasError = true;
1610
+ } finally {
1611
+ __callDispose(_stack, _error, _hasError);
1612
+ }
1533
1613
  }
1534
1614
  function sketchExtrude(sketch, height, config) {
1535
1615
  return sketch.extrude(height, config);