brepjs 8.2.0 → 8.4.0

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 (85) hide show
  1. package/dist/2d/lib/Curve2D.d.ts.map +1 -1
  2. package/dist/2d.cjs +2 -2
  3. package/dist/2d.js +3 -3
  4. package/dist/{Blueprint-D_luVeES.js → Blueprint-Bp45tnh0.js} +16 -12
  5. package/dist/{Blueprint-CTAwjJMN.cjs → Blueprint-zgFe_5Qj.cjs} +17 -13
  6. package/dist/{boolean2D-B5axNhjN.cjs → boolean2D-CfEbRMPF.cjs} +11 -11
  7. package/dist/{boolean2D-vw76Gayn.js → boolean2D-DN6ETTCq.js} +11 -11
  8. package/dist/{booleanFns-Yc3EBxdm.cjs → booleanFns-5dDG0jpA.cjs} +46 -9
  9. package/dist/{booleanFns-BhqXpQoZ.js → booleanFns-C-M6qqvB.js} +46 -9
  10. package/dist/brepjs.cjs +364 -109
  11. package/dist/brepjs.js +433 -177
  12. package/dist/{cast-C107o5ow.cjs → cast-CPNOTNFm.cjs} +3 -3
  13. package/dist/{cast-D0OhP1nV.js → cast-Cerqtxtb.js} +3 -3
  14. package/dist/core/errors.d.ts +7 -0
  15. package/dist/core/errors.d.ts.map +1 -1
  16. package/dist/core.cjs +4 -4
  17. package/dist/core.js +4 -4
  18. package/dist/{cornerFinder-DuStF5jK.cjs → cornerFinder-BQ-_VJx0.cjs} +1 -1
  19. package/dist/{cornerFinder-CPm2baSJ.js → cornerFinder-CC_MunIh.js} +1 -1
  20. package/dist/{curveBuilders-CN72XaIQ.js → curveBuilders-BREwqvuc.js} +3 -3
  21. package/dist/{curveBuilders-Du03_Yyf.cjs → curveBuilders-BkEJ-RVn.cjs} +3 -3
  22. package/dist/curveFns-VMxgfkqw.cjs +177 -0
  23. package/dist/curveFns-ZuQUBZvd.js +178 -0
  24. package/dist/{drawFns-CzBbcoXA.js → drawFns-BbhX1IUq.js} +19 -15
  25. package/dist/{drawFns-CiNxPu6J.cjs → drawFns-CKaHgGSK.cjs} +22 -18
  26. package/dist/{errors-wGhcJMpB.js → errors-CSYOlCCR.js} +10 -1
  27. package/dist/{errors-DK1VAdP4.cjs → errors-D13q2HCk.cjs} +10 -1
  28. package/dist/{faceFns-ub3CugDN.js → faceFns-CfJIbHY3.js} +4 -4
  29. package/dist/{faceFns-D1Sqnlu6.cjs → faceFns-es3GENII.cjs} +4 -4
  30. package/dist/{helpers-Dje6wrKi.cjs → helpers-C0q_FVxq.cjs} +10 -10
  31. package/dist/{helpers-BSQfs538.js → helpers-CmVkMubc.js} +7 -7
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/io.cjs +5 -5
  35. package/dist/io.js +5 -5
  36. package/dist/kernel/hullOps.d.ts +22 -0
  37. package/dist/kernel/hullOps.d.ts.map +1 -0
  38. package/dist/kernel/occtAdapter.d.ts +6 -0
  39. package/dist/kernel/occtAdapter.d.ts.map +1 -1
  40. package/dist/kernel/types.d.ts +6 -0
  41. package/dist/kernel/types.d.ts.map +1 -1
  42. package/dist/{loft-PMRx9iMG.cjs → loft-B-UCPW9P.cjs} +5 -5
  43. package/dist/{loft-BHn7GKm8.js → loft-oJq2OD3A.js} +5 -5
  44. package/dist/{measurement-B06hNs89.cjs → measurement-CYmT-C77.cjs} +3 -3
  45. package/dist/{measurement-BfhEneUl.js → measurement-Cf_SoIiR.js} +3 -3
  46. package/dist/measurement.cjs +1 -1
  47. package/dist/measurement.js +1 -1
  48. package/dist/{meshFns-BKSPaPXS.js → meshFns-CqNwW0PO.js} +6 -3
  49. package/dist/{meshFns-CFVxKBlE.cjs → meshFns-DDC_2U81.cjs} +6 -3
  50. package/dist/{occtBoundary-BFAaUtA7.cjs → occtBoundary-CocN2VKx.cjs} +419 -2
  51. package/dist/{occtBoundary-CoXB2xvx.js → occtBoundary-D_gjqgzo.js} +419 -2
  52. package/dist/{operations-CjQHEu1h.js → operations-6hdpuYmY.js} +6 -6
  53. package/dist/{operations-CdGb6IBU.cjs → operations-BQeW_DSM.cjs} +6 -6
  54. package/dist/operations.cjs +2 -2
  55. package/dist/operations.js +2 -2
  56. package/dist/query.cjs +5 -5
  57. package/dist/query.js +6 -6
  58. package/dist/result.cjs +1 -1
  59. package/dist/result.js +1 -1
  60. package/dist/{curveFns-ByeCqutv.cjs → shapeFns-B0zSdO9c.cjs} +98 -177
  61. package/dist/{curveFns-C5gSZ5EY.js → shapeFns-k1YHFwmB.js} +117 -196
  62. package/dist/{shapeTypes-UqVCIO_T.cjs → shapeTypes-BxVxLdiD.cjs} +1 -1
  63. package/dist/{shapeTypes-BU2LKv2S.js → shapeTypes-c-_pgYCx.js} +1 -1
  64. package/dist/sketching.cjs +2 -2
  65. package/dist/sketching.js +2 -2
  66. package/dist/text/textBlueprints.d.ts.map +1 -1
  67. package/dist/topology/booleanFns.d.ts.map +1 -1
  68. package/dist/topology/hullFns.d.ts +16 -0
  69. package/dist/topology/hullFns.d.ts.map +1 -0
  70. package/dist/topology/meshFns.d.ts +1 -0
  71. package/dist/topology/meshFns.d.ts.map +1 -1
  72. package/dist/topology/minkowskiFns.d.ts +20 -0
  73. package/dist/topology/minkowskiFns.d.ts.map +1 -0
  74. package/dist/topology/modifierFns.d.ts.map +1 -1
  75. package/dist/topology/shapeFns.d.ts +30 -0
  76. package/dist/topology/shapeFns.d.ts.map +1 -1
  77. package/dist/{topology-D8Au8q4i.cjs → topology-CycEc6Oe.cjs} +14 -13
  78. package/dist/{topology-BFB3LI_y.js → topology-tMKHJgw2.js} +9 -8
  79. package/dist/topology.cjs +34 -33
  80. package/dist/topology.js +59 -58
  81. package/dist/{vectors-BhfKwL9J.js → vectors-DE0XriuQ.js} +2 -2
  82. package/dist/{vectors-t1XG4LpL.cjs → vectors-DVmHF4zt.cjs} +2 -2
  83. package/dist/vectors.cjs +2 -2
  84. package/dist/vectors.js +2 -2
  85. package/package.json +5 -5
