brepjs 12.6.0 → 12.7.2

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 (43) hide show
  1. package/dist/2d.cjs +2 -2
  2. package/dist/2d.js +3 -3
  3. package/dist/{Blueprint-CtuUvzex.js → Blueprint-DymoCs1R.js} +1 -1
  4. package/dist/{Blueprint-CoFJDAQd.cjs → Blueprint-E105uFXu.cjs} +1 -1
  5. package/dist/{boolean2D-x2irapGj.js → boolean2D-BXO2hNfY.js} +2 -2
  6. package/dist/{boolean2D-Dk-vLBdl.cjs → boolean2D-D857dStk.cjs} +2 -2
  7. package/dist/{booleanFns-BJjYqwJ5.cjs → booleanFns-DeWK-2pA.cjs} +1 -1
  8. package/dist/{booleanFns-DtOkwLHI.js → booleanFns-DpAod1nu.js} +1 -1
  9. package/dist/brepjs.cjs +132 -44
  10. package/dist/brepjs.js +148 -60
  11. package/dist/{cornerFinder-BESZIitp.cjs → cornerFinder-3zfbQvXg.cjs} +1 -1
  12. package/dist/{cornerFinder-FY38t0zq.js → cornerFinder-xxlrRbwc.js} +1 -1
  13. package/dist/{drawFns-BEeoD1yO.cjs → drawFns-BKU3X1Qn.cjs} +5 -5
  14. package/dist/{drawFns-D8QyY7cg.js → drawFns-ClKmj3al.js} +5 -5
  15. package/dist/{helpers-DNzVfe-Z.cjs → helpers-6kn30cSD.cjs} +1 -1
  16. package/dist/{helpers-DeFPsrcI.js → helpers-Dnw_sLuU.js} +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/io.cjs +2 -2
  20. package/dist/io.js +2 -2
  21. package/dist/kernel/brepkitAdapter.d.ts +1 -0
  22. package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
  23. package/dist/{meshFns-BU2l_yOm.cjs → meshFns-3gy0empP.cjs} +1 -1
  24. package/dist/{meshFns-HNwWuM4v.js → meshFns-DsLRd3tA.js} +1 -1
  25. package/dist/{operations-D_3rrfrE.js → operations-DE9wMwvN.js} +2 -2
  26. package/dist/{operations-D-gTZNtM.cjs → operations-DXt8hFxd.cjs} +2 -2
  27. package/dist/operations.cjs +1 -1
  28. package/dist/operations.js +1 -1
  29. package/dist/query.cjs +2 -2
  30. package/dist/query.js +3 -3
  31. package/dist/{shapeFns-DHlLNHTn.cjs → shapeFns-D-MOoqJd.cjs} +4 -0
  32. package/dist/{shapeFns-CbXxLvV_.js → shapeFns-D2PlLFE6.js} +11 -7
  33. package/dist/sketching.cjs +2 -2
  34. package/dist/sketching.js +2 -2
  35. package/dist/topology/shapeFns.d.ts +5 -0
  36. package/dist/topology/shapeFns.d.ts.map +1 -1
  37. package/dist/{topology-C1eZ86dI.js → topology-DEi2sFry.js} +3 -3
  38. package/dist/{topology-BHnY7Szr.cjs → topology-Is3aThTo.cjs} +3 -3
  39. package/dist/topology.cjs +5 -4
  40. package/dist/topology.d.ts +1 -1
  41. package/dist/topology.d.ts.map +1 -1
  42. package/dist/topology.js +11 -10
  43. package/package.json +1 -1
