brepjs 20.12.7 → 20.12.9

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 (99) hide show
  1. package/dist/2d.cjs +6 -6
  2. package/dist/2d.js +6 -6
  3. package/dist/{adjacencyFns-hMihivxC.js → adjacencyFns-1Cmjb2ot.js} +3 -3
  4. package/dist/{adjacencyFns-mMmTBUBY.cjs → adjacencyFns-CfhGIMeR.cjs} +3 -3
  5. package/dist/{blueprint-BS50D3J_.js → blueprint-BVcuEefs.js} +5 -5
  6. package/dist/{blueprint-17RUHsoP.cjs → blueprint-DbJVzU9F.cjs} +5 -5
  7. package/dist/{blueprintFns-Dw5_4_Bk.cjs → blueprintFns-DePTHG1I.cjs} +2 -2
  8. package/dist/{blueprintFns-zy5lo2IF.js → blueprintFns-mD4pDyFP.js} +2 -2
  9. package/dist/{blueprintSketcher-BG--DxWB.cjs → blueprintSketcher-B5CFmhjg.cjs} +3 -3
  10. package/dist/{blueprintSketcher-C1WCI6E0.js → blueprintSketcher-BrGmq-65.js} +3 -3
  11. package/dist/{boolean2D-CsdyfjFE.js → boolean2D-BrHrY60M.js} +4 -4
  12. package/dist/{boolean2D-7SQ3B0pC.cjs → boolean2D-CFKg1FJ_.cjs} +4 -4
  13. package/dist/{solidBuilders-DdG4NPHM.cjs → booleanFns-C640CeaY.cjs} +11 -217
  14. package/dist/{solidBuilders-Bmr59cGp.js → booleanFns-CKDyqKz0.js} +10 -156
  15. package/dist/brepjs.cjs +325 -168
  16. package/dist/brepjs.js +282 -125
  17. package/dist/{cameraFns-BVWyAscu.js → cameraFns-DIbua1lC.js} +3 -3
  18. package/dist/{cameraFns-BAtzhCYM.cjs → cameraFns-hXUKJkLg.cjs} +3 -3
  19. package/dist/core.cjs +2 -2
  20. package/dist/core.js +2 -2
  21. package/dist/{cornerFinder-Dv_2rmaY.js → cornerFinder-BYDkloVc.js} +1 -1
  22. package/dist/{cornerFinder-e4Wc7_yp.cjs → cornerFinder-ByBGU0r7.cjs} +1 -1
  23. package/dist/{curveFns-BAM7QHrP.cjs → curveFns-Cqgtmhr0.cjs} +1 -1
  24. package/dist/{curveFns-CEI-rouh.js → curveFns-DphpaoQ4.js} +1 -1
  25. package/dist/{drawFns-Cl1i8B_B.js → drawFns-Ch3ah8K9.js} +12 -12
  26. package/dist/{drawFns-d-RvC6u6.cjs → drawFns-GwVZX47o.cjs} +12 -12
  27. package/dist/{faceFns-C-2ttg8X.cjs → faceFns-BDqVGEoB.cjs} +2 -2
  28. package/dist/{faceFns-Q87HCJrp.js → faceFns-D4cDeMRf.js} +2 -2
  29. package/dist/{healingFns-Cm4NkKD8.js → healingFns--vBKh5pa.js} +5 -5
  30. package/dist/{healingFns-DZkO5okn.cjs → healingFns-Fu7Xl8fu.cjs} +29 -29
  31. package/dist/{helpers-DpGcM2qZ.js → helpers-CroIo2SI.js} +6 -6
  32. package/dist/{helpers-BdGGaLhF.cjs → helpers-Wnq-YPWv.cjs} +6 -6
  33. package/dist/{importFns-Bp-p0jiP.js → importFns-D5Bt_44J.js} +314 -15
  34. package/dist/{importFns-DLiP26NW.cjs → importFns-tHr15Lhm.cjs} +319 -14
  35. package/dist/io/igesSupport.d.ts +6 -0
  36. package/dist/io/importFns.d.ts +15 -5
  37. package/dist/io/ioUtils.d.ts +15 -3
  38. package/dist/io/meshNesting.d.ts +11 -0
  39. package/dist/io/threemfImportFns.d.ts +6 -3
  40. package/dist/io.cjs +2 -2
  41. package/dist/io.js +2 -2
  42. package/dist/kernel/occtWasm/evolutionOps.d.ts +4 -3
  43. package/dist/kernel/occtWasm/helpers.d.ts +14 -3
  44. package/dist/kernel/occtWasm/ioOps.d.ts +13 -13
  45. package/dist/kernel/occtWasm/modifierOps.d.ts +5 -3
  46. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  47. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +1 -1
  48. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  49. package/dist/kernel/occtWasm/occtWasmTypes.d.ts +37 -2
  50. package/dist/{loftFns-DQ7Z29n3.js → loftFns-Bh_RuF7a.js} +1 -1
  51. package/dist/{loftFns-DGV1z2NJ.cjs → loftFns-T0GxcPlB.cjs} +1 -1
  52. package/dist/{measureFns-BrdCH4cH.js → measureFns-C3TZ5Fj9.js} +3 -3
  53. package/dist/{measureFns-BdSjw5fr.cjs → measureFns-DGm6ndQY.cjs} +3 -3
  54. package/dist/measurement.cjs +2 -2
  55. package/dist/measurement.js +2 -2
  56. package/dist/{meshFns-BeubBqEI.cjs → meshFns-DDgZ3vpr.cjs} +25 -5
  57. package/dist/{meshFns-UE8tByyw.js → meshFns-Go1XSyUh.js} +20 -6
  58. package/dist/{occtWasmAdapter-D3qerQTq.cjs → occtWasmAdapter-CZPZnpCe.cjs} +297 -85
  59. package/dist/{occtWasmAdapter-DA7oMgcQ.js → occtWasmAdapter-EM3EhKwk.js} +297 -85
  60. package/dist/operations.cjs +2 -2
  61. package/dist/operations.js +2 -2
  62. package/dist/{primitiveFns-3-gs-FUX.js → primitiveFns-CeRc4Sls.js} +5 -4
  63. package/dist/{primitiveFns-CLGVLwG8.cjs → primitiveFns-Dg_XWYtp.cjs} +19 -18
  64. package/dist/{principalBoxFns-CiXzjOkr.cjs → principalBoxFns-B5zdek3y.cjs} +3 -3
  65. package/dist/{principalBoxFns-RMZItjfR.js → principalBoxFns-BuK-ueAB.js} +3 -3
  66. package/dist/projection.cjs +1 -1
  67. package/dist/projection.js +1 -1
  68. package/dist/query.cjs +2 -2
  69. package/dist/query.js +2 -2
  70. package/dist/{refResolveFns-DNX0bCrP.cjs → refResolveFns-CFwsYCKA.cjs} +6 -6
  71. package/dist/{refResolveFns-kJg2iCad.js → refResolveFns-WRcvVhV-.js} +6 -6
  72. package/dist/{shapeFns-CZ6VF1yd.js → shapeFns-CYjU8PsF.js} +2 -2
  73. package/dist/{shapeFns-SgIrOjN4.cjs → shapeFns-DuxfaqTw.cjs} +2 -2
  74. package/dist/shapeRef.cjs +1 -1
  75. package/dist/shapeRef.js +1 -1
  76. package/dist/{shapeTypes-MUEH4XuH.cjs → shapeTypes--7XBFlOD.cjs} +1 -1
  77. package/dist/{shapeTypes-BNGu103j.js → shapeTypes-DvzbSivn.js} +1 -1
  78. package/dist/sketching.cjs +3 -3
  79. package/dist/sketching.js +3 -3
  80. package/dist/{originTrackingFns-c2qgRZ_9.js → solidBuilders-BqSVC4cB.js} +150 -3
  81. package/dist/{originTrackingFns-rEKOAP65.cjs → solidBuilders-D0bIZX9K.cjs} +209 -2
  82. package/dist/{surfaceBuilders-DI376ai0.js → surfaceBuilders--HOoTQad.js} +3 -3
  83. package/dist/{surfaceBuilders-DOmDVuMs.cjs → surfaceBuilders-CPQHyL_5.cjs} +3 -3
  84. package/dist/text.cjs +2 -2
  85. package/dist/text.js +2 -2
  86. package/dist/{textBlueprints-B7Vhr0xu.cjs → textBlueprints-B4HzJzZM.cjs} +9 -8
  87. package/dist/{textBlueprints-CE0oxB43.js → textBlueprints-plsbHqiI.js} +8 -7
  88. package/dist/{textMetrics-C6_kSht6.cjs → textMetrics-CBwUIDI7.cjs} +1 -1
  89. package/dist/{textMetrics-_VGqdewQ.js → textMetrics-IIS6DUTr.js} +1 -1
  90. package/dist/{threadFns-CHdY-4Cz.js → threadFns-CmZFykpi.js} +7 -7
  91. package/dist/{threadFns-1H60LrFX.cjs → threadFns-e8_26ZYw.cjs} +9 -9
  92. package/dist/topology/meshFns.d.ts +3 -0
  93. package/dist/topology.cjs +11 -11
  94. package/dist/topology.js +9 -9
  95. package/dist/{topologyQueryFns-CltEv7Pi.js → topologyQueryFns-BUzMuIs5.js} +1 -1
  96. package/dist/{topologyQueryFns-C_fXO6xL.cjs → topologyQueryFns-NszVx8a0.cjs} +1 -1
  97. package/dist/{validityTypes-GanLrmvY.js → validityTypes-CdY06B8c.js} +1 -1
  98. package/dist/{validityTypes-CGX2ES81.cjs → validityTypes-Ds4zNICF.cjs} +1 -1
  99. package/package.json +2 -2