@@ -1042,7 +1042,7 @@ function makeWire(oc, edges) {
1042
1042
  progress.delete();
1043
1043
  return wire;
1044
1044
  }
1045
- function makeFace(oc, wire, planar = true) {
1045
+ function makeFace$1(oc, wire, planar = true) {
1046
1046
  if (planar) {
1047
1047
  const builder2 = new oc.BRepBuilderAPI_MakeFace_15(wire, false);
1048
1048
  const face = builder2.Face();
@@ -1441,6 +1441,412 @@ function approximatePoints(oc, points, options = {}) {
1441
1441
  splineBuilder.delete();
1442
1442
  return edge;
1443
1443
  }
1444
+ function sub(a, b) {
1445
+ return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
1446
+ }
1447
+ function cross(a, b) {
1448
+ return {
1449
+ x: a.y * b.z - a.z * b.y,
1450
+ y: a.z * b.x - a.x * b.z,
1451
+ z: a.x * b.y - a.y * b.x
1452
+ };
1453
+ }
1454
+ function dot(a, b) {
1455
+ return a.x * b.x + a.y * b.y + a.z * b.z;
1456
+ }
1457
+ function lengthVec(v) {
1458
+ return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
1459
+ }
1460
+ function distSq(a, b) {
1461
+ const dx = a.x - b.x;
1462
+ const dy = a.y - b.y;
1463
+ const dz = a.z - b.z;
1464
+ return dx * dx + dy * dy + dz * dz;
1465
+ }
1466
+ function at(arr, i) {
1467
+ const v = arr[i];
1468
+ if (v === void 0) throw new Error(`Index ${i} out of bounds`);
1469
+ return v;
1470
+ }
1471
+ function atN(arr, i) {
1472
+ const v = arr[i];
1473
+ if (v === void 0) throw new Error(`Index ${i} out of bounds`);
1474
+ return v;
1475
+ }
1476
+ function makeFace(points, a, b, c) {
1477
+ const normal = cross(sub(at(points, b), at(points, a)), sub(at(points, c), at(points, a)));
1478
+ const len = lengthVec(normal);
1479
+ const n = len > 1e-14 ? { x: normal.x / len, y: normal.y / len, z: normal.z / len } : normal;
1480
+ return {
1481
+ a,
1482
+ b,
1483
+ c,
1484
+ normal: n,
1485
+ offset: dot(n, at(points, a)),
1486
+ alive: true,
1487
+ outsidePoints: []
1488
+ };
1489
+ }
1490
+ function signedDist(face, point) {
1491
+ return dot(face.normal, point) - face.offset;
1492
+ }
1493
+ function deduplicatePoints(points, tolerance) {
1494
+ const tolSq = tolerance * tolerance;
1495
+ const result = [];
1496
+ for (const p of points) {
1497
+ let isDuplicate = false;
1498
+ for (const q of result) {
1499
+ if (distSq(p, q) < tolSq) {
1500
+ isDuplicate = true;
1501
+ break;
1502
+ }
1503
+ }
1504
+ if (!isDuplicate) result.push(p);
1505
+ }
1506
+ return result;
1507
+ }
1508
+ function findInitialTetrahedron(points) {
1509
+ const n = points.length;
1510
+ if (n < 4) return null;
1511
+ let i0 = 0;
1512
+ let i1 = 1;
1513
+ let maxDist = distSq(at(points, 0), at(points, 1));
1514
+ for (let i = 0; i < n; i++) {
1515
+ for (let j = i + 1; j < n; j++) {
1516
+ const d = distSq(at(points, i), at(points, j));
1517
+ if (d > maxDist) {
1518
+ maxDist = d;
1519
+ i0 = i;
1520
+ i1 = j;
1521
+ }
1522
+ }
1523
+ }
1524
+ if (maxDist < 1e-20) return null;
1525
+ const lineDir = sub(at(points, i1), at(points, i0));
1526
+ let i2 = -1;
1527
+ let maxLineDist = -1;
1528
+ for (let i = 0; i < n; i++) {
1529
+ if (i === i0 || i === i1) continue;
1530
+ const v = sub(at(points, i), at(points, i0));
1531
+ const c = cross(lineDir, v);
1532
+ const d = dot(c, c);
1533
+ if (d > maxLineDist) {
1534
+ maxLineDist = d;
1535
+ i2 = i;
1536
+ }
1537
+ }
1538
+ if (i2 === -1 || maxLineDist < 1e-20) return null;
1539
+ const planeNormal = cross(
1540
+ sub(at(points, i1), at(points, i0)),
1541
+ sub(at(points, i2), at(points, i0))
1542
+ );
1543
+ const planeLen = lengthVec(planeNormal);
1544
+ if (planeLen < 1e-14) return null;
1545
+ const pn = {
1546
+ x: planeNormal.x / planeLen,
1547
+ y: planeNormal.y / planeLen,
1548
+ z: planeNormal.z / planeLen
1549
+ };
1550
+ const planeOffset = dot(pn, at(points, i0));
1551
+ let i3 = -1;
1552
+ let maxPlaneDist = -1;
1553
+ for (let i = 0; i < n; i++) {
1554
+ if (i === i0 || i === i1 || i === i2) continue;
1555
+ const d = Math.abs(dot(pn, at(points, i)) - planeOffset);
1556
+ if (d > maxPlaneDist) {
1557
+ maxPlaneDist = d;
1558
+ i3 = i;
1559
+ }
1560
+ }
1561
+ if (i3 === -1 || maxPlaneDist < 1e-14) return null;
1562
+ const sd = dot(pn, at(points, i3)) - planeOffset;
1563
+ if (sd > 0) {
1564
+ return [i0, i2, i1, i3];
1565
+ }
1566
+ return [i0, i1, i2, i3];
1567
+ }
1568
+ function quickHull(inputPoints, tolerance) {
1569
+ const points = deduplicatePoints(inputPoints, tolerance);
1570
+ if (points.length < 4) {
1571
+ throw new Error(
1572
+ points.length === 0 ? "No points provided for convex hull" : "Fewer than 4 non-coincident points; cannot form a 3D convex hull"
1573
+ );
1574
+ }
1575
+ const tet = findInitialTetrahedron(points);
1576
+ if (tet === null) {
1577
+ throw new Error("All points are coplanar; cannot form a 3D convex hull");
1578
+ }
1579
+ const [t0, t1, t2, t3] = tet;
1580
+ const centroid = {
1581
+ x: (at(points, t0).x + at(points, t1).x + at(points, t2).x + at(points, t3).x) / 4,
1582
+ y: (at(points, t0).y + at(points, t1).y + at(points, t2).y + at(points, t3).y) / 4,
1583
+ z: (at(points, t0).z + at(points, t1).z + at(points, t2).z + at(points, t3).z) / 4
1584
+ };
1585
+ function makeOutwardFace(a, b, c) {
1586
+ const face = makeFace(points, a, b, c);
1587
+ const faceCenter = {
1588
+ x: (at(points, a).x + at(points, b).x + at(points, c).x) / 3,
1589
+ y: (at(points, a).y + at(points, b).y + at(points, c).y) / 3,
1590
+ z: (at(points, a).z + at(points, b).z + at(points, c).z) / 3
1591
+ };
1592
+ const toCentroid = sub(centroid, faceCenter);
1593
+ if (dot(face.normal, toCentroid) > 0) {
1594
+ return makeFace(points, a, c, b);
1595
+ }
1596
+ return face;
1597
+ }
1598
+ const faces = [
1599
+ makeOutwardFace(t0, t1, t2),
1600
+ makeOutwardFace(t0, t2, t3),
1601
+ makeOutwardFace(t0, t3, t1),
1602
+ makeOutwardFace(t1, t3, t2)
1603
+ ];
1604
+ const tetSet = /* @__PURE__ */ new Set([t0, t1, t2, t3]);
1605
+ const epsilon = 1e-10;
1606
+ for (let i = 0; i < points.length; i++) {
1607
+ if (tetSet.has(i)) continue;
1608
+ for (const face of faces) {
1609
+ if (signedDist(face, at(points, i)) > epsilon) {
1610
+ face.outsidePoints.push(i);
1611
+ break;
1612
+ }
1613
+ }
1614
+ }
1615
+ for (let iteration = 0; iteration < points.length * 4; iteration++) {
1616
+ let currentFace = null;
1617
+ for (const face of faces) {
1618
+ if (face.alive && face.outsidePoints.length > 0) {
1619
+ currentFace = face;
1620
+ break;
1621
+ }
1622
+ }
1623
+ if (currentFace === null) break;
1624
+ let furthestIdx = atN(currentFace.outsidePoints, 0);
1625
+ let furthestDist = signedDist(currentFace, at(points, furthestIdx));
1626
+ for (let i = 1; i < currentFace.outsidePoints.length; i++) {
1627
+ const idx = atN(currentFace.outsidePoints, i);
1628
+ const d = signedDist(currentFace, at(points, idx));
1629
+ if (d > furthestDist) {
1630
+ furthestDist = d;
1631
+ furthestIdx = idx;
1632
+ }
1633
+ }
1634
+ const visibleFaces = [];
1635
+ for (const face of faces) {
1636
+ if (face.alive && signedDist(face, at(points, furthestIdx)) > epsilon) {
1637
+ visibleFaces.push(face);
1638
+ }
1639
+ }
1640
+ const edgeCount = /* @__PURE__ */ new Map();
1641
+ for (const face of visibleFaces) {
1642
+ const edges = [
1643
+ [face.a, face.b],
1644
+ [face.b, face.c],
1645
+ [face.c, face.a]
1646
+ ];
1647
+ for (const [ea, eb] of edges) {
1648
+ const key = ea < eb ? `${ea}-${eb}` : `${eb}-${ea}`;
1649
+ const entry = edgeCount.get(key);
1650
+ if (entry) {
1651
+ entry.count++;
1652
+ } else {
1653
+ edgeCount.set(key, { a: ea, b: eb, count: 1 });
1654
+ }
1655
+ }
1656
+ }
1657
+ const horizonEdges = [];
1658
+ for (const entry of edgeCount.values()) {
1659
+ if (entry.count === 1) {
1660
+ horizonEdges.push({ a: entry.a, b: entry.b });
1661
+ }
1662
+ }
1663
+ const orphanedPoints = [];
1664
+ for (const face of visibleFaces) {
1665
+ for (const idx of face.outsidePoints) {
1666
+ if (idx !== furthestIdx) {
1667
+ orphanedPoints.push(idx);
1668
+ }
1669
+ }
1670
+ face.alive = false;
1671
+ face.outsidePoints = [];
1672
+ }
1673
+ const newFaces = [];
1674
+ for (const edge of horizonEdges) {
1675
+ const newFaceObj = makeFace(points, edge.a, edge.b, furthestIdx);
1676
+ newFaces.push(newFaceObj);
1677
+ faces.push(newFaceObj);
1678
+ }
1679
+ for (const idx of orphanedPoints) {
1680
+ for (const face of newFaces) {
1681
+ if (signedDist(face, at(points, idx)) > epsilon) {
1682
+ face.outsidePoints.push(idx);
1683
+ break;
1684
+ }
1685
+ }
1686
+ }
1687
+ }
1688
+ const resultFaces = [];
1689
+ for (const face of faces) {
1690
+ if (face.alive) {
1691
+ resultFaces.push([face.a, face.b, face.c]);
1692
+ }
1693
+ }
1694
+ return { faces: resultFaces, points };
1695
+ }
1696
+ function extractVertices(oc, shapes, tolerance) {
1697
+ const vertices = [];
1698
+ const meshDeflection = Math.max(tolerance, 1);
1699
+ for (const shape of shapes) {
1700
+ const mesh2 = new oc.BRepMesh_IncrementalMesh_2(
1701
+ shape,
1702
+ meshDeflection,
1703
+ false,
1704
+ meshDeflection * 0.5,
1705
+ false
1706
+ );
1707
+ const progress = new oc.Message_ProgressRange_1();
1708
+ mesh2.Perform(progress);
1709
+ progress.delete();
1710
+ mesh2.delete();
1711
+ const explorer = new oc.TopExp_Explorer_2(
1712
+ shape,
1713
+ oc.TopAbs_ShapeEnum.TopAbs_FACE,
1714
+ oc.TopAbs_ShapeEnum.TopAbs_SHAPE
1715
+ );
1716
+ while (explorer.More()) {
1717
+ const face = oc.TopoDS.Face_1(explorer.Current());
1718
+ const location = new oc.TopLoc_Location_1();
1719
+ const tri = oc.BRep_Tool.Triangulation(face, location, 0);
1720
+ if (!tri.IsNull()) {
1721
+ const trsf = location.Transformation();
1722
+ const nbNodes = tri.get().NbNodes();
1723
+ for (let i = 1; i <= nbNodes; i++) {
1724
+ const node = tri.get().Node(i);
1725
+ const transformed = node.Transformed(trsf);
1726
+ vertices.push({
1727
+ x: transformed.X(),
1728
+ y: transformed.Y(),
1729
+ z: transformed.Z()
1730
+ });
1731
+ transformed.delete();
1732
+ node.delete();
1733
+ }
1734
+ trsf.delete();
1735
+ }
1736
+ location.delete();
1737
+ explorer.Next();
1738
+ }
1739
+ explorer.delete();
1740
+ }
1741
+ return vertices;
1742
+ }
1743
+ function buildTriFace(oc, pa, pb, pc) {
1744
+ const gpA = new oc.gp_Pnt_3(pa.x, pa.y, pa.z);
1745
+ const gpB = new oc.gp_Pnt_3(pb.x, pb.y, pb.z);
1746
+ const gpC = new oc.gp_Pnt_3(pc.x, pc.y, pc.z);
1747
+ const e1 = new oc.BRepBuilderAPI_MakeEdge_3(gpA, gpB);
1748
+ const e2 = new oc.BRepBuilderAPI_MakeEdge_3(gpB, gpC);
1749
+ const e3 = new oc.BRepBuilderAPI_MakeEdge_3(gpC, gpA);
1750
+ const wireBuilder = new oc.BRepBuilderAPI_MakeWire_1();
1751
+ wireBuilder.Add_1(e1.Edge());
1752
+ wireBuilder.Add_1(e2.Edge());
1753
+ wireBuilder.Add_1(e3.Edge());
1754
+ let face = null;
1755
+ if (wireBuilder.IsDone()) {
1756
+ const makeFaceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wireBuilder.Wire(), false);
1757
+ if (makeFaceBuilder.IsDone()) {
1758
+ face = makeFaceBuilder.Face();
1759
+ }
1760
+ makeFaceBuilder.delete();
1761
+ }
1762
+ wireBuilder.delete();
1763
+ e1.delete();
1764
+ e2.delete();
1765
+ e3.delete();
1766
+ gpA.delete();
1767
+ gpB.delete();
1768
+ gpC.delete();
1769
+ return face;
1770
+ }
1771
+ function reconstructBrep(oc, hullResult, tolerance) {
1772
+ const { faces: hullFaces, points } = hullResult;
1773
+ const ocFaces = [];
1774
+ for (const [ia, ib, ic] of hullFaces) {
1775
+ const face = buildTriFace(oc, at(points, ia), at(points, ib), at(points, ic));
1776
+ if (face !== null) {
1777
+ ocFaces.push(face);
1778
+ }
1779
+ }
1780
+ if (ocFaces.length < 4) {
1781
+ throw new Error(`hull: only ${ocFaces.length} faces built, need at least 4 for a solid`);
1782
+ }
1783
+ const sewTolerance = Math.max(tolerance, 1e-4);
1784
+ const sewing = new oc.BRepBuilderAPI_Sewing(sewTolerance, true, true, true, false);
1785
+ for (const face of ocFaces) {
1786
+ sewing.Add(face);
1787
+ }
1788
+ const sewProgress = new oc.Message_ProgressRange_1();
1789
+ sewing.Perform(sewProgress);
1790
+ sewProgress.delete();
1791
+ const sewn = sewing.SewedShape();
1792
+ sewing.delete();
1793
+ const shellExplorer = new oc.TopExp_Explorer_2(
1794
+ sewn,
1795
+ oc.TopAbs_ShapeEnum.TopAbs_SHELL,
1796
+ oc.TopAbs_ShapeEnum.TopAbs_SHAPE
1797
+ );
1798
+ if (shellExplorer.More()) {
1799
+ const shell2 = oc.TopoDS.Shell_1(shellExplorer.Current());
1800
+ shellExplorer.delete();
1801
+ const solidMaker = new oc.BRepBuilderAPI_MakeSolid_1();
1802
+ solidMaker.Add(shell2);
1803
+ const solidProgress = new oc.Message_ProgressRange_1();
1804
+ solidMaker.Build(solidProgress);
1805
+ solidProgress.delete();
1806
+ if (solidMaker.IsDone()) {
1807
+ const solid = solidMaker.Solid();
1808
+ solidMaker.delete();
1809
+ shell2.delete();
1810
+ const props = new oc.GProp_GProps_1();
1811
+ oc.BRepGProp.VolumeProperties_1(solid, props, false, false, false);
1812
+ const vol = props.Mass();
1813
+ props.delete();
1814
+ if (vol < 0) {
1815
+ solid.Complement();
1816
+ }
1817
+ return solid;
1818
+ }
1819
+ shell2.delete();
1820
+ solidMaker.delete();
1821
+ return sewn;
1822
+ }
1823
+ shellExplorer.delete();
1824
+ return sewn;
1825
+ }
1826
+ function hull(oc, shapes, tolerance) {
1827
+ if (shapes.length === 0) {
1828
+ throw new Error("hull: no shapes provided");
1829
+ }
1830
+ const vertices = extractVertices(oc, shapes, tolerance);
1831
+ if (vertices.length < 4) {
1832
+ throw new Error("hull: fewer than 4 vertices extracted from input shapes");
1833
+ }
1834
+ const hullResult = quickHull(vertices, tolerance);
1835
+ if (hullResult.faces.length < 4) {
1836
+ throw new Error("hull: degenerate hull (fewer than 4 faces)");
1837
+ }
1838
+ return reconstructBrep(oc, hullResult, tolerance);
1839
+ }
1840
+ function hullFromPoints(oc, points, tolerance) {
1841
+ if (points.length < 4) {
1842
+ throw new Error("hullFromPoints: fewer than 4 points");
1843
+ }
1844
+ const hullResult = quickHull(points, tolerance);
1845
+ if (hullResult.faces.length < 4) {
1846
+ throw new Error("hullFromPoints: degenerate hull (fewer than 4 faces)");
1847
+ }
1848
+ return reconstructBrep(oc, hullResult, tolerance);
1849
+ }
1444
1850
  class OCCTAdapter {
1445
1851
  oc;
1446
1852
  constructor(oc) {
@@ -1465,6 +1871,17 @@ class OCCTAdapter {
1465
1871
  cutAll(shape, tools, options = {}) {
1466
1872
  return cutAll(this.oc, shape, tools, options);
1467
1873
  }
1874
+ // --- Convex hull ---
1875
+ hull(shapes, tolerance) {
1876
+ return hull(this.oc, shapes, tolerance);
1877
+ }
1878
+ hullFromPoints(points, tolerance) {
1879
+ return hullFromPoints(
1880
+ this.oc,
1881
+ points.map((p) => ({ x: p.x, y: p.y, z: p.z })),
1882
+ tolerance
1883
+ );
1884
+ }
1468
1885
  // --- Shape construction (delegates to constructorOps.ts) ---
1469
1886
  makeVertex(x, y, z) {
1470
1887
  return makeVertex(this.oc, x, y, z);
@@ -1476,7 +1893,7 @@ class OCCTAdapter {
1476
1893
  return makeWire(this.oc, edges);
1477
1894
  }
1478
1895
  makeFace(wire, planar = true) {
1479
- return makeFace(this.oc, wire, planar);
1896
+ return makeFace$1(this.oc, wire, planar);
1480
1897
  }
1481
1898
  makeBox(width, height, depth) {
1482
1899
  return makeBox(this.oc, width, height, depth);