brepjs 18.77.0 → 18.78.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 (29) hide show
  1. package/dist/brepjs.cjs +135 -134
  2. package/dist/brepjs.js +8 -8
  3. package/dist/{drawFns-BBoTkSta.js → drawFns-C6h_w03r.js} +1 -1
  4. package/dist/{drawFns-DNokXs9U.cjs → drawFns-DxjMxRpE.cjs} +1 -1
  5. package/dist/{primitiveFns-ItlGYe3M.cjs → healingFns-B7dElsC4.cjs} +5 -462
  6. package/dist/{primitiveFns-DWIzRvTY.js → healingFns-DS_nK9KF.js} +6 -301
  7. package/dist/index.d.ts +1 -0
  8. package/dist/{extrudeFns-CSWqlW-n.js → loftFns-DuxEscJB.js} +92 -1
  9. package/dist/{extrudeFns-BJSW3EaV.cjs → loftFns-DycLH1Pq.cjs} +103 -0
  10. package/dist/operations/threadFns.d.ts +39 -0
  11. package/dist/operations.cjs +33 -32
  12. package/dist/operations.d.ts +1 -0
  13. package/dist/operations.js +3 -3
  14. package/dist/{booleanFns-D7Xgt-Og.js → primitiveFns-BxH5omw3.js} +300 -6
  15. package/dist/{booleanFns-CFa3bgbG.cjs → primitiveFns-JRmXxbRr.cjs} +456 -0
  16. package/dist/sketching.cjs +2 -2
  17. package/dist/sketching.js +2 -2
  18. package/dist/text.cjs +2 -2
  19. package/dist/text.js +2 -2
  20. package/dist/{textBlueprints-CYc0xi6l.js → textBlueprints-C3IbySW_.js} +4 -94
  21. package/dist/{textBlueprints-D31dKTZS.cjs → textBlueprints-SKuamOmI.cjs} +11 -113
  22. package/dist/{textMetrics-DfxB-y9A.js → textMetrics--BwiJH2B.js} +1 -1
  23. package/dist/{textMetrics-CjbXCzpg.cjs → textMetrics-Bzbkal_A.cjs} +1 -1
  24. package/dist/{historyFns-Ck2tXVAL.js → threadFns-D8-zfJ0b.js} +71 -4
  25. package/dist/{historyFns-4ggYGJB2.cjs → threadFns-aWgxzqmT.cjs} +76 -3
  26. package/dist/topology/booleanFns.d.ts +9 -1
  27. package/dist/topology.cjs +34 -34
  28. package/dist/topology.js +2 -2
  29. package/package.json +1 -1
@@ -1,13 +1,11 @@
1
- import { Z as getKernel, _ as isSolid, c as createSolid, h as isShape3D, p as isFace, r as castShapeWithKnownType, t as castShape, x as isClosedWire, y as isWire } from "./shapeTypes-CyTY0prh.js";
2
- import { A as ok, T as isOk, b as err, d as validationError, i as kernelError, l as typeCastError, t as BrepErrorCode, v as andThen, w as isErr } from "./errors-DNWJsfVU.js";
1
+ import { Z as getKernel, _ as isSolid, h as isShape3D, p as isFace, r as castShapeWithKnownType, t as castShape, y as isWire } from "./shapeTypes-CyTY0prh.js";
2
+ import { A as ok, T as isOk, b as err, d as validationError, i as kernelError, l as typeCastError, t as BrepErrorCode, w as isErr } from "./errors-DNWJsfVU.js";
3
3
  import { c as getFaces, i as getCachedIsValid, l as getOrCreateCache, m as invalidateShapeCache, p as getWires, s as getEdges } from "./topologyQueryFns-BomrmBie.js";
4
- import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
4
+ import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
5
5
  import { v as downcast } from "./faceFns-BJ2hzXJp.js";
6
- import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate } from "./shapeFns-DZ6poxP7.js";
6
+ import { _ as propagateAllMetadata, g as collectInputFaceHashes } from "./shapeFns-DZ6poxP7.js";
7
7
  import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
8
- import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-Do0rypyD.js";
9
- import { a as fuseAll, i as fuse, n as cut, r as cutAll } from "./booleanFns-D7Xgt-Og.js";
10
- import { a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces } from "./solidBuilders-BtEFUFQ9.js";
8
+ import { A as cutAll, M as fuseAll, j as fuse, k as cut } from "./primitiveFns-BxH5omw3.js";
11
9
  //#region src/topology/threeHelpers.ts