@@ -2299,16 +2299,56 @@ function multiplyMatrices4x4(a, b) {
2299
2299
  for (let i = 0; i < 4; i++) for (let j = 0; j < 4; j++) for (let k = 0; k < 4; k++) result[i * 4 + j] = result[i * 4 + j] + a[i * 4 + k] * b[k * 4 + j];
2300
2300
  return result;
2301
2301
  }
2302
+ function resolveEdgeValues(edges, value) {
2303
+ const first = [];
2304
+ const second = [];
2305
+ for (const edge of edges) {
2306
+ const v = typeof value === "function" ? value(edge) : value;
2307
+ first.push(typeof v === "number" ? v : v[0]);
2308
+ second.push(typeof v === "number" ? v : v[1]);
2309
+ }
2310
+ return {
2311
+ first,
2312
+ second
2313
+ };
2314
+ }
2315
+ /** The value every edge takes on both sides, or `undefined` when they differ. */
2316
+ function uniformEdgeValue({ first, second }) {
2317
+ const [value] = first;
2318
+ if (value === void 0) return void 0;
2319
+ return first.every((v) => v === value) && second.every((v) => v === value) ? value : void 0;
2320
+ }
2302
2321
  /**
2303
- * Resolve a callback-style radius/distance to a uniform number.
2304
- * occt-wasm's fillet/chamfer take a single radius — uniform per call.
2322
+ * Run a fillet or chamfer over `edges`, naming the edges it fails on. Edges
2323
+ * that all take one value go to `uniform`, the single-value entry point every
2324
+ * occt-wasm build has; otherwise `perEdge` gets each edge's pair as `first`
2325
+ * and `second`.
2305
2326
  */
