brepjs 18.82.4 → 18.82.6
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/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{blueprint-BBUOweQy.cjs → blueprint-C2gkyxYc.cjs} +7 -7
- package/dist/{blueprint-DjzevNhB.js → blueprint-yJsyEFn_.js} +7 -7
- package/dist/{blueprintFns-CRES_5vP.cjs → blueprintFns-CL4VZzCL.cjs} +2 -2
- package/dist/{blueprintFns-CxSMnMfl.js → blueprintFns-DjpRmsbi.js} +2 -2
- package/dist/{blueprintSketcher-CFa32JZU.cjs → blueprintSketcher-BLXntEIS.cjs} +140 -86
- package/dist/{blueprintSketcher-CIydRzRr.js → blueprintSketcher-BbYPEPMa.js} +140 -86
- package/dist/{boolean2D-Z0KE98a4.cjs → boolean2D-BbvyYF-v.cjs} +4 -4
- package/dist/{boolean2D-BRWPIJhe.js → boolean2D-C3k4iO92.js} +4 -4
- package/dist/brepjs.cjs +50 -50
- package/dist/brepjs.js +25 -25
- package/dist/{cameraFns-B3Wb4Br9.js → cameraFns-BiQGAnPd.js} +2 -2
- package/dist/{cameraFns-Drgka78Q.cjs → cameraFns-BkSHm_Vo.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-BRYZAgdE.js → cornerFinder-C9zvdkpK.js} +1 -1
- package/dist/{cornerFinder-BuYpqGO8.cjs → cornerFinder-D3lGL_Td.cjs} +1 -1
- package/dist/{curveFns-XSz4F9j3.js → curveFns-B4_om-yp.js} +1 -1
- package/dist/{curveFns-BA5zsoce.cjs → curveFns-Dlbfncal.cjs} +1 -1
- package/dist/{drawFns-DrlxFhe4.js → drawFns-DaTn2p7M.js} +12 -12
- package/dist/{drawFns-CmSMHb12.cjs → drawFns-lls9IuPY.cjs} +12 -12
- package/dist/{faceFns-BO8IXhhf.js → faceFns-4JEna8n9.js} +2 -2
- package/dist/{faceFns-6AarivqH.cjs → faceFns-Obtamglc.cjs} +2 -2
- package/dist/{healingFns-MxlhdTIc.cjs → healingFns-gHxvhsbJ.cjs} +9 -9
- package/dist/{healingFns-Ct_-O3yk.js → healingFns-uXLI1vJ7.js} +5 -5
- package/dist/{helpers-CTc8ZbY8.js → helpers-CJV31xig.js} +6 -6
- package/dist/{helpers-DN6s-TLC.cjs → helpers-rAK5qEBu.cjs} +6 -6
- package/dist/{importFns-Cb-cmpGG.cjs → importFns-BJVEly-l.cjs} +2 -2
- package/dist/{importFns-D4Xet5aD.js → importFns-Dcc2KviL.js} +2 -2
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/brepkitWasmTypes.d.ts +10 -6
- package/dist/kernel/occtWasm/kernel2dOps.d.ts +8 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/{loftFns-DxhcdpAu.cjs → loftFns-BAM49XJy.cjs} +1 -1
- package/dist/{loftFns-BVbzy6gm.js → loftFns-DF3KNz9-.js} +1 -1
- package/dist/{measureFns-BNHvjShh.cjs → measureFns-Ym_I522s.cjs} +3 -3
- package/dist/{measureFns-7Nz5JklM.js → measureFns-xpevHRLG.js} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-YXFipjjx.cjs → meshFns-DDhKhVK0.cjs} +3 -3
- package/dist/{meshFns-CWwOpBlM.js → meshFns-soCHj3jp.js} +3 -3
- package/dist/{occtWasmAdapter-BMV179Ji.js → occtWasmAdapter-BK6h0nKd.js} +29 -5
- package/dist/{occtWasmAdapter-5hzzhkME.cjs → occtWasmAdapter-Bfz5Zfmk.cjs} +29 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/primitiveFns-BmUIWDC7.js +300 -0
- package/dist/primitiveFns-SEyCwNra.cjs +461 -0
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{shapeFns-B6UAiYAx.js → shapeFns-B8REDWBf.js} +2 -2
- package/dist/{shapeFns-sF0x5Zhj.cjs → shapeFns-CE6c_4D4.cjs} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-Bb0aQZWz.cjs → shapeRefFns-C3tglb5A.cjs} +4 -4
- package/dist/{shapeRefFns-NdQvPa5J.js → shapeRefFns-O5h8bOr9.js} +4 -4
- package/dist/{shapeTypes-D4Evnmz_.js → shapeTypes-B8d_6R0X.js} +9 -6
- package/dist/{shapeTypes-D1eUDuzl.cjs → shapeTypes-nFeOa7gQ.cjs} +9 -6
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{primitiveFns-CjL5bygY.js → solidBuilders-BSnsqitN.js} +100 -257
- package/dist/{primitiveFns-LWkd7M2f.cjs → solidBuilders-DfGIPlQ2.cjs} +124 -383
- package/dist/{surfaceBuilders-R4DKNFkI.cjs → surfaceBuilders-CDX6sDZz.cjs} +2 -2
- package/dist/{surfaceBuilders-CLMyFimy.js → surfaceBuilders-D5sQZ6ah.js} +2 -2
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-BjSwFtO2.cjs → textBlueprints-BwRqV98S.cjs} +31 -48
- package/dist/{textBlueprints-BJ22J1c2.js → textBlueprints-Cqu-mcRD.js} +32 -49
- package/dist/{textMetrics-BrSfzuY6.js → textMetrics-Cikow3vH.js} +1 -1
- package/dist/{textMetrics-5DyMA99n.cjs → textMetrics-DpCTYcE2.cjs} +1 -1
- package/dist/{threadFns-DqMbjyxZ.js → threadFns-BQHEnI7a.js} +6 -5
- package/dist/{threadFns-CX9l8sRv.cjs → threadFns-BzFhh87N.cjs} +8 -7
- package/dist/topology.cjs +10 -9
- package/dist/topology.js +8 -7
- package/dist/{topologyQueryFns-5EeBz6_7.js → topologyQueryFns-BcGLEMvc.js} +1 -1
- package/dist/{topologyQueryFns-Nnu56Ke2.cjs → topologyQueryFns-Bhey0q1G.cjs} +1 -1
- package/package.json +16 -16
- package/dist/solidBuilders-CgPOdC3Q.js +0 -140
- package/dist/solidBuilders-mxHbGDW6.cjs +0 -199
|
@@ -3636,8 +3636,32 @@ function mirrorCurve2dAtPoint(curve, cx, cy) {
|
|
|
3636
3636
|
function mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
|
|
3637
3637
|
return c2dWrap(mirrorAcrossAxis(c2d(curve), originX, originY, dirX, dirY));
|
|
3638
3638
|
}
|
|
3639
|
-
|
|
3640
|
-
|
|
3639
|
+
/**
|
|
3640
|
+
* Directional affinity matching OCCT `gp_GTrsf2d::SetAffinity`: scales the
|
|
3641
|
+
* component perpendicular to the axis `(dx, dy)` through `(ox, oy)` by `ratio`,
|
|
3642
|
+
* leaving the parallel component fixed. Applied by sampling and refitting as a
|
|
3643
|
+
* Bezier, since occt-wasm has no native Geom2d transform.
|
|
3644
|
+
*/
|
|
3645
|
+
function affinityCurve2d(curve, ox, oy, dx, dy, ratio) {
|
|
3646
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
3647
|
+
if (len < 1e-15) return curve;
|
|
3648
|
+
const px = -dy / len, py = dx / len;
|
|
3649
|
+
const k = ratio - 1;
|
|
3650
|
+
const a = 1 + k * px * px, b = k * px * py, d = k * py * px, e = 1 + k * py * py;
|
|
3651
|
+
const tx = ox - a * ox - b * oy;
|
|
3652
|
+
const ty = oy - d * ox - e * oy;
|
|
3653
|
+
const c = c2d(curve);
|
|
3654
|
+
const bounds = curveBounds(c);
|
|
3655
|
+
const N = 20;
|
|
3656
|
+
const pts = [];
|
|
3657
|
+
for (let i = 0; i <= N; i++) {
|
|
3658
|
+
const [qx, qy] = evaluateCurve2d$1(c, bounds.first + (bounds.last - bounds.first) * i / N);
|
|
3659
|
+
pts.push([a * qx + b * qy + tx, d * qx + e * qy + ty]);
|
|
3660
|
+
}
|
|
3661
|
+
return c2dWrap(makeBezier2d$1(pts));
|
|
3662
|
+
}
|
|
3663
|
+
function affinityTransform2d(curve, ox, oy, dx, dy, ratio) {
|
|
3664
|
+
return affinityCurve2d(curve, ox, oy, dx, dy, ratio);
|
|
3641
3665
|
}
|
|
3642
3666
|
function createIdentityGTrsf2d() {
|
|
3643
3667
|
return {
|
|
@@ -3718,7 +3742,7 @@ function transformCurve2dGeneral(curve, gtrsf) {
|
|
|
3718
3742
|
if (t["type"] === "rotate2d") return rotateCurve2d(curve, Number(t["angle"]) || 0, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
|
|
3719
3743
|
if (t["type"] === "scale2d") return scaleCurve2d(curve, Number(t["sx"]) || 1, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
|
|
3720
3744
|
if (t["type"] === "mirror2d") return mirrorCurve2dAtPoint(curve, Number(t["ox"]) || 0, Number(t["oy"]) || 0);
|
|
3721
|
-
if (t["type"] === "affinity2d") return
|
|
3745
|
+
if (t["type"] === "affinity2d") return affinityCurve2d(curve, Number(t["axOriginX"]) || 0, Number(t["axOriginY"]) || 0, Number(t["axDirX"]) || 0, Number(t["axDirY"]) || 0, Number(t["ratio"]) || 1);
|
|
3722
3746
|
if (Number(t["dx"]) || Number(t["dy"])) return translateCurve2d(curve, Number(t["dx"]) || 0, Number(t["dy"]) || 0);
|
|
3723
3747
|
return curve;
|
|
3724
3748
|
}
|
|
@@ -5063,8 +5087,8 @@ var OcctWasmAdapter = class OcctWasmAdapter {
|
|
|
5063
5087
|
mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
|
|
5064
5088
|
return mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY);
|
|
5065
5089
|
}
|
|
5066
|
-
affinityTransform2d(curve,
|
|
5067
|
-
return affinityTransform2d(curve);
|
|
5090
|
+
affinityTransform2d(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio) {
|
|
5091
|
+
return affinityTransform2d(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio);
|
|
5068
5092
|
}
|
|
5069
5093
|
createIdentityGTrsf2d() {
|
|
5070
5094
|
return createIdentityGTrsf2d();
|
|
@@ -3636,8 +3636,32 @@ function mirrorCurve2dAtPoint(curve, cx, cy) {
|
|
|
3636
3636
|
function mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
|
|
3637
3637
|
return c2dWrap(mirrorAcrossAxis(c2d(curve), originX, originY, dirX, dirY));
|
|
3638
3638
|
}
|
|
3639
|
-
|
|
3640
|
-
|
|
3639
|
+
/**
|
|
3640
|
+
* Directional affinity matching OCCT `gp_GTrsf2d::SetAffinity`: scales the
|
|
3641
|
+
* component perpendicular to the axis `(dx, dy)` through `(ox, oy)` by `ratio`,
|
|
3642
|
+
* leaving the parallel component fixed. Applied by sampling and refitting as a
|
|
3643
|
+
* Bezier, since occt-wasm has no native Geom2d transform.
|
|
3644
|
+
*/
|
|
3645
|
+
function affinityCurve2d(curve, ox, oy, dx, dy, ratio) {
|
|
3646
|
+
const len = Math.sqrt(dx * dx + dy * dy);
|
|
3647
|
+
if (len < 1e-15) return curve;
|
|
3648
|
+
const px = -dy / len, py = dx / len;
|
|
3649
|
+
const k = ratio - 1;
|
|
3650
|
+
const a = 1 + k * px * px, b = k * px * py, d = k * py * px, e = 1 + k * py * py;
|
|
3651
|
+
const tx = ox - a * ox - b * oy;
|
|
3652
|
+
const ty = oy - d * ox - e * oy;
|
|
3653
|
+
const c = c2d(curve);
|
|
3654
|
+
const bounds = curveBounds(c);
|
|
3655
|
+
const N = 20;
|
|
3656
|
+
const pts = [];
|
|
3657
|
+
for (let i = 0; i <= N; i++) {
|
|
3658
|
+
const [qx, qy] = evaluateCurve2d$1(c, bounds.first + (bounds.last - bounds.first) * i / N);
|
|
3659
|
+
pts.push([a * qx + b * qy + tx, d * qx + e * qy + ty]);
|
|
3660
|
+
}
|
|
3661
|
+
return c2dWrap(makeBezier2d$1(pts));
|
|
3662
|
+
}
|
|
3663
|
+
function affinityTransform2d(curve, ox, oy, dx, dy, ratio) {
|
|
3664
|
+
return affinityCurve2d(curve, ox, oy, dx, dy, ratio);
|
|
3641
3665
|
}
|
|
3642
3666
|
function createIdentityGTrsf2d() {
|
|
3643
3667
|
return {
|
|
@@ -3718,7 +3742,7 @@ function transformCurve2dGeneral(curve, gtrsf) {
|
|
|
3718
3742
|
if (t["type"] === "rotate2d") return rotateCurve2d(curve, Number(t["angle"]) || 0, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
|
|
3719
3743
|
if (t["type"] === "scale2d") return scaleCurve2d(curve, Number(t["sx"]) || 1, Number(t["cx"]) || 0, Number(t["cy"]) || 0);
|
|
3720
3744
|
if (t["type"] === "mirror2d") return mirrorCurve2dAtPoint(curve, Number(t["ox"]) || 0, Number(t["oy"]) || 0);
|
|
3721
|
-
if (t["type"] === "affinity2d") return
|
|
3745
|
+
if (t["type"] === "affinity2d") return affinityCurve2d(curve, Number(t["axOriginX"]) || 0, Number(t["axOriginY"]) || 0, Number(t["axDirX"]) || 0, Number(t["axDirY"]) || 0, Number(t["ratio"]) || 1);
|
|
3722
3746
|
if (Number(t["dx"]) || Number(t["dy"])) return translateCurve2d(curve, Number(t["dx"]) || 0, Number(t["dy"]) || 0);
|
|
3723
3747
|
return curve;
|
|
3724
3748
|
}
|
|
@@ -5063,8 +5087,8 @@ var OcctWasmAdapter = class OcctWasmAdapter {
|
|
|
5063
5087
|
mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY) {
|
|
5064
5088
|
return mirrorCurve2dAcrossAxis(curve, originX, originY, dirX, dirY);
|
|
5065
5089
|
}
|
|
5066
|
-
affinityTransform2d(curve,
|
|
5067
|
-
return affinityTransform2d(curve);
|
|
5090
|
+
affinityTransform2d(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio) {
|
|
5091
|
+
return affinityTransform2d(curve, axisOriginX, axisOriginY, axisDirX, axisDirY, ratio);
|
|
5068
5092
|
}
|
|
5069
5093
|
createIdentityGTrsf2d() {
|
|
5070
5094
|
return createIdentityGTrsf2d();
|
package/dist/operations.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_threadFns = require("./threadFns-
|
|
3
|
-
const require_loftFns = require("./loftFns-
|
|
2
|
+
const require_threadFns = require("./threadFns-BzFhh87N.cjs");
|
|
3
|
+
const require_loftFns = require("./loftFns-BAM49XJy.cjs");
|
|
4
4
|
exports.addChild = require_threadFns.addChild;
|
|
5
5
|
exports.addJoint = require_threadFns.addJoint;
|
|
6
6
|
exports.addStep = require_threadFns.addStep;
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as setJointValue, B as findNode, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, G as gridPattern, H as updateNode, I as addChild, J as createAssembly, K as linearPattern, L as collectShapes, M as sphericalJoint, O as prismaticJoint, R as countNodes, S as addJoint, T as jointTransform, U as walkAssembly, V as removeChild, W as circularPattern, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, q as exportAssemblySTEP, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as createAssemblyNode } from "./threadFns-
|
|
2
|
-
import { d as twistExtrude, l as supportExtrude, o as complexExtrude, u as sweep } from "./loftFns-
|
|
1
|
+
import { A as setJointValue, B as findNode, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, G as gridPattern, H as updateNode, I as addChild, J as createAssembly, K as linearPattern, L as collectShapes, M as sphericalJoint, O as prismaticJoint, R as countNodes, S as addJoint, T as jointTransform, U as walkAssembly, V as removeChild, W as circularPattern, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, q as exportAssemblySTEP, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as createAssemblyNode } from "./threadFns-BQHEnI7a.js";
|
|
2
|
+
import { d as twistExtrude, l as supportExtrude, o as complexExtrude, u as sweep } from "./loftFns-DF3KNz9-.js";
|
|
3
3
|
export { addChild, addJoint, addStep, circularPattern, collectShapes, complexExtrude, countNodes, createAssembly, createAssemblyNode, createHistory, createRegistry, cylindricalJoint, exportAssemblySTEP, exportURDF, findNode, findStep, forwardKinematics, getShape as getHistoryShape, gridPattern, importURDF, inverseKinematics, jointTrajectory, jointTransform, jointsFromDH, linearPattern, mechanismDOF, modifyStep, planarJoint, prismaticJoint, registerOperation, registerShape, removeChild, replayFrom, replayHistory, revoluteJoint, setJointValue, setJointValues, sphericalJoint, stepCount, stepsFrom, supportExtrude, sweep, thread, twistExtrude, undoLast, updateNode, walkAssembly };
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { Z as getKernel, c as createSolid, x as isClosedWire } from "./shapeTypes-B8d_6R0X.js";
|
|
2
|
+
import { A as ok, b as err, d as validationError, v as andThen } from "./errors-DNWJsfVU.js";
|
|
3
|
+
import { t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
4
|
+
import { h as translate } from "./shapeFns-B8REDWBf.js";
|
|
5
|
+
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-D5sQZ6ah.js";
|
|
6
|
+
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-BSnsqitN.js";
|
|
7
|
+
//#region src/topology/primitiveFns.ts
|
|
8
|
+
/**
|
|
9
|
+
* Create a box with the given dimensions.
|
|
10
|
+
*
|
|
11
|
+
* @param width - Size along X.
|
|
12
|
+
* @param depth - Size along Y.
|
|
13
|
+
* @param height - Size along Z.
|
|
14
|
+
*/
|
|
15
|
+
function box(width, depth, height, options) {
|
|
16
|
+
const solid = createSolid(getKernel().makeBox(width, depth, height));
|
|
17
|
+
const center = options?.at ?? (options?.centered ? [
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0
|
|
21
|
+
] : void 0);
|
|
22
|
+
if (center) return translate(solid, [
|
|
23
|
+
center[0] - width / 2,
|
|
24
|
+
center[1] - depth / 2,
|
|
25
|
+
center[2] - height / 2
|
|
26
|
+
]);
|
|
27
|
+
return solid;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a cylinder with the given radius and height.
|
|
31
|
+
*/
|
|
32
|
+
function cylinder(radius, height, options) {
|
|
33
|
+
const at = options?.at ?? [
|
|
34
|
+
0,
|
|
35
|
+
0,
|
|
36
|
+
0
|
|
37
|
+
];
|
|
38
|
+
const axis = options?.axis ?? [
|
|
39
|
+
0,
|
|
40
|
+
0,
|
|
41
|
+
1
|
|
42
|
+
];
|
|
43
|
+
let solid = makeCylinder(radius, height, at, axis);
|
|
44
|
+
if (options?.centered) {
|
|
45
|
+
const halfShift = [
|
|
46
|
+
-axis[0] * height * .5,
|
|
47
|
+
-axis[1] * height * .5,
|
|
48
|
+
-axis[2] * height * .5
|
|
49
|
+
];
|
|
50
|
+
solid = translate(solid, halfShift);
|
|
51
|
+
}
|
|
52
|
+
return solid;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Create a sphere with the given radius.
|
|
56
|
+
*/
|
|
57
|
+
function sphere(radius, options) {
|
|
58
|
+
let solid = makeSphere(radius);
|
|
59
|
+
if (options?.at) solid = translate(solid, options.at);
|
|
60
|
+
return solid;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a cone (or frustum) with the given radii and height.
|
|
64
|
+
*
|
|
65
|
+
* @param bottomRadius - Radius at the base.
|
|
66
|
+
* @param topRadius - Radius at the top (0 for a full cone).
|
|
67
|
+
* @param height - Height of the cone.
|
|
68
|
+
*/
|
|
69
|
+
function cone(bottomRadius, topRadius, height, options) {
|
|
70
|
+
const at = options?.at ?? [
|
|
71
|
+
0,
|
|
72
|
+
0,
|
|
73
|
+
0
|
|
74
|
+
];
|
|
75
|
+
const axis = options?.axis ?? [
|
|
76
|
+
0,
|
|
77
|
+
0,
|
|
78
|
+
1
|
|
79
|
+
];
|
|
80
|
+
let solid = makeCone(bottomRadius, topRadius, height, at, axis);
|
|
81
|
+
if (options?.centered) {
|
|
82
|
+
const halfShift = [
|
|
83
|
+
-axis[0] * height * .5,
|
|
84
|
+
-axis[1] * height * .5,
|
|
85
|
+
-axis[2] * height * .5
|
|
86
|
+
];
|
|
87
|
+
solid = translate(solid, halfShift);
|
|
88
|
+
}
|
|
89
|
+
return solid;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a torus with the given major and minor radii.
|
|
93
|
+
*/
|
|
94
|
+
function torus(majorRadius, minorRadius, options) {
|
|
95
|
+
return makeTorus(majorRadius, minorRadius, options?.at ?? [
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
0
|
|
99
|
+
], options?.axis ?? [
|
|
100
|
+
0,
|
|
101
|
+
0,
|
|
102
|
+
1
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create an ellipsoid with the given axis half-lengths.
|
|
107
|
+
*
|
|
108
|
+
* @param rx - Half-length along X.
|
|
109
|
+
* @param ry - Half-length along Y.
|
|
110
|
+
* @param rz - Half-length along Z.
|
|
111
|
+
*/
|
|
112
|
+
function ellipsoid(rx, ry, rz, options) {
|
|
113
|
+
let solid = makeEllipsoid(rx, ry, rz);
|
|
114
|
+
if (options?.at) solid = translate(solid, options.at);
|
|
115
|
+
return solid;
|
|
116
|
+
}
|
|
117
|
+
/** Create a straight edge between two 3D points. */
|
|
118
|
+
function line(from, to) {
|
|
119
|
+
return makeLine(from, to);
|
|
120
|
+
}
|
|
121
|
+
/** Create a circular edge with the given radius. */
|
|
122
|
+
function circle(radius, options) {
|
|
123
|
+
const axisDir = options?.axis ?? [
|
|
124
|
+
0,
|
|
125
|
+
0,
|
|
126
|
+
1
|
|
127
|
+
];
|
|
128
|
+
return makeCircle(radius, options?.at ?? [
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0
|
|
132
|
+
], axisDir);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Create an elliptical edge.
|
|
136
|
+
*
|
|
137
|
+
* @returns An error if `minorRadius` exceeds `majorRadius`.
|
|
138
|
+
*/
|
|
139
|
+
function ellipse(majorRadius, minorRadius, options) {
|
|
140
|
+
const axisDir = options?.axis ?? [
|
|
141
|
+
0,
|
|
142
|
+
0,
|
|
143
|
+
1
|
|
144
|
+
];
|
|
145
|
+
return makeEllipse(majorRadius, minorRadius, options?.at ?? [
|
|
146
|
+
0,
|
|
147
|
+
0,
|
|
148
|
+
0
|
|
149
|
+
], axisDir, options?.xDir);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create a helical wire.
|
|
153
|
+
*
|
|
154
|
+
* @param pitch - Vertical distance per full turn.
|
|
155
|
+
* @param height - Total height.
|
|
156
|
+
* @param radius - Helix radius.
|
|
157
|
+
*/
|
|
158
|
+
function helix(pitch, height, radius, options) {
|
|
159
|
+
return makeHelix(pitch, height, radius, options?.at ?? [
|
|
160
|
+
0,
|
|
161
|
+
0,
|
|
162
|
+
0
|
|
163
|
+
], options?.axis ?? [
|
|
164
|
+
0,
|
|
165
|
+
0,
|
|
166
|
+
1
|
|
167
|
+
], options?.lefthand ?? false);
|
|
168
|
+
}
|
|
169
|
+
/** Create a circular arc edge passing through three points. */
|
|
170
|
+
function threePointArc(p1, p2, p3) {
|
|
171
|
+
return makeThreePointArc(p1, p2, p3);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Create an elliptical arc edge between two angles.
|
|
175
|
+
*
|
|
176
|
+
* All angles are in **degrees** (unlike the legacy `makeEllipseArc` which used radians).
|
|
177
|
+
*
|
|
178
|
+
* @param startAngle - Start angle in degrees.
|
|
179
|
+
* @param endAngle - End angle in degrees.
|
|
180
|
+
*/
|
|
181
|
+
function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
|
|
182
|
+
const axisDir = options?.axis ?? [
|
|
183
|
+
0,
|
|
184
|
+
0,
|
|
185
|
+
1
|
|
186
|
+
];
|
|
187
|
+
return makeEllipseArc(majorRadius, minorRadius, startAngle * DEG2RAD, endAngle * DEG2RAD, options?.at ?? [
|
|
188
|
+
0,
|
|
189
|
+
0,
|
|
190
|
+
0
|
|
191
|
+
], axisDir, options?.xDir);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create a B-spline edge that approximates a set of 3D points.
|
|
195
|
+
*
|
|
196
|
+
* @returns An error if the approximation algorithm fails.
|
|
197
|
+
*/
|
|
198
|
+
function bsplineApprox(points, config) {
|
|
199
|
+
return makeBSplineApproximation(points, config);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Create a Bezier curve edge from control points.
|
|
203
|
+
*
|
|
204
|
+
* @param points - Two or more control points.
|
|
205
|
+
*/
|
|
206
|
+
function bezier(points) {
|
|
207
|
+
return makeBezierCurve(points);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Create a circular arc edge tangent to a direction at the start point.
|
|
211
|
+
*/
|
|
212
|
+
function tangentArc(startPoint, startTgt, endPoint) {
|
|
213
|
+
return makeTangentArc(startPoint, startTgt, endPoint);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Assemble edges and/or wires into a single connected wire.
|
|
217
|
+
*/
|
|
218
|
+
function wire(listOfEdges) {
|
|
219
|
+
return assembleWire(listOfEdges);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Assemble edges into a wire and verify it forms a closed loop.
|
|
223
|
+
*
|
|
224
|
+
* Combines {@link wire} + the `closedWire` smart constructor in a single step.
|
|
225
|
+
* Returns an error if the edges cannot be assembled or the wire is not closed.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```ts
|
|
229
|
+
* const cw = unwrap(wireLoop([e1, e2, e3, e4]));
|
|
230
|
+
* const f = unwrap(face(cw)); // ClosedWire accepted directly
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
function wireLoop(listOfEdges) {
|
|
234
|
+
return andThen(assembleWire(listOfEdges), (w) => {
|
|
235
|
+
if (isClosedWire(w)) return ok(w);
|
|
236
|
+
return err(validationError("WIRE_NOT_CLOSED", "Assembled wire is not closed: start and end points do not coincide"));
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Create a planar face from a closed wire, optionally with holes.
|
|
241
|
+
* The resulting face is always oriented (consistent normal direction).
|
|
242
|
+
*/
|
|
243
|
+
function face(w, holes) {
|
|
244
|
+
return makeFace(w, holes);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Create a non-planar face from a wire using surface filling.
|
|
248
|
+
* The resulting face is always oriented.
|
|
249
|
+
*/
|
|
250
|
+
function filledFace(w) {
|
|
251
|
+
return makeNonPlanarFace(w);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Create a face bounded by a wire on an existing face's surface.
|
|
255
|
+
* The resulting face inherits orientation from the origin face.
|
|
256
|
+
*/
|
|
257
|
+
function subFace(originFace, w) {
|
|
258
|
+
return makeNewFaceWithinFace(originFace, w);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Create a polygonal face from three or more coplanar points.
|
|
262
|
+
* The resulting face is always oriented.
|
|
263
|
+
*/
|
|
264
|
+
function polygon(points) {
|
|
265
|
+
return makePolygon(points);
|
|
266
|
+
}
|
|
267
|
+
/** Create a vertex at a 3D point. */
|
|
268
|
+
function vertex(point) {
|
|
269
|
+
return makeVertex(point);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Build a compound from multiple shapes.
|
|
273
|
+
*/
|
|
274
|
+
function compound(shapeArray) {
|
|
275
|
+
return makeCompound(shapeArray);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Weld faces and shells into a single solid.
|
|
279
|
+
* The resulting solid is always validated.
|
|
280
|
+
*/
|
|
281
|
+
function solid(facesOrShells) {
|
|
282
|
+
return makeSolid(facesOrShells);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Create an offset shape from a face.
|
|
286
|
+
*/
|
|
287
|
+
function offsetFace(f, distance, tolerance) {
|
|
288
|
+
return makeOffset(f, distance, tolerance);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Weld faces and shells into a single shell.
|
|
292
|
+
*/
|
|
293
|
+
function sewShells(facesOrShells, ignoreType) {
|
|
294
|
+
return weldShellsAndFaces(facesOrShells, ignoreType);
|
|
295
|
+
}
|
|
296
|
+
function addHoles(f, holes) {
|
|
297
|
+
return addHolesInFace(f, holes);
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
export { threePointArc as C, wireLoop as D, wire as E, 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, 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 };
|