12
10
  /**
13
11
  * Convert a ShapeMesh into BufferGeometry-compatible typed arrays.
@@ -1355,297 +1353,4 @@ function fixSelfIntersection(wire) {
1355
1353
  }
1356
1354
  }
1357
1355
  //#endregion
1358
- //#region src/topology/primitiveFns.ts
1359
- /**
1360
- * Create a box with the given dimensions.
1361
- *
1362
- * @param width - Size along X.
1363
- * @param depth - Size along Y.
1364
- * @param height - Size along Z.
1365
- */
1366
- function box(width, depth, height, options) {
1367
- const solid = createSolid(getKernel().makeBox(width, depth, height));
1368
- const center = options?.at ?? (options?.centered ? [
1369
- 0,
1370
- 0,
1371
- 0
1372
- ] : void 0);
1373
- if (center) return translate(solid, [
1374
- center[0] - width / 2,
1375
- center[1] - depth / 2,
1376
- center[2] - height / 2
1377
- ]);
1378
- return solid;
1379
- }
1380
- /**
1381
- * Create a cylinder with the given radius and height.
1382
- */
1383
- function cylinder(radius, height, options) {
1384
- const at = options?.at ?? [
1385
- 0,
1386
- 0,
1387
- 0
1388
- ];
1389
- const axis = options?.axis ?? [
1390
- 0,
1391
- 0,
1392
- 1
1393
- ];
1394
- let solid = makeCylinder(radius, height, at, axis);
1395
- if (options?.centered) {
1396
- const halfShift = [
1397
- -axis[0] * height * .5,
1398
- -axis[1] * height * .5,
1399
- -axis[2] * height * .5
1400
- ];
1401
- solid = translate(solid, halfShift);
1402
- }
1403
- return solid;
1404
- }
1405
- /**
1406
- * Create a sphere with the given radius.
1407
- */
1408
- function sphere(radius, options) {
1409
- let solid = makeSphere(radius);
1410
- if (options?.at) solid = translate(solid, options.at);
1411
- return solid;
1412
- }
1413
- /**
1414
- * Create a cone (or frustum) with the given radii and height.
1415
- *
1416
- * @param bottomRadius - Radius at the base.
1417
- * @param topRadius - Radius at the top (0 for a full cone).
1418
- * @param height - Height of the cone.
1419
- */
1420
- function cone(bottomRadius, topRadius, height, options) {
1421
- const at = options?.at ?? [
1422
- 0,
1423
- 0,
1424
- 0
1425
- ];
1426
- const axis = options?.axis ?? [
1427
- 0,
1428
- 0,
1429
- 1
1430
- ];
1431
- let solid = makeCone(bottomRadius, topRadius, height, at, axis);
1432
- if (options?.centered) {
1433
- const halfShift = [
1434
- -axis[0] * height * .5,
1435
- -axis[1] * height * .5,
1436
- -axis[2] * height * .5
1437
- ];
1438
- solid = translate(solid, halfShift);
1439
- }
1440
- return solid;
1441
- }
1442
- /**
1443
- * Create a torus with the given major and minor radii.
1444
- */
1445
- function torus(majorRadius, minorRadius, options) {
1446
- return makeTorus(majorRadius, minorRadius, options?.at ?? [
1447
- 0,
1448
- 0,
1449
- 0
1450
- ], options?.axis ?? [
1451
- 0,
1452
- 0,
1453
- 1
1454
- ]);
1455
- }
1456
- /**
1457
- * Create an ellipsoid with the given axis half-lengths.
1458
- *
1459
- * @param rx - Half-length along X.
1460
- * @param ry - Half-length along Y.
1461
- * @param rz - Half-length along Z.
1462
- */
1463
- function ellipsoid(rx, ry, rz, options) {
1464
- let solid = makeEllipsoid(rx, ry, rz);
1465
- if (options?.at) solid = translate(solid, options.at);
1466
- return solid;
1467
- }
1468
- /** Create a straight edge between two 3D points. */
1469
- function line(from, to) {
1470
- return makeLine(from, to);
1471
- }
1472
- /** Create a circular edge with the given radius. */
1473
- function circle(radius, options) {
1474
- const axisDir = options?.axis ?? [
1475
- 0,
1476
- 0,
1477
- 1
1478
- ];
1479
- return makeCircle(radius, options?.at ?? [
1480
- 0,
1481
- 0,
1482
- 0
1483
- ], axisDir);
1484
- }
1485
- /**
1486
- * Create an elliptical edge.
1487
- *
1488
- * @returns An error if `minorRadius` exceeds `majorRadius`.
1489
- */
1490
- function ellipse(majorRadius, minorRadius, options) {
1491
- const axisDir = options?.axis ?? [
1492
- 0,
1493
- 0,
1494
- 1
1495
- ];
1496
- return makeEllipse(majorRadius, minorRadius, options?.at ?? [
1497
- 0,
1498
- 0,
1499
- 0
1500
- ], axisDir, options?.xDir);
1501
- }
1502
- /**
1503
- * Create a helical wire.
1504
- *
1505
- * @param pitch - Vertical distance per full turn.
1506
- * @param height - Total height.
1507
- * @param radius - Helix radius.
1508
- */
1509
- function helix(pitch, height, radius, options) {
1510
- return makeHelix(pitch, height, radius, options?.at ?? [
1511
- 0,
1512
- 0,
1513
- 0
1514
- ], options?.axis ?? [
1515
- 0,
1516
- 0,
1517
- 1
1518
- ], options?.lefthand ?? false);
1519
- }
1520
- /** Create a circular arc edge passing through three points. */
1521
- function threePointArc(p1, p2, p3) {
1522
- return makeThreePointArc(p1, p2, p3);
1523
- }
1524
- /**
1525
- * Create an elliptical arc edge between two angles.
1526
- *
1527
- * All angles are in **degrees** (unlike the legacy `makeEllipseArc` which used radians).
1528
- *
1529
- * @param startAngle - Start angle in degrees.
1530
- * @param endAngle - End angle in degrees.
1531
- */
1532
- function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
1533
- const axisDir = options?.axis ?? [
1534
- 0,
1535
- 0,
1536
- 1
1537
- ];
1538
- return makeEllipseArc(majorRadius, minorRadius, startAngle * DEG2RAD, endAngle * DEG2RAD, options?.at ?? [
1539
- 0,
1540
- 0,
1541
- 0
1542
- ], axisDir, options?.xDir);
1543
- }
1544
- /**
1545
- * Create a B-spline edge that approximates a set of 3D points.
1546
- *
1547
- * @returns An error if the approximation algorithm fails.
1548
- */
1549
- function bsplineApprox(points, config) {
1550
- return makeBSplineApproximation(points, config);
1551
- }
1552
- /**
1553
- * Create a Bezier curve edge from control points.
1554
- *
1555
- * @param points - Two or more control points.
1556
- */
1557
- function bezier(points) {
1558
- return makeBezierCurve(points);
1559
- }
1560
- /**
1561
- * Create a circular arc edge tangent to a direction at the start point.
1562
- */
1563
- function tangentArc(startPoint, startTgt, endPoint) {
1564
- return makeTangentArc(startPoint, startTgt, endPoint);
1565
- }
1566
- /**
1567
- * Assemble edges and/or wires into a single connected wire.
1568
- */
1569
- function wire(listOfEdges) {
1570
- return assembleWire(listOfEdges);
1571
- }
1572
- /**
1573
- * Assemble edges into a wire and verify it forms a closed loop.
1574
- *
1575
- * Combines {@link wire} + the `closedWire` smart constructor in a single step.
1576
- * Returns an error if the edges cannot be assembled or the wire is not closed.
1577
- *
1578
- * @example
1579
- * ```ts
1580
- * const cw = unwrap(wireLoop([e1, e2, e3, e4]));
1581
- * const f = unwrap(face(cw)); // ClosedWire accepted directly
1582
- * ```
1583
- */
1584
- function wireLoop(listOfEdges) {
1585
- return andThen(assembleWire(listOfEdges), (w) => {
1586
- if (isClosedWire(w)) return ok(w);
1587
- return err(validationError("WIRE_NOT_CLOSED", "Assembled wire is not closed: start and end points do not coincide"));
1588
- });
1589
- }
1590
- /**
1591
- * Create a planar face from a closed wire, optionally with holes.
1592
- * The resulting face is always oriented (consistent normal direction).
1593
- */
1594
- function face(w, holes) {
1595
- return makeFace(w, holes);
1596
- }
1597
- /**
1598
- * Create a non-planar face from a wire using surface filling.
1599
- * The resulting face is always oriented.
1600
- */
1601
- function filledFace(w) {
1602
- return makeNonPlanarFace(w);
1603
- }
1604
- /**
1605
- * Create a face bounded by a wire on an existing face's surface.
1606
- * The resulting face inherits orientation from the origin face.
1607
- */
1608
- function subFace(originFace, w) {
1609
- return makeNewFaceWithinFace(originFace, w);
1610
- }
1611
- /**
1612
- * Create a polygonal face from three or more coplanar points.
1613
- * The resulting face is always oriented.
1614
- */
1615
- function polygon(points) {
1616
- return makePolygon(points);
1617
- }
1618
- /** Create a vertex at a 3D point. */
1619
- function vertex(point) {
1620
- return makeVertex(point);
1621
- }
1622
- /**
1623
- * Build a compound from multiple shapes.
1624
- */
1625
- function compound(shapeArray) {
1626
- return makeCompound(shapeArray);
1627
- }
1628
- /**
1629
- * Weld faces and shells into a single solid.
1630
- * The resulting solid is always validated.
1631
- */
1632
- function solid(facesOrShells) {
1633
- return makeSolid(facesOrShells);
1634
- }
1635
- /**
1636
- * Create an offset shape from a face.
1637
- */
1638
- function offsetFace(f, distance, tolerance) {
1639
- return makeOffset(f, distance, tolerance);
1640
- }
1641
- /**
1642
- * Weld faces and shells into a single shell.
1643
- */
1644
- function sewShells(facesOrShells, ignoreType) {
1645
- return weldShellsAndFaces(facesOrShells, ignoreType);
1646
- }
1647
- function addHoles(f, holes) {
1648
- return addHolesInFace(f, holes);
1649
- }
1650
- //#endregion
1651
- export { fuseAllBisect as $, fixShape as A, offset as B, threePointArc as C, wireLoop as D, wire as E, isValid as F, chamferWithEvolution as G, thicken as H, solidFromShell as I, fuseWithEvolution as J, cutWithEvolution as K, chamfer as L, healFace as M, healSolid as N, autoHeal as O, healWire as P, cutAllBisect as Q, draft as R, tangentArc as S, vertex as T, variableFillet as U, shell as V, positionOnCurve as W, shellWithEvolution as X, intersectWithEvolution as Y, checkBoolean as Z, polygon as _, circle as a, sharedEdges as at, sphere as b, cylinder as c, chamferDistAngle as ct, ellipsoid as d, toLODGeometryData as dt, getNurbsCurveData as et, face as f, toLineGeometryData as ft, offsetFace as g, line as h, bsplineApprox as i, facesOfEdge as it, heal as j, fixSelfIntersection as k, ellipse as l, toBufferGeometryData as lt, helix as m, bezier as n, adjacentFaces as nt, compound as o, verticesOfEdge as ot, filledFace as p, filletWithEvolution as q, box as r, edgesOfFace as rt, cone as s, wiresOfFace as st, addHoles as t, getNurbsSurfaceData as tt, ellipseArc as u, toGroupedBufferGeometryData as ut, sewShells as v, torus as w, subFace as x, solid as y, fillet as z };
1356
+ export { edgesOfFace as A, shellWithEvolution as C, getNurbsCurveData as D, fuseAllBisect as E, chamferDistAngle as F, toBufferGeometryData as I, toGroupedBufferGeometryData as L, sharedEdges as M, verticesOfEdge as N, getNurbsSurfaceData as O, wiresOfFace as P, toLODGeometryData as R, intersectWithEvolution as S, cutAllBisect as T, positionOnCurve as _, healFace as a, filletWithEvolution as b, isValid as c, draft as d, fillet as f, variableFillet as g, thicken as h, heal as i, facesOfEdge as j, adjacentFaces as k, solidFromShell as l, shell as m, fixSelfIntersection as n, healSolid as o, offset as p, fixShape as r, healWire as s, autoHeal as t, chamfer as u, chamferWithEvolution as v, checkBoolean as w, fuseWithEvolution as x, cutWithEvolution as y, toLineGeometryData as z };
package/dist/index.d.ts CHANGED
@@ -141,6 +141,7 @@ export { fill } from './topology/surfaceBuilders.js';
141
141
  export { translate, rotate, mirror, scale, clone, applyMatrix, composeTransforms, transformCopy, type TransformOp, type ComposedTransform, fuse, cut, intersect, section, sectionToFace, split, slice, fillet, chamfer, shell, offset, thicken, draft, heal, simplify, mesh, meshEdges, describe, toBREP, fromBREP, isValid, isEmpty, type RotateOptions, type MirrorOptions, type ScaleOptions, } from './topology/api.js';
