brepjs 18.82.4 → 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.
- package/dist/brepjs.cjs +32 -32
- package/dist/brepjs.js +7 -7
- package/dist/{drawFns-DrlxFhe4.js → drawFns-C5Mdr0iH.js} +1 -1
- package/dist/{drawFns-CmSMHb12.cjs → drawFns-DK3DGHku.cjs} +1 -1
- package/dist/{healingFns-Ct_-O3yk.js → healingFns-C4JZHv8K.js} +1 -1
- package/dist/{healingFns-MxlhdTIc.cjs → healingFns-D3BkAVML.cjs} +5 -5
- package/dist/operations.cjs +1 -1
- package/dist/operations.js +1 -1
- package/dist/primitiveFns-BPfYb_t5.cjs +461 -0
- package/dist/primitiveFns-DkuLOFkI.js +300 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{primitiveFns-CjL5bygY.js → solidBuilders-QUpJdbiK.js} +99 -256
- package/dist/{primitiveFns-LWkd7M2f.cjs → solidBuilders-lDXPwoCz.cjs} +120 -379
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-BjSwFtO2.cjs → textBlueprints-D4pLmVno.cjs} +25 -42
- package/dist/{textBlueprints-BJ22J1c2.js → textBlueprints-f8cgx9vi.js} +28 -45
- package/dist/{textMetrics-BrSfzuY6.js → textMetrics-CQtQI4vF.js} +1 -1
- package/dist/{textMetrics-5DyMA99n.cjs → textMetrics-DTRuXeXr.cjs} +1 -1
- package/dist/{threadFns-DqMbjyxZ.js → threadFns-CvLvKdwB.js} +2 -1
- package/dist/{threadFns-CX9l8sRv.cjs → threadFns-DvSdQiRw.cjs} +4 -3
- package/dist/topology.cjs +5 -4
- package/dist/topology.js +3 -2
- package/package.json +1 -1
- package/dist/solidBuilders-CgPOdC3Q.js +0 -140
- package/dist/solidBuilders-mxHbGDW6.cjs +0 -199
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Z as getKernel, c as createSolid, h as isShape3D,
|
|
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
|
|
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
|
|
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 {
|
|
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/
|
|
458
|
+
//#region src/topology/shapeUtils.ts
|
|
459
459
|
/**
|
|
460
|
-
*
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
*
|
|
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
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
485
|
+
* Creates a cylinder with the given radius and height.
|
|
515
486
|
*
|
|
516
|
-
* @
|
|
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
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
560
|
-
* @param ry - Half-length along Y.
|
|
561
|
-
* @param rz - Half-length along Z.
|
|
503
|
+
* @category Solids
|
|
562
504
|
*/
|
|
563
|
-
function
|
|
564
|
-
|
|
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
|
-
*
|
|
509
|
+
* Creates a cone (or frustum) with the given radii and height.
|
|
587
510
|
*
|
|
588
|
-
* @
|
|
511
|
+
* @category Solids
|
|
589
512
|
*/
|
|
590
|
-
function
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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
|
-
*
|
|
525
|
+
* Creates a torus with the given major and minor radii.
|
|
604
526
|
*
|
|
605
|
-
* @
|
|
606
|
-
* @param height - Total height.
|
|
607
|
-
* @param radius - Helix radius.
|
|
527
|
+
* @category Solids
|
|
608
528
|
*/
|
|
609
|
-
function
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
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
|
-
*
|
|
541
|
+
* Creates an ellipsoid with the given axis lengths.
|
|
626
542
|
*
|
|
627
|
-
*
|
|
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
|
-
* @
|
|
630
|
-
* @param endAngle - End angle in degrees.
|
|
547
|
+
* @category Solids
|
|
631
548
|
*/
|
|
632
|
-
function
|
|
633
|
-
|
|
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
|
-
|
|
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
|
|
557
|
+
* Create an offset shape from a face.
|
|
654
558
|
*
|
|
655
|
-
* @param
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
-
*
|
|
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
|
|
670
|
-
return
|
|
575
|
+
function makeCompound(shapeArray) {
|
|
576
|
+
return createCompound(getKernel().makeCompound(shapeArray.map((s) => s.wrapped)));
|
|
671
577
|
}
|
|
672
578
|
/**
|
|
673
|
-
*
|
|
579
|
+
* Welds faces and shells into a single shell and then makes a solid.
|
|
674
580
|
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
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
|
-
* @
|
|
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
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
return err(
|
|
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 {
|
|
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 };
|