brepjs 18.82.3 → 18.82.5

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 (55) hide show
  1. package/dist/2d.cjs +4 -4
  2. package/dist/2d.js +4 -4
  3. package/dist/{blueprint-BWb1b-R_.cjs → blueprint-BBUOweQy.cjs} +1 -1
  4. package/dist/{blueprint-BBSt1k_F.js → blueprint-DjzevNhB.js} +1 -1
  5. package/dist/{blueprintFns-oFr-O71P.cjs → blueprintFns-CRES_5vP.cjs} +2 -2
  6. package/dist/{blueprintFns-DWji-hqn.js → blueprintFns-CxSMnMfl.js} +2 -2
  7. package/dist/{blueprintSketcher-CMKW8gMH.cjs → blueprintSketcher-CFa32JZU.cjs} +2 -2
  8. package/dist/{blueprintSketcher-BJn6P9IX.js → blueprintSketcher-CIydRzRr.js} +2 -2
  9. package/dist/{boolean2D-DaOXyVXh.js → boolean2D-BRWPIJhe.js} +3 -3
  10. package/dist/{boolean2D-M3i4os2c.cjs → boolean2D-Z0KE98a4.cjs} +3 -3
  11. package/dist/brepjs.cjs +40 -40
  12. package/dist/brepjs.js +15 -15
  13. package/dist/{cornerFinder-Cc1KSYKs.js → cornerFinder-BRYZAgdE.js} +1 -1
  14. package/dist/{cornerFinder-CG2Pgp7d.cjs → cornerFinder-BuYpqGO8.cjs} +1 -1
  15. package/dist/{drawFns-tHcBGNpE.js → drawFns-C5Mdr0iH.js} +6 -6
  16. package/dist/{drawFns-t-ro78FP.cjs → drawFns-DK3DGHku.cjs} +6 -6
  17. package/dist/{healingFns-Ct_-O3yk.js → healingFns-C4JZHv8K.js} +1 -1
  18. package/dist/{healingFns-MxlhdTIc.cjs → healingFns-D3BkAVML.cjs} +5 -5
  19. package/dist/{helpers-BGoSvX_s.js → helpers-CTc8ZbY8.js} +1 -1
  20. package/dist/{helpers-B0uqRA6z.cjs → helpers-DN6s-TLC.cjs} +1 -1
  21. package/dist/{importFns-DA_iBX9K.cjs → importFns-Cb-cmpGG.cjs} +1 -1
  22. package/dist/{importFns-D8lE2Bou.js → importFns-D4Xet5aD.js} +1 -1
  23. package/dist/io.cjs +1 -1
  24. package/dist/io.js +1 -1
  25. package/dist/{measureFns-Ck2YGGfE.js → measureFns-7Nz5JklM.js} +14 -0
  26. package/dist/{measureFns-CynnLMdY.cjs → measureFns-BNHvjShh.cjs} +14 -0
  27. package/dist/measurement.cjs +1 -1
  28. package/dist/measurement.js +1 -1
  29. package/dist/operations.cjs +1 -1
  30. package/dist/operations.js +1 -1
  31. package/dist/primitiveFns-BPfYb_t5.cjs +461 -0
  32. package/dist/primitiveFns-DkuLOFkI.js +300 -0
  33. package/dist/query.cjs +2 -2
  34. package/dist/query.js +2 -2
  35. package/dist/shapeRef.cjs +1 -1
  36. package/dist/shapeRef.js +1 -1
  37. package/dist/{shapeRefFns-Botsp7SL.cjs → shapeRefFns-Bb0aQZWz.cjs} +1 -1
  38. package/dist/{shapeRefFns-DS9FldJc.js → shapeRefFns-NdQvPa5J.js} +1 -1
  39. package/dist/sketching.cjs +3 -3
  40. package/dist/sketching.js +3 -3
  41. package/dist/{primitiveFns-CjL5bygY.js → solidBuilders-QUpJdbiK.js} +99 -256
  42. package/dist/{primitiveFns-LWkd7M2f.cjs → solidBuilders-lDXPwoCz.cjs} +120 -379
  43. package/dist/text.cjs +2 -2
  44. package/dist/text.js +2 -2
  45. package/dist/{textBlueprints-C2INf1kF.cjs → textBlueprints-D4pLmVno.cjs} +26 -43
  46. package/dist/{textBlueprints-C03mB6SZ.js → textBlueprints-f8cgx9vi.js} +29 -46
  47. package/dist/{textMetrics-DgGJ3bZP.js → textMetrics-CQtQI4vF.js} +1 -1
  48. package/dist/{textMetrics-B1eg4u4V.cjs → textMetrics-DTRuXeXr.cjs} +1 -1
  49. package/dist/{threadFns-DqMbjyxZ.js → threadFns-CvLvKdwB.js} +2 -1
  50. package/dist/{threadFns-CX9l8sRv.cjs → threadFns-DvSdQiRw.cjs} +4 -3
  51. package/dist/topology.cjs +5 -4
  52. package/dist/topology.js +3 -2
  53. package/package.json +1 -1
  54. package/dist/solidBuilders-CgPOdC3Q.js +0 -140
  55. package/dist/solidBuilders-mxHbGDW6.cjs +0 -199
