brepjs 12.8.2 → 12.9.1

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 (225) hide show
  1. package/dist/2d/lib/svgPath.d.ts.map +1 -1
  2. package/dist/2d/lib/vectorOperations.d.ts +4 -1
  3. package/dist/2d/lib/vectorOperations.d.ts.map +1 -1
  4. package/dist/2d.cjs +2 -2
  5. package/dist/2d.js +5 -5
  6. package/dist/{Blueprint-DbVaf6k7.js → Blueprint-1HGbugaC.js} +33 -63
  7. package/dist/{Blueprint-CQ28WJhz.cjs → Blueprint-CUyXM6CV.cjs} +15 -45
  8. package/dist/{boolean2D-0blbVtJ8.cjs → boolean2D-9OnbotKT.cjs} +9 -9
  9. package/dist/{boolean2D-y3E92F0u.js → boolean2D-CR4efa35.js} +11 -11
  10. package/dist/{booleanFns-gmsX3Cv2.cjs → booleanFns-BBd2oTvv.cjs} +43 -40
  11. package/dist/{booleanFns-BCTjYZAg.js → booleanFns-Br2KdGJq.js} +53 -50
  12. package/dist/brepjs.cjs +379 -284
  13. package/dist/brepjs.js +1437 -1341
  14. package/dist/core/definitionMaps.d.ts +2 -7
  15. package/dist/core/definitionMaps.d.ts.map +1 -1
  16. package/dist/core/dimensionTypes.d.ts +52 -0
  17. package/dist/core/dimensionTypes.d.ts.map +1 -0
  18. package/dist/core/disposal.d.ts +18 -0
  19. package/dist/core/disposal.d.ts.map +1 -1
  20. package/dist/core/errors.d.ts +1 -8
  21. package/dist/core/errors.d.ts.map +1 -1
  22. package/dist/core/kernelErrorTranslation.d.ts +15 -0
  23. package/dist/core/kernelErrorTranslation.d.ts.map +1 -0
  24. package/dist/core/planeOps.d.ts +14 -0
  25. package/dist/core/planeOps.d.ts.map +1 -1
  26. package/dist/core/result.d.ts +4 -0
  27. package/dist/core/result.d.ts.map +1 -1
  28. package/dist/core/shapeTypes.d.ts +14 -146
  29. package/dist/core/shapeTypes.d.ts.map +1 -1
  30. package/dist/core/typeDiscriminants.d.ts +14 -0
  31. package/dist/core/typeDiscriminants.d.ts.map +1 -0
  32. package/dist/core/validityTypes.d.ts +100 -0
  33. package/dist/core/validityTypes.d.ts.map +1 -0
  34. package/dist/core.cjs +52 -11
  35. package/dist/core.d.ts +1 -1
  36. package/dist/core.d.ts.map +1 -1
  37. package/dist/core.js +118 -75
  38. package/dist/{curveFns-mROFhiuG.js → curveFns-1u0oZ0u0.js} +14 -14
  39. package/dist/{curveFns-BZngcnQ1.cjs → curveFns-BwLvO_Ia.cjs} +2 -2
  40. package/dist/{drawFns-Bwakrq7w.js → drawFns-B0na6sbo.js} +16 -16
  41. package/dist/{drawFns-CjRc1NfQ.cjs → drawFns-CzlEePor.cjs} +18 -18
  42. package/dist/{faceFns-DB1Fc5gy.cjs → faceFns-BAKkZG6D.cjs} +2 -2
  43. package/dist/{faceFns-B8GnxjdY.js → faceFns-DGMp47Os.js} +3 -3
  44. package/dist/{helpers-C8NoT0Wu.cjs → helpers-DVdscQxW.cjs} +73 -8
  45. package/dist/{helpers-X0juxnwj.js → helpers-sJjnIXDA.js} +85 -20
  46. package/dist/index.d.ts +10 -11
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/io.cjs +4 -4
  49. package/dist/io.js +4 -4
  50. package/dist/kernel/brepkit/booleanOps.d.ts +23 -0
  51. package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -0
  52. package/dist/kernel/brepkit/constructionOps.d.ts +51 -0
  53. package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -0
  54. package/dist/kernel/brepkit/evolutionOps.d.ts +31 -0
  55. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -0
  56. package/dist/kernel/brepkit/geometryOps.d.ts +56 -0
  57. package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -0
  58. package/dist/kernel/brepkit/helpers.d.ts +84 -0
  59. package/dist/kernel/brepkit/helpers.d.ts.map +1 -0
  60. package/dist/kernel/brepkit/internalOps.d.ts +28 -0
  61. package/dist/kernel/brepkit/internalOps.d.ts.map +1 -0
  62. package/dist/kernel/brepkit/ioOps.d.ts +43 -0
  63. package/dist/kernel/brepkit/ioOps.d.ts.map +1 -0
  64. package/dist/kernel/brepkit/measureOps.d.ts +30 -0
  65. package/dist/kernel/brepkit/measureOps.d.ts.map +1 -0
  66. package/dist/kernel/brepkit/meshOps.d.ts +7 -0
  67. package/dist/kernel/brepkit/meshOps.d.ts.map +1 -0
  68. package/dist/kernel/brepkit/modifierOps.d.ts +15 -0
  69. package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -0
  70. package/dist/kernel/brepkit/repairOps.d.ts +14 -0
  71. package/dist/kernel/brepkit/repairOps.d.ts.map +1 -0
  72. package/dist/kernel/brepkit/sweepOps.d.ts +27 -0
  73. package/dist/kernel/brepkit/sweepOps.d.ts.map +1 -0
  74. package/dist/kernel/brepkit/topologyOps.d.ts +16 -0
  75. package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -0
  76. package/dist/kernel/brepkit/transformOps.d.ts +14 -0
  77. package/dist/kernel/brepkit/transformOps.d.ts.map +1 -0
  78. package/dist/kernel/brepkitAdapter.d.ts +1 -1
  79. package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
  80. package/dist/kernel/brepkitWasmTypes.d.ts +8 -0
  81. package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
  82. package/dist/kernel/defaultAdapter.d.ts.map +1 -1
  83. package/dist/kernel/extendedConstructorOps.d.ts +9 -1
  84. package/dist/kernel/extendedConstructorOps.d.ts.map +1 -1
  85. package/dist/kernel/index.d.ts +1 -0
  86. package/dist/kernel/index.d.ts.map +1 -1
  87. package/dist/kernel/interfaces/boolean-ops.d.ts +25 -0
  88. package/dist/kernel/interfaces/boolean-ops.d.ts.map +1 -0
  89. package/dist/kernel/interfaces/construction-ops.d.ts +76 -0
  90. package/dist/kernel/interfaces/construction-ops.d.ts.map +1 -0
  91. package/dist/kernel/interfaces/core.d.ts +45 -0
  92. package/dist/kernel/interfaces/core.d.ts.map +1 -0
  93. package/dist/kernel/interfaces/evolution-ops.d.ts +19 -0
  94. package/dist/kernel/interfaces/evolution-ops.d.ts.map +1 -0
  95. package/dist/kernel/interfaces/geometry-ops.d.ts +77 -0
  96. package/dist/kernel/interfaces/geometry-ops.d.ts.map +1 -0
  97. package/dist/kernel/interfaces/index.d.ts +29 -0
  98. package/dist/kernel/interfaces/index.d.ts.map +1 -0
  99. package/dist/kernel/interfaces/io-ops.d.ts +66 -0
  100. package/dist/kernel/interfaces/io-ops.d.ts.map +1 -0
  101. package/dist/kernel/interfaces/measure-ops.d.ts +35 -0
  102. package/dist/kernel/interfaces/measure-ops.d.ts.map +1 -0
  103. package/dist/kernel/interfaces/mesh-ops.d.ts +21 -0
  104. package/dist/kernel/interfaces/mesh-ops.d.ts.map +1 -0
  105. package/dist/kernel/interfaces/modifier-ops.d.ts +22 -0
  106. package/dist/kernel/interfaces/modifier-ops.d.ts.map +1 -0
  107. package/dist/kernel/interfaces/repair-ops.d.ts +36 -0
  108. package/dist/kernel/interfaces/repair-ops.d.ts.map +1 -0
  109. package/dist/kernel/interfaces/sweep-ops.d.ts +49 -0
  110. package/dist/kernel/interfaces/sweep-ops.d.ts.map +1 -0
  111. package/dist/kernel/interfaces/topology-ops.d.ts +30 -0
  112. package/dist/kernel/interfaces/topology-ops.d.ts.map +1 -0
  113. package/dist/kernel/interfaces/transform-ops.d.ts +20 -0
  114. package/dist/kernel/interfaces/transform-ops.d.ts.map +1 -0
  115. package/dist/kernel/modifierOps.d.ts +2 -2
  116. package/dist/kernel/modifierOps.d.ts.map +1 -1
  117. package/dist/kernel/types.d.ts +2 -446
  118. package/dist/kernel/types.d.ts.map +1 -1
  119. package/dist/{loft-hp3pc1M7.cjs → loft-BNvBZzqe.cjs} +5 -5
  120. package/dist/{loft-Bhw-FMoL.js → loft-D0aCZRaB.js} +7 -7
  121. package/dist/measurement/measureFns.d.ts +2 -2
  122. package/dist/measurement/measureFns.d.ts.map +1 -1
  123. package/dist/{measurement-D8EJ694A.js → measurement-C7o5jE6G.js} +2 -2
  124. package/dist/{measurement-BoNTUBAp.cjs → measurement-DZcaxo1A.cjs} +2 -2
  125. package/dist/measurement.cjs +1 -1
  126. package/dist/measurement.js +1 -1
  127. package/dist/{meshFns-BnV0ZR8w.cjs → meshFns-7dgZgNYK.cjs} +4 -4
  128. package/dist/{meshFns-nQjK38EC.js → meshFns-CtUl9fGY.js} +3 -3
  129. package/dist/operations/compoundOpsFns.d.ts +38 -0
  130. package/dist/operations/compoundOpsFns.d.ts.map +1 -0
  131. package/dist/operations/extrude.d.ts +2 -12
  132. package/dist/operations/extrude.d.ts.map +1 -1
  133. package/dist/operations/extrudeFns.d.ts +2 -93
  134. package/dist/operations/extrudeFns.d.ts.map +1 -1
  135. package/dist/operations/guidedSweepFns.d.ts +3 -22
  136. package/dist/operations/guidedSweepFns.d.ts.map +1 -1
  137. package/dist/operations/loft.d.ts +2 -16
  138. package/dist/operations/loft.d.ts.map +1 -1
  139. package/dist/operations/multiSweepFns.d.ts +3 -29
  140. package/dist/operations/multiSweepFns.d.ts.map +1 -1
  141. package/dist/operations/roofFns.d.ts +2 -2
  142. package/dist/operations/roofFns.d.ts.map +1 -1
  143. package/dist/operations/sweepFns.d.ts +121 -0
  144. package/dist/operations/sweepFns.d.ts.map +1 -0
  145. package/dist/{operations-BfbkK6DU.js → operations-DisJ5F8s.js} +110 -57
  146. package/dist/{operations-CYpmLSC4.cjs → operations-DwZ-RBO1.cjs} +97 -44
  147. package/dist/operations.cjs +2 -2
  148. package/dist/operations.js +14 -14
  149. package/dist/originTrackingFns-NJ1dWoiF.js +137 -0
  150. package/dist/originTrackingFns-dhaCe8Yb.cjs +136 -0
  151. package/dist/query/edgeFinder.d.ts +4 -14
  152. package/dist/query/edgeFinder.d.ts.map +1 -1
  153. package/dist/query/faceFinder.d.ts +4 -14
  154. package/dist/query/faceFinder.d.ts.map +1 -1
  155. package/dist/query/finderCore.d.ts +6 -0
  156. package/dist/query/finderCore.d.ts.map +1 -1
  157. package/dist/query/shapeFinders.d.ts +32 -0
  158. package/dist/query/shapeFinders.d.ts.map +1 -0
  159. package/dist/query/wireFinder.d.ts +4 -9
  160. package/dist/query/wireFinder.d.ts.map +1 -1
  161. package/dist/query.cjs +54 -32
  162. package/dist/query.js +56 -34
  163. package/dist/{result-fAX0OZzI.cjs → result-DJAAj1yb.cjs} +8 -59
  164. package/dist/{result-BaSD1fqR.js → result-DtuwWSUD.js} +38 -89
  165. package/dist/result.cjs +1 -1
  166. package/dist/result.js +22 -22
  167. package/dist/shapeFns-BJbua5kT.js +34 -0
  168. package/dist/shapeFns-w9tWELHX.cjs +33 -0
  169. package/dist/{shapeTypes-CpSaBLDv.js → shapeTypes-CAEAyk8j.js} +233 -172
  170. package/dist/{shapeTypes-7xEam9Ri.cjs → shapeTypes-owrg2MNK.cjs} +421 -360
  171. package/dist/sketching/Sketcher.d.ts.map +1 -1
  172. package/dist/sketching.cjs +2 -2
  173. package/dist/sketching.js +2 -2
  174. package/dist/{solidBuilders-994_MQwB.cjs → solidBuilders-BLQ4I6Ig.cjs} +3 -3
  175. package/dist/{solidBuilders-DmwhTCCd.js → solidBuilders-BS-1220W.js} +3 -3
  176. package/dist/{surfaceBuilders-nQdJ56fe.js → surfaceBuilders-Dj6AjhOv.js} +7 -7
  177. package/dist/{surfaceBuilders-5VA34a3_.cjs → surfaceBuilders-KU_7OD2q.cjs} +3 -3
  178. package/dist/topology/booleanFns.d.ts.map +1 -1
  179. package/dist/topology/compoundOpsFns.d.ts +3 -35
  180. package/dist/topology/compoundOpsFns.d.ts.map +1 -1
  181. package/dist/topology/index.d.ts +0 -1
  182. package/dist/topology/index.d.ts.map +1 -1
  183. package/dist/topology/metadataPropagation.d.ts +30 -0
  184. package/dist/topology/metadataPropagation.d.ts.map +1 -0
  185. package/dist/topology/modifierFns.d.ts.map +1 -1
  186. package/dist/topology/originTrackingFns.d.ts +23 -0
  187. package/dist/topology/originTrackingFns.d.ts.map +1 -0
  188. package/dist/topology/shapeFns.d.ts +6 -120
  189. package/dist/topology/shapeFns.d.ts.map +1 -1
  190. package/dist/topology/topologyQueryFns.d.ts +67 -0
  191. package/dist/topology/topologyQueryFns.d.ts.map +1 -0
  192. package/dist/topology/transformFns.d.ts +49 -0
  193. package/dist/topology/transformFns.d.ts.map +1 -0
  194. package/dist/topology/wrapperFns.d.ts.map +1 -1
  195. package/dist/{topology-ANwCzGL8.cjs → topology-CyPHYYjV.cjs} +205 -20
  196. package/dist/{topology-C7x98OVn.js → topology-D6LeuhI_.js} +235 -50
  197. package/dist/topology.cjs +18 -17
  198. package/dist/topology.js +92 -91
  199. package/dist/topologyQueryFns-De439iBP.js +119 -0
  200. package/dist/topologyQueryFns-fz5kz5e1.cjs +118 -0
  201. package/dist/{types-CWDdqcrq.js → types-CcKqsmd0.js} +2 -2
  202. package/dist/utils/precisionRound.d.ts +4 -0
  203. package/dist/utils/precisionRound.d.ts.map +1 -1
  204. package/dist/utils/vec2d.d.ts +5 -0
  205. package/dist/utils/vec2d.d.ts.map +1 -1
  206. package/dist/{vecOps-ZDdZWbwT.js → vecOps-LTN--A58.js} +15 -15
  207. package/dist/{vectors-D_IiZx0q.cjs → vectors-C8N_QeEX.cjs} +9 -1
  208. package/dist/{vectors-Bx8wkNui.js → vectors-DTREgnVp.js} +15 -7
  209. package/dist/vectors.cjs +1 -1
  210. package/dist/vectors.js +23 -23
  211. package/package.json +3 -3
  212. package/dist/core/geometryHelpers.d.ts +0 -30
  213. package/dist/core/geometryHelpers.d.ts.map +0 -1
  214. package/dist/core/memory.d.ts +0 -6
  215. package/dist/core/memory.d.ts.map +0 -1
  216. package/dist/core/typeErrors.d.ts +0 -17
  217. package/dist/core/typeErrors.d.ts.map +0 -1
  218. package/dist/cornerFinder-Ckz-mPHE.js +0 -59
  219. package/dist/cornerFinder-ZmOyOOsh.cjs +0 -58
  220. package/dist/shapeFns-C2SnNvdH.cjs +0 -468
  221. package/dist/shapeFns-FDuKkrDR.js +0 -469
  222. package/dist/utils/round2.d.ts +0 -3
  223. package/dist/utils/round2.d.ts.map +0 -1
  224. package/dist/utils/round5.d.ts +0 -3
  225. package/dist/utils/round5.d.ts.map +0 -1