2306
- function resolveUniformRadius(edges, radius) {
2307
- if (typeof radius === "number") return radius;
2308
- if (Array.isArray(radius)) return radius[0];
2309
- if (edges.length === 0) throw new Error("occt-wasm: no edges provided");
2310
- const val = radius(edges[0]);
2311
- return typeof val === "number" ? val : val[0];
2327
+ function runEdgeTreatment(Module, edges, value, uniform, perEdge) {
2328
+ const values = resolveEdgeValues(edges, value);
2329
+ const shared = uniformEdgeValue(values);
2330
+ const edgeVec = makeVecU32(Module, edges.map(unwrap));
2331
+ try {
2332
+ if (shared !== void 0) return reportingFaultyEdges(edges, () => uniform(edgeVec, shared));
2333
+ const first = makeVecDouble(Module, values.first);
2334
+ const second = makeVecDouble(Module, values.second);
2335
+ try {
2336
+ return reportingFaultyEdges(edges, () => perEdge(edgeVec, first, second));
2337
+ } finally {
2338
+ first.delete();
2339
+ second.delete();
2340
+ }
2341
+ } finally {
2342
+ edgeVec.delete();
2343
+ }
2344
+ }
2345
+ /** Each face's draft angle, in radians. */
2346
+ function draftAnglesRad(faces, angleDeg) {
2347
+ return faces.map((face) => (typeof angleDeg === "function" ? angleDeg(face) : angleDeg) * Math.PI / 180);
2348
+ }
2349
+ /** The peer range still admits older builds, which lack the per-edge and unit entry points. */
2350
+ function needsOcctWasm59(what) {
2351
+ return new UnsupportedKernelOperationError(`occt-wasm: ${what} requires occt-wasm >= 5.9.0`);
2312
2352
  }
2313
2353
  /**
2314
2354
  * Rotate a shape from the kernel's default Z-axis to an arbitrary direction.
@@ -3754,29 +3794,42 @@ function surfaceCurvature(k, face, u, v) {
3754
3794
  // src/kernel/occtWasm/modifierOps.ts
3755
3795
  var HASH_UPPER_BOUND = 2147483647;
3756
3796
  function fillet(k, Module, shape, edges, radius) {
3757
- const r = resolveUniformRadius(edges, radius);
3758
- const vec = makeVecU32(Module, edges.map(unwrap));
3759
- try {
3760
- return wrapResult(k, reportingFaultyEdges(edges, () => k.fillet(unwrap(shape), vec, r)));
3761
- } finally {
3762
- vec.delete();
3763
- }
3797
+ const id = unwrap(shape);
3798
+ return wrapResult(k, runEdgeTreatment(Module, edges, radius, (edgeVec, r) => k.fillet(id, edgeVec, r), (edgeVec, startRadii, endRadii) => {
3799
+ if (!k.filletRadii) throw needsOcctWasm59("per-edge or tapered fillet radii");
3800
+ return k.filletRadii(id, edgeVec, startRadii, endRadii);
3801
+ }));
3764
3802
  }
3765
3803
  function chamfer(k, Module, shape, edges, distance) {
3766
- const d = resolveUniformRadius(edges, distance);
3767
- const vec = makeVecU32(Module, edges.map(unwrap));
3804
+ const id = unwrap(shape);
3805
+ const faceVec = makeVecU32(Module, []);
3768
3806
  try {
3769
- return wrapResult(k, reportingFaultyEdges(edges, () => k.chamfer(unwrap(shape), vec, d)));
3807
+ return wrapResult(k, runEdgeTreatment(Module, edges, distance, (edgeVec, d) => k.chamfer(id, edgeVec, d), (edgeVec, distances1, distances2) => {
3808
+ if (!k.chamferDistances) throw needsOcctWasm59("per-edge or asymmetric chamfer distances");
3809
+ return k.chamferDistances(id, edgeVec, distances1, distances2, faceVec);
3810
+ }));
3770
3811
  } finally {
3771
- vec.delete();
3812
+ faceVec.delete();
3772
3813
  }
3773
3814
  }
3774
3815
  function chamferDistAngle(k, Module, shape, edges, distance, angleDeg) {
3775
- const vec = makeVecU32(Module, edges.map(unwrap));
3816
+ const id = unwrap(shape);
3817
+ const edgeVec = makeVecU32(Module, edges.map(unwrap));
3776
3818
  try {
3777
- return wrapResult(k, k.chamferDistAngle(unwrap(shape), vec, distance, angleDeg));
3819
+ if (!k.chamferDistAngles) return wrapResult(k, k.chamferDistAngle(id, edgeVec, distance, angleDeg));
3820
+ const chamferDistAngles = k.chamferDistAngles.bind(k);
3821
+ const distanceVec = makeVecDouble(Module, Array(edges.length).fill(distance));
3822
+ const angleVec = makeVecDouble(Module, Array(edges.length).fill(angleDeg));
3823
+ const faceVec = makeVecU32(Module, []);
3824
+ try {
3825
+ return wrapResult(k, reportingFaultyEdges(edges, () => chamferDistAngles(id, edgeVec, distanceVec, angleVec, faceVec)));
3826
+ } finally {
3827
+ distanceVec.delete();
3828
+ angleVec.delete();
3829
+ faceVec.delete();
3830
+ }
3778
3831
  } finally {
3779
- vec.delete();
3832
+ edgeVec.delete();
3780
3833
  }
3781
3834
  }
3782
3835
  function shell(k, Module, shape, faces, thickness, tolerance) {
@@ -3858,13 +3911,30 @@ function filletVariable(k, shape, spec) {
3858
3911
  }
3859
3912
  throw new UnsupportedKernelOperationError("occt-wasm: filletVariable: unrecognized spec");
3860
3913
  }
3861
- function draft(k, shape, faces, pullDirection, _neutralPlane, angleDeg) {
3862
- let currentId = unwrap(shape);
3863
- for (const face of faces) {
3864
- const angleRad = (typeof angleDeg === "function" ? angleDeg(face) : angleDeg) * Math.PI / 180;
3865
- currentId = k.draft(currentId, unwrap(face), angleRad, pullDirection[0], pullDirection[1], pullDirection[2]);
3914
+ /**
3915
+ * Before 5.9 occt-wasm drafts one face per call about the XY plane through the
3916
+ * origin. That is the caller's plane (through `neutralPlane`, normal to the
3917
+ * pull) only for a pull along Z and a point at z = 0.
3918
+ */
3919
+ function legacyDraft(k, shape, faces, pullDirection, neutralPlane, anglesRad) {
3920
+ const [face] = faces;
3921
+ const [angle] = anglesRad;
3922
+ const [dx, dy, dz] = pullDirection;
3923
+ if (!(faces.length === 1 && dx === 0 && dy === 0 && neutralPlane[2] === 0) || face === void 0 || angle === void 0) throw needsOcctWasm59("drafting several faces, or about a neutral plane off z = 0,");
3924
+ return wrapResult(k, k.draft(unwrap(shape), unwrap(face), angle, dx, dy, dz));
3925
+ }
3926
+ /** Draft every face in one operation about the plane through `neutralPlane` normal to the pull. */
3927
+ function draft(k, Module, shape, faces, pullDirection, neutralPlane, angleDeg) {
3928
+ const anglesRad = draftAnglesRad(faces, angleDeg);
3929
+ if (!k.draftFaces) return legacyDraft(k, shape, faces, pullDirection, neutralPlane, anglesRad);
3930
+ const faceVec = makeVecU32(Module, faces.map(unwrap));
3931
+ const angleVec = makeVecDouble(Module, anglesRad);
3932
+ try {
3933
+ return wrapResult(k, k.draftFaces(unwrap(shape), faceVec, angleVec, ...pullDirection, ...neutralPlane, ...pullDirection));
3934
+ } finally {
3935
+ faceVec.delete();
3936
+ angleVec.delete();
3866
3937
  }
3867
- return wrapResult(k, currentId);
3868
3938
  }
3869
3939
  function defeature(k, Module, shape, faces) {
3870
3940
  const vec = makeVecU32(Module, faces.map(unwrap));
@@ -4480,10 +4550,85 @@ function buildGltfManifest(vCount, nCount, iCount, posBytes, nrmBytes, idxBytes,
4480
4550
  ]
4481
4551
  };
4482
4552
  }