@@ -1,13 +1,13 @@
1
- import { Z as getKernel, c as createSolid, h as isShape3D, t as castShape, x as isClosedWire } from "./shapeTypes-D4Evnmz_.js";
1
+ import { Z as getKernel, _ as isSolid, c as createSolid, g as isShell, h as isShape3D, i as createCompound, l as createVertex, t as castShape } from "./shapeTypes-D4Evnmz_.js";
2
2
  import { A as ok, R as unwrap, 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";
3
3
  import { f as getVertices, p as getWires, s as getEdges } from "./topologyQueryFns-5EeBz6_7.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 { h as vecScale, t as vecAdd } from "./vecOps-SKPRvPH-.js";
6
6
  import { o as resolvePlane } from "./planeOps-DSjjtrjg.js";
7
- import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate, v as propagateMetadataByHash } from "./shapeFns-B6UAiYAx.js";
7
+ import { _ as cast, v as downcast } from "./faceFns-BO8IXhhf.js";
8
+ import { _ as propagateAllMetadata, g as collectInputFaceHashes, v as propagateMetadataByHash } from "./shapeFns-B6UAiYAx.js";
8
9
  import { n as getAtOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
9
- 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-CLMyFimy.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-CgPOdC3Q.js";
10
+ import { r as makeFace } from "./surfaceBuilders-CLMyFimy.js";
11
11
  //#region src/topology/booleanFns.ts
12
12
  /**
13
13
  * Boolean and compound operations — functional replacements for _3DShape boolean methods.
@@ -455,297 +455,140 @@ function booleanPipelineFallback(base, steps, options) {
455
455
  return ok(current);
456
456
  }
457
457
  //#endregion
458
- //#region src/topology/primitiveFns.ts
458
+ //#region src/topology/shapeUtils.ts
459
459
  /**
460
- * Create a box with the given dimensions.
461
- *
462
- * @param width - Size along X.
463
- * @param depth - Size along Y.
464
- * @param height - Size along Z.
460
+ * Shape assembly utilities welding and sewing operations.
465
461
  */
466
- function box(width, depth, height, options) {
467
- const solid = createSolid(getKernel().makeBox(width, depth, height));
468
- const center = options?.at ?? (options?.centered ? [
469
- 0,
470
- 0,
471
- 0
472
- ] : void 0);
473
- if (center) return translate(solid, [
474
- center[0] - width / 2,
475
- center[1] - depth / 2,
476
- center[2] - height / 2
477
- ]);
478
- return solid;
462
+ /** Sew faces/shells into a single shape using the kernel's sewing algorithm. */
463
+ function weldShapes(facesOrShells) {
464
+ return unwrap(cast(unwrap(downcast(getKernel().sew(facesOrShells.map((s) => s.wrapped))))));
479
465
  }
480
466
  /**
481
- * Create a cylinder with the given radius and height.
467
+ * Welds faces and shells into a single shell.
468
+ *
469
+ * @param facesOrShells - An array of faces and shells to be welded.
470
+ * @param ignoreType - If true, the function will not check if the result is a shell.
471
+ * @returns A shell that contains all the faces and shells.
482
472
  */
483
- function cylinder(radius, height, options) {
484
- const at = options?.at ?? [
485
- 0,
486
- 0,
487
- 0
488
- ];
489
- const axis = options?.axis ?? [
490
- 0,
491
- 0,
492
- 1
493
- ];
494
- let solid = makeCylinder(radius, height, at, axis);
495
- if (options?.centered) {
496
- const halfShift = [
497
- -axis[0] * height * .5,
498
- -axis[1] * height * .5,
499
- -axis[2] * height * .5
500
- ];
501
- solid = translate(solid, halfShift);
502
- }
503
- return solid;
473
+ function weldShellsAndFaces(facesOrShells, ignoreType = false) {
474
+ const shell = weldShapes(facesOrShells);
475
+ if (!ignoreType && !isShell(shell)) return err(typeCastError("WELD_NOT_SHELL", "Could not make a shell from faces and shells"));
476
+ return ok(shell);
504
477
  }
478
+ //#endregion
479
+ //#region src/topology/solidBuilders.ts
505
480
  /**
506
- * Create a sphere with the given radius.
481
+ * Solid and primitive construction helpers boxes, cylinders, spheres, cones,
482
+ * tori, ellipsoids, vertices, compounds, and offsets.
507
483
  */
508
- function sphere(radius, options) {
509
- let solid = makeSphere(radius);
510
- if (options?.at) solid = translate(solid, options.at);
511
- return solid;
512
- }
513
484
  /**
514
- * Create a cone (or frustum) with the given radii and height.
485
+ * Creates a cylinder with the given radius and height.
515
486
  *
516
- * @param bottomRadius - Radius at the base.
517
- * @param topRadius - Radius at the top (0 for a full cone).
518
- * @param height - Height of the cone.
487
+ * @category Solids
519
488
  */
520
- function cone(bottomRadius, topRadius, height, options) {
521
- const at = options?.at ?? [
522
- 0,
523
- 0,
524
- 0
525
- ];
526
- const axis = options?.axis ?? [
527
- 0,
528
- 0,
529
- 1
530
- ];
531
- let solid = makeCone(bottomRadius, topRadius, height, at, axis);
532
- if (options?.centered) {
533
- const halfShift = [
534
- -axis[0] * height * .5,
535
- -axis[1] * height * .5,
536
- -axis[2] * height * .5
537
- ];
538
- solid = translate(solid, halfShift);
539
- }
540
- return solid;
489
+ function makeCylinder(radius, height, location = [
490
+ 0,
491
+ 0,
492
+ 0
493
+ ], direction = [
494
+ 0,
495
+ 0,
496
+ 1
497
+ ]) {
498
+ return createSolid(getKernel().makeCylinder(radius, height, [...location], [...direction]));
541
499
  }
542
500
  /**
543
- * Create a torus with the given major and minor radii.
544
- */
545
- function torus(majorRadius, minorRadius, options) {
546
- return makeTorus(majorRadius, minorRadius, options?.at ?? [
547
- 0,
548
- 0,
549
- 0
550
- ], options?.axis ?? [
551
- 0,
552
- 0,
553
- 1
554
- ]);
555
- }
556
- /**
557
- * Create an ellipsoid with the given axis half-lengths.
501
+ * Creates a sphere with the given radius.
558
502
  *
559
- * @param rx - Half-length along X.
560
- * @param ry - Half-length along Y.
561
- * @param rz - Half-length along Z.
503
+ * @category Solids
562
504
  */
563
- function ellipsoid(rx, ry, rz, options) {
564
- let solid = makeEllipsoid(rx, ry, rz);
565
- if (options?.at) solid = translate(solid, options.at);
566
- return solid;
567
- }
568
- /** Create a straight edge between two 3D points. */
569
- function line(from, to) {
570
- return makeLine(from, to);
571
- }
572
- /** Create a circular edge with the given radius. */
573
- function circle(radius, options) {
574
- const axisDir = options?.axis ?? [
575
- 0,
576
- 0,
577
- 1
578
- ];
579
- return makeCircle(radius, options?.at ?? [
580
- 0,
581
- 0,
582
- 0
583
- ], axisDir);
505
+ function makeSphere(radius) {
506
+ return createSolid(getKernel().makeSphere(radius));
584
507
  }
585
508
  /**
586
- * Create an elliptical edge.
509
+ * Creates a cone (or frustum) with the given radii and height.
587
510
  *
588
- * @returns An error if `minorRadius` exceeds `majorRadius`.
511
+ * @category Solids
589
512
  */
590
- function ellipse(majorRadius, minorRadius, options) {
591
- const axisDir = options?.axis ?? [
592
- 0,
593
- 0,
594
- 1
595
- ];
596
- return makeEllipse(majorRadius, minorRadius, options?.at ?? [
597
- 0,
598
- 0,
599
- 0
600
- ], axisDir, options?.xDir);
513
+ function makeCone(radius1, radius2, height, location = [
514
+ 0,
515
+ 0,
516
+ 0
517
+ ], direction = [
518
+ 0,
519
+ 0,
520
+ 1
521
+ ]) {
522
+ return createSolid(getKernel().makeCone(radius1, radius2, height, [...location], [...direction]));
601
523
  }
602
524
  /**
603
- * Create a helical wire.
525
+ * Creates a torus with the given major and minor radii.
604
526
  *
605
- * @param pitch - Vertical distance per full turn.
606
- * @param height - Total height.
607
- * @param radius - Helix radius.
527
+ * @category Solids
608
528
  */
609
- function helix(pitch, height, radius, options) {
610
- return makeHelix(pitch, height, radius, options?.at ?? [
611
- 0,
612
- 0,
613
- 0
614
- ], options?.axis ?? [
615
- 0,
616
- 0,
617
- 1
618
- ], options?.lefthand ?? false);
619
- }
620
- /** Create a circular arc edge passing through three points. */
621
- function threePointArc(p1, p2, p3) {
622
- return makeThreePointArc(p1, p2, p3);
529
+ function makeTorus(majorRadius, minorRadius, location = [
530
+ 0,
531
+ 0,
532
+ 0
533
+ ], direction = [
534
+ 0,
535
+ 0,
536
+ 1
537
+ ]) {
538
+ return createSolid(getKernel().makeTorus(majorRadius, minorRadius, [...location], [...direction]));
623
539
  }
624
540
  /**
625
- * Create an elliptical arc edge between two angles.
541
+ * Creates an ellipsoid with the given axis lengths.
626
542
  *
627
- * All angles are in **degrees** (unlike the legacy `makeEllipseArc` which used radians).
543
+ * The algorithm creates a unit BSpline sphere surface, transforms its
544
+ * control-point poles with an affinity matrix to match the requested
545
+ * axis half-lengths, then sews the result into a solid.
628
546
  *
629
- * @param startAngle - Start angle in degrees.
630
- * @param endAngle - End angle in degrees.
547
+ * @category Solids
631
548
  */
632
- function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
633
- const axisDir = options?.axis ?? [
634
- 0,
635
- 0,
636
- 1
637
- ];
638
- return makeEllipseArc(majorRadius, minorRadius, startAngle * DEG2RAD, endAngle * DEG2RAD, options?.at ?? [
639
- 0,
640
- 0,
641
- 0
642
- ], axisDir, options?.xDir);
549
+ function makeEllipsoid(aLength, bLength, cLength) {
550
+ return createSolid(getKernel().makeEllipsoid(aLength, bLength, cLength));
643
551
  }
644
- /**
645
- * Create a B-spline edge that approximates a set of 3D points.
646
- *
647
- * @returns An error if the approximation algorithm fails.
648
- */
649
- function bsplineApprox(points, config) {
650
- return makeBSplineApproximation(points, config);
552
+ /** Create a vertex at a 3D point. */
553
+ function makeVertex(point) {
554
+ return createVertex(getKernel().makeVertex(point[0], point[1], point[2]));
651
555
  }
652
556
  /**
653
- * Create a Bezier curve edge from control points.
557
+ * Create an offset shape from a face.
654
558
  *
655
- * @param points - Two or more control points.
656
- */
657
- function bezier(points) {
658
- return makeBezierCurve(points);
659
- }
660
- /**
661
- * Create a circular arc edge tangent to a direction at the start point.
662
- */
663
- function tangentArc(startPoint, startTgt, endPoint) {
664
- return makeTangentArc(startPoint, startTgt, endPoint);
559
+ * @param offset - Signed offset distance (positive = outward).
560
+ * @param tolerance - Geometric tolerance for the offset algorithm.
561
+ * @returns An error if the result is not a valid 3D shape.
562
+ */
563
+ function makeOffset(face, offset, tolerance = 1e-6) {
564
+ return andThen(downcast(getKernel().offset(face.wrapped, offset, tolerance)), (downcasted) => andThen(cast(downcasted), (newShape) => {
565
+ if (!isShape3D(newShape)) return err(typeCastError("OFFSET_NOT_3D", "Could not offset to a 3d shape"));
566
+ return ok(newShape);
567
+ }));
665
568
  }
666
569
  /**
667
- * Assemble edges and/or wires into a single connected wire.
570
+ * Build a compound from multiple shapes.
571
+ *
572
+ * @param shapeArray - Shapes to group into a single compound.
573
+ * @returns A new Compound containing all input shapes.
668
574
  */
669
- function wire(listOfEdges) {
670
- return assembleWire(listOfEdges);
575
+ function makeCompound(shapeArray) {
576
+ return createCompound(getKernel().makeCompound(shapeArray.map((s) => s.wrapped)));
671
577
  }
672
578
  /**
673
- * Assemble edges into a wire and verify it forms a closed loop.
579
+ * Welds faces and shells into a single shell and then makes a solid.
674
580
  *
675
- * Combines {@link wire} + the `closedWire` smart constructor in a single step.
676
- * Returns an error if the edges cannot be assembled or the wire is not closed.
581
+ * @param facesOrShells - An array of faces and shells to be welded.
582
+ * @returns A solid that contains all the faces and shells.
677
583
  *
678
- * @example
679
- * ```ts
680
- * const cw = unwrap(wireLoop([e1, e2, e3, e4]));
681
- * const f = unwrap(face(cw)); // ClosedWire accepted directly
682
- * ```
584
+ * @category Solids
683
585
  */
684
- function wireLoop(listOfEdges) {
685
- return andThen(assembleWire(listOfEdges), (w) => {
686
- if (isClosedWire(w)) return ok(w);
687
- return err(validationError("WIRE_NOT_CLOSED", "Assembled wire is not closed: start and end points do not coincide"));
586
+ function makeSolid(facesOrShells) {
587
+ const shell = weldShapes(facesOrShells);
588
+ return andThen(cast(getKernel().solidFromShell(shell.wrapped)), (solid) => {
589
+ if (!isSolid(solid)) return err(typeCastError("SOLID_BUILD_FAILED", "Could not make a solid of faces and shells"));
590
+ return ok(solid);
688
591
  });
689
592
  }
690
- /**
691
- * Create a planar face from a closed wire, optionally with holes.
692
- * The resulting face is always oriented (consistent normal direction).
693
- */
694
- function face(w, holes) {
695
- return makeFace(w, holes);
696
- }
697
- /**
698
- * Create a non-planar face from a wire using surface filling.
699
- * The resulting face is always oriented.
700
- */
701
- function filledFace(w) {
702
- return makeNonPlanarFace(w);
703
- }
704
- /**
705
- * Create a face bounded by a wire on an existing face's surface.
706
- * The resulting face inherits orientation from the origin face.
707
- */
708
- function subFace(originFace, w) {
709
- return makeNewFaceWithinFace(originFace, w);
710
- }
711
- /**
712
- * Create a polygonal face from three or more coplanar points.
713
- * The resulting face is always oriented.
714
- */
715
- function polygon(points) {
716
- return makePolygon(points);
717
- }
718
- /** Create a vertex at a 3D point. */
719
- function vertex(point) {
720
- return makeVertex(point);
721
- }
722
- /**
723
- * Build a compound from multiple shapes.
724
- */
725
- function compound(shapeArray) {
726
- return makeCompound(shapeArray);
727
- }
728
- /**
729
- * Weld faces and shells into a single solid.
730
- * The resulting solid is always validated.
731
- */
732
- function solid(facesOrShells) {
733
- return makeSolid(facesOrShells);
734
- }
735
- /**
736
- * Create an offset shape from a face.
737
- */
738
- function offsetFace(f, distance, tolerance) {
739
- return makeOffset(f, distance, tolerance);
740
- }
741
- /**
742
- * Weld faces and shells into a single shell.
743
- */
744
- function sewShells(facesOrShells, ignoreType) {
745
- return weldShellsAndFaces(facesOrShells, ignoreType);
746
- }
747
- function addHoles(f, holes) {
748
- return addHolesInFace(f, holes);
749
- }
750
593
  //#endregion
751
- export { cutAll as A, threePointArc as C, wireLoop as D, wire as E, sectionToFace as F, slice as I, split as L, fuseAll as M, intersect as N, booleanPipeline as O, section as P, tangentArc as S, vertex as T, polygon as _, circle as a, sphere as b, cylinder as c, ellipsoid as d, face as f, offsetFace as g, line as h, bsplineApprox as i, fuse as j, cut as k, ellipse as l, helix as m, bezier as n, compound as o, filledFace as p, box as r, cone as s, addHoles as t, ellipseArc as u, sewShells as v, torus as w, subFace as x, solid as y };
594
+ export { section as _, makeOffset as a, split as b, makeTorus as c, booleanPipeline as d, cut as f, intersect as g, fuseAll as h, makeEllipsoid as i, makeVertex as l, fuse as m, makeCone as n, makeSolid as o, cutAll as p, makeCylinder as r, makeSphere as s, makeCompound as t, weldShellsAndFaces as u, sectionToFace as v, slice as y };