142
142
  export { extrude, revolve, loft, type RevolveOptions, type LoftOptions as CleanLoftOptions, type SweepOptions as CleanSweepOptions, } from './operations/api.js';
143
143
  export { loftAll, type LoftAllEntry } from './operations/loftFns.js';
144
+ export { thread, type ThreadOptions } from './operations/threadFns.js';
144
145
  export { drill, pocket, boss, mirrorJoin, rectangularPattern, } from './operations/compoundOpsFns.js';
145
146
  export { shape, BrepWrapperError, type Wrapped, type Wrapped3D, type WrappedCurve, type WrappedFace, } from './topology/wrapperFns.js';
146
147
  export { type ExternalGearParams, type InternalGearParams, type PlanetaryGearParams, type GearResult, type PlanetaryGearAssembly, type GearDiagnostic, type GearDiagnosticCode, type GearDiagnosticSeverity, type GearGeometry, type PlanetPlacement, type PlanetPlacementParams, makeExternalGear, makeInternalGear, makePlanetaryGear, gearGeometry, validatePlanetary, planetPlacements, } from './gear/index.js';
@@ -1,5 +1,6 @@
1
1
  import { Z as getKernel, c as createSolid, h as isShape3D, t as castShape, y as isWire } from "./shapeTypes-CyTY0prh.js";