4553
+ var MM_PER_UNIT = {
4554
+ mm: 1,
4555
+ millimeter: 1,
4556
+ millimetre: 1,
4557
+ cm: 10,
4558
+ centimeter: 10,
4559
+ centimetre: 10,
4560
+ m: 1e3,
4561
+ meter: 1e3,
4562
+ metre: 1e3,
4563
+ km: 1e6,
4564
+ kilometer: 1e6,
4565
+ kilometre: 1e6,
4566
+ in: 25.4,
4567
+ inch: 25.4,
4568
+ ft: 304.8,
4569
+ foot: 304.8,
4570
+ feet: 304.8,
4571
+ mi: 1609344,
4572
+ mile: 1609344,
4573
+ mil: .0254,
4574
+ thou: .0254,
4575
+ um: .001,
4576
+ micron: .001,
4577
+ micrometer: .001,
4578
+ micrometre: .001,
4579
+ uin: 254e-7,
4580
+ microinch: 254e-7
4581
+ };
4582
+ function mmPerUnit(unit) {
4583
+ const mm = MM_PER_UNIT[unit.toLowerCase()];
4584
+ if (mm === void 0) throw new Error(`occt-wasm: unknown STEP length unit '${unit}'`);
4585
+ return mm;
4586
+ }
4587
+ /**
4588
+ * brepjs writes lengths in `unit` and reads the shapes as `modelUnit`, which
4589
+ * defaults to `unit` (so `unit` alone relabels and does not scale). occt-wasm
4590
+ * reads shapes as millimeters and scales them into the unit written, so a
4591
+ * model in another unit is scaled to millimeters first.
4592
+ */
4593
+ function resolveStepUnits(options) {
4594
+ const write = options?.unit ?? options?.modelUnit ?? "mm";
4595
+ return {
4596
+ write,
4597
+ modelScale: mmPerUnit(options?.modelUnit ?? write)
4598
+ };
4599
+ }
4600
+ /**
4601
+ * The writer for `units`: the 5.9 unit-aware one, else the millimeter-only
4602
+ * one when the file is in millimeters anyway.
4603
+ */
4604
+ function stepWriter(withUnit, inMillimeters, units) {
4605
+ if (withUnit) return (id) => withUnit(id, units.write);
4606
+ if (mmPerUnit(units.write) === 1) return inMillimeters;
4607
+ throw needsOcctWasm59(`STEP export in '${units.write}'`);
4608
+ }
4609
+ /** Run `use` on `id` scaled by `factor` about the origin, releasing the scaled copy. */
4610
+ function withScaled(k, id, factor, use) {
4611
+ if (factor === 1) return use(id);
4612
+ const scaled = k.scale(id, 0, 0, 0, factor);
4613
+ try {
4614
+ return use(scaled);
4615
+ } finally {
4616
+ k.release(scaled);
4617
+ }
4618
+ }
4619
+ /** One STEP file holding every shape (as a compound when there are several). */
4620
+ function writeStepShapes(k, makeCompound, shapes, units) {
4621
+ const write = stepWriter(k.exportStepWithUnit?.bind(k), (id) => k.exportStep(id), units);
4622
+ if (shapes.length === 1) return withScaled(k, unwrap(shapes[0]), units.modelScale, write);
4623
+ const compoundId = unwrap(makeCompound(shapes));
4624
+ try {
4625
+ return withScaled(k, compoundId, units.modelScale, write);
4626
+ } finally {
4627
+ k.release(compoundId);
4628
+ }
4629
+ }
4483
4630
  function exportSTEP(k, makeCompound, shapes) {
4484
- if (shapes.length === 1) return k.exportStep(unwrap(shapes[0]));
4485
- const compound = makeCompound(shapes);
4486
- return k.exportStep(unwrap(compound));
4631
+ return writeStepShapes(k, makeCompound, shapes, resolveStepUnits(void 0));
4487
4632
  }
