brepjs 15.1.13 → 15.2.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 (70) hide show
  1. package/dist/2d/lib/curve2D.d.ts.map +1 -1
  2. package/dist/2d.cjs +5 -5
  3. package/dist/2d.js +5 -5
  4. package/dist/{blueprint-DpfTrOOt.cjs → blueprint-CVDdCwvY.cjs} +10 -8
  5. package/dist/{blueprint-CY11BkHM.js → blueprint-DiLT1cjs.js} +10 -8
  6. package/dist/{blueprintFns-C-XRp3LD.js → blueprintFns-1Ulj1yXX.js} +2 -2
  7. package/dist/{blueprintFns-DTGzK_O3.cjs → blueprintFns-VagQe-2I.cjs} +2 -2
  8. package/dist/{boolean2D-CNan_aDM.cjs → boolean2D-C_vue9r7.cjs} +7 -7
  9. package/dist/{boolean2D-Dj0eTZfG.js → boolean2D-_yG91bHX.js} +7 -7
  10. package/dist/{booleanFns-B86ltlZD.cjs → booleanFns-C7c98iPH.cjs} +4 -4
  11. package/dist/{booleanFns-CiiCf7YH.js → booleanFns-QZtMt5Aa.js} +4 -4
  12. package/dist/brepjs.cjs +20 -20
  13. package/dist/brepjs.js +20 -20
  14. package/dist/core.cjs +1 -1
  15. package/dist/core.js +1 -1
  16. package/dist/{cornerFinder-lO-ySgHJ.js → cornerFinder-CvF2SrsV.js} +1 -1
  17. package/dist/{cornerFinder-DNmYCgaQ.cjs → cornerFinder-DP1-TfDV.cjs} +1 -1
  18. package/dist/{curveFns-B_pwrAMv.cjs → curveFns-Bukd9jhv.cjs} +1 -1
  19. package/dist/{curveFns-Dv0wz8Zm.js → curveFns-Dn4gbNzG.js} +1 -1
  20. package/dist/{drawFns-CJxFWoi9.js → drawFns-BIFwKDPT.js} +10 -10
  21. package/dist/{drawFns-BNSmHZXu.cjs → drawFns-mX41AgJp.cjs} +10 -10
  22. package/dist/{extrudeFns-B9muBNIT.cjs → extrudeFns-B588lxcH.cjs} +1 -1
  23. package/dist/{extrudeFns-lgSsOjwq.js → extrudeFns-DjfHvYJe.js} +1 -1
  24. package/dist/{faceFns-DnIpKBex.cjs → faceFns-CKL9Us23.cjs} +1 -1
  25. package/dist/{faceFns-CauBoVg1.js → faceFns-DMFG-piP.js} +1 -1
  26. package/dist/{helpers-B_-mIteL.js → helpers-B2J4sg4l.js} +5 -5
  27. package/dist/{helpers-kil7evW4.cjs → helpers-B48K8Z6B.cjs} +5 -5
  28. package/dist/{historyFns-DYrliEQE.js → historyFns-BpfArwQu.js} +4 -4
  29. package/dist/{historyFns-D7UojEn3.cjs → historyFns-Bxg4_ieD.cjs} +4 -4
  30. package/dist/{importFns-CPzDHVKm.js → importFns-D6eumXiz.js} +2 -2
  31. package/dist/{importFns-Y4wgn0rJ.cjs → importFns-UkXALkBs.cjs} +2 -2
  32. package/dist/io.cjs +2 -2
  33. package/dist/io.js +2 -2
  34. package/dist/kernel/geometry2d.d.ts.map +1 -1
  35. package/dist/kernel/occt/defaultAdapter.d.ts.map +1 -1
  36. package/dist/kernel/occt/kernel2dOps.d.ts +61 -68
  37. package/dist/kernel/occt/kernel2dOps.d.ts.map +1 -1
  38. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  39. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  40. package/dist/{measureFns-Bt0Rd9q9.cjs → measureFns-C2SnZLhD.cjs} +2 -2
  41. package/dist/{measureFns-Bey2EmNQ.js → measureFns-Zc5RWsI4.js} +2 -2
  42. package/dist/measurement.cjs +1 -1
  43. package/dist/measurement.js +1 -1
  44. package/dist/{meshFns-Cxs6gU44.cjs → meshFns-CO9qVJ24.cjs} +2 -2
  45. package/dist/{meshFns-DO58R94T.js → meshFns-gTPomZkK.js} +2 -2
  46. package/dist/{occtWasmAdapter-BBr9e9ej.js → occtWasmAdapter-BRiWV_v0.js} +65 -14
  47. package/dist/{occtWasmAdapter-DcGOi3MQ.cjs → occtWasmAdapter-CPINzXxh.cjs} +65 -14
  48. package/dist/operations.cjs +2 -2
  49. package/dist/operations.js +2 -2
  50. package/dist/{primitiveFns-CWiHuJw9.cjs → primitiveFns-CriBoS7M.cjs} +5 -5
  51. package/dist/{primitiveFns-Rpdnd3FK.js → primitiveFns-CtWBTFPI.js} +5 -5
  52. package/dist/query.cjs +2 -2
  53. package/dist/query.js +2 -2
  54. package/dist/{shapeFns-CBRy0V_S.cjs → shapeFns-DkFzoJav.cjs} +2 -2
  55. package/dist/{shapeFns-4ySHDRyO.js → shapeFns-QGgHStIU.js} +2 -2
  56. package/dist/shapeRef.cjs +1 -1
  57. package/dist/shapeRef.js +1 -1
  58. package/dist/{shapeRefFns-D21Yl4Eu.js → shapeRefFns-Gv4-NGJD.js} +3 -3
  59. package/dist/{shapeRefFns-oAyQxHO1.cjs → shapeRefFns-t-5-Aqku.cjs} +3 -3
  60. package/dist/{shapeTypes-CaSWO-Hg.cjs → shapeTypes-Bfw136X-.cjs} +772 -589
  61. package/dist/{shapeTypes-BLV4Ktdb.js → shapeTypes-Ct7W6h2X.js} +768 -589
  62. package/dist/sketching.cjs +2 -2
  63. package/dist/sketching.js +2 -2
  64. package/dist/{solidBuilders-BexZFemn.js → solidBuilders-CQipZFOw.js} +2 -2
  65. package/dist/{solidBuilders-BZFaM6nk.cjs → solidBuilders-DI9d6ZIx.cjs} +2 -2
  66. package/dist/{surfaceBuilders-Bixz70pj.cjs → surfaceBuilders-DzTJA3fK.cjs} +2 -2
  67. package/dist/{surfaceBuilders-AnSYsNAb.js → surfaceBuilders-Im6Xef27.js} +2 -2
  68. package/dist/topology.cjs +6 -6
  69. package/dist/topology.js +6 -6
  70. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- const require_occtWasmAdapter = require("./occtWasmAdapter-DcGOi3MQ.cjs");
1
+ const require_occtWasmAdapter = require("./occtWasmAdapter-CPINzXxh.cjs");
2
2
  const require_errors = require("./errors-CXRNVCec.cjs");
3
3
  //#region src/kernel/kernel2dTypes.ts
4
4
  /** Check if the kernel supports 2D geometry operations. */
@@ -3197,612 +3197,797 @@ function createAxis3$1(oc, ox, oy, oz, zx, zy, zz, xx, xy, xz) {
3197
3197
  }
3198
3198
  //#endregion
3199
3199
  //#region src/kernel/occt/kernel2dOps.ts