2
2
  import { A as ok, b as err, d as validationError, i as kernelError, l as typeCastError, t as BrepErrorCode, w as isErr } from "./errors-DNWJsfVU.js";
3
+ import { r as toVec3 } from "./types-D24Y27N0.js";
3
4
  import { c as vecLength, d as vecNormalize, t as vecAdd } from "./vecOps-SKPRvPH-.js";
4
5
  //#region src/operations/extrudeUtils.ts
5
6
  /**
@@ -370,4 +371,94 @@ function extrudeAll(entries) {
370
371
  }
371
372
  }
372
373
  //#endregion
373
- export { guidedSweep as a, sweep as c, complexExtrude as i, twistExtrude as l, extrudeAll as n, multiSectionSweep as o, revolve as r, supportExtrude as s, extrude as t };
374
+ //#region src/operations/loftFns.ts
375
+ /**
376
+ * Functional loft operation using branded shape types.
377
+ */
378
+ /**
379
+ * Loft through a set of wire profiles to create a 3D shape.
380
+ *
381
+ * Builds a `BRepOffsetAPI_ThruSections` surface through the given wires,
382
+ * optionally starting and/or ending at point vertices. Produces a solid
383
+ * by default, or a shell when `returnShell` is `true`.
384
+ *
385
+ * @param wires - Ordered wire profiles to loft through.
386
+ * @param config - Loft configuration (ruled interpolation, start/end points).
387
+ * @param returnShell - When `true`, return a shell instead of a solid.
388
+ * @returns `Result` containing the lofted 3D shape, or an error on failure.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const result = loft([bottomWire, topWire], { ruled: false });
393
+ * ```
394
+ *
395
+ * @see {@link loft!loft | loft} for the OOP API equivalent.
396
+ */
397
+ function loft(wires, { ruled = true, startPoint, endPoint, tolerance = 1e-6 } = {}, returnShell = false) {
398
+ if (wires.length === 0 && !startPoint && !endPoint) return err(validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
399
+ const kernel = getKernel();
400
+ const startVertex = startPoint ? kernel.makeVertex(...toVec3(startPoint)) : void 0;
401
+ const endVertex = endPoint ? kernel.makeVertex(...toVec3(endPoint)) : void 0;
402
+ try {
403
+ const result = castShape(kernel.loftAdvanced(wires.map((w) => w.wrapped), {
404
+ solid: !returnShell,
405
+ ruled,
406
+ tolerance,
407
+ ...startVertex ? { startVertex } : {},
408
+ ...endVertex ? { endVertex } : {}
409
+ }));
410
+ if (!isShape3D(result)) return err(typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
411
+ return ok(result);
412
+ } catch (e) {
413
+ return err(kernelError("LOFT_FAILED", "Loft operation failed", e, void 0, "Common causes: wire profiles with different edge counts, self-intersecting result, or profiles too far apart. Ensure profiles are compatible and ordered."));
414
+ }
415
+ }
416
+ /**
417
+ * Batch loft: build N independent lofts in a single kernel call.
418
+ *
419
+ * Uses the C++ LoftBatch extractor when available (single WASM call),
420
+ * falling back to N individual loft operations otherwise.
421
+ *
422
+ * @returns Array of 3D shapes, one per entry.
423
+ */
424
+ function loftAll(entries) {
425
+ if (entries.length === 0) return ok([]);
426
+ const kernel = getKernel();
427
+ const verticesToDelete = [];
428
+ const kernelEntries = entries.map((e) => {
429
+ const startVertex = e.startPoint ? kernel.makeVertex(...toVec3(e.startPoint)) : void 0;
430
+ const endVertex = e.endPoint ? kernel.makeVertex(...toVec3(e.endPoint)) : void 0;
431
+ if (startVertex) verticesToDelete.push(startVertex);
432
+ if (endVertex) verticesToDelete.push(endVertex);
433
+ return {
434
+ wires: e.wires.map((w) => w.wrapped),
435
+ solid: true,
436
+ ruled: e.ruled ?? true,
437
+ tolerance: e.tolerance ?? 1e-6,
438
+ startVertex,
439
+ endVertex
440
+ };
441
+ });
442
+ try {
443
+ const shapes = kernel.loftBatch?.(kernelEntries) ?? kernelEntries.map((e) => kernel.loftAdvanced(e.wires, {
444
+ solid: e.solid,
445
+ ruled: e.ruled,
446
+ tolerance: e.tolerance,
447
+ startVertex: e.startVertex,
448
+ endVertex: e.endVertex
449
+ }));
450
+ const results = [];
451
+ for (const shape of shapes) {
452
+ const cast = castShape(shape);
453
+ if (!isShape3D(cast)) return err(typeCastError("LOFT_ALL_NOT_3D", "Batch loft entry did not produce a 3D shape"));
454
+ results.push(cast);
455
+ }
456
+ return ok(results);
457
+ } catch (e) {
458
+ return err(kernelError("LOFT_ALL_FAILED", "Batch loft operation failed", e));
459
+ } finally {
460
+ for (const v of verticesToDelete) kernel.dispose(v);
461
+ }
462
+ }
463
+ //#endregion
464
+ export { revolve as a, multiSectionSweep as c, twistExtrude as d, extrudeAll as i, supportExtrude as l, loftAll as n, complexExtrude as o, extrude as r, guidedSweep as s, loft as t, sweep as u };
@@ -1,5 +1,6 @@
1
1
  const require_shapeTypes = require("./shapeTypes-CxSqNvHA.cjs");
2
2
  const require_errors = require("./errors-CXJtc4I7.cjs");
3
+ const require_types = require("./types-KjA8tY4Y.cjs");
3
4
  const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
4
5
  //#region src/operations/extrudeUtils.ts
5
6
  /**
@@ -370,6 +371,96 @@ function extrudeAll(entries) {
370
371
  }
371
372
  }
372
373
  //#endregion
374
+ //#region src/operations/loftFns.ts
375
+ /**
376
+ * Functional loft operation using branded shape types.
377
+ */
378
+ /**
379
+ * Loft through a set of wire profiles to create a 3D shape.
380
+ *
381
+ * Builds a `BRepOffsetAPI_ThruSections` surface through the given wires,
382
+ * optionally starting and/or ending at point vertices. Produces a solid
383
+ * by default, or a shell when `returnShell` is `true`.
384
+ *
385
+ * @param wires - Ordered wire profiles to loft through.
386
+ * @param config - Loft configuration (ruled interpolation, start/end points).
387
+ * @param returnShell - When `true`, return a shell instead of a solid.
388
+ * @returns `Result` containing the lofted 3D shape, or an error on failure.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const result = loft([bottomWire, topWire], { ruled: false });
393
+ * ```
394
+ *
395
+ * @see {@link loft!loft | loft} for the OOP API equivalent.
396
+ */
397
+ function loft(wires, { ruled = true, startPoint, endPoint, tolerance = 1e-6 } = {}, returnShell = false) {
398
+ if (wires.length === 0 && !startPoint && !endPoint) return require_errors.err(require_errors.validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
399
+ const kernel = require_shapeTypes.getKernel();
400
+ const startVertex = startPoint ? kernel.makeVertex(...require_types.toVec3(startPoint)) : void 0;
401
+ const endVertex = endPoint ? kernel.makeVertex(...require_types.toVec3(endPoint)) : void 0;
402
+ try {
403
+ const result = require_shapeTypes.castShape(kernel.loftAdvanced(wires.map((w) => w.wrapped), {
404
+ solid: !returnShell,
405
+ ruled,
406
+ tolerance,
407
+ ...startVertex ? { startVertex } : {},
408
+ ...endVertex ? { endVertex } : {}
409
+ }));
410
+ if (!require_shapeTypes.isShape3D(result)) return require_errors.err(require_errors.typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
411
+ return require_errors.ok(result);
412
+ } catch (e) {
413
+ return require_errors.err(require_errors.kernelError("LOFT_FAILED", "Loft operation failed", e, void 0, "Common causes: wire profiles with different edge counts, self-intersecting result, or profiles too far apart. Ensure profiles are compatible and ordered."));
414
+ }
415
+ }
416
+ /**
417
+ * Batch loft: build N independent lofts in a single kernel call.
418
+ *
419
+ * Uses the C++ LoftBatch extractor when available (single WASM call),
420
+ * falling back to N individual loft operations otherwise.
421
+ *
422
+ * @returns Array of 3D shapes, one per entry.
423
+ */
424
+ function loftAll(entries) {
425
+ if (entries.length === 0) return require_errors.ok([]);
426
+ const kernel = require_shapeTypes.getKernel();
427
+ const verticesToDelete = [];
428
+ const kernelEntries = entries.map((e) => {
429
+ const startVertex = e.startPoint ? kernel.makeVertex(...require_types.toVec3(e.startPoint)) : void 0;
430
+ const endVertex = e.endPoint ? kernel.makeVertex(...require_types.toVec3(e.endPoint)) : void 0;
431
+ if (startVertex) verticesToDelete.push(startVertex);
432
+ if (endVertex) verticesToDelete.push(endVertex);
433
+ return {
434
+ wires: e.wires.map((w) => w.wrapped),
435
+ solid: true,
436
+ ruled: e.ruled ?? true,
437
+ tolerance: e.tolerance ?? 1e-6,
438
+ startVertex,
439
+ endVertex
440
+ };
441
+ });
442
+ try {
443
+ const shapes = kernel.loftBatch?.(kernelEntries) ?? kernelEntries.map((e) => kernel.loftAdvanced(e.wires, {
444
+ solid: e.solid,
445
+ ruled: e.ruled,
446
+ tolerance: e.tolerance,
447
+ startVertex: e.startVertex,
448
+ endVertex: e.endVertex
449
+ }));
450
+ const results = [];
451
+ for (const shape of shapes) {
452
+ const cast = require_shapeTypes.castShape(shape);
453
+ if (!require_shapeTypes.isShape3D(cast)) return require_errors.err(require_errors.typeCastError("LOFT_ALL_NOT_3D", "Batch loft entry did not produce a 3D shape"));
454
+ results.push(cast);
455
+ }
456
+ return require_errors.ok(results);
457
+ } catch (e) {
458
+ return require_errors.err(require_errors.kernelError("LOFT_ALL_FAILED", "Batch loft operation failed", e));
459
+ } finally {
460
+ for (const v of verticesToDelete) kernel.dispose(v);
461
+ }
462
+ }
463
+ //#endregion
373
464
  Object.defineProperty(exports, "complexExtrude", {
374
465
  enumerable: true,
375
466
  get: function() {
@@ -394,6 +485,18 @@ Object.defineProperty(exports, "guidedSweep", {
394
485
  return guidedSweep;
395
486
  }
396
487
  });
488
+ Object.defineProperty(exports, "loft", {
489
+ enumerable: true,
490
+ get: function() {
491
+ return loft;
492
+ }
493
+ });
494
+ Object.defineProperty(exports, "loftAll", {
495
+ enumerable: true,
496
+ get: function() {
497
+ return loftAll;
498
+ }
499
+ });
397
500
  Object.defineProperty(exports, "multiSectionSweep", {
398
501
  enumerable: true,
399
502
  get: function() {
@@ -0,0 +1,39 @@
1
+ import { Shape3D } from '../core/shapeTypes.js';
2
+ import { Result } from '../core/result.js';
3
+ /** Configuration for {@link thread}. Units are mm; angles derive from pitch. */
4
+ export interface ThreadOptions {
5
+ /** Core radius (external) or nominal hole radius (internal), at the thread root. */
6
+ radius: number;
7
+ /** Axial distance per full turn. */
8
+ pitch: number;
9
+ /** Total thread length along the axis. Turn count = `height / pitch`. */
10
+ height: number;
11
+ /** Radial thread height (crest minus root). Defaults to `0.6 * pitch` (≈ISO 60° V). */
12
+ depth?: number;
13
+ /** Axial half-width of the V tooth. Defaults to `0.42 * pitch`. */
14
+ toothHalfWidth?: number;
15
+ /** Loft sections per turn — higher is smoother but slower. Defaults to `20`. */
16
+ sectionsPerTurn?: number;
17
+ /** Left-handed thread. Defaults to `false` (right-handed). */
18
+ lefthand?: boolean;
19
+ /** Point the tooth toward the axis (for an internal thread to `cut` from a bore). */
20
+ inward?: boolean;
21
+ }
22
+ /**
23
+ * Build a helical screw-thread ridge by lofting rotated tooth sections.
24
+ *
25
+ * @param options - {@link ThreadOptions}.
26
+ * @returns `Result` with the thread-ridge solid, or an error.
27
+ *
28
+ * @example External thread (Ø12 rod, 2.5 mm pitch):
29
+ * ```ts
30
+ * const ridge = thread({ radius: 6, pitch: 2.5, height: 7.5 });
31
+ * const rod = fuse(cylinder(6.15, 7.5), unwrap(ridge));
32
+ * ```
33
+ * @example Internal thread (tapped Ø6 hole):
34
+ * ```ts
35
+ * const ridge = thread({ radius: 3, pitch: 1, height: 6, inward: true });
36
+ * const nut = cut(boredBlock, unwrap(ridge));
37
+ * ```
38
+ */
39
+ export declare function thread(options: ThreadOptions): Result<Shape3D>;
@@ -1,33 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_historyFns = require("./historyFns-4ggYGJB2.cjs");
3
- const require_extrudeFns = require("./extrudeFns-BJSW3EaV.cjs");
4
- exports.addChild = require_historyFns.addChild;
5
- exports.addStep = require_historyFns.addStep;
6
- exports.circularPattern = require_historyFns.circularPattern;
7
- exports.collectShapes = require_historyFns.collectShapes;
8
- exports.complexExtrude = require_extrudeFns.complexExtrude;
9
- exports.countNodes = require_historyFns.countNodes;
10
- exports.createAssembly = require_historyFns.createAssembly;
11
- exports.createAssemblyNode = require_historyFns.createAssemblyNode;
12
- exports.createHistory = require_historyFns.createHistory;
13
- exports.createRegistry = require_historyFns.createRegistry;
14
- exports.exportAssemblySTEP = require_historyFns.exportAssemblySTEP;
15
- exports.findNode = require_historyFns.findNode;
16
- exports.findStep = require_historyFns.findStep;
17
- exports.getHistoryShape = require_historyFns.getShape;
18
- exports.gridPattern = require_historyFns.gridPattern;
19
- exports.linearPattern = require_historyFns.linearPattern;
20
- exports.modifyStep = require_historyFns.modifyStep;
21
- exports.registerOperation = require_historyFns.registerOperation;
22
- exports.registerShape = require_historyFns.registerShape;
23
- exports.removeChild = require_historyFns.removeChild;
24
- exports.replayFrom = require_historyFns.replayFrom;
25
- exports.replayHistory = require_historyFns.replayHistory;
26
- exports.stepCount = require_historyFns.stepCount;
27
- exports.stepsFrom = require_historyFns.stepsFrom;
28
- exports.supportExtrude = require_extrudeFns.supportExtrude;
29
- exports.sweep = require_extrudeFns.sweep;
30
- exports.twistExtrude = require_extrudeFns.twistExtrude;
31
- exports.undoLast = require_historyFns.undoLast;
32
- exports.updateNode = require_historyFns.updateNode;
33
- exports.walkAssembly = require_historyFns.walkAssembly;
2
+ const require_threadFns = require("./threadFns-aWgxzqmT.cjs");
3
+ const require_loftFns = require("./loftFns-DycLH1Pq.cjs");
4
+ exports.addChild = require_threadFns.addChild;
5
+ exports.addStep = require_threadFns.addStep;
6
+ exports.circularPattern = require_threadFns.circularPattern;
7
+ exports.collectShapes = require_threadFns.collectShapes;
8
+ exports.complexExtrude = require_loftFns.complexExtrude;
9
+ exports.countNodes = require_threadFns.countNodes;
10
+ exports.createAssembly = require_threadFns.createAssembly;
11
+ exports.createAssemblyNode = require_threadFns.createAssemblyNode;
12
+ exports.createHistory = require_threadFns.createHistory;
13
+ exports.createRegistry = require_threadFns.createRegistry;
14
+ exports.exportAssemblySTEP = require_threadFns.exportAssemblySTEP;
15
+ exports.findNode = require_threadFns.findNode;
16
+ exports.findStep = require_threadFns.findStep;
17
+ exports.getHistoryShape = require_threadFns.getShape;
18
+ exports.gridPattern = require_threadFns.gridPattern;
19
+ exports.linearPattern = require_threadFns.linearPattern;
20
+ exports.modifyStep = require_threadFns.modifyStep;
21
+ exports.registerOperation = require_threadFns.registerOperation;
22
+ exports.registerShape = require_threadFns.registerShape;
23
+ exports.removeChild = require_threadFns.removeChild;
24
+ exports.replayFrom = require_threadFns.replayFrom;
25
+ exports.replayHistory = require_threadFns.replayHistory;
26
+ exports.stepCount = require_threadFns.stepCount;
27
+ exports.stepsFrom = require_threadFns.stepsFrom;
28
+ exports.supportExtrude = require_loftFns.supportExtrude;
29
+ exports.sweep = require_loftFns.sweep;
30
+ exports.thread = require_threadFns.thread;
31
+ exports.twistExtrude = require_loftFns.twistExtrude;
32
+ exports.undoLast = require_threadFns.undoLast;
33
+ exports.updateNode = require_threadFns.updateNode;
34
+ exports.walkAssembly = require_threadFns.walkAssembly;
@@ -7,6 +7,7 @@
7
7
  * ```
8
8
  */
9
9
  export { sweep, supportExtrude, complexExtrude, twistExtrude, type SweepOptions, type ExtrusionProfile, } from './operations/extrudeFns.js';
10
+ export { thread, type ThreadOptions } from './operations/threadFns.js';
10
11
  export { linearPattern, circularPattern, gridPattern } from './operations/patternFns.js';
11
12
  export { createAssemblyNode, addChild, removeChild, updateNode, findNode, walkAssembly, countNodes, collectShapes, type AssemblyNode, type AssemblyNodeOptions, } from './operations/assemblyFns.js';
12
13
  export { exportAssemblySTEP, type ShapeOptions, type SupportedUnit, } from './operations/exporterFns.js';