@@ -43,6 +43,7 @@ var __callDispose = (stack, error, hasError) => {
43
43
  };
44
44
  return next();
45
45
  };
46
+ import { e as err, t as typeCastError, o as ok } from "./result-DtuwWSUD.js";
46
47
  function supportsKernel2D(kernel) {
47
48
  return "makeLine2d" in kernel;
48
49
  }
@@ -1081,7 +1082,17 @@ function chamferDistAngle(oc, shape, edges, distance2, angleDeg) {
1081
1082
  return result;
1082
1083
  }
1083
1084
  function offsetWire2D(oc, wire, offsetVal, joinType) {
1084
- const jt = joinType ?? oc.GeomAbs_JoinType.GeomAbs_Arc;
1085
+ let jt;
1086
+ if (typeof joinType === "string") {
1087
+ const map = {
1088
+ arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
1089
+ intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
1090
+ tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
1091
+ };
1092
+ jt = map[joinType] ?? oc.GeomAbs_JoinType.GeomAbs_Arc;
1093
+ } else {
1094
+ jt = joinType ?? oc.GeomAbs_JoinType.GeomAbs_Arc;
1095
+ }
1085
1096
  const offsetter = new oc.BRepOffsetAPI_MakeOffset_3(wire, jt, false);
1086
1097
  offsetter.Perform(offsetVal, 0);
1087
1098
  const result = offsetter.Shape();
@@ -2207,6 +2218,74 @@ function dispose(_oc, handle) {
2207
2218
  } catch {
2208
2219
  }
2209
2220
  }