3200
- function mapContinuity(oc, continuity) {
3201
- switch (continuity) {
3202
- case "C0": return oc.GeomAbs_Shape.GeomAbs_C0;
3203
- case "C1": return oc.GeomAbs_Shape.GeomAbs_C1;
3204
- case "C2": return oc.GeomAbs_Shape.GeomAbs_C2;
3205
- case "C3": return oc.GeomAbs_Shape.GeomAbs_C3;
3206
- }
3200
+ var noop$1 = () => {};
3201
+ /** Cast opaque Curve2dHandle to internal Curve2dObj. */
3202
+ function c2d$1(handle) {
3203
+ return handle;
3207
3204
  }
3208
- /**
3209
- * Extract a numeric value from an OCCT Emscripten enum.
3210
- * Emscripten returns enum objects with a `.value` property, not raw numbers.
3211
- */
3212
- function unwrapOcctEnum(val) {
3213
- return typeof val === "number" ? val : Number(val?.value ?? val);
3205
+ /** Unwrap trimmed curve wrappers to get the basis geometry. */
3206
+ function c2dBasis$1(handle) {
3207
+ let c = c2d$1(handle);
3208
+ while (c.__bk2d === "trimmed") c = c.basis;
3209
+ return c;
3214
3210
  }
3215
- /**
3216
- * Get the GeomAbs_CurveType index for a 2D curve via a temporary adaptor.
3217
- * Caller avoids repeating the adaptor-create / GetType / unwrap / delete cycle.
3218
- */
3219
- function getCurve2dTypeIndex(oc, curve) {
3220
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3221
- const idx = unwrapOcctEnum(adaptor.GetType());
3222
- adaptor.delete();
3223
- return idx;
3211
+ /** Cast opaque BBox2dHandle to internal BBox2d. */
3212
+ function bb2d$1(handle) {
3213
+ return handle;
3224
3214
  }
3225
- /** Wrap a raw Geom2d_Curve in a Handle_Geom2d_Curve. */
3226
- function wrapCurve2dHandle$1(oc, handle) {
3227
- const inner = handle.get();
3228
- return new oc.Handle_Geom2d_Curve_2(inner);
3215
+ function createPoint2d$1(x, y) {
3216
+ return {
3217
+ x,
3218
+ y
3219
+ };
3229
3220
  }
3230
- /** Create a Geom2dAdaptor_Curve for algorithmic queries. Caller must delete. */
3231
- function createCurve2dAdaptor$1(oc, handle) {
3232
- return new oc.Geom2dAdaptor_Curve_2(handle);
3221
+ function createDirection2d$1(x, y) {
3222
+ const l = Math.sqrt(x * x + y * y);
3223
+ if (l < 1e-15) throw new Error("occt: createDirection2d called with zero-length vector");
3224
+ return {
3225
+ x: x / l,
3226
+ y: y / l
3227
+ };
3233
3228
  }
3234
- function createPoint2d$1(oc, x, y) {
3235
- return new oc.gp_Pnt2d_3(x, y);
3229
+ function createVector2d$1(x, y) {
3230
+ return {
3231
+ x,
3232
+ y
3233
+ };
3236
3234
  }
3237
- function createDirection2d$1(oc, x, y) {
3238
- return new oc.gp_Dir2d_5(x, y);
3235
+ function createAxis2d$1(px, py, dx, dy) {
3236
+ return {
3237
+ px,
3238
+ py,
3239
+ dx,
3240
+ dy,
3241
+ delete: noop$1
3242
+ };
3239
3243
  }
3240
- function createVector2d$1(oc, x, y) {
3241
- return new oc.gp_Vec2d_4(x, y);
3244
+ function wrapCurve2dHandle$1(handle) {
3245
+ return handle;
3242
3246
  }
3243
- function createAxis2d$1(oc, px, py, dx, dy) {
3244
- const pnt = new oc.gp_Pnt2d_3(px, py);
3245
- const dir = new oc.gp_Dir2d_5(dx, dy);
3246
- const axis = new oc.gp_Ax2d_2(pnt, dir);
3247
- pnt.delete();
3248
- dir.delete();
3249
- return axis;
3247
+ function createCurve2dAdaptor$1(handle) {
3248
+ return handle;
3250
3249
  }
3251
- function makeLine2d$1(oc, x1, y1, x2, y2) {
3252
- const p1 = new oc.gp_Pnt2d_3(x1, y1);
3253
- const p2 = new oc.gp_Pnt2d_3(x2, y2);
3254
- const maker = new oc.GCE2d_MakeSegment_1(p1, p2);
3255
- const curve = maker.Value();
3256
- maker.delete();
3257
- p1.delete();
3258
- p2.delete();
3259
- return curve;
3250
+ function makeLine2d$1(x1, y1, x2, y2) {
3251
+ return require_occtWasmAdapter.makeLine2d(x1, y1, x2, y2);
3260
3252
  }
3261
- function makeCircle2d$1(oc, cx, cy, radius, sense = true) {
3262
- const center = new oc.gp_Pnt2d_3(cx, cy);
3263
- const maker = new oc.GCE2d_MakeCircle_7(center, radius, sense);
3264
- const curve = maker.Value();
3265
- maker.delete();
3266
- center.delete();
3267
- return curve;
3253
+ function makeCircle2d$1(cx, cy, radius, sense) {
3254
+ return require_occtWasmAdapter.makeCircle2d(cx, cy, radius, sense);
3268
3255
  }
3269
- function makeArc2dThreePoints$1(oc, x1, y1, xm, ym, x2, y2) {
3270
- const p1 = new oc.gp_Pnt2d_3(x1, y1);
3271
- const pm = new oc.gp_Pnt2d_3(xm, ym);
3272
- const p2 = new oc.gp_Pnt2d_3(x2, y2);
3273
- const maker = new oc.GCE2d_MakeArcOfCircle_4(p1, pm, p2);
3274
- try {
3275
- if (!maker.IsDone()) throw new Error("makeArc2dThreePoints: construction failed (collinear points?)");
3276
- return maker.Value();
3277
- } finally {
3278
- maker.delete();
3279
- p2.delete();
3280
- pm.delete();
3281
- p1.delete();
3256
+ function makeArc2dThreePoints$1(x1, y1, xm, ym, x2, y2) {
3257
+ const d = 2 * (x1 * (ym - y2) + xm * (y2 - y1) + x2 * (y1 - ym));
3258
+ if (Math.abs(d) < 1e-12) return require_occtWasmAdapter.makeLine2d(x1, y1, x2, y2);
3259
+ const cx = ((x1 * x1 + y1 * y1) * (ym - y2) + (xm * xm + ym * ym) * (y2 - y1) + (x2 * x2 + y2 * y2) * (y1 - ym)) / d;
3260
+ const cy = ((x1 * x1 + y1 * y1) * (x2 - xm) + (xm * xm + ym * ym) * (x1 - x2) + (x2 * x2 + y2 * y2) * (xm - x1)) / d;
3261
+ const radius = Math.sqrt((x1 - cx) ** 2 + (y1 - cy) ** 2);
3262
+ const a1 = Math.atan2(y1 - cy, x1 - cx);
3263
+ const am = Math.atan2(ym - cy, xm - cx);
3264
+ const a2 = Math.atan2(y2 - cy, x2 - cx);
3265
+ let da1m = am - a1;
3266
+ if (da1m < 0) da1m += 2 * Math.PI;
3267
+ let da12 = a2 - a1;
3268
+ if (da12 < 0) da12 += 2 * Math.PI;
3269
+ const sense = da1m < da12;
3270
+ const circle = require_occtWasmAdapter.makeCircle2d(cx, cy, radius, sense);
3271
+ if (!sense) {
3272
+ const tStart = -a1;
3273
+ let tEnd = -a2;
3274
+ if (tEnd < tStart - 1e-9) tEnd += 2 * Math.PI;
3275
+ return {
3276
+ __bk2d: "trimmed",
3277
+ basis: circle,
3278
+ tStart,
3279
+ tEnd
3280
+ };
3282
3281
  }
3282
+ let tEnd = a2;
3283
+ if (tEnd < a1 - 1e-9) tEnd += 2 * Math.PI;
3284
+ return {
3285
+ __bk2d: "trimmed",
3286
+ basis: circle,
3287
+ tStart: a1,
3288
+ tEnd
3289
+ };
3283
3290
  }
3284
- function makeArc2dTangent$1(oc, startX, startY, tangentX, tangentY, endX, endY) {
3285
- const start = new oc.gp_Pnt2d_3(startX, startY);
3286
- const tangent = new oc.gp_Vec2d_4(tangentX, tangentY);
3287
- const end = new oc.gp_Pnt2d_3(endX, endY);
3288
- const maker = new oc.GCE2d_MakeArcOfCircle_5(start, tangent, end);
3289
- try {
3290
- if (!maker.IsDone()) throw new Error("makeArc2dTangent: construction failed");
3291
- return maker.Value();
3292
- } finally {
3293
- maker.delete();
3294
- end.delete();
3295
- tangent.delete();
3296
- start.delete();
3291
+ function makeArc2dTangent$1(sx, sy, tx, ty, ex, ey) {
3292
+ const len = Math.sqrt(tx * tx + ty * ty);
3293
+ const ntx = len > 0 ? tx / len : 0;
3294
+ const nty = len > 0 ? ty / len : 0;
3295
+ const dx = sx - ex;
3296
+ const dy = sy - ey;
3297
+ const denom = 2 * (dy * ntx - dx * nty);
3298
+ if (Math.abs(denom) < 1e-12) return require_occtWasmAdapter.makeLine2d(sx, sy, ex, ey);
3299
+ const t = -(dx * dx + dy * dy) / denom;
3300
+ const cx = sx - t * nty;
3301
+ const cy = sy + t * ntx;
3302
+ const radius = Math.abs(t);
3303
+ const a1 = Math.atan2(sy - cy, sx - cx);
3304
+ const a2 = Math.atan2(ey - cy, ex - cx);
3305
+ const ccwTanX = -(sy - cy) / radius;
3306
+ const ccwTanY = (sx - cx) / radius;
3307
+ const dotCcw = ntx * ccwTanX + nty * ccwTanY;
3308
+ let aMid;
3309
+ if (dotCcw > 0) {
3310
+ let da = a2 - a1;
3311
+ if (da <= 0) da += 2 * Math.PI;
3312
+ aMid = a1 + da / 2;
3313
+ } else {
3314
+ let da = a2 - a1;
3315
+ if (da >= 0) da -= 2 * Math.PI;
3316
+ aMid = a1 + da / 2;
3297
3317
  }
3318
+ return makeArc2dThreePoints$1(sx, sy, cx + radius * Math.cos(aMid), cy + radius * Math.sin(aMid), ex, ey);
3298
3319
  }
3299
- function makeEllipse2d$1(oc, cx, cy, majorRadius, minorRadius, xDirX = 1, xDirY = 0, sense = true) {
3300
- const center = new oc.gp_Pnt2d_3(cx, cy);
3301
- const dir = new oc.gp_Dir2d_5(xDirX, xDirY);
3302
- const ax = new oc.gp_Ax2d_2(center, dir);
3303
- const elips = new oc.gp_Elips2d_2(ax, majorRadius, minorRadius, sense);
3304
- const maker = new oc.GCE2d_MakeEllipse_1(elips);
3305
- try {
3306
- if (!maker.IsDone()) throw new Error("makeEllipse2d: construction failed");
3307
- return maker.Value();
3308
- } finally {
3309
- maker.delete();
3310
- elips.delete();
3311
- ax.delete();
3312
- dir.delete();
3313
- center.delete();
3314
- }
3320
+ function makeEllipse2d$1(cx, cy, major, minor, xDirX, xDirY, sense) {
3321
+ return require_occtWasmAdapter.makeEllipse2d(cx, cy, major, minor, xDirX, xDirY, sense);
3315
3322
  }
3316
- function makeEllipseArc2d$1(oc, cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX = 1, xDirY = 0, sense = true) {
3317
- const center = new oc.gp_Pnt2d_3(cx, cy);
3318
- const dir = new oc.gp_Dir2d_5(xDirX, xDirY);
3319
- const ax = new oc.gp_Ax2d_2(center, dir);
3320
- const elips = new oc.gp_Elips2d_2(ax, majorRadius, minorRadius, true);
3321
- const maker = new oc.GCE2d_MakeArcOfEllipse_1(elips, startAngle, endAngle, sense);
3322
- try {
3323
- if (!maker.IsDone()) throw new Error("makeEllipseArc2d: construction failed");
3324
- return maker.Value();
3325
- } finally {
3326
- maker.delete();
3327
- elips.delete();
3328
- ax.delete();
3329
- dir.delete();
3330
- center.delete();
3331
- }
3323
+ function makeEllipseArc2d$1(cx, cy, major, minor, start, end, xDirX, xDirY, sense) {
3324
+ return {
3325
+ __bk2d: "trimmed",
3326
+ basis: require_occtWasmAdapter.makeEllipse2d(cx, cy, major, minor, xDirX, xDirY, sense),
3327
+ tStart: start,
3328
+ tEnd: end
3329
+ };
3332
3330
  }
3333
- function makeBezier2d$1(oc, points) {
3334
- const arr = new oc.TColgp_Array1OfPnt2d_2(1, points.length);
3335
- for (let i = 0; i < points.length; i++) {
3336
- const p = points[i];
3337
- const gpPnt = new oc.gp_Pnt2d_3(p[0], p[1]);
3338
- arr.SetValue_1(i + 1, gpPnt);
3339
- gpPnt.delete();
3340
- }
3341
- const bezier = new oc.Geom2d_BezierCurve_1(arr);
3342
- arr.delete();
3343
- return new oc.Handle_Geom2d_Curve_2(bezier);
3331
+ function makeBezier2d$1(points) {
3332
+ return require_occtWasmAdapter.makeBezier2d(points);
3344
3333
  }
3345
- function makeBSpline2d$1(oc, points, options = {}) {
3346
- const { degMin = 1, degMax = 3, continuity = "C2", tolerance = .001, smoothing = null } = options;
3347
- const pnts = new oc.TColgp_Array1OfPnt2d_2(1, points.length);
3348
- for (let i = 0; i < points.length; i++) {
3349
- const p = points[i];
3350
- const gpPnt = new oc.gp_Pnt2d_3(p[0], p[1]);
3351
- pnts.SetValue_1(i + 1, gpPnt);
3352
- gpPnt.delete();
3353
- }
3354
- let splineBuilder;
3355
- if (smoothing) splineBuilder = new oc.Geom2dAPI_PointsToBSpline_6(pnts, smoothing[0], smoothing[1], smoothing[2], degMax, mapContinuity(oc, continuity), tolerance);
3356
- else splineBuilder = new oc.Geom2dAPI_PointsToBSpline_2(pnts, degMin, degMax, mapContinuity(oc, continuity), tolerance);
3357
- pnts.delete();
3358
- if (!splineBuilder.IsDone()) {
3359
- splineBuilder.delete();
3360
- throw new Error("B-spline 2D approximation failed");
3334
+ function makeBSpline2d$1(points, _options) {
3335
+ const n = points.length;
3336
+ const degree = Math.min(3, n - 1);
3337
+ const knots = [];
3338
+ const mults = [];
3339
+ knots.push(0);
3340
+ mults.push(degree + 1);
3341
+ const nInternal = n - degree - 1;
3342
+ for (let i = 1; i <= nInternal; i++) {
3343
+ knots.push(i / (nInternal + 1));
3344
+ mults.push(1);
3361
3345
  }
3362
- const curve = splineBuilder.Curve();
3363
- splineBuilder.delete();
3364
- return curve;
3346
+ knots.push(1);
3347
+ mults.push(degree + 1);
3348
+ return {
3349
+ __bk2d: "bspline",
3350
+ poles: [...points],
3351
+ knots,
3352
+ multiplicities: mults,
3353
+ degree,
3354
+ isPeriodic: false
3355
+ };
3365
3356
  }
3366
- function evaluateCurve2d$1(_oc, curve, param) {
3367
- const p = curve.get().Value(param);
3368
- const result = [p.X(), p.Y()];
3369
- p.delete();
3370
- return result;
3357
+ function evaluateCurve2d$1(curve, param) {
3358
+ return require_occtWasmAdapter.evaluateCurve2d(c2d$1(curve), param);
3371
3359
  }
3372
- function evaluateCurve2dD1$1(oc, curve, param) {
3373
- const inner = curve.get();
3374
- const pnt = new oc.gp_Pnt2d_1();
3375
- const vec = new oc.gp_Vec2d_1();
3376
- inner.D1(param, pnt, vec);
3377
- const result = {
3378
- point: [pnt.X(), pnt.Y()],
3379
- tangent: [vec.X(), vec.Y()]
3360
+ function evaluateCurve2dD1$1(curve, param) {
3361
+ return {
3362
+ point: require_occtWasmAdapter.evaluateCurve2d(c2d$1(curve), param),
3363
+ tangent: require_occtWasmAdapter.tangentCurve2d(c2d$1(curve), param)
3380
3364
  };
3381
- pnt.delete();
3382
- vec.delete();
3383
- return result;
3384
3365
  }
3385
- function getCurve2dBounds$1(_oc, curve) {
3386
- const inner = curve.get();
3366
+ function getCurve2dBounds$1(curve) {
3367
+ return require_occtWasmAdapter.curveBounds(c2d$1(curve));
3368
+ }
3369
+ function getCurve2dType$1(curve) {
3370
+ return require_occtWasmAdapter.curveTypeName(c2dBasis$1(curve));
3371
+ }
3372
+ function trimCurve2d$1(curve, start, end) {
3387
3373
  return {
3388
- first: inner.FirstParameter(),
3389
- last: inner.LastParameter()
3374
+ __bk2d: "trimmed",
3375
+ basis: c2d$1(curve),
3376
+ tStart: start,
3377
+ tEnd: end
3390
3378
  };
3391
3379
  }
3392
- var CURVE_TYPE_NAMES = [
3393
- "LINE",
3394
- "CIRCLE",
3395
- "ELLIPSE",
3396
- "HYPERBOLA",
3397
- "PARABOLA",
3398
- "BEZIER_CURVE",
3399
- "BSPLINE_CURVE",
3400
- "OFFSET_CURVE",
3401
- "OTHER_CURVE"
3402
- ];
3403
- function getCurve2dType$1(oc, curve) {
3404
- return CURVE_TYPE_NAMES[getCurve2dTypeIndex(oc, curve)] ?? "OTHER_CURVE";
3380
+ function copyCurve2d$1(curve) {
3381
+ return JSON.parse(JSON.stringify(curve));
3405
3382
  }
3406
- function trimCurve2d$1(oc, curve, start, end) {
3407
- const trimmed = new oc.Geom2d_TrimmedCurve(curve, start, end, true, true);
3408
- return new oc.Handle_Geom2d_Curve_2(trimmed);
3383
+ function offsetCurve2d$1(curve, offset) {
3384
+ const c = c2d$1(curve);
3385
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3386
+ const N = 30;
3387
+ const poles = [];
3388
+ for (let i = 0; i <= N; i++) {
3389
+ const t = bounds.first + (bounds.last - bounds.first) * i / N;
3390
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3391
+ const [tvx, tvy] = require_occtWasmAdapter.tangentCurve2d(c, t);
3392
+ const tLen = Math.sqrt(tvx * tvx + tvy * tvy);
3393
+ if (tLen > 1e-12) poles.push([px - tvy / tLen * offset, py + tvx / tLen * offset]);
3394
+ else poles.push([px, py]);
3395
+ }
3396
+ return makeBSpline2d$1(poles);
3409
3397
  }
3410
- function reverseCurve2d$1(_oc, curve) {
3411
- curve.get().Reverse();
3398
+ function translateCurve2d$1(curve, dx, dy) {
3399
+ return require_occtWasmAdapter.translateCurve2d(c2d$1(curve), dx, dy);
3412
3400
  }
3413
- function copyCurve2d$1(_oc, curve) {
3414
- return curve.get().Copy();
3401
+ function rotateCurve2d$1(curve, angle, cx, cy) {
3402
+ return require_occtWasmAdapter.rotateCurve2d(c2d$1(curve), angle, cx, cy);
3415
3403
  }
3416
- function offsetCurve2d$1(oc, curve, offset) {
3417
- const offsetCurve = new oc.Geom2d_OffsetCurve_1(curve, offset, true);
3418
- return new oc.Handle_Geom2d_Curve_2(offsetCurve);
3404
+ function scaleCurve2d$1(curve, factor, cx, cy) {
3405
+ return require_occtWasmAdapter.scaleCurve2d(c2d$1(curve), factor, cx, cy);
3419
3406
  }
3420
- function transformCurve(oc, curve, trsf) {
3421
- const gtrsf = new oc.gp_GTrsf2d_2(trsf);
3422
- const result = oc.GeomLib.GTransform(curve, gtrsf);
3423
- gtrsf.delete();
3424
- trsf.delete();
3425
- return result;
3407
+ function mirrorCurve2dAtPoint$1(curve, cx, cy) {
3408
+ return require_occtWasmAdapter.mirrorAtPoint(c2d$1(curve), cx, cy);
3426
3409
  }
3427
- function translateCurve2d$1(oc, curve, dx, dy) {
3428
- const v = new oc.gp_Vec2d_4(dx, dy);
3429
- const trsf = new oc.gp_Trsf2d_1();
3430
- trsf.SetTranslation_1(v);
3431
- v.delete();
3432
- return transformCurve(oc, curve, trsf);
3433
- }
3434
- function rotateCurve2d$1(oc, curve, angle, cx, cy) {
3435
- const center = new oc.gp_Pnt2d_3(cx, cy);
3436
- const trsf = new oc.gp_Trsf2d_1();
3437
- trsf.SetRotation(center, angle);
3438
- center.delete();
3439
- return transformCurve(oc, curve, trsf);
3410
+ function mirrorCurve2dAcrossAxis$1(curve, ox, oy, dx, dy) {
3411
+ return require_occtWasmAdapter.mirrorAcrossAxis(c2d$1(curve), ox, oy, dx, dy);
3440
3412
  }
3441
- function scaleCurve2d$1(oc, curve, factor, cx, cy) {
3442
- const center = new oc.gp_Pnt2d_3(cx, cy);
3443
- const trsf = new oc.gp_Trsf2d_1();
3444
- trsf.SetScale(center, factor);
3445
- center.delete();
3446
- return transformCurve(oc, curve, trsf);
3413
+ function affinityTransform2d$1(curve, ox, oy, dx, dy, ratio) {
3414
+ return transformCurve2dGeneral$1(curve, createAffinityGTrsf2d$1(ox, oy, dx, dy, ratio));
3447
3415
  }
3448
- function mirrorCurve2dAtPoint$1(oc, curve, cx, cy) {
3449
- const center = new oc.gp_Pnt2d_3(cx, cy);
3450
- const trsf = new oc.gp_Trsf2d_1();
3451
- trsf.SetMirror_1(center);
3452
- center.delete();
3453
- return transformCurve(oc, curve, trsf);
3454
- }
3455
- function mirrorCurve2dAcrossAxis$1(oc, curve, originX, originY, dirX, dirY) {
3456
- const origin = new oc.gp_Pnt2d_3(originX, originY);
3457
- const dir = new oc.gp_Dir2d_5(dirX, dirY);
3458
- const ax = new oc.gp_Ax2d_2(origin, dir);
3459
- const trsf = new oc.gp_Trsf2d_1();
3460
- trsf.SetMirror_2(ax);
3461
- ax.delete();
3462
- dir.delete();
3463
- origin.delete();
3464
- return transformCurve(oc, curve, trsf);
3465
- }
3466
- function affinityTransform2d$1(oc, curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio) {
3467
- const origin = new oc.gp_Pnt2d_3(axisOriginX, axisOriginY);
3468
- const dir = new oc.gp_Dir2d_5(axisDirX, axisDirY);
3469
- const ax = new oc.gp_Ax2d_2(origin, dir);
3470
- const gtrsf = new oc.gp_GTrsf2d_1();
3471
- gtrsf.SetAffinity(ax, ratio);
3472
- ax.delete();
3473
- dir.delete();
3474
- origin.delete();
3475
- const result = oc.GeomLib.GTransform(curve, gtrsf);
3476
- gtrsf.delete();
3477
- return result;
3416
+ function _gtrsf$1(m, tx, ty) {
3417
+ return {
3418
+ m,
3419
+ tx,
3420
+ ty,
3421
+ delete: noop$1
3422
+ };
3478
3423
  }
3479
- /** Helper: wrap a gp_Trsf2d in a gp_GTrsf2d and delete the trsf. */
3480
- function wrapTrsf2dAsGTrsf2d(oc, trsf) {
3481
- const gtrsf = new oc.gp_GTrsf2d_2(trsf);
3482
- trsf.delete();
3483
- return gtrsf;
3424
+ function createIdentityGTrsf2d$1() {
3425
+ return _gtrsf$1([
3426
+ 1,
3427
+ 0,
3428
+ 0,
3429
+ 0,
3430
+ 1,
3431
+ 0,
3432
+ 0,
3433
+ 0,
3434
+ 1
3435
+ ], 0, 0);
3436
+ }
3437
+ function createAffinityGTrsf2d$1(ox, oy, dx, dy, ratio) {
3438
+ const len = Math.sqrt(dx * dx + dy * dy);
3439
+ if (len < 1e-15) return createIdentityGTrsf2d$1();
3440
+ const px = -dy / len, py = dx / len;
3441
+ const k = ratio - 1;
3442
+ const m = [
3443
+ 1 + k * px * px,
3444
+ k * px * py,
3445
+ 0,
3446
+ k * py * px,
3447
+ 1 + k * py * py,
3448
+ 0,
3449
+ 0,
3450
+ 0,
3451
+ 1
3452
+ ];
3453
+ return _gtrsf$1(m, ox - m[0] * ox - m[1] * oy, oy - m[3] * ox - m[4] * oy);
3484
3454
  }
3485
- function createIdentityGTrsf2d$1(oc) {
3486
- return new oc.gp_GTrsf2d_1();
3455
+ function createTranslationGTrsf2d$1(dx, dy) {
3456
+ return _gtrsf$1([
3457
+ 1,
3458
+ 0,
3459
+ 0,
3460
+ 0,
3461
+ 1,
3462
+ 0,
3463
+ 0,
3464
+ 0,
3465
+ 1
3466
+ ], dx, dy);
3487
3467
  }
3488
- function createAffinityGTrsf2d$1(oc, originX, originY, dirX, dirY, ratio) {
3489
- const origin = new oc.gp_Pnt2d_3(originX, originY);
3490
- const dir = new oc.gp_Dir2d_5(dirX, dirY);
3491
- const ax = new oc.gp_Ax2d_2(origin, dir);
3492
- const gtrsf = new oc.gp_GTrsf2d_1();
3493
- gtrsf.SetAffinity(ax, ratio);
3494
- ax.delete();
3495
- dir.delete();
3496
- origin.delete();
3497
- return gtrsf;
3498
- }
3499
- function createTranslationGTrsf2d$1(oc, dx, dy) {
3500
- const v = new oc.gp_Vec2d_4(dx, dy);
3501
- const trsf = new oc.gp_Trsf2d_1();
3502
- trsf.SetTranslation_1(v);
3503
- v.delete();
3504
- return wrapTrsf2dAsGTrsf2d(oc, trsf);
3505
- }
3506
- function createMirrorGTrsf2d$1(oc, cx, cy, mode, originX = 0, originY = 0, dirX = 1, dirY = 0) {
3507
- const trsf = new oc.gp_Trsf2d_1();
3508
- if (mode === "point") {
3509
- const p = new oc.gp_Pnt2d_3(cx, cy);
3510
- trsf.SetMirror_1(p);
3511
- p.delete();
3512
- } else {
3513
- const p = new oc.gp_Pnt2d_3(originX, originY);
3514
- const dir = new oc.gp_Dir2d_5(dirX, dirY);
3515
- const ax = new oc.gp_Ax2d_2(p, dir);
3516
- trsf.SetMirror_2(ax);
3517
- ax.delete();
3518
- dir.delete();
3519
- p.delete();
3520
- }
3521
- return wrapTrsf2dAsGTrsf2d(oc, trsf);
3522
- }
3523
- function createRotationGTrsf2d$1(oc, angle, cx, cy) {
3524
- const p = new oc.gp_Pnt2d_3(cx, cy);
3525
- const trsf = new oc.gp_Trsf2d_1();
3526
- trsf.SetRotation(p, angle);
3527
- p.delete();
3528
- return wrapTrsf2dAsGTrsf2d(oc, trsf);
3529
- }
3530
- function createScaleGTrsf2d$1(oc, factor, cx, cy) {
3531
- const p = new oc.gp_Pnt2d_3(cx, cy);
3532
- const trsf = new oc.gp_Trsf2d_1();
3533
- trsf.SetScale(p, factor);
3534
- p.delete();
3535
- return wrapTrsf2dAsGTrsf2d(oc, trsf);
3536
- }
3537
- function setGTrsf2dTranslationPart$1(oc, gtrsf, dx, dy) {
3538
- const xy = new oc.gp_XY_2(dx, dy);
3539
- gtrsf.SetTranslationPart(xy);
3540
- xy.delete();
3468
+ function createMirrorGTrsf2d$1(cx, cy, mode, ox, oy, dx, dy) {
3469
+ if (mode === "axis" && dx !== void 0 && dy !== void 0) {
3470
+ const len = Math.sqrt(dx * dx + dy * dy);
3471
+ const nx = dx / len, ny = dy / len;
3472
+ const m = [
3473
+ 2 * nx * nx - 1,
3474
+ 2 * nx * ny,
3475
+ 0,
3476
+ 2 * nx * ny,
3477
+ 2 * ny * ny - 1,
3478
+ 0,
3479
+ 0,
3480
+ 0,
3481
+ 1
3482
+ ];
3483
+ const apx = ox ?? cx, apy = oy ?? cy;
3484
+ return _gtrsf$1(m, apx - m[0] * apx - m[1] * apy, apy - m[3] * apx - m[4] * apy);
3485
+ }
3486
+ return _gtrsf$1([
3487
+ -1,
3488
+ 0,
3489
+ 0,
3490
+ 0,
3491
+ -1,
3492
+ 0,
3493
+ 0,
3494
+ 0,
3495
+ 1
3496
+ ], 2 * cx, 2 * cy);
3497
+ }
3498
+ function createRotationGTrsf2d$1(angle, cx, cy) {
3499
+ const c = Math.cos(angle), s = Math.sin(angle);
3500
+ return _gtrsf$1([
3501
+ c,
3502
+ -s,
3503
+ 0,
3504
+ s,
3505
+ c,
3506
+ 0,
3507
+ 0,
3508
+ 0,
3509
+ 1
3510
+ ], cx - c * cx + s * cy, cy - s * cx - c * cy);
3541
3511
  }
3542
- function multiplyGTrsf2d$1(_oc, base, other) {
3543
- base.Multiply(other);
3512
+ function createScaleGTrsf2d$1(factor, cx, cy) {
3513
+ return _gtrsf$1([
3514
+ factor,
3515
+ 0,
3516
+ 0,
3517
+ 0,
3518
+ factor,
3519
+ 0,
3520
+ 0,
3521
+ 0,
3522
+ 1
3523
+ ], cx * (1 - factor), cy * (1 - factor));
3544
3524
  }
3545
- function transformCurve2dGeneral$1(oc, curve, gtrsf) {
3546
- return oc.GeomLib.GTransform(curve, gtrsf);
3525
+ function setGTrsf2dTranslationPart$1(gtrsf, dx, dy) {
3526
+ gtrsf.tx = dx;
3527
+ gtrsf.ty = dy;
3528
+ }
3529
+ function multiplyGTrsf2d$1(base, other) {
3530
+ const a = base.m, b = other.m;
3531
+ base.m = [
3532
+ a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
3533
+ a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
3534
+ a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
3535
+ a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
3536
+ a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
3537
+ a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
3538
+ a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
3539
+ a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
3540
+ a[6] * b[2] + a[7] * b[5] + a[8] * b[8]
3541
+ ];
3542
+ const oldTx = base.tx, oldTy = base.ty;
3543
+ const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
3544
+ base.tx = a[0] * otx + a[1] * oty + oldTx;
3545
+ base.ty = a[3] * otx + a[4] * oty + oldTy;
3546
+ }
3547
+ function transformCurve2dGeneral$1(curve, gtrsf) {
3548
+ const c = c2d$1(curve);
3549
+ const m = gtrsf.m ?? [
3550
+ 1,
3551
+ 0,
3552
+ 0,
3553
+ 0,
3554
+ 1,
3555
+ 0,
3556
+ 0,
3557
+ 0,
3558
+ 1
3559
+ ];
3560
+ const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
3561
+ if (Math.abs(m[0] - 1) < 1e-12 && Math.abs(m[4] - 1) < 1e-12 && Math.abs(m[1]) < 1e-12 && Math.abs(m[3]) < 1e-12) return require_occtWasmAdapter.translateCurve2d(c, tx, ty);
3562
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3563
+ const N = 20;
3564
+ const pts = [];
3565
+ for (let i = 0; i <= N; i++) {
3566
+ const t = bounds.first + (bounds.last - bounds.first) * i / N;
3567
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3568
+ pts.push([m[0] * px + m[1] * py + tx, m[3] * px + m[4] * py + ty]);
3569
+ }
3570
+ return require_occtWasmAdapter.makeBezier2d(pts);
3571
+ }
3572
+ function intersectCurves2d$1(c1, c2, tolerance) {
3573
+ const result = require_occtWasmAdapter.intersectCurves2dFn(c2d$1(c1), c2d$1(c2), tolerance);
3574
+ const segments = result.segments.map((s) => Object.assign(s, { delete() {} }));
3575
+ return {
3576
+ points: result.points,
3577
+ segments
3578
+ };
3579
+ }
3580
+ function projectPointOnCurve2d$1(curve, x, y) {
3581
+ const c = c2d$1(curve);
3582
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3583
+ if (c.__bk2d === "line") {
3584
+ const ddx = x - c.ox;
3585
+ const ddy = y - c.oy;
3586
+ const t = Math.max(bounds.first, Math.min(bounds.last, ddx * c.dx + ddy * c.dy));
3587
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3588
+ return {
3589
+ param: t,
3590
+ distance: Math.sqrt((px - x) ** 2 + (py - y) ** 2)
3591
+ };
3592
+ }
3593
+ if (c.__bk2d === "circle") {
3594
+ const angle = Math.atan2(y - c.cy, x - c.cx);
3595
+ let t = c.sense ? angle : -angle;
3596
+ while (t < 0) t += 2 * Math.PI;
3597
+ while (t > 2 * Math.PI) t -= 2 * Math.PI;
3598
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3599
+ return {
3600
+ param: t,
3601
+ distance: Math.sqrt((px - x) ** 2 + (py - y) ** 2)
3602
+ };
3603
+ }
3604
+ if (!isFinite(bounds.first) || !isFinite(bounds.last)) return null;
3605
+ let bestT = bounds.first;
3606
+ let bestDist = Infinity;
3607
+ const N = 200;
3608
+ const dt = (bounds.last - bounds.first) / N;
3609
+ for (let i = 0; i <= N; i++) {
3610
+ const t = bounds.first + i * dt;
3611
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3612
+ const dd = (px - x) ** 2 + (py - y) ** 2;
3613
+ if (dd < bestDist) {
3614
+ bestDist = dd;
3615
+ bestT = t;
3616
+ }
3617
+ }
3618
+ for (let iter = 0; iter < 10; iter++) {
3619
+ const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, bestT);
3620
+ const [tvx, tvy] = require_occtWasmAdapter.tangentCurve2d(c, bestT);
3621
+ const dot = (px - x) * tvx + (py - y) * tvy;
3622
+ const ddenom = tvx * tvx + tvy * tvy;
3623
+ if (ddenom < 1e-20) break;
3624
+ const step = dot / ddenom;
3625
+ const newT = Math.max(bounds.first, Math.min(bounds.last, bestT - step));
3626
+ if (Math.abs(newT - bestT) < 1e-14) break;
3627
+ bestT = newT;
3628
+ }
3629
+ const [fx, fy] = require_occtWasmAdapter.evaluateCurve2d(c, bestT);
3630
+ return {
3631
+ param: bestT,
3632
+ distance: Math.sqrt((fx - x) ** 2 + (fy - y) ** 2)
3633
+ };
3634
+ }
3635
+ function distanceBetweenCurves2d$1(c1, c2, p1s, p1e, p2s, p2e) {
3636
+ const curve1 = c2d$1(c1);
3637
+ const curve2 = c2d$1(c2);
3638
+ let bestT1 = p1s;
3639
+ let bestT2 = p2s;
3640
+ let minDistSq = Infinity;
3641
+ const N = 50;
3642
+ for (let i = 0; i <= N; i++) {
3643
+ const t1 = p1s + (p1e - p1s) * i / N;
3644
+ const [x1, y1] = require_occtWasmAdapter.evaluateCurve2d(curve1, t1);
3645
+ for (let j = 0; j <= N; j++) {
3646
+ const t2 = p2s + (p2e - p2s) * j / N;
3647
+ const [x2, y2] = require_occtWasmAdapter.evaluateCurve2d(curve2, t2);
3648
+ const dd = (x2 - x1) ** 2 + (y2 - y1) ** 2;
3649
+ if (dd < minDistSq) {
3650
+ minDistSq = dd;
3651
+ bestT1 = t1;
3652
+ bestT2 = t2;
3653
+ }
3654
+ }
3655
+ }
3656
+ let t1 = bestT1;
3657
+ let t2 = bestT2;
3658
+ for (let iter = 0; iter < 20; iter++) {
3659
+ const [x2, y2] = require_occtWasmAdapter.evaluateCurve2d(curve2, t2);
3660
+ const proj1 = projectPointOnCurve2d$1(c1, x2, y2);
3661
+ if (proj1) {
3662
+ const newT1 = Math.max(p1s, Math.min(p1e, proj1.param));
3663
+ const converged1 = Math.abs(newT1 - t1) < 1e-12;
3664
+ t1 = newT1;
3665
+ if (converged1) break;
3666
+ }
3667
+ const [x1, y1] = require_occtWasmAdapter.evaluateCurve2d(curve1, t1);
3668
+ const proj2 = projectPointOnCurve2d$1(c2, x1, y1);
3669
+ if (proj2) {
3670
+ const newT2 = Math.max(p2s, Math.min(p2e, proj2.param));
3671
+ const converged2 = Math.abs(newT2 - t2) < 1e-12;
3672
+ t2 = newT2;
3673
+ if (converged2) break;
3674
+ }
3675
+ }
3676
+ const [fx1, fy1] = require_occtWasmAdapter.evaluateCurve2d(curve1, t1);
3677
+ const [fx2, fy2] = require_occtWasmAdapter.evaluateCurve2d(curve2, t2);
3678
+ return Math.sqrt((fx2 - fx1) ** 2 + (fy2 - fy1) ** 2);
3547
3679
  }
3548
- function intersectCurves2d$1(oc, c1, c2, tolerance) {
3549
- const intersector = new oc.Geom2dAPI_InterCurveCurve_1();
3550
- intersector.Init_1(c1, c2, tolerance);
3551
- const points = [];
3552
- const nPoints = intersector.NbPoints();
3553
- for (let i = 1; i <= nPoints; i++) {
3554
- const p = intersector.Point(i);
3555
- points.push([p.X(), p.Y()]);
3556
- p.delete();
3557
- }
3558
- const segments = [];
3559
- const nSegments = intersector.NbSegments();
3560
- for (let i = 1; i <= nSegments; i++) {
3561
- const h1 = new oc.Handle_Geom2d_Curve_1();
3562
- const h2 = new oc.Handle_Geom2d_Curve_1();
3563
- try {
3564
- intersector.Segment(i, h1, h2);
3565
- segments.push(h1);
3566
- h2.delete();
3567
- } catch {
3568
- h1.delete();
3569
- h2.delete();
3680
+ function approximateCurve2dAsBSpline$1(curve, tol, cont, maxSeg) {
3681
+ const c = c2d$1(curve);
3682
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3683
+ const degree = Math.max(3, {
3684
+ C0: 1,
3685
+ C1: 2,
3686
+ C2: 3,
3687
+ C3: 4
3688
+ }[cont] ?? 4);
3689
+ let curN = Math.max(100, maxSeg * 10);
3690
+ let poles = [];
3691
+ let maxErr = Infinity;
3692
+ for (let attempt = 0; attempt < 3 && maxErr > tol; attempt++) {
3693
+ poles = [];
3694
+ for (let i = 0; i <= curN; i++) {
3695
+ const t = bounds.first + (bounds.last - bounds.first) * i / curN;
3696
+ poles.push(require_occtWasmAdapter.evaluateCurve2d(c, t));
3697
+ }
3698
+ maxErr = 0;
3699
+ for (let i = 0; i < curN; i++) {
3700
+ const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / curN;
3701
+ const [ex, ey] = require_occtWasmAdapter.evaluateCurve2d(c, tMid);
3702
+ const p0 = poles[i];
3703
+ const p1 = poles[i + 1];
3704
+ const mx = (p0[0] + p1[0]) / 2;
3705
+ const my = (p0[1] + p1[1]) / 2;
3706
+ const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
3707
+ if (err > maxErr) maxErr = err;
3570
3708
  }
3709
+ if (maxErr > tol) curN = Math.min(curN * 2, 500);
3571
3710
  }
3572
- intersector.delete();
3573
- return {
3574
- points,
3575
- segments
3576
- };
3711
+ return makeBSpline2d$1(poles, { degMax: degree });
3577
3712
  }
3578
- function projectPointOnCurve2d$1(oc, curve, x, y) {
3579
- const pnt = new oc.gp_Pnt2d_3(x, y);
3580
- const projector = new oc.Geom2dAPI_ProjectPointOnCurve_2(pnt, curve);
3581
- pnt.delete();
3582
- let result = null;
3583
- try {
3584
- if (projector.NbPoints() > 0) result = {
3585
- param: projector.LowerDistanceParameter(),
3586
- distance: projector.LowerDistance()
3713
+ function decomposeBSpline2dToBeziers$1(curve) {
3714
+ const c = c2dBasis$1(curve);
3715
+ if (c.__bk2d === "bezier") return [curve];
3716
+ if (c.__bk2d !== "bspline") return decomposeBSpline2dToBeziers$1(approximateCurve2dAsBSpline$1(curve, 1e-6, "C2", 10));
3717
+ const trimBounds = require_occtWasmAdapter.curveBounds(c2d$1(curve));
3718
+ const first = trimBounds.first;
3719
+ const last = trimBounds.last;
3720
+ const internalKnots = [];
3721
+ for (const k of c.knots) if (k > first + 1e-12 && k < last - 1e-12) internalKnots.push(k);
3722
+ const breakpoints = [
3723
+ first,
3724
+ ...internalKnots,
3725
+ last
3726
+ ];
3727
+ const result = [];
3728
+ for (let i = 0; i < breakpoints.length - 1; i++) {
3729
+ const t0 = breakpoints[i];
3730
+ const t1 = breakpoints[i + 1];
3731
+ const span = t1 - t0;
3732
+ if (span < 1e-15) continue;
3733
+ const p0 = require_occtWasmAdapter.evaluateCurve2d(c, t0);
3734
+ const p3 = require_occtWasmAdapter.evaluateCurve2d(c, t1);
3735
+ const tan0 = require_occtWasmAdapter.tangentCurve2d(c, t0);
3736
+ const tan3 = require_occtWasmAdapter.tangentCurve2d(c, t1);
3737
+ const s = span / 3;
3738
+ const bezier = {
3739
+ __bk2d: "bezier",
3740
+ poles: [
3741
+ p0,
3742
+ [p0[0] + tan0[0] * s, p0[1] + tan0[1] * s],
3743
+ [p3[0] - tan3[0] * s, p3[1] - tan3[1] * s],
3744
+ p3
3745
+ ]
3587
3746
  };
3588
- } catch {}
3589
- projector.delete();
3590
- return result;
3591
- }
3592
- function distanceBetweenCurves2d$1(oc, c1, c2, p1Start, p1End, p2Start, p2End) {
3593
- const extrema = new oc.Geom2dAPI_ExtremaCurveCurve(c1, c2, p1Start, p1End, p2Start, p2End);
3594
- let distance;
3595
- try {
3596
- distance = extrema.LowerDistance();
3597
- } catch {
3598
- distance = Infinity;
3747
+ result.push(bezier);
3599
3748
  }
3600
- extrema.delete();
3601
- return distance;
3602
- }
3603
- function approximateCurve2dAsBSpline$1(oc, curve, tolerance, continuity, maxSegments) {
3604
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3605
- const convert = new oc.Geom2dConvert_ApproxCurve_2(adaptor.ShallowCopy(), tolerance, mapContinuity(oc, continuity), maxSegments, 3);
3606
- const result = convert.Curve();
3607
- convert.delete();
3608
- adaptor.delete();
3609
- return result;
3610
- }
3611
- function decomposeBSpline2dToBeziers$1(oc, curve) {
3612
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3613
- const handle = adaptor.BSpline();
3614
- adaptor.delete();
3615
- const convert = new oc.Geom2dConvert_BSplineCurveToBezierCurve_1(handle);
3616
- const arcs = [];
3617
- const nArcs = convert.NbArcs();
3618
- for (let i = 1; i <= nArcs; i++) arcs.push(convert.Arc(i));
3619
- convert.delete();
3620
- return arcs;
3749
+ return result.length > 0 ? result : [curve];
3621
3750
  }
3622
- function createBoundingBox2d$1(oc) {
3623
- return new oc.Bnd_Box2d();
3751
+ function createBoundingBox2d$1() {
3752
+ return require_occtWasmAdapter.createBBox2d();
3624
3753
  }
3625
- function addCurveToBBox2d$1(oc, bbox, curve, tolerance) {
3626
- oc.BndLib_Add2dCurve.Add_3(curve, tolerance, bbox);
3754
+ function addCurveToBBox2d$1(bbox, curve, tol) {
3755
+ require_occtWasmAdapter.addCurveToBBox(bb2d$1(bbox), c2d$1(curve), tol);
3627
3756
  }
3628
- function getBBox2dBounds$1(_oc, bbox) {
3757
+ function getBBox2dBounds$1(bbox) {
3758
+ const b = bb2d$1(bbox);
3629
3759
  return {
3630
- xMin: bbox.GetXMin(),
3631
- yMin: bbox.GetYMin(),
3632
- xMax: bbox.GetXMax(),
3633
- yMax: bbox.GetYMax()
3760
+ xMin: b.xMin,
3761
+ yMin: b.yMin,
3762
+ xMax: b.xMax,
3763
+ yMax: b.yMax
3634
3764
  };
3635
3765
  }
3636
- function mergeBBox2d$1(_oc, target, other) {
3637
- target.Add_1(other);
3766
+ function mergeBBox2d$1(target, other) {
3767
+ const t = bb2d$1(target), o = bb2d$1(other);
3768
+ t.xMin = Math.min(t.xMin, o.xMin);
3769
+ t.yMin = Math.min(t.yMin, o.yMin);
3770
+ t.xMax = Math.max(t.xMax, o.xMax);
3771
+ t.yMax = Math.max(t.yMax, o.yMax);
3638
3772
  }
3639
- function isBBox2dOut$1(_oc, a, b) {
3640
- return a.IsOut_4(b);
3773
+ function isBBox2dOut$1(a, b) {
3774
+ const ba = bb2d$1(a), bbb = bb2d$1(b);
3775
+ return ba.xMax < bbb.xMin || bbb.xMax < ba.xMin || ba.yMax < bbb.yMin || bbb.yMax < ba.yMin;
3641
3776
  }
3642
- function isBBox2dOutPoint$1(oc, bbox, x, y) {
3643
- const pnt = new oc.gp_Pnt2d_3(x, y);
3644
- const result = bbox.IsOut_1(pnt);
3645
- pnt.delete();
3646
- return result;
3777
+ function isBBox2dOutPoint$1(bbox, x, y) {
3778
+ const b = bb2d$1(bbox);
3779
+ return x < b.xMin || x > b.xMax || y < b.yMin || y > b.yMax;
3647
3780
  }
3648
- function getCurve2dCircleData$1(oc, curve) {
3649
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3650
- if (unwrapOcctEnum(adaptor.GetType()) !== 1) {
3651
- adaptor.delete();
3652
- return null;
3653
- }
3654
- const circle = adaptor.Circle();
3655
- const center = circle.Location();
3656
- const result = {
3657
- cx: center.X(),
3658
- cy: center.Y(),
3659
- radius: circle.Radius(),
3660
- isDirect: circle.IsDirect()
3781
+ function getCurve2dCircleData$1(curve) {
3782
+ const c = c2dBasis$1(curve);
3783
+ if (c.__bk2d === "circle") return {
3784
+ cx: c.cx,
3785
+ cy: c.cy,
3786
+ radius: c.radius,
3787
+ isDirect: c.sense
3661
3788
  };
3662
- center.delete();
3663
- circle.delete();
3664
- adaptor.delete();
3665
- return result;
3789
+ return null;
3666
3790
  }
3667
- function getCurve2dEllipseData$1(oc, curve) {
3668
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3669
- if (unwrapOcctEnum(adaptor.GetType()) !== 2) {
3670
- adaptor.delete();
3671
- return null;
3672
- }
3673
- const elips = adaptor.Ellipse();
3674
- const xAxis = elips.XAxis();
3675
- const xDir = xAxis.Direction();
3676
- const result = {
3677
- majorRadius: elips.MajorRadius(),
3678
- minorRadius: elips.MinorRadius(),
3679
- xAxisAngle: Math.atan2(xDir.Y(), xDir.X()),
3680
- isDirect: elips.IsDirect()
3791
+ function getCurve2dEllipseData$1(curve) {
3792
+ const c = c2dBasis$1(curve);
3793
+ if (c.__bk2d === "ellipse") return {
3794
+ majorRadius: c.majorRadius,
3795
+ minorRadius: c.minorRadius,
3796
+ xAxisAngle: c.xDirAngle,
3797
+ isDirect: c.sense
3681
3798
  };
3682
- xDir.delete();
3683
- xAxis.delete();
3684
- elips.delete();
3685
- adaptor.delete();
3686
- return result;
3799
+ return null;
3687
3800
  }
3688
- function getCurve2dBezierPoles$1(oc, curve) {
3689
- if (getCurve2dTypeIndex(oc, curve) !== 5) return null;
3690
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3691
- const bezier = adaptor.Bezier().get();
3692
- const poles = [];
3693
- const nbPoles = bezier.NbPoles();
3694
- for (let i = 1; i <= nbPoles; i++) {
3695
- const p = bezier.Pole(i);
3696
- poles.push([p.X(), p.Y()]);
3697
- p.delete();
3698
- }
3699
- adaptor.delete();
3700
- return poles;
3801
+ function getCurve2dBezierPoles$1(curve) {
3802
+ const c = c2dBasis$1(curve);
3803
+ if (c.__bk2d === "bezier") return [...c.poles];
3804
+ return null;
3701
3805
  }
3702
- function getCurve2dBezierDegree$1(oc, curve) {
3703
- if (getCurve2dTypeIndex(oc, curve) !== 5) return null;
3704
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3705
- const degree = adaptor.Bezier().get().Degree();
3706
- adaptor.delete();
3707
- return degree;
3806
+ function getCurve2dBezierDegree$1(curve) {
3807
+ const c = c2dBasis$1(curve);
3808
+ if (c.__bk2d === "bezier") return c.poles.length - 1;
3809
+ return null;
3708
3810
  }
3709
- function getCurve2dBSplineData$1(oc, curve) {
3710
- if (getCurve2dTypeIndex(oc, curve) !== 6) return null;
3711
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3712
- const bspline = adaptor.BSpline().get();
3713
- const poles = [];
3714
- const polesArr = bspline.Poles_2();
3715
- for (let i = polesArr.Lower(); i <= polesArr.Upper(); i++) {
3716
- const p = polesArr.Value(i);
3717
- poles.push([p.X(), p.Y()]);
3718
- }
3719
- const knots = [];
3720
- const knotsArr = bspline.Knots_2();
3721
- for (let i = knotsArr.Lower(); i <= knotsArr.Upper(); i++) knots.push(knotsArr.Value(i));
3722
- const multiplicities = [];
3723
- const multsArr = bspline.Multiplicities_2();
3724
- for (let i = multsArr.Lower(); i <= multsArr.Upper(); i++) multiplicities.push(multsArr.Value(i));
3725
- const result = {
3726
- poles,
3727
- knots,
3728
- multiplicities,
3729
- degree: bspline.Degree(),
3730
- isPeriodic: bspline.IsPeriodic()
3811
+ function getCurve2dBSplineData$1(curve) {
3812
+ const c = c2dBasis$1(curve);
3813
+ if (c.__bk2d === "bspline") return {
3814
+ poles: [...c.poles],
3815
+ knots: [...c.knots],
3816
+ multiplicities: [...c.multiplicities],
3817
+ degree: c.degree,
3818
+ isPeriodic: c.isPeriodic
3731
3819
  };
3732
- adaptor.delete();
3733
- return result;
3820
+ return null;
3734
3821
  }
3735
- function serializeCurve2d$1(oc, curve) {
3736
- return oc.GeomToolsWrapper.Write(curve);
3737
- }
3738
- function deserializeCurve2d$1(oc, data) {
3739
- return oc.GeomToolsWrapper.Read(data);
3740
- }
3741
- function splitCurve2d$1(oc, curve, params) {
3742
- const inner = curve.get();
3743
- const first = inner.FirstParameter();
3744
- const last = inner.LastParameter();
3745
- const sorted = [...params].sort((a, b) => a - b);
3746
- const boundaries = [];
3747
- let prev = first;
3748
- for (const p of sorted) if (p > first && p < last) {
3749
- boundaries.push([prev, p]);
3750
- prev = p;
3751
- }
3752
- boundaries.push([prev, last]);
3753
- const adaptor = new oc.Geom2dAdaptor_Curve_2(curve);
3754
- const geomType = unwrapOcctEnum(adaptor.GetType());
3755
- const results = boundaries.map(([start, end]) => {
3756
- if (geomType === 5) {
3757
- const curveCopy = new oc.Geom2d_BezierCurve_1(adaptor.Bezier().get().Poles_2());
3758
- curveCopy.Segment(start, end);
3759
- return new oc.Handle_Geom2d_Curve_2(curveCopy);
3760
- }
3761
- if (geomType === 6) {
3762
- const bspline = adaptor.BSpline().get();
3763
- const curveCopy = new oc.Geom2d_BSplineCurve_1(bspline.Poles_2(), bspline.Knots_2(), bspline.Multiplicities_2(), bspline.Degree(), bspline.IsPeriodic());
3764
- curveCopy.Segment(start, end, 1e-9);
3765
- return new oc.Handle_Geom2d_Curve_2(curveCopy);
3766
- }
3767
- const trimmed = new oc.Geom2d_TrimmedCurve(curve, start, end, true, true);
3768
- return new oc.Handle_Geom2d_Curve_2(trimmed);
3822
+ function serializeCurve2d$1(curve) {
3823
+ return require_occtWasmAdapter.serializeCurve2d(c2d$1(curve));
3824
+ }
3825
+ function deserializeCurve2d$1(data) {
3826
+ return require_occtWasmAdapter.deserializeCurve2d(data);
3827
+ }
3828
+ function splitCurve2d$1(curve, params) {
3829
+ const c = c2d$1(curve);
3830
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3831
+ const sortedParams = [
3832
+ bounds.first,
3833
+ ...[...params].sort((a, b) => a - b),
3834
+ bounds.last
3835
+ ];
3836
+ const result = [];
3837
+ for (let i = 0; i < sortedParams.length - 1; i++) result.push({
3838
+ __bk2d: "trimmed",
3839
+ basis: c,
3840
+ tStart: sortedParams[i],
3841
+ tEnd: sortedParams[i + 1]
3769
3842
  });
3770
- adaptor.delete();
3771
- return results;
3843
+ return result;
3772
3844
  }
3773
- function liftCurve2dToPlane$1(oc, curve, planeOrigin, planeZ, planeX) {
3774
- const origin = new oc.gp_Pnt_3(planeOrigin[0], planeOrigin[1], planeOrigin[2]);
3775
- const zDir = new oc.gp_Dir_5(planeZ[0], planeZ[1], planeZ[2]);
3776
- const xDir = new oc.gp_Dir_5(planeX[0], planeX[1], planeX[2]);
3777
- const ax = new oc.gp_Ax2_2(origin, zDir, xDir);
3778
- const curve3d = oc.GeomLib.To3d(ax, curve);
3779
- const edgeBuilder = new oc.BRepBuilderAPI_MakeEdge_24(curve3d);
3845
+ /** Create a straight 3D edge between two points. */
3846
+ function makeLineEdge3d(oc, p1, p2) {
3847
+ const gp1 = new oc.gp_Pnt_3(p1[0], p1[1], p1[2]);
3848
+ const gp2 = new oc.gp_Pnt_3(p2[0], p2[1], p2[2]);
3849
+ const builder = new oc.BRepBuilderAPI_MakeEdge_3(gp1, gp2);
3850
+ const edge = builder.Edge();
3851
+ builder.delete();
3852
+ gp1.delete();
3853
+ gp2.delete();
3854
+ return edge;
3855
+ }
3856
+ /** Create a circular arc edge through 3 points. */
3857
+ function makeCircleArcEdge3d(oc, startPt, midPt, endPt) {
3858
+ const gpStart = new oc.gp_Pnt_3(startPt[0], startPt[1], startPt[2]);
3859
+ const gpMid = new oc.gp_Pnt_3(midPt[0], midPt[1], midPt[2]);
3860
+ const gpEnd = new oc.gp_Pnt_3(endPt[0], endPt[1], endPt[2]);
3861
+ const arcGeom = new oc.GC_MakeArcOfCircle_4(gpStart, gpMid, gpEnd).Value().get();
3862
+ const curveHandle = new oc.Handle_Geom_Curve_2(arcGeom);
3863
+ const edgeBuilder = new oc.BRepBuilderAPI_MakeEdge_24(curveHandle);
3780
3864
  const edge = edgeBuilder.Edge();
3781
3865
  edgeBuilder.delete();
3782
- curve3d.delete();
3783
- ax.delete();
3784
- xDir.delete();
3785
- zDir.delete();
3786
- origin.delete();
3866
+ curveHandle.delete();
3867
+ gpStart.delete();
3868
+ gpMid.delete();
3869
+ gpEnd.delete();
3787
3870
  return edge;
3788
3871
  }
3789
- function buildEdgeOnSurface$1(oc, curve, surface) {
3790
- const edgeMaker = new oc.BRepBuilderAPI_MakeEdge_30(curve, surface);
3791
- const edge = edgeMaker.Edge();
3792
- edgeMaker.delete();
3872
+ /** Interpolate a 3D BSpline through the given points and return an edge. */
3873
+ function interpolatePoints3d(oc, points) {
3874
+ const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
3875
+ const reusePnt = new oc.gp_Pnt_1();
3876
+ for (let i = 0; i < points.length; i++) {
3877
+ const p = points[i];
3878
+ reusePnt.SetCoord_2(p[0], p[1], p[2]);
3879
+ pnts.SetValue_1(i + 1, reusePnt);
3880
+ }
3881
+ reusePnt.delete();
3882
+ const interp = new oc.GeomAPI_PointsToBSpline_2(pnts, 3, 8, oc.GeomAbs_Shape.GeomAbs_C2, 1e-6);
3883
+ pnts.delete();
3884
+ if (!interp.IsDone()) {
3885
+ interp.delete();
3886
+ throw new Error("Interpolation failed — GeomAPI_PointsToBSpline did not converge");
3887
+ }
3888
+ const curve3d = interp.Curve();
3889
+ const geomHandle = new oc.Handle_Geom_Curve_2(curve3d.get());
3890
+ const builder = new oc.BRepBuilderAPI_MakeEdge_24(geomHandle);
3891
+ const edge = builder.Edge();
3892
+ builder.delete();
3893
+ interp.delete();
3793
3894
  return edge;
3794
3895
  }
3896
+ function liftCurve2dToPlane$1(oc, curve, planeOrigin, planeZ, planeX) {
3897
+ const c = c2d$1(curve);
3898
+ const y = [
3899
+ planeZ[1] * planeX[2] - planeZ[2] * planeX[1],
3900
+ planeZ[2] * planeX[0] - planeZ[0] * planeX[2],
3901
+ planeZ[0] * planeX[1] - planeZ[1] * planeX[0]
3902
+ ];
3903
+ const lift = (u, v) => [
3904
+ planeOrigin[0] + u * planeX[0] + v * y[0],
3905
+ planeOrigin[1] + u * planeX[1] + v * y[1],
3906
+ planeOrigin[2] + u * planeX[2] + v * y[2]
3907
+ ];
3908
+ if (c.__bk2d === "line") return makeLineEdge3d(oc, lift(c.ox, c.oy), lift(c.ox + c.dx * c.len, c.oy + c.dy * c.len));
3909
+ if (c.__bk2d === "circle" || c.__bk2d === "trimmed") {
3910
+ let basis = c;
3911
+ while (basis.__bk2d === "trimmed") basis = basis.basis;
3912
+ if (basis.__bk2d === "circle") {
3913
+ const circ = basis;
3914
+ const center3d = lift(circ.cx, circ.cy);
3915
+ const axisDir = circ.sense ? planeZ : [
3916
+ -planeZ[0],
3917
+ -planeZ[1],
3918
+ -planeZ[2]
3919
+ ];
3920
+ if (c.__bk2d === "circle") {
3921
+ const gpCenter = new oc.gp_Pnt_3(center3d[0], center3d[1], center3d[2]);
3922
+ const gpDir = new oc.gp_Dir_5(axisDir[0], axisDir[1], axisDir[2]);
3923
+ const gpAx2 = new oc.gp_Ax2_4(gpCenter, gpDir);
3924
+ const gpCirc = new oc.gp_Circ_2(gpAx2, circ.radius);
3925
+ const builder = new oc.BRepBuilderAPI_MakeEdge_8(gpCirc);
3926
+ const edge = builder.Edge();
3927
+ builder.delete();
3928
+ gpCirc.delete();
3929
+ gpAx2.delete();
3930
+ gpDir.delete();
3931
+ gpCenter.delete();
3932
+ return edge;
3933
+ }
3934
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3935
+ const [su, sv] = require_occtWasmAdapter.evaluateCurve2d(c, bounds.first);
3936
+ const [mu, mv] = require_occtWasmAdapter.evaluateCurve2d(c, (bounds.first + bounds.last) / 2);
3937
+ const [eu, ev] = require_occtWasmAdapter.evaluateCurve2d(c, bounds.last);
3938
+ return makeCircleArcEdge3d(oc, lift(su, sv), lift(mu, mv), lift(eu, ev));
3939
+ }
3940
+ }
3941
+ if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
3942
+ const pts3d = c.poles.map(([u, v]) => lift(u, v));
3943
+ if (pts3d.length === 2) return makeLineEdge3d(oc, pts3d[0], pts3d[1]);
3944
+ return interpolatePoints3d(oc, pts3d);
3945
+ }
3946
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3947
+ const nSamples = 60;
3948
+ const pts3d = [];
3949
+ for (let i = 0; i <= nSamples; i++) {
3950
+ const t = bounds.first + (bounds.last - bounds.first) * i / nSamples;
3951
+ const [u, v] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3952
+ pts3d.push(lift(u, v));
3953
+ }
3954
+ return interpolatePoints3d(oc, pts3d);
3955
+ }
3956
+ function buildEdgeOnSurface$1(oc, curve, surface) {
3957
+ const c = c2d$1(curve);
3958
+ const bounds = require_occtWasmAdapter.curveBounds(c);
3959
+ const N = 60;
3960
+ const pts3d = [];
3961
+ for (let i = 0; i <= N; i++) {
3962
+ const t = bounds.first + (bounds.last - bounds.first) * i / N;
3963
+ const [u, v] = require_occtWasmAdapter.evaluateCurve2d(c, t);
3964
+ const gpPnt = surface.get().Value(u, v);
3965
+ pts3d.push([
3966
+ gpPnt.X(),
3967
+ gpPnt.Y(),
3968
+ gpPnt.Z()
3969
+ ]);
3970
+ gpPnt.delete();
3971
+ }
3972
+ return interpolatePoints3d(oc, pts3d);
3973
+ }
3795
3974
  function extractSurfaceFromFace$1(oc, face) {
3796
3975
  return oc.BRep_Tool.Surface_2(face);
3797
3976
  }
3798
3977
  function extractCurve2dFromEdge$1(oc, edge, face) {
3799
3978
  const adaptor = new oc.BRepAdaptor_Curve2d_2(edge, face);
3800
- const curveHandle = adaptor.Curve();
3801
- const first = adaptor.FirstParameter();
3802
- const last = adaptor.LastParameter();
3979
+ const first = Number(adaptor.FirstParameter());
3980
+ const last = Number(adaptor.LastParameter());
3981
+ const N = 30;
3982
+ const points = [];
3983
+ for (let i = 0; i <= N; i++) {
3984
+ const t = first + (last - first) * i / N;
3985
+ const pt = adaptor.Value(t);
3986
+ points.push([pt.X(), pt.Y()]);
3987
+ pt.delete();
3988
+ }
3803
3989
  adaptor.delete();
3804
- const trimmed = new oc.Geom2d_TrimmedCurve(curveHandle, first, last, true, true);
3805
- return new oc.Handle_Geom2d_Curve_2(trimmed);
3990
+ return makeBSpline2d$1(points);
3806
3991
  }
3807
3992
  function buildCurves3d$1(oc, wire) {
3808
3993
  oc.BRepLib.BuildCurves3d_2(wire);
@@ -5486,172 +5671,170 @@ var DefaultAdapter = class {
5486
5671
  return exportSTEPConfigured$1(this.oc, shapes, options);
5487
5672
  }
5488
5673
  wrapCurve2dHandle(handle) {
5489
- return wrapCurve2dHandle$1(this.oc, handle);
5674
+ return wrapCurve2dHandle$1(handle);
5490
5675
  }
5491
5676
  createCurve2dAdaptor(handle) {
5492
- return createCurve2dAdaptor$1(this.oc, handle);
5677
+ return createCurve2dAdaptor$1(handle);
5493
5678
  }
5494
5679
  createPoint2d(x, y) {
5495
- return createPoint2d$1(this.oc, x, y);
5680
+ return createPoint2d$1(x, y);
5496
5681
  }
5497
5682
  createDirection2d(x, y) {
5498
- return createDirection2d$1(this.oc, x, y);
5683
+ return createDirection2d$1(x, y);
5499
5684
  }
5500
5685
  createVector2d(x, y) {
5501
- return createVector2d$1(this.oc, x, y);
5686
+ return createVector2d$1(x, y);
5502
5687
  }
5503
5688
  createAxis2d(px, py, dx, dy) {
5504
- return createAxis2d$1(this.oc, px, py, dx, dy);
5689
+ return createAxis2d$1(px, py, dx, dy);
5505
5690
  }
5506
5691
  makeLine2d(x1, y1, x2, y2) {
5507
- return makeLine2d$1(this.oc, x1, y1, x2, y2);
5692
+ return makeLine2d$1(x1, y1, x2, y2);
5508
5693
  }
5509
5694
  makeCircle2d(cx, cy, radius, sense) {
5510
- return makeCircle2d$1(this.oc, cx, cy, radius, sense);
5695
+ return makeCircle2d$1(cx, cy, radius, sense);
5511
5696
  }
5512
5697
  makeArc2dThreePoints(x1, y1, xm, ym, x2, y2) {
5513
- return makeArc2dThreePoints$1(this.oc, x1, y1, xm, ym, x2, y2);
5698
+ return makeArc2dThreePoints$1(x1, y1, xm, ym, x2, y2);
5514
5699
  }
5515
5700
  makeArc2dTangent(startX, startY, tangentX, tangentY, endX, endY) {
5516
- return makeArc2dTangent$1(this.oc, startX, startY, tangentX, tangentY, endX, endY);
5701
+ return makeArc2dTangent$1(startX, startY, tangentX, tangentY, endX, endY);
5517
5702
  }
5518
5703
  makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense) {
5519
- return makeEllipse2d$1(this.oc, cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense);
5704
+ return makeEllipse2d$1(cx, cy, majorRadius, minorRadius, xDirX, xDirY, sense);
5520
5705
  }
5521
5706
  makeEllipseArc2d(cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense) {
5522
- return makeEllipseArc2d$1(this.oc, cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense);
5707
+ return makeEllipseArc2d$1(cx, cy, majorRadius, minorRadius, startAngle, endAngle, xDirX, xDirY, sense);
5523
5708
  }
5524
5709
  makeBezier2d(points) {
5525
- return makeBezier2d$1(this.oc, points);
5710
+ return makeBezier2d$1(points);
5526
5711
  }
5527
5712
  makeBSpline2d(points, options) {
5528
- return makeBSpline2d$1(this.oc, points, options);
5713
+ return makeBSpline2d$1(points, options);
5529
5714
  }
5530
5715
  evaluateCurve2d(curve, param) {
5531
- return evaluateCurve2d$1(this.oc, curve, param);
5716
+ return evaluateCurve2d$1(curve, param);
5532
5717
  }
5533
5718
  evaluateCurve2dD1(curve, param) {
5534
- return evaluateCurve2dD1$1(this.oc, curve, param);
5719
+ return evaluateCurve2dD1$1(curve, param);
5535
5720
  }
5536
5721
  getCurve2dBounds(curve) {
5537
- return getCurve2dBounds$1(this.oc, curve);
5722
+ return getCurve2dBounds$1(curve);
5538
5723
  }
5539
5724
  getCurve2dType(curve) {
5540
- return getCurve2dType$1(this.oc, curve);
5725
+ return getCurve2dType$1(curve);
5541
5726
  }
5542
5727
  trimCurve2d(curve, start, end) {
5543
- return trimCurve2d$1(this.oc, curve, start, end);
5544
- }
5545
- reverseCurve2d(curve) {
5546
- reverseCurve2d$1(this.oc, curve);
5728
+ return trimCurve2d$1(curve, start, end);
5547
5729
  }
5730
+ reverseCurve2d(curve) {}
5548
5731
  copyCurve2d(curve) {
5549
- return copyCurve2d$1(this.oc, curve);
5732
+ return copyCurve2d$1(curve);
5550
5733
  }
5551
5734
  offsetCurve2d(curve, offset) {
5552
- return offsetCurve2d$1(this.oc, curve, offset);
5735
+ return offsetCurve2d$1(curve, offset);
5553
5736
  }
5554
5737
  translateCurve2d(curve, dx, dy) {
5555
- return translateCurve2d$1(this.oc, curve, dx, dy);
5738
+ return translateCurve2d$1(curve, dx, dy);
5556
5739
  }
5557
5740
  rotateCurve2d(curve, angle, cx, cy) {
5558
- return rotateCurve2d$1(this.oc, curve, angle, cx, cy);
5741
+ return rotateCurve2d$1(curve, angle, cx, cy);
5559
5742
  }
5560
5743
  scaleCurve2d(curve, factor, cx, cy) {
5561
- return scaleCurve2d$1(this.oc, curve, factor, cx, cy);
5744
+ return scaleCurve2d$1(curve, factor, cx, cy);
5562
5745
  }
5563
5746
  mirrorCurve2dAtPoint(curve, cx, cy) {
5564
- return mirrorCurve2dAtPoint$1(this.oc, curve, cx, cy);
5747
+ return mirrorCurve2dAtPoint$1(curve, cx, cy);
5565
5748
  }
5566
5749
  mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
5567
- return mirrorCurve2dAcrossAxis$1(this.oc, curve, originX, originY, dirX, dirY);
5750
+ return mirrorCurve2dAcrossAxis$1(curve, originX, originY, dirX, dirY);
5568
5751
  }
5569
5752
  affinityTransform2d(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio) {
5570
- return affinityTransform2d$1(this.oc, curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio);
5753
+ return affinityTransform2d$1(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio);
5571
5754
  }
5572
5755
  createIdentityGTrsf2d() {
5573
- return createIdentityGTrsf2d$1(this.oc);
5756
+ return createIdentityGTrsf2d$1();
5574
5757
  }
5575
5758
  createAffinityGTrsf2d(originX, originY, dirX, dirY, ratio) {
5576
- return createAffinityGTrsf2d$1(this.oc, originX, originY, dirX, dirY, ratio);
5759
+ return createAffinityGTrsf2d$1(originX, originY, dirX, dirY, ratio);
5577
5760
  }
5578
5761
  createTranslationGTrsf2d(dx, dy) {
5579
- return createTranslationGTrsf2d$1(this.oc, dx, dy);
5762
+ return createTranslationGTrsf2d$1(dx, dy);
5580
5763
  }
5581
5764
  createMirrorGTrsf2d(cx, cy, mode, originX, originY, dirX, dirY) {
5582
- return createMirrorGTrsf2d$1(this.oc, cx, cy, mode, originX, originY, dirX, dirY);
5765
+ return createMirrorGTrsf2d$1(cx, cy, mode, originX, originY, dirX, dirY);
5583
5766
  }
5584
5767
  createRotationGTrsf2d(angle, cx, cy) {
5585
- return createRotationGTrsf2d$1(this.oc, angle, cx, cy);
5768
+ return createRotationGTrsf2d$1(angle, cx, cy);
5586
5769
  }
5587
5770
  createScaleGTrsf2d(factor, cx, cy) {
5588
- return createScaleGTrsf2d$1(this.oc, factor, cx, cy);
5771
+ return createScaleGTrsf2d$1(factor, cx, cy);
5589
5772
  }
5590
5773
  setGTrsf2dTranslationPart(gtrsf, dx, dy) {
5591
- setGTrsf2dTranslationPart$1(this.oc, gtrsf, dx, dy);
5774
+ setGTrsf2dTranslationPart$1(gtrsf, dx, dy);
5592
5775
  }
5593
5776
  multiplyGTrsf2d(base, other) {
5594
- multiplyGTrsf2d$1(this.oc, base, other);
5777
+ multiplyGTrsf2d$1(base, other);
5595
5778
  }
5596
5779
  transformCurve2dGeneral(curve, gtrsf) {
5597
- return transformCurve2dGeneral$1(this.oc, curve, gtrsf);
5780
+ return transformCurve2dGeneral$1(curve, gtrsf);
5598
5781
  }
5599
5782
  intersectCurves2d(c1, c2, tolerance) {
5600
- return intersectCurves2d$1(this.oc, c1, c2, tolerance);
5783
+ return intersectCurves2d$1(c1, c2, tolerance);
5601
5784
  }
5602
5785
  projectPointOnCurve2d(curve, x, y) {
5603
- return projectPointOnCurve2d$1(this.oc, curve, x, y);
5786
+ return projectPointOnCurve2d$1(curve, x, y);
5604
5787
  }
5605
5788
  distanceBetweenCurves2d(c1, c2, p1Start, p1End, p2Start, p2End) {
5606
- return distanceBetweenCurves2d$1(this.oc, c1, c2, p1Start, p1End, p2Start, p2End);
5789
+ return distanceBetweenCurves2d$1(c1, c2, p1Start, p1End, p2Start, p2End);
5607
5790
  }
5608
5791
  approximateCurve2dAsBSpline(curve, tolerance, continuity, maxSegments) {
5609
- return approximateCurve2dAsBSpline$1(this.oc, curve, tolerance, continuity, maxSegments);
5792
+ return approximateCurve2dAsBSpline$1(curve, tolerance, continuity, maxSegments);
5610
5793
  }
5611
5794
  decomposeBSpline2dToBeziers(curve) {
5612
- return decomposeBSpline2dToBeziers$1(this.oc, curve);
5795
+ return decomposeBSpline2dToBeziers$1(curve);
5613
5796
  }
5614
5797
  createBoundingBox2d() {
5615
- return createBoundingBox2d$1(this.oc);
5798
+ return createBoundingBox2d$1();
5616
5799
  }
5617
5800
  addCurveToBBox2d(bbox, curve, tolerance) {
5618
- addCurveToBBox2d$1(this.oc, bbox, curve, tolerance);
5801
+ addCurveToBBox2d$1(bbox, curve, tolerance);
5619
5802
  }
5620
5803
  getBBox2dBounds(bbox) {
5621
- return getBBox2dBounds$1(this.oc, bbox);
5804
+ return getBBox2dBounds$1(bbox);
5622
5805
  }
5623
5806
  mergeBBox2d(target, other) {
5624
- mergeBBox2d$1(this.oc, target, other);
5807
+ mergeBBox2d$1(target, other);
5625
5808
  }
5626
5809
  isBBox2dOut(a, b) {
5627
- return isBBox2dOut$1(this.oc, a, b);
5810
+ return isBBox2dOut$1(a, b);
5628
5811
  }
5629
5812
  isBBox2dOutPoint(bbox, x, y) {
5630
- return isBBox2dOutPoint$1(this.oc, bbox, x, y);
5813
+ return isBBox2dOutPoint$1(bbox, x, y);
5631
5814
  }
5632
5815
  getCurve2dCircleData(curve) {
5633
- return getCurve2dCircleData$1(this.oc, curve);
5816
+ return getCurve2dCircleData$1(curve);
5634
5817
  }
5635
5818
  getCurve2dEllipseData(curve) {
5636
- return getCurve2dEllipseData$1(this.oc, curve);
5819
+ return getCurve2dEllipseData$1(curve);
5637
5820
  }
5638
5821
  getCurve2dBezierPoles(curve) {
5639
- return getCurve2dBezierPoles$1(this.oc, curve);
5822
+ return getCurve2dBezierPoles$1(curve);
5640
5823
  }
5641
5824
  getCurve2dBezierDegree(curve) {
5642
- return getCurve2dBezierDegree$1(this.oc, curve);
5825
+ return getCurve2dBezierDegree$1(curve);
5643
5826
  }
5644
5827
  getCurve2dBSplineData(curve) {
5645
- return getCurve2dBSplineData$1(this.oc, curve);
5828
+ return getCurve2dBSplineData$1(curve);
5646
5829
  }
5647
5830
  serializeCurve2d(curve) {
5648
- return serializeCurve2d$1(this.oc, curve);
5831
+ return serializeCurve2d$1(curve);
5649
5832
  }
5650
5833
  deserializeCurve2d(data) {
5651
- return deserializeCurve2d$1(this.oc, data);
5834
+ return deserializeCurve2d$1(data);
5652
5835
  }
5653
5836
  splitCurve2d(curve, params) {
5654
- return splitCurve2d$1(this.oc, curve, params);
5837
+ return splitCurve2d$1(curve, params);
5655
5838
  }
5656
5839
  liftCurve2dToPlane(curve, planeOrigin, planeZ, planeX) {
5657
5840
  return liftCurve2dToPlane$1(this.oc, curve, planeOrigin, planeZ, planeX);