package/dist/2d.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const Blueprint = require("./Blueprint-CoFJDAQd.cjs");
4
- const boolean2D = require("./boolean2D-Dk-vLBdl.cjs");
3
+ const Blueprint = require("./Blueprint-E105uFXu.cjs");
4
+ const boolean2D = require("./boolean2D-D857dStk.cjs");
5
5
  function reverseCurve(curve) {
6
6
  const cloned = curve.clone();
7
7
  cloned.reverse();
package/dist/2d.js CHANGED
@@ -1,6 +1,6 @@
1
- import { B as Blueprint } from "./Blueprint-CtuUvzex.js";
2
- import { d, C } from "./Blueprint-CtuUvzex.js";
3
- import { e, C as C2, f, l, g, n, k, q, o, p, r } from "./boolean2D-x2irapGj.js";
1
+ import { B as Blueprint } from "./Blueprint-DymoCs1R.js";
2
+ import { d, C } from "./Blueprint-DymoCs1R.js";
3
+ import { e, C as C2, f, l, g, n, k, q, o, p, r } from "./boolean2D-BXO2hNfY.js";
4
4
  function reverseCurve(curve) {
5
5
  const cloned = curve.clone();
6
6
  cloned.reverse();
@@ -4,7 +4,7 @@ import { B as getKernel, J as getKernel2D, K as registerForCleanup, L as unregis
4
4
  import { u as uvBounds, f as faceGeomType, e as faceCenter, h as uvCoordinates, c as cast } from "./faceFns-B6ebRh5I.js";
5
5
  import { g as getOrientation } from "./curveFns-LRNGcHXh.js";
6
6
  import { o as ok, e as err, b as computationError, r as unwrap, y as validationError } from "./errors-B7kgv0cd.js";
7
- import { d as distance2d, s as samePoint, b as scalarMultiply2d, c as add2d, e as subtract2d, g as getSingleFace } from "./helpers-DeFPsrcI.js";
7
+ import { d as distance2d, s as samePoint, b as scalarMultiply2d, c as add2d, e as subtract2d, g as getSingleFace } from "./helpers-Dnw_sLuU.js";
8
8
  import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
9
9
  import { m as makeFace } from "./surfaceBuilders-D7ZH2QNS.js";
10
10
  import { bug } from "./result.js";
@@ -5,7 +5,7 @@ const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
5
5
  const faceFns = require("./faceFns-BLTEPBKq.cjs");
6
6
  const curveFns = require("./curveFns-Ch87sD5O.cjs");
7
7
  const errors = require("./errors-9fDehDNc.cjs");
8
- const helpers = require("./helpers-DNzVfe-Z.cjs");
8
+ const helpers = require("./helpers-6kn30cSD.cjs");
9
9
  const vecOps = require("./vecOps-CjRL1jau.cjs");
10
10
  const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
11
11
  const result = require("./result.cjs");
@@ -53,8 +53,8 @@ import { J as getKernel2D, I as createFace, G as createWire, B as getKernel, H a
53
53
  import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-LRNGcHXh.js";
54
54
  import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-D7ZH2QNS.js";
55
55
  import { bug } from "./result.js";
56
- import { s as samePoint$1, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-DeFPsrcI.js";
57
- import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, n as normalize2d, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, o as asSVG, B as Blueprint, p as make2dEllipseArc, q as make2dTangentArc, r as make2dBezierCurve, s as removeDuplicatePoints } from "./Blueprint-CtuUvzex.js";
56
+ import { s as samePoint$1, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-Dnw_sLuU.js";
57
+ import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, n as normalize2d, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, o as asSVG, B as Blueprint, p as make2dEllipseArc, q as make2dTangentArc, r as make2dBezierCurve, s as removeDuplicatePoints } from "./Blueprint-DymoCs1R.js";
58
58
  const intersectCurves = (first, second, precision = 1e-9) => {
59
59
  if (first.boundingBox.isOut(second.boundingBox))
60
60
  return ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
@@ -54,8 +54,8 @@ const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
54
54
  const curveFns = require("./curveFns-Ch87sD5O.cjs");
55
55
  const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
56
56
  const result = require("./result.cjs");
57
- const helpers = require("./helpers-DNzVfe-Z.cjs");
58
- const Blueprint = require("./Blueprint-CoFJDAQd.cjs");
57
+ const helpers = require("./helpers-6kn30cSD.cjs");
58
+ const Blueprint = require("./Blueprint-E105uFXu.cjs");
59
59
  const intersectCurves = (first, second, precision = 1e-9) => {
60
60
  if (first.boundingBox.isOut(second.boundingBox))
61
61
  return errors.ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
@@ -3,7 +3,7 @@ const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
3
3
  const errors = require("./errors-9fDehDNc.cjs");
4
4
  const vectors = require("./vectors-TlfO1hu2.cjs");
5
5
  const vecOps = require("./vecOps-CjRL1jau.cjs");
6
- const shapeFns = require("./shapeFns-DHlLNHTn.cjs");
6
+ const shapeFns = require("./shapeFns-D-MOoqJd.cjs");
7
7
  const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
8
8
  const shapeTagStore = /* @__PURE__ */ new WeakMap();
9
9
  const tagMetadataStore = /* @__PURE__ */ new WeakMap();
@@ -2,7 +2,7 @@ import { B as getKernel, c as castShape, p as isShape3D } from "./shapeTypes-CpS
2
2
  import { o as ok, d as isErr, e as err, y as validationError, B as BrepErrorCode, p as typeCastError, k as kernelError } from "./errors-B7kgv0cd.js";
3
3
  import { r as resolvePlane } from "./vectors-cec8p8NQ.js";
4
4
  import { H as HASH_CODE_MAX, n as vecScale, v as vecAdd } from "./vecOps-ZDdZWbwT.js";
5
- import { a as getFaces, p as propagateOriginsByHash, b as propagateOriginsFromEvolution, c as getWires, d as getEdges, e as getVertices, g as getFaceOrigins } from "./shapeFns-CbXxLvV_.js";
5
+ import { a as getFaces, p as propagateOriginsByHash, b as propagateOriginsFromEvolution, c as getWires, d as getEdges, e as getVertices, g as getFaceOrigins } from "./shapeFns-D2PlLFE6.js";
6
6
  import { m as makeFace } from "./surfaceBuilders-D7ZH2QNS.js";
7
7
  const shapeTagStore = /* @__PURE__ */ new WeakMap();
8
8
  const tagMetadataStore = /* @__PURE__ */ new WeakMap();
package/dist/brepjs.cjs CHANGED
@@ -48,28 +48,28 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
48
48
  const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
49
49
  const errors = require("./errors-9fDehDNc.cjs");
50
50
  const vecOps = require("./vecOps-CjRL1jau.cjs");
51
- const Blueprint = require("./Blueprint-CoFJDAQd.cjs");
51
+ const Blueprint = require("./Blueprint-E105uFXu.cjs");
52
52
  const loft$2 = require("./loft-DR1UN5uN.cjs");
53
- const operations = require("./operations-D-gTZNtM.cjs");
54
- const boolean2D = require("./boolean2D-Dk-vLBdl.cjs");
53
+ const operations = require("./operations-DXt8hFxd.cjs");
54
+ const boolean2D = require("./boolean2D-D857dStk.cjs");
55
55
  const _2d = require("./2d.cjs");
56
- const helpers = require("./helpers-DNzVfe-Z.cjs");
56
+ const helpers = require("./helpers-6kn30cSD.cjs");
57
57
  const io = require("./io.cjs");
58
- const drawFns = require("./drawFns-BEeoD1yO.cjs");
58
+ const drawFns = require("./drawFns-BKU3X1Qn.cjs");
59
59
  const types = require("./types-CA_xrgDq.cjs");
60
60
  const vectors = require("./vectors-TlfO1hu2.cjs");
61
- const shapeFns = require("./shapeFns-DHlLNHTn.cjs");
62
- const booleanFns = require("./booleanFns-BJjYqwJ5.cjs");
63
- const topology = require("./topology-BHnY7Szr.cjs");
61
+ const shapeFns = require("./shapeFns-D-MOoqJd.cjs");
62
+ const booleanFns = require("./booleanFns-DeWK-2pA.cjs");
63
+ const topology = require("./topology-Is3aThTo.cjs");
64
64
  const curveFns = require("./curveFns-Ch87sD5O.cjs");
65
65
  const faceFns = require("./faceFns-BLTEPBKq.cjs");
66
- const meshFns = require("./meshFns-BU2l_yOm.cjs");
66
+ const meshFns = require("./meshFns-3gy0empP.cjs");
67
67
  const measurement = require("./measurement-DoYXRaKI.cjs");
68
68
  const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
69
69
  const query = require("./query.cjs");
70
70
  const solidBuilders = require("./solidBuilders-BzfRBizW.cjs");
71
71
  const result = require("./result.cjs");
72
- const cornerFinder = require("./cornerFinder-BESZIitp.cjs");
72
+ const cornerFinder = require("./cornerFinder-3zfbQvXg.cjs");
73
73
  const worker = require("./worker.cjs");
74
74
  function supportsProjection(kernel) {
75
75
  return "projectShape" in kernel;
@@ -1206,6 +1206,23 @@ class BrepkitAdapter {
1206
1206
  const radius = Math.sqrt(
1207
1207
  (p1[0] - center[0]) ** 2 + (p1[1] - center[1]) ** 2 + (p1[2] - center[2]) ** 2
1208
1208
  );
1209
+ if (typeof this.bk.makeCircleArc3d === "function") {
1210
+ const id = this.bk.makeCircleArc3d(
1211
+ p1[0],
1212
+ p1[1],
1213
+ p1[2],
1214
+ p3[0],
1215
+ p3[1],
1216
+ p3[2],
1217
+ center[0],
1218
+ center[1],
1219
+ center[2],
1220
+ nz[0],
1221
+ nz[1],
1222
+ nz[2]
1223
+ );
1224
+ return edgeHandle(id);
1225
+ }
1209
1226
  const lx = [p1[0] - center[0], p1[1] - center[1], p1[2] - center[2]];
1210
1227
  const lxLen = Math.sqrt(lx[0] ** 2 + lx[1] ** 2 + lx[2] ** 2);
1211
1228
  const uxA = [lx[0] / lxLen, lx[1] / lxLen, lx[2] / lxLen];
@@ -1214,9 +1231,9 @@ class BrepkitAdapter {
1214
1231
  nz[2] * uxA[0] - nz[0] * uxA[2],
1215
1232
  nz[0] * uxA[1] - nz[1] * uxA[0]
1216
1233
  ];
1217
- const v3 = [p3[0] - center[0], p3[1] - center[1], p3[2] - center[2]];
1218
- const dotX = v3[0] * uxA[0] + v3[1] * uxA[1] + v3[2] * uxA[2];
1219
- const dotY = v3[0] * uyA[0] + v3[1] * uyA[1] + v3[2] * uyA[2];
1234
+ const v3f = [p3[0] - center[0], p3[1] - center[1], p3[2] - center[2]];
1235
+ const dotX = v3f[0] * uxA[0] + v3f[1] * uxA[1] + v3f[2] * uxA[2];
1236
+ const dotY = v3f[0] * uyA[0] + v3f[1] * uyA[1] + v3f[2] * uyA[2];
1220
1237
  let endAngle = Math.atan2(dotY, dotX);
1221
1238
  if (endAngle <= 0) endAngle += 2 * Math.PI;
1222
1239
  return this.makeCircleNurbs(center, normal, radius, 0, endAngle);
@@ -1259,21 +1276,73 @@ class BrepkitAdapter {
1259
1276
  return edgeHandle(id);
1260
1277
  }
1261
1278
  makeTangentArc(startPoint, startTangent, endPoint) {
1262
- const cp1 = [
1263
- startPoint[0] + startTangent[0] / 3,
1264
- startPoint[1] + startTangent[1] / 3,
1265
- startPoint[2] + startTangent[2] / 3
1279
+ const tLen = Math.sqrt(startTangent[0] ** 2 + startTangent[1] ** 2 + startTangent[2] ** 2);
1280
+ if (tLen < 1e-12) return this.makeLineEdge(startPoint, endPoint);
1281
+ const t = [
1282
+ startTangent[0] / tLen,
1283
+ startTangent[1] / tLen,
1284
+ startTangent[2] / tLen
1285
+ ];
1286
+ const ch = [
1287
+ startPoint[0] - endPoint[0],
1288
+ startPoint[1] - endPoint[1],
1289
+ startPoint[2] - endPoint[2]
1290
+ ];
1291
+ const chDotT = ch[0] * t[0] + ch[1] * t[1] + ch[2] * t[2];
1292
+ const perp = [
1293
+ ch[0] - chDotT * t[0],
1294
+ ch[1] - chDotT * t[1],
1295
+ ch[2] - chDotT * t[2]
1296
+ ];
1297
+ const perpLen = Math.sqrt(perp[0] ** 2 + perp[1] ** 2 + perp[2] ** 2);
1298
+ if (perpLen < 1e-12) return this.makeLineEdge(startPoint, endPoint);
1299
+ const n = [perp[0] / perpLen, perp[1] / perpLen, perp[2] / perpLen];
1300
+ const chord2 = ch[0] ** 2 + ch[1] ** 2 + ch[2] ** 2;
1301
+ const nDotCh = n[0] * ch[0] + n[1] * ch[1] + n[2] * ch[2];
1302
+ const s = -chord2 / (2 * nDotCh);
1303
+ const center = [
1304
+ startPoint[0] + s * n[0],
1305
+ startPoint[1] + s * n[1],
1306
+ startPoint[2] + s * n[2]
1307
+ ];
1308
+ const radius = Math.abs(s);
1309
+ const e1 = [
1310
+ (startPoint[0] - center[0]) / radius,
1311
+ (startPoint[1] - center[1]) / radius,
1312
+ (startPoint[2] - center[2]) / radius
1313
+ ];
1314
+ const e2 = [
1315
+ (endPoint[0] - center[0]) / radius,
1316
+ (endPoint[1] - center[1]) / radius,
1317
+ (endPoint[2] - center[2]) / radius
1266
1318
  ];
1267
- const dx = endPoint[0] - cp1[0];
1268
- const dy = endPoint[1] - cp1[1];
1269
- const dz = endPoint[2] - cp1[2];
1270
- const len = Math.sqrt(dx * dx + dy * dy + dz * dz);
1271
- const cp2 = [
1272
- endPoint[0] - dx / (3 * Math.max(len, 1e-10)),
1273
- endPoint[1] - dy / (3 * Math.max(len, 1e-10)),
1274
- endPoint[2] - dz / (3 * Math.max(len, 1e-10))
1319
+ let mx = e1[0] + e2[0];
1320
+ let my = e1[1] + e2[1];
1321
+ let mz = e1[2] + e2[2];
1322
+ let mLen = Math.sqrt(mx * mx + my * my + mz * mz);
1323
+ if (mLen < 1e-12) {
1324
+ mx = t[0];
1325
+ my = t[1];
1326
+ mz = t[2];
1327
+ mLen = 1;
1328
+ }
1329
+ const mid = [
1330
+ center[0] + radius * mx / mLen,
1331
+ center[1] + radius * my / mLen,
1332
+ center[2] + radius * mz / mLen
1275
1333
  ];
1276
- return this.makeBezierEdge([startPoint, cp1, cp2, endPoint]);
1334
+ const toMid = [
1335
+ mid[0] - startPoint[0],
1336
+ mid[1] - startPoint[1],
1337
+ mid[2] - startPoint[2]
1338
+ ];
1339
+ const dotTM = t[0] * toMid[0] + t[1] * toMid[1] + t[2] * toMid[2];
1340
+ if (dotTM < 0) {
1341
+ mid[0] = center[0] - radius * mx / mLen;
1342
+ mid[1] = center[1] - radius * my / mLen;
1343
+ mid[2] = center[2] - radius * mz / mLen;
1344
+ }
1345
+ return this.makeArcEdge(startPoint, mid, endPoint);
1277
1346
  }
1278
1347
  makeHelixWire(pitch, height, radius, center, _direction, leftHanded) {
1279
1348
  const turns = height / pitch;
@@ -1419,11 +1488,13 @@ class BrepkitAdapter {
1419
1488
  if (_options?.transitionMode !== void 0) {
1420
1489
  warnOnce("sweep-transition", "Sweep transition mode not supported; ignored.");
1421
1490
  }
1491
+ const profileHandle = wire;
1492
+ const faceId = profileHandle.type === "wire" ? this.bk.makeFaceFromWire(profileHandle.id) : unwrap(wire, "face");
1422
1493
  const spineHandle = spine;
1423
1494
  if (spineHandle.type === "wire") {
1424
1495
  const edges = this.iterShapes(spine, "edge");
1425
1496
  const edgeIds = edges.map((e) => unwrap(e, "edge"));
1426
- const id2 = this.bk.sweepAlongEdges(unwrap(wire, "face"), edgeIds);
1497
+ const id2 = this.bk.sweepAlongEdges(faceId, edgeIds);
1427
1498
  return solidHandle(id2);
1428
1499
  }
1429
1500
  const nurbsData = this.extractNurbsFromEdge(spine);
@@ -1431,7 +1502,7 @@ class BrepkitAdapter {
1431
1502
  throw new Error("brepkit: sweep spine must be an edge or wire");
1432
1503
  }
1433
1504
  const id = this.bk.sweep(
1434
- unwrap(wire, "face"),
1505
+ faceId,
1435
1506
  nurbsData.degree,
1436
1507
  nurbsData.knots,
1437
1508
  nurbsData.controlPoints,
@@ -2154,8 +2225,18 @@ class BrepkitAdapter {
2154
2225
  // ═══════════════════════════════════════════════════════════════════════
2155
2226
  volume(shape2) {
2156
2227
  const h = shape2;
2157
- if (h.type !== "solid") return 0;
2158
- return this.bk.volume(unwrap(shape2), DEFAULT_DEFLECTION);
2228
+ if (h.type === "solid") {
2229
+ return this.bk.volume(unwrap(shape2), DEFAULT_DEFLECTION);
2230
+ }
2231
+ if (h.type === "compound") {
2232
+ const solids = this.iterShapes(shape2, "solid");
2233
+ let total = 0;
2234
+ for (const s of solids) {
2235
+ total += this.bk.volume(unwrap(s), DEFAULT_DEFLECTION);
2236
+ }
2237
+ return total;
2238
+ }
2239
+ return 0;
2159
2240
  }
2160
2241
  area(shape2) {
2161
2242
  const h = shape2;
@@ -3319,7 +3400,7 @@ class BrepkitAdapter {
3319
3400
  return { x, y };
3320
3401
  }
3321
3402
  createAxis2d(px, py, dx, dy) {
3322
- return { px, py, dx, dy };
3403
+ return { px, py, dx, dy, delete: noop };
3323
3404
  }
3324
3405
  wrapCurve2dHandle(handle2) {
3325
3406
  return handle2;
@@ -3351,9 +3432,14 @@ class BrepkitAdapter {
3351
3432
  const sense = da1m < da12;
3352
3433
  const circle = makeCircle2d(cx, cy, radius, sense);
3353
3434
  if (!sense) {
3354
- return { __bk2d: "trimmed", basis: circle, tStart: -a1, tEnd: -a2 };
3435
+ const tStart = -a1;
3436
+ let tEnd2 = -a2;
3437
+ if (tEnd2 < tStart - 1e-9) tEnd2 += 2 * Math.PI;
3438
+ return { __bk2d: "trimmed", basis: circle, tStart, tEnd: tEnd2 };
3355
3439
  }
3356
- return { __bk2d: "trimmed", basis: circle, tStart: a1, tEnd: a2 };
3440
+ let tEnd = a2;
3441
+ if (tEnd < a1 - 1e-9) tEnd += 2 * Math.PI;
3442
+ return { __bk2d: "trimmed", basis: circle, tStart: a1, tEnd };
3357
3443
  }
3358
3444
  makeArc2dTangent(sx, sy, tx, ty, ex, ey) {
3359
3445
  const len = Math.sqrt(tx * tx + ty * ty);
@@ -3492,8 +3578,13 @@ class BrepkitAdapter {
3492
3578
  return this.transformCurve2dGeneral(curve, gtrsf);
3493
3579
  }
3494
3580
  // --- General 2D transforms (stored as 3×3 matrices) ---
3581
+ // All GTrsf2d methods return objects with a no-op .delete() to match OCCT's
3582
+ // Emscripten WASM objects, which callers (e.g. curves.ts) rely on for cleanup.
3583
+ _gtrsf(m, tx, ty) {
3584
+ return { m, tx, ty, delete: noop };
3585
+ }
3495
3586
  createIdentityGTrsf2d() {
3496
- return { m: [1, 0, 0, 0, 1, 0, 0, 0, 1], tx: 0, ty: 0 };
3587
+ return this._gtrsf([1, 0, 0, 0, 1, 0, 0, 0, 1], 0, 0);
3497
3588
  }
3498
3589
  createAffinityGTrsf2d(ox, oy, dx, dy, ratio) {
3499
3590
  const len = Math.sqrt(dx * dx + dy * dy);
@@ -3503,10 +3594,10 @@ class BrepkitAdapter {
3503
3594
  const m = [1 + k * px * px, k * px * py, 0, k * py * px, 1 + k * py * py, 0, 0, 0, 1];
3504
3595
  const txv = ox - m[0] * ox - m[1] * oy;
3505
3596
  const tyv = oy - m[3] * ox - m[4] * oy;
3506
- return { m, tx: txv, ty: tyv };
3597
+ return this._gtrsf(m, txv, tyv);
3507
3598
  }
3508
3599
  createTranslationGTrsf2d(dx, dy) {
3509
- return { m: [1, 0, 0, 0, 1, 0, 0, 0, 1], tx: dx, ty: dy };
3600
+ return this._gtrsf([1, 0, 0, 0, 1, 0, 0, 0, 1], dx, dy);
3510
3601
  }
3511
3602
  createMirrorGTrsf2d(cx, cy, mode, ox, oy, dx, dy) {
3512
3603
  if (mode === "axis" && dx !== void 0 && dy !== void 0) {
@@ -3516,20 +3607,16 @@ class BrepkitAdapter {
3516
3607
  const px = ox ?? cx, py = oy ?? cy;
3517
3608
  const txv = px - m[0] * px - m[1] * py;
3518
3609
  const tyv = py - m[3] * px - m[4] * py;
3519
- return { m, tx: txv, ty: tyv };
3610
+ return this._gtrsf(m, txv, tyv);
3520
3611
  }
3521
- return { m: [-1, 0, 0, 0, -1, 0, 0, 0, 1], tx: 2 * cx, ty: 2 * cy };
3612
+ return this._gtrsf([-1, 0, 0, 0, -1, 0, 0, 0, 1], 2 * cx, 2 * cy);
3522
3613
  }
3523
3614
  createRotationGTrsf2d(angle, cx, cy) {
3524
3615
  const c = Math.cos(angle), s = Math.sin(angle);
3525
- return { m: [c, -s, 0, s, c, 0, 0, 0, 1], tx: cx - c * cx + s * cy, ty: cy - s * cx - c * cy };
3616
+ return this._gtrsf([c, -s, 0, s, c, 0, 0, 0, 1], cx - c * cx + s * cy, cy - s * cx - c * cy);
3526
3617
  }
3527
3618
  createScaleGTrsf2d(factor, cx, cy) {
3528
- return {
3529
- m: [factor, 0, 0, 0, factor, 0, 0, 0, 1],
3530
- tx: cx * (1 - factor),
3531
- ty: cy * (1 - factor)
3532
- };
3619
+ return this._gtrsf([factor, 0, 0, 0, factor, 0, 0, 0, 1], cx * (1 - factor), cy * (1 - factor));
3533
3620
  }
3534
3621
  setGTrsf2dTranslationPart(gtrsf, dx, dy) {
3535
3622
  gtrsf.tx = dx;
@@ -7449,6 +7536,7 @@ exports.getFaces = shapeFns.getFaces;
7449
7536
  exports.getHashCode = shapeFns.getHashCode;
7450
7537
  exports.getVertices = shapeFns.getVertices;
7451
7538
  exports.getWires = shapeFns.getWires;
7539
+ exports.invalidateShapeCache = shapeFns.invalidateShapeCache;
7452
7540
  exports.isEqualShape = shapeFns.isEqualShape;
7453
7541
  exports.isSameShape = shapeFns.isSameShape;
7454
7542
  exports.iterEdges = shapeFns.iterEdges;