4488
4633
  function exportSTL(mesh, shape, binary, tolerance = DEFAULT_STL_TOLERANCE, angularTolerance = DEFAULT_STL_ANGULAR_TOLERANCE) {
4489
4634
  const { vertices, triangles } = mesh(shape, {
@@ -4508,22 +4653,19 @@ function importSTL(k, Module, data) {
4508
4653
  return wrapResult(k, k.importStl(""));
4509
4654
  }
4510
4655
  function exportIGES(k, makeCompound, shapes) {
4511
- if (shapes.length === 1) return k.exportIges(unwrap(shapes[0]));
4512
- const compound = makeCompound(shapes);
4513
- return k.exportIges(unwrap(compound));
4656
+ const exportIges = k.exportIges?.bind(k);
4657
+ if (!exportIges) throw new UnsupportedKernelOperationError("occt-wasm: exportIGES is unsupported");
4658
+ if (shapes.length === 1) return exportIges(unwrap(shapes[0]));
4659
+ return exportIges(unwrap(makeCompound(shapes)));
4514
4660
  }
4515
4661
  function importIGES(k, data) {
4516
- const str = typeof data === "string" ? data : new TextDecoder().decode(data);
4517
- return [wrapResult(k, k.importIges(str))];
4662
+ const importIges = k.importIges?.bind(k);
4663
+ if (!importIges) throw new UnsupportedKernelOperationError("occt-wasm: importIGES is unsupported");
4664
+ return [wrapResult(k, importIges(typeof data === "string" ? data : new TextDecoder().decode(data)))];
4518
4665
  }
4519
- function exportSTEPAssembly(k, Module, parts, _options) {
4666
+ function exportSTEPAssembly(k, parts, options) {
4520
4667
  if (parts.length === 0) return "";
4521
- const doc = createXCAFDocument(k, Module, parts);
4522
- try {
4523
- return writeXCAFToSTEP(k, doc);
4524
- } finally {
4525
- doc.delete();
4526
- }
4668
+ return writeXcafParts(k, parts, resolveStepUnits(options));
4527
4669
  }
4528
4670
  function exportGLB(mesh, shape, tolerance) {
4529
4671
  const result = mesh(shape, {
@@ -4651,9 +4793,9 @@ function toBREP(k, shape) {
4651
4793
  function fromBREP(k, data) {
4652
4794
  return wrapResult(k, k.fromBREP(data));
4653
4795
  }
4654
- function createXCAFDocument(k, _Module, shapes) {
4796
+ function addXcafParts(k, parts) {
4655
4797
  const docId = k.xcafNewDocument();
4656
- for (const entry of shapes) {
4798
+ for (const entry of parts) {
4657
4799
  const labelId = k.xcafAddShape(docId, unwrap(entry.shape));
4658
4800
  if (entry.name) k.xcafSetName(docId, labelId, entry.name);
4659
4801
  if (entry.color) {
@@ -4661,37 +4803,94 @@ function createXCAFDocument(k, _Module, shapes) {
4661
4803
  k.xcafSetColor(docId, labelId, r / 255, g / 255, b / 255);
4662
4804
  }
4663
4805
  }
4664
- return handle("compound", docId);
4806
+ return docId;
4665
4807
  }
4666
- function writeXCAFToSTEP(k, doc, _options) {
4667
- const docId = unwrap(doc);
4808
+ function writeXcafDoc(k, docId, units) {
4668
4809
  const roots = k.xcafGetRootLabels(docId);
4669
- const hasShapes = (() => {
4810
+ try {
4811
+ if (roots.size() === 0) return "";
4812
+ } finally {
4813
+ roots.delete();
4814
+ }
4815
+ return stepWriter(k.xcafExportSTEPWithUnit?.bind(k), (id) => k.xcafExportSTEP(id), units)(docId);
4816
+ }
4817
+ /** Write `parts` as one XCAF STEP file, scaling each into millimeters first if needed. */
4818
+ function writeXcafParts(k, parts, units) {
4819
+ const scaled = [];
4820
+ try {
4821
+ const docId = addXcafParts(k, parts.map((part) => {
4822
+ if (units.modelScale === 1) return part;
4823
+ const id = k.scale(unwrap(part.shape), 0, 0, 0, units.modelScale);
4824
+ scaled.push(id);
4825
+ return {
4826
+ ...part,
4827
+ shape: id
4828
+ };
4829
+ }));
4670
4830
  try {
4671
- return roots.size() > 0;
4831
+ return writeXcafDoc(k, docId, units);
4672
4832
  } finally {
4673
- roots.delete();
4833
+ k.xcafClose(docId);
4674
4834
  }
4675
- })();
4835
+ } finally {
4836
+ for (const id of scaled) k.release(id);
4837
+ }
4838
+ }
4839
+ function createXCAFDocument(k, makeCompound, shapes) {
4840
+ const retainedId = unwrap(makeCompound(shapes.map((s) => s.shape)));
4676
4841
  try {
4677
- return hasShapes ? k.xcafExportSTEP(docId) : "";
4842
+ return {
4843
+ ...handle("compound", addXcafParts(k, shapes)),
4844
+ retainedId,
4845
+ labels: shapes.map(({ name, color }) => ({
4846
+ name,
4847
+ color
4848
+ }))
4849
+ };
4850
+ } catch (e) {
4851
+ k.release(retainedId);
4852
+ throw e;
4853
+ }
4854
+ }
4855
+ function writeXCAFToSTEP(k, doc, options) {
4856
+ const docId = unwrap(doc);
4857
+ const { retainedId, labels } = doc;
4858
+ try {
4859
+ const units = resolveStepUnits(options);
4860
+ if (units.modelScale === 1) return writeXcafDoc(k, docId, units);
4861
+ if (retainedId === void 0 || labels === void 0) throw new Error("occt-wasm: this XCAF document does not record its parts");
4862
+ return writeScaledXcafParts(k, retainedId, labels, units);
4678
4863
  } finally {
4679
4864
  k.xcafClose(docId);
4865
+ if (retainedId !== void 0) k.release(retainedId);
4680
4866
  }
4681
4867
  }
4682
- function exportSTEPConfigured(k, Module, shapes, _options) {
4683
- if (shapes.length === 0) return "";
4684
- const doc = createXCAFDocument(k, Module, shapes.map((s) => ({
4685
- shape: s.shape,
4686
- name: s.name ?? "",
4687
- color: s.color
4688
- })));
4868
+ /** Scale the retained compound once and write its children as the labeled parts. */
4869
+ function writeScaledXcafParts(k, retainedId, labels, units) {
4870
+ const scaledId = k.scale(retainedId, 0, 0, 0, units.modelScale);
4871
+ const children = k.iterShapes(scaledId);
4872
+ const childIds = [];
4689
4873
  try {
4690
- return writeXCAFToSTEP(k, doc);
4874
+ for (let i = 0; i < children.size(); i++) childIds.push(children.get(i));
4875
+ return writeXcafParts(k, labels.map((label, i) => ({
4876
+ ...label,
4877
+ shape: handle("compound", childIds[i] ?? 0)
4878
+ })), {
4879
+ ...units,
4880
+ modelScale: 1
4881
+ });
4691
4882
  } finally {
4692
- doc.delete();
4883
+ children.delete();
4884
+ for (const id of childIds) k.release(id);
4885
+ k.release(scaledId);
4693
4886
  }
4694
4887
  }
4888
+ function exportSTEPConfigured(k, makeCompound, shapes, options) {
4889
+ if (shapes.length === 0) return "";
4890
+ const units = resolveStepUnits(options);
4891
+ if (!shapes.some((s) => s.name || s.color)) return writeStepShapes(k, makeCompound, shapes.map((s) => s.shape), units);
4892
+ return writeXcafParts(k, shapes, units);
4893
+ }
4695
4894
  // src/kernel/occtWasm/constructionOps.ts
4696
4895
  function makeVertex(k, x, y, z) {
4697
4896
  return handle("vertex", k.makeVertex(x, y, z));
@@ -5924,32 +6123,36 @@ function cutAllWithHistory(k, Module, shape, tools, inputFaceHashes, hashUpperBo
5924
6123
  return withSolidIds(k, [shape], (argIds) => withSolidIds(k, tools, (toolIds) => viaBooleanOp(k, Module, "cut", argIds, toolIds, inputFaceHashes, hashUpperBound, options)));
5925
6124
  }
5926
6125
  function filletWithHistory(k, Module, shape, edges, radius, inputFaceHashes, hashUpperBound) {
5927
- const r = resolveUniformRadius(edges, radius);
5928
- const edgeVec = makeVecU32(Module, edges.map(unwrap));
6126
+ const shapeId = unwrap(shape);
5929
6127
  const hashVec = makeVecInt(Module, inputFaceHashes);
5930
6128
  try {
5931
- const { id, evolution } = parseEvolution(reportingFaultyEdges(edges, () => k.filletWithHistory(unwrap(shape), edgeVec, r, hashVec, hashUpperBound)));
6129
+ const { id, evolution } = parseEvolution(runEdgeTreatment(Module, edges, radius, (edgeVec, r) => k.filletWithHistory(shapeId, edgeVec, r, hashVec, hashUpperBound), (edgeVec, startRadii, endRadii) => {
6130
+ if (!k.filletRadiiWithHistory) throw needsOcctWasm59("per-edge or tapered fillet radii");
6131
+ return k.filletRadiiWithHistory(shapeId, edgeVec, startRadii, endRadii, hashVec, hashUpperBound);
6132
+ }));
5932
6133
  return {
5933
6134
  shape: wrapResult(k, id),
5934
6135
  evolution
5935
6136
  };
5936
6137
  } finally {
5937
- edgeVec.delete();
5938
6138
  hashVec.delete();
5939
6139
  }
5940
6140
  }
5941
6141
  function chamferWithHistory(k, Module, shape, edges, distance, inputFaceHashes, hashUpperBound) {
5942
- const d = resolveUniformRadius(edges, distance);
5943
- const edgeVec = makeVecU32(Module, edges.map(unwrap));
6142
+ const shapeId = unwrap(shape);
6143
+ const faceVec = makeVecU32(Module, []);
5944
6144
  const hashVec = makeVecInt(Module, inputFaceHashes);
5945
6145
  try {
5946
- const { id, evolution } = parseEvolution(reportingFaultyEdges(edges, () => k.chamferWithHistory(unwrap(shape), edgeVec, d, hashVec, hashUpperBound)));
6146
+ const { id, evolution } = parseEvolution(runEdgeTreatment(Module, edges, distance, (edgeVec, d) => k.chamferWithHistory(shapeId, edgeVec, d, hashVec, hashUpperBound), (edgeVec, distances1, distances2) => {
6147
+ if (!k.chamferDistancesWithHistory) throw needsOcctWasm59("per-edge or asymmetric chamfer distances");
6148
+ return k.chamferDistancesWithHistory(shapeId, edgeVec, distances1, distances2, faceVec, hashVec, hashUpperBound);
6149
+ }));
5947
6150
  return {
5948
6151
  shape: wrapResult(k, id),
5949
6152
  evolution
5950
6153
  };
5951
6154
  } finally {
5952
- edgeVec.delete();
6155
+ faceVec.delete();
5953
6156
  hashVec.delete();
5954
6157
  }
5955
6158
  }
@@ -5991,21 +6194,30 @@ function offsetWithHistory(k, Module, shape, distance, inputFaceHashes, hashUppe
5991
6194
  hashVec.delete();
5992
6195
  }
5993
6196
  }
5994
- function draftWithHistory(k, shape, faces, pullDirection, angleDeg) {
5995
- const [dx, dy, dz] = pullDirection;
5996
- let currentId = unwrap(shape);
5997
- for (const face of faces) {
5998
- const angleRad = (typeof angleDeg === "number" ? angleDeg : angleDeg(face)) * Math.PI / 180;
5999
- currentId = k.draft(currentId, unwrap(face), angleRad, dx, dy, dz);
6000
- }
6001
- return {
6002
- shape: wrapResult(k, currentId),
6197
+ function draftWithHistory(k, Module, shape, faces, pullDirection, neutralPlane, angleDeg, inputFaceHashes, hashUpperBound) {
6198
+ if (!k.draftFacesWithHistory) return {
6199
+ shape: draft(k, Module, shape, faces, pullDirection, neutralPlane, angleDeg),
6003
6200
  evolution: {
6004
6201
  modified: /* @__PURE__ */ new Map(),
6005
6202
  generated: /* @__PURE__ */ new Map(),
6006
6203
  deleted: /* @__PURE__ */ new Set()
6007
6204
  }
6008
6205
  };
6206
+ const anglesRad = draftAnglesRad(faces, angleDeg);
6207
+ const faceVec = makeVecU32(Module, faces.map(unwrap));
6208
+ const angleVec = makeVecDouble(Module, anglesRad);
6209
+ const hashVec = makeVecInt(Module, inputFaceHashes);
6210
+ try {
6211
+ const { id, evolution } = parseEvolution(k.draftFacesWithHistory(unwrap(shape), faceVec, angleVec, ...pullDirection, ...neutralPlane, ...pullDirection, hashVec, hashUpperBound));
6212
+ return {
6213
+ shape: wrapResult(k, id),
6214
+ evolution
6215
+ };
6216
+ } finally {
6217
+ faceVec.delete();
6218
+ angleVec.delete();
6219
+ hashVec.delete();
6220
+ }
6009
6221
  }
6010
6222
  function applyComposedTransformWithHistory(transformFn, iterShapesFn, hashCodeFn, shape, transformHandle, inputFaceHashes, hashUpperBound) {
6011
6223
  const result = transformFn(shape, transformHandle);
@@ -6367,7 +6579,7 @@ var OcctWasmAdapter = class OcctWasmAdapter {
6367
6579
  return filletVariable(this.k, shape, spec);
6368
6580
  }
6369
6581
  draft(shape, faces, pullDirection, neutralPlane, angleDeg) {
6370
- return draft(this.k, shape, faces, pullDirection, neutralPlane, angleDeg);
6582
+ return draft(this.k, this.Module, shape, faces, pullDirection, neutralPlane, angleDeg);
6371
6583
  }
6372
6584
  defeature(shape, faces) {
6373
6585
  return defeature(this.k, this.Module, shape, faces);
@@ -6459,8 +6671,8 @@ var OcctWasmAdapter = class OcctWasmAdapter {
6459
6671
  offsetWithHistory(shape, distance, inputFaceHashes, hashUpperBound, tolerance) {
6460
6672
  return offsetWithHistory(this.k, this.Module, shape, distance, inputFaceHashes, hashUpperBound, tolerance);
6461
6673
  }
6462
- draftWithHistory(shape, faces, pullDirection, _neutralPlane, angleDeg, _inputFaceHashes, _hashUpperBound) {
6463
- return draftWithHistory(this.k, shape, faces, pullDirection, angleDeg);
6674
+ draftWithHistory(shape, faces, pullDirection, neutralPlane, angleDeg, inputFaceHashes, hashUpperBound) {
6675
+ return draftWithHistory(this.k, this.Module, shape, faces, pullDirection, neutralPlane, angleDeg, inputFaceHashes, hashUpperBound);
6464
6676
  }
6465
6677
  applyComposedTransformWithHistory(shape, transformHandle, inputFaceHashes, hashUpperBound) {
6466
6678
  return applyComposedTransformWithHistory((s, t) => this.transform(s, t), (s, t) => this.iterShapes(s, t), (s, ub) => this.hashCode(s, ub), shape, transformHandle, inputFaceHashes, hashUpperBound);
@@ -6496,7 +6708,7 @@ var OcctWasmAdapter = class OcctWasmAdapter {
6496
6708
  return importIGES(this.k, data);
6497
6709
  }
6498
6710
  exportSTEPAssembly(parts, options) {
6499
- return exportSTEPAssembly(this.k, this.Module, parts, options);
6711
+ return exportSTEPAssembly(this.k, parts, options);
6500
6712
  }
6501
6713
  export3MF(_shape, _tolerance) {
6502
6714
  throw new Error("export3MF is only available with the brepkit kernel");
@@ -6526,13 +6738,13 @@ var OcctWasmAdapter = class OcctWasmAdapter {
6526
6738
  return fromBREP(this.k, data);
6527
6739
  }
6528
6740
  createXCAFDocument(shapes) {
6529
- return createXCAFDocument(this.k, this.Module, shapes);
6741
+ return createXCAFDocument(this.k, this.makeCompound.bind(this), shapes);
6530
6742
  }
6531
6743
  writeXCAFToSTEP(doc, options) {
6532
6744
  return writeXCAFToSTEP(this.k, doc, options);
6533
6745
  }
6534
6746
  exportSTEPConfigured(shapes, options) {
6535
- return exportSTEPConfigured(this.k, this.Module, shapes, options);
6747
+ return exportSTEPConfigured(this.k, this.makeCompound.bind(this), shapes, options);
6536
6748
  }
6537
6749
  volume(shape) {
6538
6750
  return volume(this.k, shape);
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_threadFns = require("./threadFns-1H60LrFX.cjs");
3
- const require_loftFns = require("./loftFns-DGV1z2NJ.cjs");
2
+ const require_threadFns = require("./threadFns-e8_26ZYw.cjs");
3
+ const require_loftFns = require("./loftFns-T0GxcPlB.cjs");
4
4
  exports.addChild = require_threadFns.addChild;
5
5
  exports.addJoint = require_threadFns.addJoint;
6
6
  exports.addStep = require_threadFns.addStep;
@@ -1,3 +1,3 @@
1
- import { A as setJointValue, B as walkAssembly, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, F as countNodes, H as circularPattern, I as createAssemblyNode, L as findNode, M as sphericalJoint, N as addChild, O as prismaticJoint, P as collectShapes, R as removeChild, S as addJoint, T as jointTransform, U as gridPattern, V as exportAssemblySTEP, W as linearPattern, Y as createAssembly, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as updateNode } from "./threadFns-CHdY-4Cz.js";
2
- import { c as twistExtrude, o as supportExtrude, r as complexExtrude, s as sweep } from "./loftFns-DQ7Z29n3.js";
1
+ import { A as setJointValue, B as walkAssembly, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, F as countNodes, H as circularPattern, I as createAssemblyNode, L as findNode, M as sphericalJoint, N as addChild, O as prismaticJoint, P as collectShapes, R as removeChild, S as addJoint, T as jointTransform, U as gridPattern, V as exportAssemblySTEP, W as linearPattern, Y as createAssembly, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as updateNode } from "./threadFns-CmZFykpi.js";
2
+ import { c as twistExtrude, o as supportExtrude, r as complexExtrude, s as sweep } from "./loftFns-Bh_RuF7a.js";
3
3
  export { addChild, addJoint, addStep, circularPattern, collectShapes, complexExtrude, countNodes, createAssembly, createAssemblyNode, createHistory, createRegistry, cylindricalJoint, exportAssemblySTEP, exportURDF, findNode, findStep, forwardKinematics, getShape as getHistoryShape, gridPattern, importURDF, inverseKinematics, jointTrajectory, jointTransform, jointsFromDH, linearPattern, mechanismDOF, modifyStep, planarJoint, prismaticJoint, registerOperation, registerShape, removeChild, replayFrom, replayHistory, revoluteJoint, setJointValue, setJointValues, sphericalJoint, stepCount, stepsFrom, supportExtrude, sweep, thread, twistExtrude, undoLast, updateNode, walkAssembly };
@@ -1,10 +1,11 @@
1
- import { E as GeometryCleanupError, G as _usingCtx, d as createSolid, n as castResultShape, q as getKernel } from "./shapeTypes-BNGu103j.js";
1
+ import { E as GeometryCleanupError, G as _usingCtx, d as createSolid, n as castResultShape, q as getKernel } from "./shapeTypes-DvzbSivn.js";
2
2
  import { E as ok, d as validationError, g as err, m as andThen, t as BrepErrorCode } from "./errors-BTccWbtE.js";
3
- import { n as isClosedWire } from "./validityTypes-GanLrmvY.js";
3
+ import { n as isClosedWire } from "./validityTypes-CdY06B8c.js";
4
4
  import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-iraOnb2p.js";
5
5
  import { d as vecNormalize, h as vecScale } from "./vecOps-S-m9H_fe.js";
6
- import { C as propagateAllMetadata, S as hasAnyMetadata, T as propagateMetadataThroughRelocation, a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces, w as propagateMetadataByHash, x as collectInputFaceHashes } from "./solidBuilders-Bmr59cGp.js";
7
- import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-DI376ai0.js";
6
+ import { a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces } from "./solidBuilders-BqSVC4cB.js";
7
+ import { d as collectInputFaceHashes, f as hasAnyMetadata, h as propagateMetadataThroughRelocation, m as propagateMetadataByHash, p as propagateAllMetadata } from "./booleanFns-CKDyqKz0.js";
8
+ import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders--HOoTQad.js";
8
9
  // src/topology/transformFns.ts
9
10
  /**
10
11
  * Immutable shape transforms — translate, rotate, scale, mirror, applyMatrix.