2221
+ function makeRectangle(oc, width, height) {
2222
+ const e1 = makeLineEdge(oc, [0, 0, 0], [width, 0, 0]);
2223
+ const e2 = makeLineEdge(oc, [width, 0, 0], [width, height, 0]);
2224
+ const e3 = makeLineEdge(oc, [width, height, 0], [0, height, 0]);
2225
+ const e4 = makeLineEdge(oc, [0, height, 0], [0, 0, 0]);
2226
+ const bw = new oc.BRepBuilderAPI_MakeWire_1();
2227
+ bw.Add_1(e1);
2228
+ bw.Add_1(e2);
2229
+ bw.Add_1(e3);
2230
+ bw.Add_1(e4);
2231
+ const wire = bw.Wire();
2232
+ bw.delete();
2233
+ e1.delete();
2234
+ e2.delete();
2235
+ e3.delete();
2236
+ e4.delete();
2237
+ const bf = new oc.BRepBuilderAPI_MakeFace_15(wire, false);
2238
+ const face = bf.Face();
2239
+ bf.delete();
2240
+ return face;
2241
+ }
2242
+ function createPoint3d(oc, x, y, z) {
2243
+ return new oc.gp_Pnt_3(x, y, z);
2244
+ }
2245
+ function createDirection3d(oc, x, y, z) {
2246
+ return new oc.gp_Dir_4(x, y, z);
2247
+ }
2248
+ function createVector3d(oc, x, y, z) {
2249
+ return new oc.gp_Vec_4(x, y, z);
2250
+ }
2251
+ function createAxis1(oc, cx, cy, cz, dx, dy, dz) {
2252
+ const pnt = new oc.gp_Pnt_3(cx, cy, cz);
2253
+ const dir = new oc.gp_Dir_4(dx, dy, dz);
2254
+ const ax = new oc.gp_Ax1_2(pnt, dir);
2255
+ pnt.delete();
2256
+ dir.delete();
2257
+ return ax;
2258
+ }
2259
+ function createAxis2(oc, ox, oy, oz, zx, zy, zz, xx, xy, xz) {
2260
+ const pnt = new oc.gp_Pnt_3(ox, oy, oz);
2261
+ const z = new oc.gp_Dir_4(zx, zy, zz);
2262
+ let ax;
2263
+ if (xx !== void 0 && xy !== void 0 && xz !== void 0) {
2264
+ const x = new oc.gp_Dir_4(xx, xy, xz);
2265
+ ax = new oc.gp_Ax2_2(pnt, z, x);
2266
+ x.delete();
2267
+ } else {
2268
+ ax = new oc.gp_Ax2_3(pnt, z);
2269
+ }
2270
+ pnt.delete();
2271
+ z.delete();
2272
+ return ax;
2273
+ }
2274
+ function createAxis3(oc, ox, oy, oz, zx, zy, zz, xx, xy, xz) {
2275
+ const pnt = new oc.gp_Pnt_3(ox, oy, oz);
2276
+ const z = new oc.gp_Dir_4(zx, zy, zz);
2277
+ let ax;
2278
+ if (xx !== void 0 && xy !== void 0 && xz !== void 0) {
2279
+ const x = new oc.gp_Dir_4(xx, xy, xz);
2280
+ ax = new oc.gp_Ax3_3(pnt, z, x);
2281
+ x.delete();
2282
+ } else {
2283
+ ax = new oc.gp_Ax3_4(pnt, z);
2284
+ }
2285
+ pnt.delete();
2286
+ z.delete();
2287
+ return ax;
2288
+ }
2210
2289
  function mapContinuity(oc, continuity) {
2211
2290
  switch (continuity) {
2212
2291
  case "C0":
@@ -4110,12 +4189,7 @@ class DefaultAdapter {
4110
4189
  return makeBoxFromCorners(this.oc, p1, p2);
4111
4190
  }
4112
4191
  makeRectangle(width, height) {
4113
- const e1 = this.makeLineEdge([0, 0, 0], [width, 0, 0]);
4114
- const e2 = this.makeLineEdge([width, 0, 0], [width, height, 0]);
4115
- const e3 = this.makeLineEdge([width, height, 0], [0, height, 0]);
4116
- const e4 = this.makeLineEdge([0, height, 0], [0, 0, 0]);
4117
- const wire = this.makeWire([e1, e2, e3, e4]);
4118
- return this.makeFace(wire);
4192
+ return makeRectangle(this.oc, width, height);
4119
4193
  }
4120
4194
  solidFromShell(shell2) {
4121
4195
  return solidFromShell(this.oc, shell2);
@@ -4332,17 +4406,7 @@ class DefaultAdapter {
4332
4406
  }
4333
4407
  // --- 2D offset ---
4334
4408
  offsetWire2D(wire, offset2, joinType) {
4335
- let jt = joinType;
4336
- if (typeof joinType === "string") {
4337
- const oc = this.oc;
4338
- const map = {
4339
- arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
4340
- intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
4341
- tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
4342
- };
4343
- jt = map[joinType];
4344
- }
4345
- return offsetWire2D(this.oc, wire, offset2, jt);
4409
+ return offsetWire2D(this.oc, wire, offset2, joinType);
4346
4410
  }
4347
4411
  // --- Distance ---
4348
4412
  distance(shape1, shape2) {
@@ -4778,51 +4842,22 @@ class DefaultAdapter {
4778
4842
  }
4779
4843
  // --- 3D Geometry primitive factories ---
4780
4844
  createPoint3d(x, y, z) {
4781
- return new this.oc.gp_Pnt_3(x, y, z);
4845
+ return createPoint3d(this.oc, x, y, z);
4782
4846
  }
4783
4847
  createDirection3d(x, y, z) {
4784
- return new this.oc.gp_Dir_4(x, y, z);
4848
+ return createDirection3d(this.oc, x, y, z);
4785
4849
  }
4786
4850
  createVector3d(x, y, z) {
4787
- return new this.oc.gp_Vec_4(x, y, z);
4851
+ return createVector3d(this.oc, x, y, z);
4788
4852
  }
4789
4853
  createAxis1(cx, cy, cz, dx, dy, dz) {
4790
- const pnt = new this.oc.gp_Pnt_3(cx, cy, cz);
4791
- const dir = new this.oc.gp_Dir_4(dx, dy, dz);
4792
- const ax = new this.oc.gp_Ax1_2(pnt, dir);
4793
- pnt.delete();
4794
- dir.delete();
4795
- return ax;
4854
+ return createAxis1(this.oc, cx, cy, cz, dx, dy, dz);
4796
4855
  }
4797
4856
  createAxis2(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
4798
- const pnt = new this.oc.gp_Pnt_3(ox, oy, oz);
4799
- const z = new this.oc.gp_Dir_4(zx, zy, zz);
4800
- let ax;
4801
- if (xx !== void 0 && xy !== void 0 && xz !== void 0) {
4802
- const x = new this.oc.gp_Dir_4(xx, xy, xz);
4803
- ax = new this.oc.gp_Ax2_2(pnt, z, x);
4804
- x.delete();
4805
- } else {
4806
- ax = new this.oc.gp_Ax2_3(pnt, z);
4807
- }
4808
- pnt.delete();
4809
- z.delete();
4810
- return ax;
4857
+ return createAxis2(this.oc, ox, oy, oz, zx, zy, zz, xx, xy, xz);
4811
4858
  }
4812
4859
  createAxis3(ox, oy, oz, zx, zy, zz, xx, xy, xz) {
4813
- const pnt = new this.oc.gp_Pnt_3(ox, oy, oz);
4814
- const z = new this.oc.gp_Dir_4(zx, zy, zz);
4815
- let ax;
4816
- if (xx !== void 0 && xy !== void 0 && xz !== void 0) {
4817
- const x = new this.oc.gp_Dir_4(xx, xy, xz);
4818
- ax = new this.oc.gp_Ax3_3(pnt, z, x);
4819
- x.delete();
4820
- } else {
4821
- ax = new this.oc.gp_Ax3_4(pnt, z);
4822
- }
4823
- pnt.delete();
4824
- z.delete();
4825
- return ax;
4860
+ return createAxis3(this.oc, ox, oy, oz, zx, zy, zz, xx, xy, xz);
4826
4861
  }
4827
4862
  // --- Unsupported brepkit-only methods ---
4828
4863
  export3MF(_shape, _tolerance) {
@@ -4966,7 +5001,13 @@ function withKernel(id, fn) {
4966
5001
  _defaultKernelId = id;
4967
5002
  _cachedDefault = _kernels.get(id) ?? null;
4968
5003
  try {
4969
- return fn();
5004
+ const result = fn();
5005
+ if (result instanceof Promise) {
5006
+ throw new Error(
5007
+ "withKernel() callback returned a Promise. Async code must use getKernel(id) directly — the kernel override is restored synchronously in finally."
5008
+ );
5009
+ }
5010
+ return result;
4970
5011
  } finally {
4971
5012
  _defaultKernelId = prev;
4972
5013
  _cachedDefault = prev ? _kernels.get(prev) ?? null : null;
@@ -4992,7 +5033,38 @@ if (!globalWithRegistry.FinalizationRegistry) {
4992
5033
  }
4993
5034
  };
4994
5035
  }
5036
+ const _stats = {
5037
+ liveHandles: 0,
5038
+ peakHandles: 0,
5039
+ gcCollected: 0,
5040
+ scopeEnters: 0,
5041
+ scopeExits: 0
5042
+ };
5043
+ function getDisposalStats() {
5044
+ return { ..._stats };
5045
+ }
5046
+ function resetDisposalStats() {
5047
+ _stats.liveHandles = 0;
5048
+ _stats.peakHandles = 0;
5049
+ _stats.gcCollected = 0;
5050
+ _stats.scopeEnters = 0;
5051
+ _stats.scopeExits = 0;
5052
+ }
5053
+ function trackHandleCreated() {
5054
+ _stats.liveHandles++;
5055
+ if (_stats.liveHandles > _stats.peakHandles) {
5056
+ _stats.peakHandles = _stats.liveHandles;
5057
+ }
5058
+ }
5059
+ function trackHandleDisposed() {
5060
+ _stats.liveHandles--;
5061
+ }
5062
+ function trackGcCollected() {
5063
+ _stats.gcCollected++;
5064
+ _stats.liveHandles--;
5065
+ }
4995
5066
  const registry = new FinalizationRegistry((heldValue) => {
5067
+ trackGcCollected();
4996
5068
  try {
4997
5069
  heldValue.delete();
4998
5070
  } catch {
@@ -5003,6 +5075,7 @@ function createHandle(ocShape) {
5003
5075
  const dispose2 = () => {
5004
5076
  if (!disposed) {
5005
5077
  disposed = true;
5078
+ trackHandleDisposed();
5006
5079
  registry.unregister(handle);
5007
5080
  try {
5008
5081
  ocShape.delete();
@@ -5025,6 +5098,7 @@ function createHandle(ocShape) {
5025
5098
  dispose2();
5026
5099
  }
5027
5100
  };
5101
+ trackHandleCreated();
5028
5102
  registry.register(handle, ocShape, handle);
5029
5103
  return handle;
5030
5104
  }
@@ -5041,6 +5115,7 @@ function createKernelHandle(ocObj) {
5041
5115
  [Symbol.dispose]() {
5042
5116
  if (!disposed) {
5043
5117
  disposed = true;
5118
+ trackHandleDisposed();
5044
5119
  registry.unregister(handle);
5045
5120
  try {
5046
5121
  ocObj.delete();
@@ -5049,11 +5124,15 @@ function createKernelHandle(ocObj) {
5049
5124
  }
5050
5125
  }
5051
5126
  };
5127
+ trackHandleCreated();
5052
5128
  registry.register(handle, ocObj, handle);
5053
5129
  return handle;
5054
5130
  }
5055
5131
  class DisposalScope {
5056
5132
  handles = [];
5133
+ constructor() {
5134
+ _stats.scopeEnters++;
5135
+ }
5057
5136
  /** Register a resource for disposal when scope ends. */
5058
5137
  register(resource) {
5059
5138
  this.handles.push(() => {
@@ -5075,6 +5154,7 @@ class DisposalScope {
5075
5154
  return disposable;
5076
5155
  }
5077
5156
  [Symbol.dispose]() {
5157
+ _stats.scopeExits++;
5078
5158
  for (let i = this.handles.length - 1; i >= 0; i--) {
5079
5159
  this.handles[i]?.();
5080
5160
  }
@@ -5123,20 +5203,64 @@ async function withScopeResultAsync(fn) {
5123
5203
  function isLive(handle) {
5124
5204
  return !handle.disposed;
5125
5205
  }
5126
- function brandHandle(handle) {
5206
+ function is3D(s) {
5207
+ return s.__is2D !== true;
5208
+ }
5209
+ function is2D(s) {
5210
+ return s.__is2D === true;
5211
+ }
5212
+ function as3D(s) {
5213
+ if (!is3D(s)) throw new Error("Expected 3D shape, got 2D");
5214
+ return s;
5215
+ }
5216
+ function as2D(s) {
5217
+ if (!is2D(s)) throw new Error("Expected 2D shape, got 3D");
5218
+ return s;
5219
+ }
5220
+ const CURVE_TYPE_BY_INT = [
5221
+ "LINE",
5222
+ // 0
5223
+ "CIRCLE",
5224
+ // 1
5225
+ "ELLIPSE",
5226
+ // 2
5227
+ "HYPERBOLA",
5228
+ // 3
5229
+ "PARABOLA",
5230
+ // 4
5231
+ "BEZIER_CURVE",
5232
+ // 5
5233
+ "BSPLINE_CURVE",
5234
+ // 6
5235
+ "OFFSET_CURVE",
5236
+ // 7
5237
+ "OTHER_CURVE"
5238
+ // 8
5239
+ ];
5240
+ const findCurveType = (type) => {
5241
+ const idx = typeof type === "number" ? type : Number(type?.value ?? type);
5242
+ const curveType2 = CURVE_TYPE_BY_INT[idx];
5243
+ if (!curveType2) return err(typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
5244
+ return ok(curveType2);
5245
+ };
5246
+ function getShapeKind(shape) {
5247
+ return getKernel().shapeType(shape.wrapped);
5248
+ }
5249
+ function brandHandle(handle, dim) {
5250
+ if (dim === "2D") handle.__is2D = true;
5127
5251
  return handle;
5128
5252
  }
5129
- function createVertex(ocShape) {
5130
- return brandHandle(createHandle(ocShape));
5253
+ function createVertex(ocShape, dim) {
5254
+ return brandHandle(createHandle(ocShape), dim);
5131
5255
  }
5132
- function createEdge(ocShape) {
5133
- return brandHandle(createHandle(ocShape));
5256
+ function createEdge(ocShape, dim) {
5257
+ return brandHandle(createHandle(ocShape), dim);
5134
5258
  }
5135
- function createWire(ocShape) {
5136
- return brandHandle(createHandle(ocShape));
5259
+ function createWire(ocShape, dim) {
5260
+ return brandHandle(createHandle(ocShape), dim);
5137
5261
  }
5138
- function createFace(ocShape) {
5139
- return brandHandle(createHandle(ocShape));
5262
+ function createFace(ocShape, dim) {
5263
+ return brandHandle(createHandle(ocShape), dim);
5140
5264
  }
5141
5265
  function createShell(ocShape) {
5142
5266
  return brandHandle(createHandle(ocShape));
@@ -5147,11 +5271,8 @@ function createSolid(ocShape) {
5147
5271
  function createCompSolid(ocShape) {
5148
5272
  return brandHandle(createHandle(ocShape));
5149
5273
  }
5150
- function createCompound(ocShape) {
5151
- return brandHandle(createHandle(ocShape));
5152
- }
5153
- function getShapeKind(shape) {
5154
- return getKernel().shapeType(shape.wrapped);
5274
+ function createCompound(ocShape, dim) {
5275
+ return brandHandle(createHandle(ocShape), dim);
5155
5276
  }
5156
5277
  function isVertex(s) {
5157
5278
  return getShapeKind(s) === "vertex";
@@ -5184,121 +5305,61 @@ function isShape1D(s) {
5184
5305
  const kind = getShapeKind(s);
5185
5306
  return kind === "edge" || kind === "wire";
5186
5307
  }
5187
- function is3D(s) {
5188
- return s.__is2D !== true;
5189
- }
5190
- function is2D(s) {
5191
- return s.__is2D === true;
5192
- }
5193
- function as3D(s) {
5194
- if (!is3D(s)) throw new Error("Expected 3D shape, got 2D");
5195
- return s;
5196
- }
5197
- function as2D(s) {
5198
- if (!is2D(s)) throw new Error("Expected 2D shape, got 3D");
5199
- return s;
5200
- }
5201
- function isClosedWire(wire) {
5202
- return getKernel().curveIsClosed(wire.wrapped);
5203
- }
5204
- function isOrientedFace(face) {
5205
- return getKernel().isValid(face.wrapped);
5206
- }
5207
- function isManifoldShell(shell2) {
5208
- const kernel = getKernel();
5209
- if (!kernel.isValid(shell2.wrapped)) return false;
5210
- const validate = kernel.isValidStrict?.bind(kernel) ?? kernel.isValid.bind(kernel);
5211
- try {
5212
- const solid = kernel.solidFromShell(shell2.wrapped);
5213
- const valid = validate(solid);
5214
- try {
5215
- kernel.dispose(solid);
5216
- } catch {
5217
- }
5218
- return valid;
5219
- } catch {
5220
- return false;
5221
- }
5222
- }
5223
- function isValidSolid(solid) {
5224
- return getKernel().isValid(solid.wrapped);
5225
- }
5226
- function closedWire(wire) {
5227
- if (isClosedWire(wire)) return { valid: true, shape: wire };
5228
- return { valid: false, reason: "Wire is not closed: start and end points do not coincide" };
5229
- }
5230
- function orientedFace(face) {
5231
- if (isOrientedFace(face)) return { valid: true, shape: face };
5232
- return { valid: false, reason: "Face orientation is inconsistent or face is invalid" };
5233
- }
5234
- function manifoldShell(shell2) {
5235
- if (isManifoldShell(shell2)) return { valid: true, shape: shell2 };
5236
- return { valid: false, reason: "Shell is not manifold: has free edges or is invalid" };
5237
- }
5238
- function validSolid(solid) {
5239
- if (isValidSolid(solid)) return { valid: true, shape: solid };
5240
- return { valid: false, reason: "Solid failed BRepCheck validation" };
5241
- }
5242
- function castShape(ocShape) {
5308
+ function castShape(ocShape, dim) {
5243
5309
  const kernel = getKernel();
5244
5310
  const st = kernel.shapeType(ocShape);
5245
5311
  const dc = kernel.downcast(ocShape, st);
5246
- if (st === "vertex") return createVertex(dc);
5247
- if (st === "edge") return createEdge(dc);
5248
- if (st === "wire") return createWire(dc);
5249
- if (st === "face") return createFace(dc);
5312
+ if (st === "vertex") return createVertex(dc, dim);
5313
+ if (st === "edge") return createEdge(dc, dim);
5314
+ if (st === "wire") return createWire(dc, dim);
5315
+ if (st === "face") return createFace(dc, dim);
5250
5316
  if (st === "shell") return createShell(dc);
5251
5317
  if (st === "solid") return createSolid(dc);
5252
5318
  if (st === "compsolid") return createCompSolid(dc);
5253
- return createCompound(dc);
5319
+ return createCompound(dc, dim);
5254
5320
  }
5255
5321
  function castShape3D(ocShape) {
5256
5322
  return castShape(ocShape);
5257
5323
  }
5258
5324
  export {
5259
- withScopeResultAsync as A,
5260
- getKernel as B,
5261
- createCompound as C,
5325
+ initFromOC as A,
5326
+ is2D as B,
5327
+ is3D as C,
5262
5328
  DisposalScope as D,
5263
- createVertex as E,
5264
- createSolid as F,
5265
- createWire as G,
5266
- createEdge as H,
5267
- createFace as I,
5268
- getKernel2D as J,
5269
- registerForCleanup as K,
5270
- unregisterFromCleanup as L,
5271
- as2D as M,
5272
- as3D as N,
5273
- castShape3D as O,
5274
- createShell as P,
5275
- initFromOC as Q,
5276
- registerKernel as R,
5277
- withKernel as S,
5278
- closedWire as a,
5279
- createHandle as b,
5329
+ isCompound as E,
5330
+ isLive as F,
5331
+ isShape1D as G,
5332
+ isVertex as H,
5333
+ registerKernel as I,
5334
+ resetDisposalStats as J,
5335
+ withKernel as K,
5336
+ withScope as L,
5337
+ withScopeResult as M,
5338
+ withScopeResultAsync as N,
5339
+ getShapeKind as a,
5340
+ isWire as b,
5280
5341
  castShape as c,
5281
- createKernelHandle as d,
5282
- is3D as e,
5283
- isClosedWire as f,
5284
- getShapeKind as g,
5285
- isCompound as h,
5286
- is2D as i,
5287
- isEdge as j,
5288
- isFace as k,
5289
- isLive as l,
5290
- isManifoldShell as m,
5291
- isOrientedFace as n,
5292
- isShape1D as o,
5293
- isShape3D as p,
5294
- isShell as q,
5295
- isSolid as r,
5296
- isValidSolid as s,
5297
- isVertex as t,
5298
- isWire as u,
5299
- manifoldShell as v,
5300
- orientedFace as w,
5301
- validSolid as x,
5302
- withScope as y,
5303
- withScopeResult as z
5342
+ isShell as d,
5343
+ createCompound as e,
5344
+ createVertex as f,
5345
+ getKernel as g,
5346
+ createSolid as h,
5347
+ isEdge as i,
5348
+ isShape3D as j,
5349
+ isSolid as k,
5350
+ createWire as l,
5351
+ createEdge as m,
5352
+ createFace as n,
5353
+ isFace as o,
5354
+ getKernel2D as p,
5355
+ as2D as q,
5356
+ registerForCleanup as r,
5357
+ as3D as s,
5358
+ castShape3D as t,
5359
+ unregisterFromCleanup as u,
5360
+ createHandle as v,
5361
+ createKernelHandle as w,
5362
+ createShell as x,
5363
+ findCurveType as y,
5364
+ getDisposalStats as z
5304
5365
  };