brepjs 18.20.5 → 18.22.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.
- package/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{blueprint-B6vmOy5_.cjs → blueprint-BRsNfnfQ.cjs} +5 -5
- package/dist/{blueprint-0bBVK6Be.js → blueprint-CQ04Ov5Z.js} +5 -5
- package/dist/{blueprintFns-Aiise3pc.cjs → blueprintFns-C5DCLCtZ.cjs} +2 -2
- package/dist/{blueprintFns-BJbTjW94.js → blueprintFns-DpPZNhFx.js} +2 -2
- package/dist/{blueprintSketcher-D_Z8NfOF.cjs → blueprintSketcher-DaF5OR4M.cjs} +3 -3
- package/dist/{blueprintSketcher-BkZrvGoG.js → blueprintSketcher-OwXVDMOb.js} +3 -3
- package/dist/{boolean2D-BAJ3efk_.js → boolean2D-BQKMy6dN.js} +4 -4
- package/dist/{boolean2D-1gc4kqNS.cjs → boolean2D-gwOq0VXi.cjs} +4 -4
- package/dist/{booleanFns-BsjoPJAS.js → booleanFns-CuXl5XQP.js} +4 -4
- package/dist/{booleanFns-D3mYqZxL.cjs → booleanFns-cmeKRsth.cjs} +4 -4
- package/dist/brepjs.cjs +24 -24
- package/dist/brepjs.js +24 -24
- package/dist/{cameraFns-QK8ahyDz.js → cameraFns-DC2ShyXC.js} +2 -2
- package/dist/{cameraFns-DgTBC2w3.cjs → cameraFns-LurBny3f.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-CkLZ23Kp.cjs → cornerFinder-BjjFVnDq.cjs} +1 -1
- package/dist/{cornerFinder-BaSsAk69.js → cornerFinder-CF8fVEx2.js} +1 -1
- package/dist/{curveFns-CE3b2sDD.cjs → curveFns-BR8gQOAc.cjs} +1 -1
- package/dist/{curveFns-BiSx9FTh.js → curveFns-Cimni2kq.js} +1 -1
- package/dist/{drawFns-BtHAHYa-.js → drawFns-Bh1LGuSX.js} +12 -12
- package/dist/{drawFns-BaxDgrlX.cjs → drawFns-btYAn61y.cjs} +12 -12
- package/dist/{extrudeFns-CRG478Q3.js → extrudeFns-BmF17qhf.js} +1 -1
- package/dist/{extrudeFns-DUPpueiL.cjs → extrudeFns-CLrrRprF.cjs} +1 -1
- package/dist/{faceFns-CLzDRrUE.cjs → faceFns-BFEUkmn7.cjs} +2 -2
- package/dist/{faceFns-C3C6l-X0.js → faceFns-D9UAkqPb.js} +2 -2
- package/dist/{helpers-DwG3OFk0.cjs → helpers-BnF1MObz.cjs} +6 -6
- package/dist/{helpers-rNVdiDLn.js → helpers-DnrXynu0.js} +6 -6
- package/dist/{historyFns-DSCnjCkQ.cjs → historyFns-BX9Bu5NT.cjs} +4 -4
- package/dist/{historyFns-CEr9D6ay.js → historyFns-DGDKVD6-.js} +4 -4
- package/dist/{importFns-Hh3S9NPm.js → importFns-B9RUaVsc.js} +191 -139
- package/dist/{importFns-A8v4Pdw2.cjs → importFns-BMN4KCmX.cjs} +191 -139
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occt/advancedOps.d.ts +9 -13
- package/dist/{measureFns-DMyJp_x3.cjs → measureFns-CaOR1TEA.cjs} +3 -3
- package/dist/{measureFns--uvW_r_P.js → measureFns-CiCx5o_s.js} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-DTn__aNb.cjs → meshFns-CIdP0f35.cjs} +2 -2
- package/dist/{meshFns-Bxt57KX1.js → meshFns-k-gSXquL.js} +2 -2
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{primitiveFns-CX5c_YGt.cjs → primitiveFns-Ds2LNkol.cjs} +55 -34
- package/dist/{primitiveFns-w1zNsxTH.js → primitiveFns-OvPYb4CU.js} +55 -34
- 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-cTuUm-aP.cjs → shapeFns-BD6oYLMM.cjs} +2 -2
- package/dist/{shapeFns-Dsxp5d_u.js → shapeFns-ByuSx62n.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-zFWzAmQZ.js → shapeRefFns-Bv3Jj1vz.js} +4 -4
- package/dist/{shapeRefFns-SctbRFju.cjs → shapeRefFns-CybMlSCu.cjs} +4 -4
- package/dist/{shapeTypes-DmHPJc_M.js → shapeTypes-BdIQ-d5X.js} +119 -127
- package/dist/{shapeTypes-C1FUZ2zE.cjs → shapeTypes-D6hfaPZq.cjs} +119 -127
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-BGJvTrDt.cjs → solidBuilders-DAHTAqeh.cjs} +2 -2
- package/dist/{solidBuilders-CJ8ckc61.js → solidBuilders-TJZOIga_.js} +2 -2
- package/dist/{surfaceBuilders-B7A2uoBJ.cjs → surfaceBuilders-CzRFME5_.cjs} +2 -2
- package/dist/{surfaceBuilders-B_wXW8QS.js → surfaceBuilders-rNgtRqTR.js} +2 -2
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-LYHgEdsx.js → textBlueprints-C9eKTxef.js} +7 -7
- package/dist/{textBlueprints-BCTQk9T8.cjs → textBlueprints-D7gWCZ88.cjs} +7 -7
- package/dist/{textMetrics-Dd-Vva8S.js → textMetrics-0y73spLE.js} +1 -1
- package/dist/{textMetrics-BNfyRNxm.cjs → textMetrics-B5SN90x5.cjs} +1 -1
- package/dist/topology.cjs +7 -7
- package/dist/topology.js +7 -7
- package/dist/{topologyQueryFns-CcHXn5M2.js → topologyQueryFns-Ds2H75YB.js} +1 -1
- package/dist/{topologyQueryFns-DCICDnwA.cjs → topologyQueryFns-hG0APAJN.cjs} +1 -1
- package/package.json +2 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D6hfaPZq.cjs");
|
|
2
2
|
const require_errors = require("./errors-DxoD7zgx.cjs");
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-hG0APAJN.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
|
-
const require_faceFns = require("./faceFns-
|
|
6
|
-
const require_shapeFns = require("./shapeFns-
|
|
5
|
+
const require_faceFns = require("./faceFns-BFEUkmn7.cjs");
|
|
6
|
+
const require_shapeFns = require("./shapeFns-BD6oYLMM.cjs");
|
|
7
7
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
8
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
9
|
-
const require_booleanFns = require("./booleanFns-
|
|
10
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
8
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CzRFME5_.cjs");
|
|
9
|
+
const require_booleanFns = require("./booleanFns-cmeKRsth.cjs");
|
|
10
|
+
const require_solidBuilders = require("./solidBuilders-DAHTAqeh.cjs");
|
|
11
11
|
//#region src/topology/threeHelpers.ts
|
|
12
12
|
/**
|
|
13
13
|
* Convert a ShapeMesh into BufferGeometry-compatible typed arrays.
|
|
@@ -852,13 +852,10 @@ function thicken(shape, thickness) {
|
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* @param shape - The shape to modify.
|
|
858
|
-
* @param edges - Edges to fillet. Pass `undefined` to fillet all edges.
|
|
859
|
-
* @param radius - Constant radius, variable radius `[r1, r2]`, or per-edge callback.
|
|
855
|
+
* Validate fillet inputs and resolve the user-supplied radius into a
|
|
856
|
+
* kernel-ready value paired with the filtered edge list.
|
|
860
857
|
*/
|
|
861
|
-
function
|
|
858
|
+
function normalizeFilletInputs(shape, edges, radius) {
|
|
862
859
|
const check = validateNotNull(shape, "fillet: shape");
|
|
863
860
|
if (require_errors.isErr(check)) return check;
|
|
864
861
|
const paramErr = validatePositiveParam(radius, {
|
|
@@ -871,30 +868,46 @@ function fillet(shape, edges, radius, { trackEvolution = true } = {}) {
|
|
|
871
868
|
if (paramErr) return paramErr;
|
|
872
869
|
const selectedEdges = edges ?? require_topologyQueryFns.getEdges(shape);
|
|
873
870
|
if (selectedEdges.length === 0) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.FILLET_NO_EDGES, "No edges found for fillet", void 0, void 0, "Check that the shape has edges, or adjust your edge finder criteria"));
|
|
871
|
+
if (typeof radius === "function") {
|
|
872
|
+
const resolved = resolveEdgeCallback(selectedEdges, radius);
|
|
873
|
+
if (!resolved) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.FILLET_NO_EDGES, "No edges with positive radius for fillet", void 0, void 0, "Check that the radius callback returns positive values"));
|
|
874
|
+
return require_errors.ok({
|
|
875
|
+
filteredEdges: resolved.edges,
|
|
876
|
+
kernelRadius: resolved.kernelParam,
|
|
877
|
+
selectedCount: selectedEdges.length
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
return require_errors.ok({
|
|
881
|
+
filteredEdges: [...selectedEdges],
|
|
882
|
+
kernelRadius: radius,
|
|
883
|
+
selectedCount: selectedEdges.length
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Apply a fillet (rounded edge) to selected edges of a 3D shape.
|
|
888
|
+
*
|
|
889
|
+
* @param shape - The shape to modify.
|
|
890
|
+
* @param edges - Edges to fillet. Pass `undefined` to fillet all edges.
|
|
891
|
+
* @param radius - Constant radius, variable radius `[r1, r2]`, or per-edge callback.
|
|
892
|
+
*/
|
|
893
|
+
function fillet(shape, edges, radius, { trackEvolution = true } = {}) {
|
|
894
|
+
const normalized = normalizeFilletInputs(shape, edges, radius);
|
|
895
|
+
if (require_errors.isErr(normalized)) return normalized;
|
|
896
|
+
const { filteredEdges, kernelRadius, selectedCount } = normalized.value;
|
|
874
897
|
try {
|
|
875
|
-
|
|
876
|
-
let kernelRadius;
|
|
877
|
-
if (typeof radius === "function") {
|
|
878
|
-
const resolved = resolveEdgeCallback(selectedEdges, radius);
|
|
879
|
-
if (!resolved) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.FILLET_NO_EDGES, "No edges with positive radius for fillet", void 0, void 0, "Check that the radius callback returns positive values"));
|
|
880
|
-
filteredEdges = resolved.edges;
|
|
881
|
-
kernelRadius = resolved.kernelParam;
|
|
882
|
-
} else {
|
|
883
|
-
filteredEdges = [...selectedEdges];
|
|
884
|
-
kernelRadius = radius;
|
|
885
|
-
}
|
|
898
|
+
const edgeShapes = filteredEdges.map((e) => e.wrapped);
|
|
886
899
|
if (!trackEvolution) {
|
|
887
|
-
const cast = require_shapeTypes.castShape(require_shapeTypes.getKernel().fillet(shape.wrapped,
|
|
900
|
+
const cast = require_shapeTypes.castShape(require_shapeTypes.getKernel().fillet(shape.wrapped, edgeShapes, kernelRadius));
|
|
888
901
|
if (!require_shapeTypes.isShape3D(cast)) return require_errors.err(require_errors.kernelError(require_errors.BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape"));
|
|
889
902
|
return require_errors.ok(cast);
|
|
890
903
|
}
|
|
891
904
|
const inputFaceHashes = require_shapeFns.collectInputFaceHashes([shape]);
|
|
892
|
-
const { shape: resultShape, evolution } = require_shapeTypes.getKernel().filletWithHistory(shape.wrapped,
|
|
905
|
+
const { shape: resultShape, evolution } = require_shapeTypes.getKernel().filletWithHistory(shape.wrapped, edgeShapes, kernelRadius, inputFaceHashes, require_constants.HASH_CODE_MAX);
|
|
893
906
|
return finalizeShape3D(evolution, resultShape, [shape], require_errors.BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape");
|
|
894
907
|
} catch (e) {
|
|
895
908
|
return require_errors.err(require_errors.kernelError("FILLET_FAILED", `Fillet operation failed: ${e instanceof Error ? e.message : String(e)}`, e, {
|
|
896
909
|
operation: "fillet",
|
|
897
|
-
edgeCount:
|
|
910
|
+
edgeCount: selectedCount,
|
|
898
911
|
radius
|
|
899
912
|
}));
|
|
900
913
|
}
|
|
@@ -998,6 +1011,19 @@ function offset(shape, distance, tolerance = 1e-6) {
|
|
|
998
1011
|
}
|
|
999
1012
|
}
|
|
1000
1013
|
/**
|
|
1014
|
+
* Validate draft inputs (null shape, scalar angle bounds, faces non-empty).
|
|
1015
|
+
* Returns an Err Result on failure, `undefined` on success.
|
|
1016
|
+
*/
|
|
1017
|
+
function validateDraftInputs(shape, faces, angle) {
|
|
1018
|
+
const check = validateNotNull(shape, "draft: shape");
|
|
1019
|
+
if (require_errors.isErr(check)) return check;
|
|
1020
|
+
if (typeof angle === "number") {
|
|
1021
|
+
if (Math.abs(angle) < 1e-10) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle cannot be zero", void 0, void 0, "Provide a non-zero angle in degrees"));
|
|
1022
|
+
if (Math.abs(angle) >= 90) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle must be between -90 and 90 degrees (exclusive)", void 0, void 0, "Typical draft angles are 1-5 degrees for injection molding"));
|
|
1023
|
+
}
|
|
1024
|
+
if (faces.length === 0) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_NO_FACES, "No faces specified for draft", void 0, void 0, "Select at least one face to apply the draft angle to"));
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1001
1027
|
* Apply a draft (taper) to selected faces of a 3D shape.
|
|
1002
1028
|
*
|
|
1003
1029
|
* Draft tilts faces by a specified angle relative to a pull direction,
|
|
@@ -1011,13 +1037,8 @@ function offset(shape, distance, tolerance = 1e-6) {
|
|
|
1011
1037
|
* @param angle - Constant angle in degrees, or per-face callback returning degrees (null to skip).
|
|
1012
1038
|
*/
|
|
1013
1039
|
function draft(shape, faces, pullDirection, neutralPlane, angle) {
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
if (typeof angle === "number") {
|
|
1017
|
-
if (Math.abs(angle) < 1e-10) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle cannot be zero", void 0, void 0, "Provide a non-zero angle in degrees"));
|
|
1018
|
-
if (Math.abs(angle) >= 90) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle must be between -90 and 90 degrees (exclusive)", void 0, void 0, "Typical draft angles are 1-5 degrees for injection molding"));
|
|
1019
|
-
}
|
|
1020
|
-
if (faces.length === 0) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_NO_FACES, "No faces specified for draft", void 0, void 0, "Select at least one face to apply the draft angle to"));
|
|
1040
|
+
const inputErr = validateDraftInputs(shape, faces, angle);
|
|
1041
|
+
if (inputErr) return inputErr;
|
|
1021
1042
|
try {
|
|
1022
1043
|
const { filteredFaces, kernelAngle } = resolveDraftCallback(faces, angle);
|
|
1023
1044
|
if (filteredFaces.length === 0) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.DRAFT_NO_FACES, "No faces with valid draft angle", void 0, void 0, "Check that the angle callback returns non-zero values between -90 and 90 degrees"));
|
|
@@ -1,13 +1,13 @@
|
|
|
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-
|
|
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-BdIQ-d5X.js";
|
|
2
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-BJSTLaDI.js";
|
|
3
|
-
import { c as getOrCreateCache, d as invalidateShapeCache, i as getCachedIsValid, o as getEdges, s as getFaces, u as getWires } from "./topologyQueryFns-
|
|
3
|
+
import { c as getOrCreateCache, d as invalidateShapeCache, i as getCachedIsValid, o as getEdges, s as getFaces, u as getWires } from "./topologyQueryFns-Ds2H75YB.js";
|
|
4
4
|
import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
|
-
import { _ as downcast } from "./faceFns-
|
|
6
|
-
import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate } from "./shapeFns-
|
|
5
|
+
import { _ as downcast } from "./faceFns-D9UAkqPb.js";
|
|
6
|
+
import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate } from "./shapeFns-ByuSx62n.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-
|
|
9
|
-
import { a as fuseAll, i as fuse, n as cut, r as cutAll } from "./booleanFns-
|
|
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-
|
|
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-rNgtRqTR.js";
|
|
9
|
+
import { a as fuseAll, i as fuse, n as cut, r as cutAll } from "./booleanFns-CuXl5XQP.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-TJZOIga_.js";
|
|
11
11
|
//#region src/topology/threeHelpers.ts
|
|
12
12
|
/**
|
|
13
13
|
* Convert a ShapeMesh into BufferGeometry-compatible typed arrays.
|
|
@@ -852,13 +852,10 @@ function thicken(shape, thickness) {
|
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
854
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
857
|
-
* @param shape - The shape to modify.
|
|
858
|
-
* @param edges - Edges to fillet. Pass `undefined` to fillet all edges.
|
|
859
|
-
* @param radius - Constant radius, variable radius `[r1, r2]`, or per-edge callback.
|
|
855
|
+
* Validate fillet inputs and resolve the user-supplied radius into a
|
|
856
|
+
* kernel-ready value paired with the filtered edge list.
|
|
860
857
|
*/
|
|
861
|
-
function
|
|
858
|
+
function normalizeFilletInputs(shape, edges, radius) {
|
|
862
859
|
const check = validateNotNull(shape, "fillet: shape");
|
|
863
860
|
if (isErr(check)) return check;
|
|
864
861
|
const paramErr = validatePositiveParam(radius, {
|
|
@@ -871,30 +868,46 @@ function fillet(shape, edges, radius, { trackEvolution = true } = {}) {
|
|
|
871
868
|
if (paramErr) return paramErr;
|
|
872
869
|
const selectedEdges = edges ?? getEdges(shape);
|
|
873
870
|
if (selectedEdges.length === 0) return err(validationError(BrepErrorCode.FILLET_NO_EDGES, "No edges found for fillet", void 0, void 0, "Check that the shape has edges, or adjust your edge finder criteria"));
|
|
871
|
+
if (typeof radius === "function") {
|
|
872
|
+
const resolved = resolveEdgeCallback(selectedEdges, radius);
|
|
873
|
+
if (!resolved) return err(validationError(BrepErrorCode.FILLET_NO_EDGES, "No edges with positive radius for fillet", void 0, void 0, "Check that the radius callback returns positive values"));
|
|
874
|
+
return ok({
|
|
875
|
+
filteredEdges: resolved.edges,
|
|
876
|
+
kernelRadius: resolved.kernelParam,
|
|
877
|
+
selectedCount: selectedEdges.length
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
return ok({
|
|
881
|
+
filteredEdges: [...selectedEdges],
|
|
882
|
+
kernelRadius: radius,
|
|
883
|
+
selectedCount: selectedEdges.length
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Apply a fillet (rounded edge) to selected edges of a 3D shape.
|
|
888
|
+
*
|
|
889
|
+
* @param shape - The shape to modify.
|
|
890
|
+
* @param edges - Edges to fillet. Pass `undefined` to fillet all edges.
|
|
891
|
+
* @param radius - Constant radius, variable radius `[r1, r2]`, or per-edge callback.
|
|
892
|
+
*/
|
|
893
|
+
function fillet(shape, edges, radius, { trackEvolution = true } = {}) {
|
|
894
|
+
const normalized = normalizeFilletInputs(shape, edges, radius);
|
|
895
|
+
if (isErr(normalized)) return normalized;
|
|
896
|
+
const { filteredEdges, kernelRadius, selectedCount } = normalized.value;
|
|
874
897
|
try {
|
|
875
|
-
|
|
876
|
-
let kernelRadius;
|
|
877
|
-
if (typeof radius === "function") {
|
|
878
|
-
const resolved = resolveEdgeCallback(selectedEdges, radius);
|
|
879
|
-
if (!resolved) return err(validationError(BrepErrorCode.FILLET_NO_EDGES, "No edges with positive radius for fillet", void 0, void 0, "Check that the radius callback returns positive values"));
|
|
880
|
-
filteredEdges = resolved.edges;
|
|
881
|
-
kernelRadius = resolved.kernelParam;
|
|
882
|
-
} else {
|
|
883
|
-
filteredEdges = [...selectedEdges];
|
|
884
|
-
kernelRadius = radius;
|
|
885
|
-
}
|
|
898
|
+
const edgeShapes = filteredEdges.map((e) => e.wrapped);
|
|
886
899
|
if (!trackEvolution) {
|
|
887
|
-
const cast = castShape(getKernel().fillet(shape.wrapped,
|
|
900
|
+
const cast = castShape(getKernel().fillet(shape.wrapped, edgeShapes, kernelRadius));
|
|
888
901
|
if (!isShape3D(cast)) return err(kernelError(BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape"));
|
|
889
902
|
return ok(cast);
|
|
890
903
|
}
|
|
891
904
|
const inputFaceHashes = collectInputFaceHashes([shape]);
|
|
892
|
-
const { shape: resultShape, evolution } = getKernel().filletWithHistory(shape.wrapped,
|
|
905
|
+
const { shape: resultShape, evolution } = getKernel().filletWithHistory(shape.wrapped, edgeShapes, kernelRadius, inputFaceHashes, HASH_CODE_MAX);
|
|
893
906
|
return finalizeShape3D(evolution, resultShape, [shape], BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape");
|
|
894
907
|
} catch (e) {
|
|
895
908
|
return err(kernelError("FILLET_FAILED", `Fillet operation failed: ${e instanceof Error ? e.message : String(e)}`, e, {
|
|
896
909
|
operation: "fillet",
|
|
897
|
-
edgeCount:
|
|
910
|
+
edgeCount: selectedCount,
|
|
898
911
|
radius
|
|
899
912
|
}));
|
|
900
913
|
}
|
|
@@ -998,6 +1011,19 @@ function offset(shape, distance, tolerance = 1e-6) {
|
|
|
998
1011
|
}
|
|
999
1012
|
}
|
|
1000
1013
|
/**
|
|
1014
|
+
* Validate draft inputs (null shape, scalar angle bounds, faces non-empty).
|
|
1015
|
+
* Returns an Err Result on failure, `undefined` on success.
|
|
1016
|
+
*/
|
|
1017
|
+
function validateDraftInputs(shape, faces, angle) {
|
|
1018
|
+
const check = validateNotNull(shape, "draft: shape");
|
|
1019
|
+
if (isErr(check)) return check;
|
|
1020
|
+
if (typeof angle === "number") {
|
|
1021
|
+
if (Math.abs(angle) < 1e-10) return err(validationError(BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle cannot be zero", void 0, void 0, "Provide a non-zero angle in degrees"));
|
|
1022
|
+
if (Math.abs(angle) >= 90) return err(validationError(BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle must be between -90 and 90 degrees (exclusive)", void 0, void 0, "Typical draft angles are 1-5 degrees for injection molding"));
|
|
1023
|
+
}
|
|
1024
|
+
if (faces.length === 0) return err(validationError(BrepErrorCode.DRAFT_NO_FACES, "No faces specified for draft", void 0, void 0, "Select at least one face to apply the draft angle to"));
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1001
1027
|
* Apply a draft (taper) to selected faces of a 3D shape.
|
|
1002
1028
|
*
|
|
1003
1029
|
* Draft tilts faces by a specified angle relative to a pull direction,
|
|
@@ -1011,13 +1037,8 @@ function offset(shape, distance, tolerance = 1e-6) {
|
|
|
1011
1037
|
* @param angle - Constant angle in degrees, or per-face callback returning degrees (null to skip).
|
|
1012
1038
|
*/
|
|
1013
1039
|
function draft(shape, faces, pullDirection, neutralPlane, angle) {
|
|
1014
|
-
const
|
|
1015
|
-
if (
|
|
1016
|
-
if (typeof angle === "number") {
|
|
1017
|
-
if (Math.abs(angle) < 1e-10) return err(validationError(BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle cannot be zero", void 0, void 0, "Provide a non-zero angle in degrees"));
|
|
1018
|
-
if (Math.abs(angle) >= 90) return err(validationError(BrepErrorCode.DRAFT_INVALID_ANGLE, "Draft angle must be between -90 and 90 degrees (exclusive)", void 0, void 0, "Typical draft angles are 1-5 degrees for injection molding"));
|
|
1019
|
-
}
|
|
1020
|
-
if (faces.length === 0) return err(validationError(BrepErrorCode.DRAFT_NO_FACES, "No faces specified for draft", void 0, void 0, "Select at least one face to apply the draft angle to"));
|
|
1040
|
+
const inputErr = validateDraftInputs(shape, faces, angle);
|
|
1041
|
+
if (inputErr) return inputErr;
|
|
1021
1042
|
try {
|
|
1022
1043
|
const { filteredFaces, kernelAngle } = resolveDraftCallback(faces, angle);
|
|
1023
1044
|
if (filteredFaces.length === 0) return err(validationError(BrepErrorCode.DRAFT_NO_FACES, "No faces with valid draft angle", void 0, void 0, "Check that the angle callback returns non-zero values between -90 and 90 degrees"));
|
package/dist/projection.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cameraFns = require("./cameraFns-
|
|
2
|
+
const require_cameraFns = require("./cameraFns-LurBny3f.cjs");
|
|
3
3
|
exports.PROJECTION_PLANES = require_cameraFns.PROJECTION_PLANES;
|
|
4
4
|
exports.cameraFromPlane = require_cameraFns.cameraFromPlane;
|
|
5
5
|
exports.cameraLookAt = require_cameraFns.cameraLookAt;
|
package/dist/projection.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-
|
|
1
|
+
import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-DC2ShyXC.js";
|
|
2
2
|
export { PROJECTION_PLANES, cameraFromPlane, cameraLookAt, createCamera, isProjectionPlane, makeProjectedEdges, projectEdges };
|
package/dist/query.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helpers = require("./helpers-
|
|
3
|
-
const require_cornerFinder = require("./cornerFinder-
|
|
2
|
+
const require_helpers = require("./helpers-BnF1MObz.cjs");
|
|
3
|
+
const require_cornerFinder = require("./cornerFinder-BjjFVnDq.cjs");
|
|
4
4
|
exports.cornerFinder = require_cornerFinder.cornerFinder;
|
|
5
5
|
exports.edgeFinder = require_helpers.edgeFinder;
|
|
6
6
|
exports.faceFinder = require_helpers.faceFinder;
|
package/dist/query.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-
|
|
2
|
-
import { t as cornerFinder } from "./cornerFinder-
|
|
1
|
+
import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-DnrXynu0.js";
|
|
2
|
+
import { t as cornerFinder } from "./cornerFinder-CF8fVEx2.js";
|
|
3
3
|
export { cornerFinder, edgeFinder, faceFinder, getSingleFace };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D6hfaPZq.cjs");
|
|
2
2
|
const require_errors = require("./errors-DxoD7zgx.cjs");
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-hG0APAJN.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
//#region src/topology/metadata/originTrackingFns.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Z as getKernel, t as castShape } from "./shapeTypes-
|
|
1
|
+
import { Z as getKernel, t as castShape } from "./shapeTypes-BdIQ-d5X.js";
|
|
2
2
|
import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-BJSTLaDI.js";
|
|
3
|
-
import { _ as kernelCall, c as getOrCreateCache, r as getCacheEntry, s as getFaces, v as kernelCallRaw } from "./topologyQueryFns-
|
|
3
|
+
import { _ as kernelCall, c as getOrCreateCache, r as getCacheEntry, s as getFaces, v as kernelCallRaw } from "./topologyQueryFns-Ds2H75YB.js";
|
|
4
4
|
import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
//#region src/topology/metadata/originTrackingFns.ts
|
|
6
6
|
/**
|
package/dist/shapeRef.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shapeRefFns = require("./shapeRefFns-
|
|
2
|
+
const require_shapeRefFns = require("./shapeRefFns-CybMlSCu.cjs");
|
|
3
3
|
exports.assignRoles = require_shapeRefFns.assignRoles;
|
|
4
4
|
exports.captureHint = require_shapeRefFns.captureHint;
|
|
5
5
|
exports.createRef = require_shapeRefFns.createRef;
|
package/dist/shapeRef.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as updateRoles, i as resolveRef, n as captureHint, o as defaultScorer, r as createRef, t as assignRoles } from "./shapeRefFns-
|
|
1
|
+
import { a as updateRoles, i as resolveRef, n as captureHint, o as defaultScorer, r as createRef, t as assignRoles } from "./shapeRefFns-Bv3Jj1vz.js";
|
|
2
2
|
export { assignRoles, captureHint, createRef, defaultScorer, resolveRef, updateRoles };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
|
|
2
|
-
import { s as getFaces } from "./topologyQueryFns-
|
|
3
|
-
import { c as normalAt, n as faceCenter, r as faceGeomType } from "./faceFns-
|
|
4
|
-
import { n as getHashCode } from "./shapeFns-
|
|
5
|
-
import { n as measureArea } from "./measureFns
|
|
2
|
+
import { s as getFaces } from "./topologyQueryFns-Ds2H75YB.js";
|
|
3
|
+
import { c as normalAt, n as faceCenter, r as faceGeomType } from "./faceFns-D9UAkqPb.js";
|
|
4
|
+
import { n as getHashCode } from "./shapeFns-ByuSx62n.js";
|
|
5
|
+
import { n as measureArea } from "./measureFns-CiCx5o_s.js";
|
|
6
6
|
//#region src/topology/shapeRef/scoring.ts
|
|
7
7
|
/**
|
|
8
8
|
* Default face scorer combining surface type, normal alignment, centroid proximity,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
|
|
2
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
-
const require_faceFns = require("./faceFns-
|
|
4
|
-
const require_shapeFns = require("./shapeFns-
|
|
5
|
-
const require_measureFns = require("./measureFns-
|
|
2
|
+
const require_topologyQueryFns = require("./topologyQueryFns-hG0APAJN.cjs");
|
|
3
|
+
const require_faceFns = require("./faceFns-BFEUkmn7.cjs");
|
|
4
|
+
const require_shapeFns = require("./shapeFns-BD6oYLMM.cjs");
|
|
5
|
+
const require_measureFns = require("./measureFns-CaOR1TEA.cjs");
|
|
6
6
|
//#region src/topology/shapeRef/scoring.ts
|
|
7
7
|
/**
|
|
8
8
|
* Default face scorer combining surface type, normal alignment, centroid proximity,
|
|
@@ -4181,23 +4181,8 @@ function fixSelfIntersection$1(oc, wire) {
|
|
|
4181
4181
|
fixer.delete();
|
|
4182
4182
|
return result;
|
|
4183
4183
|
}
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
const adaptor = new oc.BRepAdaptor_Surface_2(face, false);
|
|
4187
|
-
const P = new oc.gp_Pnt_1();
|
|
4188
|
-
const D1U = new oc.gp_Vec_1();
|
|
4189
|
-
const D1V = new oc.gp_Vec_1();
|
|
4190
|
-
const D2U = new oc.gp_Vec_1();
|
|
4191
|
-
const D2V = new oc.gp_Vec_1();
|
|
4192
|
-
const D2UV = new oc.gp_Vec_1();
|
|
4193
|
-
adaptor.D2(u, v, P, D1U, D1V, D2U, D2V, D2UV);
|
|
4194
|
-
const E = D1U.Dot(D1U);
|
|
4195
|
-
const F = D1U.Dot(D1V);
|
|
4196
|
-
const G = D1V.Dot(D1V);
|
|
4197
|
-
const N = D1U.Crossed(D1V);
|
|
4198
|
-
const nLen = N.Magnitude();
|
|
4199
|
-
let result;
|
|
4200
|
-
if (nLen < 1e-15) result = {
|
|
4184
|
+
function degenerateCurvature() {
|
|
4185
|
+
return {
|
|
4201
4186
|
gaussian: 0,
|
|
4202
4187
|
mean: 0,
|
|
4203
4188
|
max: 0,
|
|
@@ -4213,65 +4198,69 @@ function surfaceCurvature$1(oc, face, u, v) {
|
|
|
4213
4198
|
0
|
|
4214
4199
|
]
|
|
4215
4200
|
};
|
|
4216
|
-
|
|
4201
|
+
}
|
|
4202
|
+
/**
|
|
4203
|
+
* Solve principal curvatures and one principal direction in (du, dv) coords
|
|
4204
|
+
* from the first and second fundamental forms. Returns null if the system is
|
|
4205
|
+
* degenerate (E*G - F*F ≈ 0).
|
|
4206
|
+
*/
|
|
4207
|
+
function solvePrincipalCurvatures(E, F, G, L, M, N2) {
|
|
4208
|
+
const denom = E * G - F * F;
|
|
4209
|
+
if (Math.abs(denom) < 1e-15) return null;
|
|
4210
|
+
const mean = (E * N2 - 2 * F * M + G * L) / (2 * denom);
|
|
4211
|
+
const gaussian = (L * N2 - M * M) / denom;
|
|
4212
|
+
const sqrtDisc = Math.sqrt(Math.max(0, mean * mean - gaussian));
|
|
4213
|
+
const k1 = mean + sqrtDisc;
|
|
4214
|
+
const k2 = mean - sqrtDisc;
|
|
4215
|
+
const a12 = (G * M - F * N2) / denom;
|
|
4216
|
+
const a21 = (E * M - F * L) / denom;
|
|
4217
|
+
const a11 = (G * L - F * M) / denom;
|
|
4218
|
+
let du1, dv1;
|
|
4219
|
+
if (Math.abs(a12) > 1e-15) {
|
|
4220
|
+
du1 = a12;
|
|
4221
|
+
dv1 = k1 - a11;
|
|
4222
|
+
} else if (Math.abs(a21) > 1e-15) {
|
|
4223
|
+
du1 = k1 - (E * N2 - F * M) / denom;
|
|
4224
|
+
dv1 = a21;
|
|
4225
|
+
} else {
|
|
4226
|
+
du1 = 1;
|
|
4227
|
+
dv1 = 0;
|
|
4228
|
+
}
|
|
4229
|
+
return {
|
|
4230
|
+
mean,
|
|
4231
|
+
gaussian,
|
|
4232
|
+
k1,
|
|
4233
|
+
k2,
|
|
4234
|
+
du1,
|
|
4235
|
+
dv1
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
/** Compute surface curvature at a UV point on a face. */
|
|
4239
|
+
function surfaceCurvature$1(oc, face, u, v) {
|
|
4240
|
+
const adaptor = new oc.BRepAdaptor_Surface_2(face, false);
|
|
4241
|
+
const P = new oc.gp_Pnt_1();
|
|
4242
|
+
const D1U = new oc.gp_Vec_1();
|
|
4243
|
+
const D1V = new oc.gp_Vec_1();
|
|
4244
|
+
const D2U = new oc.gp_Vec_1();
|
|
4245
|
+
const D2V = new oc.gp_Vec_1();
|
|
4246
|
+
const D2UV = new oc.gp_Vec_1();
|
|
4247
|
+
adaptor.D2(u, v, P, D1U, D1V, D2U, D2V, D2UV);
|
|
4248
|
+
const E = D1U.Dot(D1U);
|
|
4249
|
+
const F = D1U.Dot(D1V);
|
|
4250
|
+
const G = D1V.Dot(D1V);
|
|
4251
|
+
const N = D1U.Crossed(D1V);
|
|
4252
|
+
const nLen = N.Magnitude();
|
|
4253
|
+
let result = degenerateCurvature();
|
|
4254
|
+
if (nLen >= 1e-15) {
|
|
4217
4255
|
N.Divide(nLen);
|
|
4218
|
-
const
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
D1U.
|
|
4225
|
-
D1V.
|
|
4226
|
-
D2U.delete();
|
|
4227
|
-
D2V.delete();
|
|
4228
|
-
D2UV.delete();
|
|
4229
|
-
N.delete();
|
|
4230
|
-
adaptor.delete();
|
|
4231
|
-
return {
|
|
4232
|
-
gaussian: 0,
|
|
4233
|
-
mean: 0,
|
|
4234
|
-
max: 0,
|
|
4235
|
-
min: 0,
|
|
4236
|
-
maxDirection: [
|
|
4237
|
-
1,
|
|
4238
|
-
0,
|
|
4239
|
-
0
|
|
4240
|
-
],
|
|
4241
|
-
minDirection: [
|
|
4242
|
-
0,
|
|
4243
|
-
1,
|
|
4244
|
-
0
|
|
4245
|
-
]
|
|
4246
|
-
};
|
|
4247
|
-
}
|
|
4248
|
-
const mean = (E * N2 - 2 * F * M + G * L) / (2 * denom);
|
|
4249
|
-
const gaussian = (L * N2 - M * M) / denom;
|
|
4250
|
-
const disc = Math.max(0, mean * mean - gaussian);
|
|
4251
|
-
const sqrtDisc = Math.sqrt(disc);
|
|
4252
|
-
const k1 = mean + sqrtDisc;
|
|
4253
|
-
const k2 = mean - sqrtDisc;
|
|
4254
|
-
const a12 = (G * M - F * N2) / denom;
|
|
4255
|
-
const a21 = (E * M - F * L) / denom;
|
|
4256
|
-
const a11 = (G * L - F * M) / denom;
|
|
4257
|
-
let du1, dv1;
|
|
4258
|
-
if (Math.abs(a12) > 1e-15) {
|
|
4259
|
-
du1 = a12;
|
|
4260
|
-
dv1 = k1 - a11;
|
|
4261
|
-
} else if (Math.abs(a21) > 1e-15) {
|
|
4262
|
-
du1 = k1 - (E * N2 - F * M) / denom;
|
|
4263
|
-
dv1 = a21;
|
|
4264
|
-
} else {
|
|
4265
|
-
du1 = 1;
|
|
4266
|
-
dv1 = 0;
|
|
4267
|
-
}
|
|
4268
|
-
result = {
|
|
4269
|
-
gaussian,
|
|
4270
|
-
mean,
|
|
4271
|
-
max: k1,
|
|
4272
|
-
min: k2,
|
|
4273
|
-
maxDirection: dirFromUV(D1U, D1V, du1, dv1),
|
|
4274
|
-
minDirection: dirFromUV(D1U, D1V, -dv1, du1)
|
|
4256
|
+
const solved = solvePrincipalCurvatures(E, F, G, D2U.Dot(N), D2UV.Dot(N), D2V.Dot(N));
|
|
4257
|
+
if (solved) result = {
|
|
4258
|
+
gaussian: solved.gaussian,
|
|
4259
|
+
mean: solved.mean,
|
|
4260
|
+
max: solved.k1,
|
|
4261
|
+
min: solved.k2,
|
|
4262
|
+
maxDirection: dirFromUV(D1U, D1V, solved.du1, solved.dv1),
|
|
4263
|
+
minDirection: dirFromUV(D1U, D1V, -solved.dv1, solved.du1)
|
|
4275
4264
|
};
|
|
4276
4265
|
}
|
|
4277
4266
|
P.delete();
|
|
@@ -4467,61 +4456,51 @@ function writeXCAFToSTEP$1(oc, doc, options = {}) {
|
|
|
4467
4456
|
sessionHandle.delete();
|
|
4468
4457
|
return result;
|
|
4469
4458
|
}
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
const
|
|
4473
|
-
const
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
oc.
|
|
4477
|
-
oc.
|
|
4478
|
-
oc.
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
nameStr.delete();
|
|
4486
|
-
const mainLabel = doc.Main();
|
|
4487
|
-
const shapeTool = oc.XCAFDoc_DocumentTool.ShapeTool(mainLabel).get();
|
|
4488
|
-
const colorTool = oc.XCAFDoc_DocumentTool.ColorTool(mainLabel).get();
|
|
4489
|
-
oc.XCAFDoc_ShapeTool.SetAutoNaming(false);
|
|
4490
|
-
for (const part of shapes) {
|
|
4491
|
-
const shapeNode = shapeTool.AddShape(part.shape, false, true);
|
|
4492
|
-
if (part.name) {
|
|
4493
|
-
const partName = new oc.TCollection_ExtendedString_2(part.name, true);
|
|
4494
|
-
oc.TDataStd_Name.Set_1(shapeNode, partName);
|
|
4495
|
-
partName.delete();
|
|
4496
|
-
}
|
|
4497
|
-
if (part.color) {
|
|
4498
|
-
const [r, g, b, a] = part.color;
|
|
4499
|
-
const rgba = new oc.Quantity_ColorRGBA_5(r / 255, g / 255, b / 255, a / 255);
|
|
4500
|
-
colorTool.SetColor_3(shapeNode, rgba, oc.XCAFDoc_ColorType.XCAFDoc_ColorSurf);
|
|
4501
|
-
rgba.delete();
|
|
4502
|
-
}
|
|
4459
|
+
function exportStepConfiguredXCAF(oc, shapes) {
|
|
4460
|
+
new oc.STEPCAFControl_Writer_1().delete();
|
|
4461
|
+
const nameStr = new oc.TCollection_ExtendedString_2("XmlOcaf", true);
|
|
4462
|
+
const doc = new oc.TDocStd_Document(nameStr);
|
|
4463
|
+
nameStr.delete();
|
|
4464
|
+
const mainLabel = doc.Main();
|
|
4465
|
+
const shapeTool = oc.XCAFDoc_DocumentTool.ShapeTool(mainLabel).get();
|
|
4466
|
+
const colorTool = oc.XCAFDoc_DocumentTool.ColorTool(mainLabel).get();
|
|
4467
|
+
oc.XCAFDoc_ShapeTool.SetAutoNaming(false);
|
|
4468
|
+
for (const part of shapes) {
|
|
4469
|
+
const shapeNode = shapeTool.AddShape(part.shape, false, true);
|
|
4470
|
+
if (part.name) {
|
|
4471
|
+
const partName = new oc.TCollection_ExtendedString_2(part.name, true);
|
|
4472
|
+
oc.TDataStd_Name.Set_1(shapeNode, partName);
|
|
4473
|
+
partName.delete();
|
|
4503
4474
|
}
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
writer.Transfer_1(docHandle, oc.STEPControl_StepModelType.STEPControl_AsIs, null, progress);
|
|
4510
|
-
progress.delete();
|
|
4511
|
-
const filename = uniqueIOFilename("_step_cfg_export", "step");
|
|
4512
|
-
const status = writer.Write(filename);
|
|
4513
|
-
let result = "";
|
|
4514
|
-
if (status === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
|
|
4515
|
-
const content = oc.FS.readFile("/" + filename);
|
|
4516
|
-
result = new TextDecoder().decode(content);
|
|
4517
|
-
oc.FS.unlink("/" + filename);
|
|
4475
|
+
if (part.color) {
|
|
4476
|
+
const [r, g, b, a] = part.color;
|
|
4477
|
+
const rgba = new oc.Quantity_ColorRGBA_5(r / 255, g / 255, b / 255, a / 255);
|
|
4478
|
+
colorTool.SetColor_3(shapeNode, rgba, oc.XCAFDoc_ColorType.XCAFDoc_ColorSurf);
|
|
4479
|
+
rgba.delete();
|
|
4518
4480
|
}
|
|
4519
|
-
writer.delete();
|
|
4520
|
-
sessionHandle.delete();
|
|
4521
|
-
docHandle.delete();
|
|
4522
|
-
doc.delete();
|
|
4523
|
-
return result;
|
|
4524
4481
|
}
|
|
4482
|
+
const session = new oc.XSControl_WorkSession();
|
|
4483
|
+
const sessionHandle = new oc.Handle_XSControl_WorkSession_2(session);
|
|
4484
|
+
const writer = new oc.STEPCAFControl_Writer_2(sessionHandle, false);
|
|
4485
|
+
const docHandle = new oc.Handle_TDocStd_Document_2(doc);
|
|
4486
|
+
const progress = new oc.Message_ProgressRange_1();
|
|
4487
|
+
writer.Transfer_1(docHandle, oc.STEPControl_StepModelType.STEPControl_AsIs, null, progress);
|
|
4488
|
+
progress.delete();
|
|
4489
|
+
const filename = uniqueIOFilename("_step_cfg_export", "step");
|
|
4490
|
+
const status = writer.Write(filename);
|
|
4491
|
+
let result = "";
|
|
4492
|
+
if (status === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
|
|
4493
|
+
const content = oc.FS.readFile("/" + filename);
|
|
4494
|
+
result = new TextDecoder().decode(content);
|
|
4495
|
+
oc.FS.unlink("/" + filename);
|
|
4496
|
+
}
|
|
4497
|
+
writer.delete();
|
|
4498
|
+
sessionHandle.delete();
|
|
4499
|
+
docHandle.delete();
|
|
4500
|
+
doc.delete();
|
|
4501
|
+
return result;
|
|
4502
|
+
}
|
|
4503
|
+
function exportStepConfiguredSimple(oc, shapes) {
|
|
4525
4504
|
const writer = new oc.STEPControl_Writer_1();
|
|
4526
4505
|
writer.Model(true).delete();
|
|
4527
4506
|
const progress = new oc.Message_ProgressRange_1();
|
|
@@ -4537,6 +4516,19 @@ function exportSTEPConfigured$1(oc, shapes, options = {}) {
|
|
|
4537
4516
|
}
|
|
4538
4517
|
throw new Error("STEP configured export failed: writer did not complete successfully");
|
|
4539
4518
|
}
|
|
4519
|
+
/** Export shapes to STEP with full configuration. */
|
|
4520
|
+
function exportSTEPConfigured$1(oc, shapes, options = {}) {
|
|
4521
|
+
const unit = options.unit ?? "MM";
|
|
4522
|
+
const modelUnit = options.modelUnit ?? unit;
|
|
4523
|
+
const schema = options.schema ?? 5;
|
|
4524
|
+
oc.Interface_Static.SetCVal("xstep.cascade.unit", modelUnit);
|
|
4525
|
+
oc.Interface_Static.SetCVal("write.step.unit", unit);
|
|
4526
|
+
oc.Interface_Static.SetIVal("write.surfacecurve.mode", true);
|
|
4527
|
+
oc.Interface_Static.SetIVal("write.precision.mode", 0);
|
|
4528
|
+
oc.Interface_Static.SetIVal("write.step.assembly", 2);
|
|
4529
|
+
oc.Interface_Static.SetIVal("write.step.schema", schema);
|
|
4530
|
+
return shapes.some((s) => s.name || s.color) ? exportStepConfiguredXCAF(oc, shapes) : exportStepConfiguredSimple(oc, shapes);
|
|
4531
|
+
}
|
|
4540
4532
|
/** Co-located factory: returns the advanced-ops slice of {@link KernelAdapter} bound to `oc`. */
|
|
4541
4533
|
function makeAdvancedOps(oc) {
|
|
4542
4534
|
return {
|