brepjs 18.119.2 → 18.119.4
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/blueprints/blueprints.d.ts +3 -0
- package/dist/2d/blueprints/compoundBlueprint.d.ts +3 -0
- package/dist/2d/blueprints/lib.d.ts +6 -0
- package/dist/2d/lib/curve2D.d.ts +6 -1
- package/dist/2d/lib/curve2dFns.d.ts +6 -1
- package/dist/2d.cjs +7 -7
- package/dist/2d.js +7 -7
- package/dist/{adjacencyFns-BdM5p58J.js → adjacencyFns-DLityMyV.js} +2 -2
- package/dist/{adjacencyFns-Brrc7jlS.cjs → adjacencyFns-DSxuQYnb.cjs} +2 -2
- package/dist/{blueprint-DJJo8WkI.js → blueprint-DEMSX-hc.js} +37 -10
- package/dist/{blueprint-DTNT4qYJ.cjs → blueprint-DUnNPwQL.cjs} +43 -10
- package/dist/{blueprintFns-CcpboZ80.js → blueprintFns-DSj4RTjU.js} +9 -4
- package/dist/{blueprintFns-2XDZfCxX.cjs → blueprintFns-Dg8V99O9.cjs} +9 -4
- package/dist/{blueprintSketcher-DDPyypmC.js → blueprintSketcher-gMuUUPb-.js} +185 -54
- package/dist/{blueprintSketcher-C0EXFVb2.cjs → blueprintSketcher-gXVPrPlj.cjs} +192 -61
- package/dist/{boolean2D-Ddfo_dd0.cjs → boolean2D-BpmxQ1AH.cjs} +5 -5
- package/dist/{boolean2D-C_PVz8xT.js → boolean2D-DKT0BgZs.js} +5 -5
- package/dist/brepjs.cjs +105 -92
- package/dist/brepjs.js +39 -27
- package/dist/{cameraFns-Czr5vABD.cjs → cameraFns-2-haLzLi.cjs} +4 -4
- package/dist/{cameraFns-D9tdBYLM.js → cameraFns-CG_J66Hl.js} +4 -4
- package/dist/core.cjs +12 -11
- package/dist/core.js +4 -3
- package/dist/{cornerFinder-Cqg-Dz74.js → cornerFinder-CPFM7bA0.js} +1 -1
- package/dist/{cornerFinder-DETRDOMz.cjs → cornerFinder-mfsUMi5g.cjs} +1 -1
- package/dist/{curveFns-RENXKp64.js → curveFns-DX13KRh2.js} +2 -2
- package/dist/{curveFns-D7utcbnf.cjs → curveFns-GmFnqNo3.cjs} +2 -2
- package/dist/{drawFns-D9Rf4foW.cjs → drawFns-CI6CpqO8.cjs} +35 -16
- package/dist/{drawFns-B9HbtAoc.js → drawFns-CrfBz_wj.js} +35 -16
- package/dist/{errors-B3CDG537.js → errors-MHLiNE-C.js} +1 -92
- package/dist/{errors-CJU8CHng.cjs → errors-RHkKO5bZ.cjs} +0 -103
- package/dist/{faceFns-CPswi9Cm.cjs → faceFns-BK4r7Dxk.cjs} +3 -3
- package/dist/{faceFns-CB6uzvOg.js → faceFns-DJj9Nb6T.js} +3 -3
- package/dist/{healingFns-BFTYLiAm.js → healingFns-DxcRyVCG.js} +5 -6
- package/dist/{healingFns-bhMxTTqw.cjs → healingFns-Hx4oTlq8.cjs} +27 -28
- package/dist/{helpers-Cu4ag5bh.cjs → helpers-BfkBvokP.cjs} +8 -24
- package/dist/{helpers-BiN4qQZP.js → helpers-Du_OdHuy.js} +9 -25
- package/dist/{importFns-X8vBhZI2.js → importFns-DqxAZFb-.js} +3 -3
- package/dist/{importFns-DS4J1xLv.cjs → importFns-pr-r5qiV.cjs} +3 -3
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/{loftFns-ChHjzUK-.cjs → loftFns-BdpZ8FMN.cjs} +2 -125
- package/dist/{loftFns-BF5X7ltI.js → loftFns-BeGJ6dxx.js} +4 -109
- package/dist/{measureFns-B5Zzg1qM.cjs → measureFns-CJGrmhHT.cjs} +4 -4
- package/dist/{measureFns-CC7HhAH3.js → measureFns-CMnbcUZC.js} +4 -4
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-D57Fyqyf.js → meshFns-Cs5EBsf7.js} +4 -4
- package/dist/{meshFns-CaXmWmhe.cjs → meshFns-Dqf5QBhQ.cjs} +5 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/originTrackingFns-DZmdiQ-O.js +203 -0
- package/dist/originTrackingFns-fpEgTIwV.cjs +226 -0
- package/dist/{planeOps-Cp6GQ23-.js → planeOps-CQahLrCx.js} +1 -1
- package/dist/{planeOps-Cr25KWWA.cjs → planeOps-VlFxtvzY.cjs} +1 -1
- package/dist/primitiveFns-B_rflH83.cjs +773 -0
- package/dist/primitiveFns-Cxo3xDKY.js +558 -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/{refResolveFns-3bw9-U-e.js → refResolveFns-BbRLD8LA.js} +6 -6
- package/dist/{refResolveFns-BxmgIhQM.cjs → refResolveFns-CVDLwh12.cjs} +6 -6
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
- package/dist/shapeFns-BTFx-os7.js +43 -0
- package/dist/shapeFns-D_5TgiUi.cjs +84 -0
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-Bpsu5KJO.cjs → shapeTypes-CkcIL7zv.cjs} +1 -222
- package/dist/{shapeTypes-CnKFSfDT.js → shapeTypes-t49f64Dx.js} +2 -139
- package/dist/sketching/drawing.d.ts +9 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-I8_V8qqU.js → solidBuilders-DTgqQC3W.js} +310 -8
- package/dist/{solidBuilders-Bp7lQW62.cjs → solidBuilders-IiIzjKAr.cjs} +401 -15
- package/dist/{surfaceBuilders-D8_08oOR.cjs → surfaceBuilders-Biqx51el.cjs} +6 -5
- package/dist/{surfaceBuilders-BNR7yMQO.js → surfaceBuilders-BryY-i0F.js} +4 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-B5zcLGvJ.cjs → textBlueprints-BY0FEg59.cjs} +138 -51
- package/dist/{textBlueprints-igbNvKcd.js → textBlueprints-ZzYg3XTS.js} +116 -11
- package/dist/{textMetrics-CJvtpbc3.js → textMetrics-Diakbtem.js} +2 -2
- package/dist/{textMetrics-08fF0QNf.cjs → textMetrics-f5yXR4OG.cjs} +2 -2
- package/dist/{threadFns-CqSMNyTZ.js → threadFns-BOtXTHZ9.js} +8 -8
- package/dist/{threadFns-Co6vWEWx.cjs → threadFns-DRrk9Qod.cjs} +8 -8
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-C3fhJndG.cjs → topologyQueryFns-Bia7o8l_.cjs} +97 -6
- package/dist/{topologyQueryFns-DNqT88yx.js → topologyQueryFns-BkQ6Q7gN.js} +93 -2
- package/dist/validityTypes-DiTgeCD9.js +129 -0
- package/dist/validityTypes-ZGMVlv7b.cjs +200 -0
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +1 -1
- package/package.json +8 -8
- package/dist/primitiveFns-CRy_CUVg.cjs +0 -492
- package/dist/primitiveFns-DCIH-SBm.js +0 -331
- package/dist/shapeFns-BrHFNLMA.js +0 -771
- package/dist/shapeFns-qm9VRo4i.cjs +0 -962
|
@@ -1,49 +1,124 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
-
return target;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
-
key = keys[i];
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
-
get: ((k) => from[k]).bind(null, key),
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
//#endregion
|
|
32
|
-
const require_shapeTypes = require("./shapeTypes-Bpsu5KJO.cjs");
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
33
3
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
34
|
-
const require_errors = require("./errors-
|
|
4
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
35
5
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
36
6
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
37
|
-
const require_planeOps = require("./planeOps-
|
|
38
|
-
const require_faceFns = require("./faceFns-
|
|
39
|
-
const
|
|
7
|
+
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
8
|
+
const require_faceFns = require("./faceFns-BK4r7Dxk.cjs");
|
|
9
|
+
const require_solidBuilders = require("./solidBuilders-IiIzjKAr.cjs");
|
|
10
|
+
const require_curveFns = require("./curveFns-GmFnqNo3.cjs");
|
|
40
11
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
41
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const require_loftFns = require("./loftFns-ChHjzUK-.cjs");
|
|
12
|
+
const require_surfaceBuilders = require("./surfaceBuilders-Biqx51el.cjs");
|
|
13
|
+
const require_blueprintSketcher = require("./blueprintSketcher-gXVPrPlj.cjs");
|
|
14
|
+
const require_loftFns = require("./loftFns-BdpZ8FMN.cjs");
|
|
45
15
|
let opentype_js = require("opentype.js");
|
|
46
|
-
opentype_js = __toESM(opentype_js, 1);
|
|
16
|
+
opentype_js = require_rolldown_runtime.__toESM(opentype_js, 1);
|
|
17
|
+
//#region src/operations/extrudeFns.ts
|
|
18
|
+
/**
|
|
19
|
+
* Basic extrusion operations — extrude and revolve.
|
|
20
|
+
*
|
|
21
|
+
* Sweep-based operations (sweep, supportExtrude, complexExtrude, twistExtrude)
|
|
22
|
+
* have moved to `./sweepFns.js`.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Extrude a face along a vector to produce a solid.
|
|
26
|
+
*
|
|
27
|
+
* @param face - The planar face to extrude.
|
|
28
|
+
* @param extrusionVec - Direction and magnitude of the extrusion as `[x, y, z]`.
|
|
29
|
+
* @returns `Result` containing the extruded solid, or an error if validation or operation fails.
|
|
30
|
+
*/
|
|
31
|
+
function extrude(face, extrusionVec) {
|
|
32
|
+
if (require_shapeTypes.getKernel().isNull(face.wrapped)) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.NULL_SHAPE_INPUT, "extrude: face is a null shape"));
|
|
33
|
+
if (require_vecOps.vecLength(extrusionVec) < 1e-10) return require_errors.err(require_errors.validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
|
|
34
|
+
try {
|
|
35
|
+
const kernel = require_shapeTypes.getKernel();
|
|
36
|
+
const len = require_vecOps.vecLength(extrusionVec);
|
|
37
|
+
const dir = require_vecOps.vecNormalize(extrusionVec);
|
|
38
|
+
const shape = kernel.extrude(face.wrapped, [...dir], len);
|
|
39
|
+
const solid = require_shapeTypes.createSolid(kernel.downcast(shape, "solid"));
|
|
40
|
+
require_shapeTypes.disposeDowncastSource(shape, solid);
|
|
41
|
+
return require_errors.ok(solid);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return require_errors.err(require_errors.kernelError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
|
|
44
|
+
operation: "extrude",
|
|
45
|
+
vectorLength: require_vecOps.vecLength(extrusionVec)
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Revolve a face around an axis to create a solid of revolution.
|
|
51
|
+
*
|
|
52
|
+
* @param face - The face to revolve.
|
|
53
|
+
* @param center - A point on the rotation axis. Defaults to the origin.
|
|
54
|
+
* @param direction - Direction vector of the rotation axis. Defaults to Z-up.
|
|
55
|
+
* @param angle - Rotation angle in **radians**. Defaults to 2π (a full revolution).
|
|
56
|
+
* @returns `Result` containing the revolved 3D shape, or an error if the result is not 3D.
|
|
57
|
+
*/
|
|
58
|
+
function revolve(face, center = [
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
0
|
|
62
|
+
], direction = [
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
65
|
+
1
|
|
66
|
+
], angle = 2 * Math.PI) {
|
|
67
|
+
if (require_shapeTypes.getKernel().isNull(face.wrapped)) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
|
|
68
|
+
try {
|
|
69
|
+
const result = require_shapeTypes.castResultShape(require_shapeTypes.getKernel().revolveVec(face.wrapped, [...center], [...direction], angle));
|
|
70
|
+
if (!require_shapeTypes.isShape3D(result)) {
|
|
71
|
+
require_shapeTypes.disposeResultShape(result);
|
|
72
|
+
return require_errors.err(require_errors.typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
73
|
+
}
|
|
74
|
+
return require_errors.ok(result);
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return require_errors.err(require_errors.kernelError("REVOLVE_FAILED", "Revolution operation failed", e, {
|
|
77
|
+
operation: "revolve",
|
|
78
|
+
angle
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Batch extrude: build N independent extrusions in a single kernel call.
|
|
84
|
+
*
|
|
85
|
+
* Uses the C++ ExtrudeBatch extractor when available (single WASM call),
|
|
86
|
+
* falling back to N individual extrude operations otherwise.
|
|
87
|
+
*
|
|
88
|
+
* @returns Array of valid solids, one per entry.
|
|
89
|
+
*/
|
|
90
|
+
function extrudeAll(entries) {
|
|
91
|
+
if (entries.length === 0) return require_errors.ok([]);
|
|
92
|
+
const kernel = require_shapeTypes.getKernel();
|
|
93
|
+
const kernelEntries = [];
|
|
94
|
+
for (let i = 0; i < entries.length; i++) {
|
|
95
|
+
const e = entries[i];
|
|
96
|
+
if (!e) continue;
|
|
97
|
+
const vec = typeof e.height === "number" ? [
|
|
98
|
+
0,
|
|
99
|
+
0,
|
|
100
|
+
e.height
|
|
101
|
+
] : e.height;
|
|
102
|
+
const len = require_vecOps.vecLength(vec);
|
|
103
|
+
if (len < 1e-10) return require_errors.err(require_errors.validationError("EXTRUDE_ALL_ZERO_VECTOR", `extrudeAll: entry ${i} has zero-length extrusion vector`));
|
|
104
|
+
const direction = [...require_vecOps.vecNormalize(vec)];
|
|
105
|
+
kernelEntries.push({
|
|
106
|
+
face: e.face.wrapped,
|
|
107
|
+
direction,
|
|
108
|
+
length: len
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
return require_errors.ok((kernel.extrudeBatch?.(kernelEntries) ?? kernelEntries.map((e) => kernel.extrude(e.face, e.direction, e.length))).map((shape) => {
|
|
113
|
+
const solid = require_shapeTypes.createSolid(kernel.downcast(shape, "solid"));
|
|
114
|
+
require_shapeTypes.disposeDowncastSource(shape, solid);
|
|
115
|
+
return solid;
|
|
116
|
+
}));
|
|
117
|
+
} catch (e) {
|
|
118
|
+
return require_errors.err(require_errors.kernelError("EXTRUDE_ALL_FAILED", "Batch extrusion operation failed", e));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
47
122
|
//#region src/sketching/compoundSketch.ts
|
|
48
123
|
/**
|
|
49
124
|
* Represent a face with holes as a group of sketches (one outer + zero or more inner).
|
|
@@ -177,7 +252,7 @@ function sketchWires(sketch) {
|
|
|
177
252
|
*/
|
|
178
253
|
function sketchRevolve(sketch, revolutionAxis, { origin } = {}) {
|
|
179
254
|
const face = require_errors.unwrap(require_surfaceBuilders.makeFace(sketch.wire));
|
|
180
|
-
const solid = require_errors.unwrap(
|
|
255
|
+
const solid = require_errors.unwrap(revolve(face, origin ? require_types.toVec3(origin) : sketch.defaultOrigin, revolutionAxis ? require_types.toVec3(revolutionAxis) : [
|
|
181
256
|
0,
|
|
182
257
|
0,
|
|
183
258
|
1
|
|
@@ -208,7 +283,7 @@ function sketchExtrude(sketch, extrusionDistance, { extrusionDirection, extrusio
|
|
|
208
283
|
return solid;
|
|
209
284
|
}
|
|
210
285
|
const face = require_errors.unwrap(require_surfaceBuilders.makeFace(sketch.wire));
|
|
211
|
-
const solid = require_errors.unwrap(
|
|
286
|
+
const solid = require_errors.unwrap(extrude(face, [...extrusionVec]));
|
|
212
287
|
face[Symbol.dispose]();
|
|
213
288
|
sketch.delete();
|
|
214
289
|
return solid;
|
|
@@ -292,7 +367,7 @@ function compoundSketchExtrude(sketch, extrusionDistance, { extrusionDirection,
|
|
|
292
367
|
if (extrusionProfile && !twistAngle) return holedSweptSolid(sketch.sketches, (s) => require_loftFns.complexExtrude(s.wire, origin ? require_types.toVec3(origin) : sketch.outerSketch.defaultOrigin, extrusionVec, extrusionProfile));
|
|
293
368
|
if (twistAngle) return holedSweptSolid(sketch.sketches, (s) => require_loftFns.twistExtrude(s.wire, twistAngle, origin ? require_types.toVec3(origin) : sketch.outerSketch.defaultOrigin, extrusionVec, extrusionProfile));
|
|
294
369
|
const face = compoundSketchFace(sketch);
|
|
295
|
-
const solid = require_errors.unwrap(
|
|
370
|
+
const solid = require_errors.unwrap(extrude(face, extrusionVec));
|
|
296
371
|
face[Symbol.dispose]();
|
|
297
372
|
return solid;
|
|
298
373
|
}
|
|
@@ -305,7 +380,7 @@ function compoundSketchRevolve(sketch, revolutionAxis, { origin } = {}) {
|
|
|
305
380
|
1
|
|
306
381
|
];
|
|
307
382
|
const face = compoundSketchFace(sketch);
|
|
308
|
-
const solid = require_errors.unwrap(
|
|
383
|
+
const solid = require_errors.unwrap(revolve(face, center, dir));
|
|
309
384
|
face[Symbol.dispose]();
|
|
310
385
|
return solid;
|
|
311
386
|
}
|
|
@@ -665,12 +740,6 @@ Object.defineProperty(exports, "Sketches", {
|
|
|
665
740
|
return Sketches;
|
|
666
741
|
}
|
|
667
742
|
});
|
|
668
|
-
Object.defineProperty(exports, "__exportAll", {
|
|
669
|
-
enumerable: true,
|
|
670
|
-
get: function() {
|
|
671
|
-
return __exportAll;
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
743
|
Object.defineProperty(exports, "compoundSketchExtrude", {
|
|
675
744
|
enumerable: true,
|
|
676
745
|
get: function() {
|
|
@@ -695,6 +764,18 @@ Object.defineProperty(exports, "compoundSketchRevolve", {
|
|
|
695
764
|
return compoundSketchRevolve;
|
|
696
765
|
}
|
|
697
766
|
});
|
|
767
|
+
Object.defineProperty(exports, "extrude", {
|
|
768
|
+
enumerable: true,
|
|
769
|
+
get: function() {
|
|
770
|
+
return extrude;
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
Object.defineProperty(exports, "extrudeAll", {
|
|
774
|
+
enumerable: true,
|
|
775
|
+
get: function() {
|
|
776
|
+
return extrudeAll;
|
|
777
|
+
}
|
|
778
|
+
});
|
|
698
779
|
Object.defineProperty(exports, "getFont", {
|
|
699
780
|
enumerable: true,
|
|
700
781
|
get: function() {
|
|
@@ -707,6 +788,12 @@ Object.defineProperty(exports, "loadFont", {
|
|
|
707
788
|
return loadFont;
|
|
708
789
|
}
|
|
709
790
|
});
|
|
791
|
+
Object.defineProperty(exports, "revolve", {
|
|
792
|
+
enumerable: true,
|
|
793
|
+
get: function() {
|
|
794
|
+
return revolve;
|
|
795
|
+
}
|
|
796
|
+
});
|
|
710
797
|
Object.defineProperty(exports, "sketchExtrude", {
|
|
711
798
|
enumerable: true,
|
|
712
799
|
get: function() {
|
|
@@ -1,17 +1,122 @@
|
|
|
1
|
-
import { l as createFace, p as createWire } from "./shapeTypes-
|
|
1
|
+
import { K as getKernel, d as createSolid, h as disposeResultShape, l as createFace, m as disposeDowncastSource, n as castResultShape, p as createWire, x as isShape3D } from "./shapeTypes-t49f64Dx.js";
|
|
2
2
|
import { n as bug } from "./bug-BdOHwn_e.js";
|
|
3
|
-
import {
|
|
3
|
+
import { E as ok, P as unwrap, d as validationError, g as err, i as kernelError, l as typeCastError, r as ioError, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
5
|
-
import { d as vecNormalize, h as vecScale, r as vecCross } from "./vecOps-SKPRvPH-.js";
|
|
6
|
-
import { n as createPlane } from "./planeOps-
|
|
7
|
-
import { v as copyShape } from "./faceFns-
|
|
8
|
-
import {
|
|
5
|
+
import { c as vecLength, d as vecNormalize, h as vecScale, r as vecCross } from "./vecOps-SKPRvPH-.js";
|
|
6
|
+
import { n as createPlane } from "./planeOps-CQahLrCx.js";
|
|
7
|
+
import { v as copyShape } from "./faceFns-DJj9Nb6T.js";
|
|
8
|
+
import { o as makeSolid, p as cutAll, t as makeCompound } from "./solidBuilders-DTgqQC3W.js";
|
|
9
|
+
import { l as curveStartPoint, u as curveTangentAt } from "./curveFns-DX13KRh2.js";
|
|
9
10
|
import { n as getAtOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
10
|
-
import { i as makeNewFaceWithinFace, r as makeFace, t as addHolesInFace } from "./surfaceBuilders-
|
|
11
|
-
import {
|
|
12
|
-
import { r as
|
|
13
|
-
import { a as revolve, d as twistExtrude, o as complexExtrude, r as extrude, t as loft, u as sweep } from "./loftFns-BF5X7ltI.js";
|
|
11
|
+
import { i as makeNewFaceWithinFace, r as makeFace, t as addHolesInFace } from "./surfaceBuilders-BryY-i0F.js";
|
|
12
|
+
import { r as organiseBlueprints, t as BlueprintSketcher } from "./blueprintSketcher-gMuUUPb-.js";
|
|
13
|
+
import { c as twistExtrude, r as complexExtrude, s as sweep, t as loft } from "./loftFns-BeGJ6dxx.js";
|
|
14
14
|
import opentype from "opentype.js";
|
|
15
|
+
//#region src/operations/extrudeFns.ts
|
|
16
|
+
/**
|
|
17
|
+
* Basic extrusion operations — extrude and revolve.
|
|
18
|
+
*
|
|
19
|
+
* Sweep-based operations (sweep, supportExtrude, complexExtrude, twistExtrude)
|
|
20
|
+
* have moved to `./sweepFns.js`.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Extrude a face along a vector to produce a solid.
|
|
24
|
+
*
|
|
25
|
+
* @param face - The planar face to extrude.
|
|
26
|
+
* @param extrusionVec - Direction and magnitude of the extrusion as `[x, y, z]`.
|
|
27
|
+
* @returns `Result` containing the extruded solid, or an error if validation or operation fails.
|
|
28
|
+
*/
|
|
29
|
+
function extrude(face, extrusionVec) {
|
|
30
|
+
if (getKernel().isNull(face.wrapped)) return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "extrude: face is a null shape"));
|
|
31
|
+
if (vecLength(extrusionVec) < 1e-10) return err(validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
|
|
32
|
+
try {
|
|
33
|
+
const kernel = getKernel();
|
|
34
|
+
const len = vecLength(extrusionVec);
|
|
35
|
+
const dir = vecNormalize(extrusionVec);
|
|
36
|
+
const shape = kernel.extrude(face.wrapped, [...dir], len);
|
|
37
|
+
const solid = createSolid(kernel.downcast(shape, "solid"));
|
|
38
|
+
disposeDowncastSource(shape, solid);
|
|
39
|
+
return ok(solid);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return err(kernelError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
|
|
42
|
+
operation: "extrude",
|
|
43
|
+
vectorLength: vecLength(extrusionVec)
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Revolve a face around an axis to create a solid of revolution.
|
|
49
|
+
*
|
|
50
|
+
* @param face - The face to revolve.
|
|
51
|
+
* @param center - A point on the rotation axis. Defaults to the origin.
|
|
52
|
+
* @param direction - Direction vector of the rotation axis. Defaults to Z-up.
|
|
53
|
+
* @param angle - Rotation angle in **radians**. Defaults to 2π (a full revolution).
|
|
54
|
+
* @returns `Result` containing the revolved 3D shape, or an error if the result is not 3D.
|
|
55
|
+
*/
|
|
56
|
+
function revolve(face, center = [
|
|
57
|
+
0,
|
|
58
|
+
0,
|
|
59
|
+
0
|
|
60
|
+
], direction = [
|
|
61
|
+
0,
|
|
62
|
+
0,
|
|
63
|
+
1
|
|
64
|
+
], angle = 2 * Math.PI) {
|
|
65
|
+
if (getKernel().isNull(face.wrapped)) return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
|
|
66
|
+
try {
|
|
67
|
+
const result = castResultShape(getKernel().revolveVec(face.wrapped, [...center], [...direction], angle));
|
|
68
|
+
if (!isShape3D(result)) {
|
|
69
|
+
disposeResultShape(result);
|
|
70
|
+
return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
71
|
+
}
|
|
72
|
+
return ok(result);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
return err(kernelError("REVOLVE_FAILED", "Revolution operation failed", e, {
|
|
75
|
+
operation: "revolve",
|
|
76
|
+
angle
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Batch extrude: build N independent extrusions in a single kernel call.
|
|
82
|
+
*
|
|
83
|
+
* Uses the C++ ExtrudeBatch extractor when available (single WASM call),
|
|
84
|
+
* falling back to N individual extrude operations otherwise.
|
|
85
|
+
*
|
|
86
|
+
* @returns Array of valid solids, one per entry.
|
|
87
|
+
*/
|
|
88
|
+
function extrudeAll(entries) {
|
|
89
|
+
if (entries.length === 0) return ok([]);
|
|
90
|
+
const kernel = getKernel();
|
|
91
|
+
const kernelEntries = [];
|
|
92
|
+
for (let i = 0; i < entries.length; i++) {
|
|
93
|
+
const e = entries[i];
|
|
94
|
+
if (!e) continue;
|
|
95
|
+
const vec = typeof e.height === "number" ? [
|
|
96
|
+
0,
|
|
97
|
+
0,
|
|
98
|
+
e.height
|
|
99
|
+
] : e.height;
|
|
100
|
+
const len = vecLength(vec);
|
|
101
|
+
if (len < 1e-10) return err(validationError("EXTRUDE_ALL_ZERO_VECTOR", `extrudeAll: entry ${i} has zero-length extrusion vector`));
|
|
102
|
+
const direction = [...vecNormalize(vec)];
|
|
103
|
+
kernelEntries.push({
|
|
104
|
+
face: e.face.wrapped,
|
|
105
|
+
direction,
|
|
106
|
+
length: len
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
return ok((kernel.extrudeBatch?.(kernelEntries) ?? kernelEntries.map((e) => kernel.extrude(e.face, e.direction, e.length))).map((shape) => {
|
|
111
|
+
const solid = createSolid(kernel.downcast(shape, "solid"));
|
|
112
|
+
disposeDowncastSource(shape, solid);
|
|
113
|
+
return solid;
|
|
114
|
+
}));
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return err(kernelError("EXTRUDE_ALL_FAILED", "Batch extrusion operation failed", e));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
15
120
|
//#region src/sketching/compoundSketch.ts
|
|
16
121
|
/**
|
|
17
122
|
* Represent a face with holes as a group of sketches (one outer + zero or more inner).
|
|
@@ -615,4 +720,4 @@ function textBlueprints(text, { startX = 0, startY = 0, fontSize = 16, fontFamil
|
|
|
615
720
|
return organiseBlueprints(Array.from(sketchFontCommands(writtenText.commands))).mirror([0, 0]);
|
|
616
721
|
}
|
|
617
722
|
//#endregion
|
|
618
|
-
export { wrapSketchDataArray as _, Sketch as a, compoundSketchLoft as c, sketchFace as d, sketchLoft as f, wrapSketchData as g, sketchWires as h, Sketches as i, compoundSketchRevolve as l, sketchSweep as m, getFont as n, compoundSketchExtrude as o, sketchRevolve as p, loadFont as r, compoundSketchFace as s, textBlueprints as t, sketchExtrude as u, CompoundSketch as v };
|
|
723
|
+
export { wrapSketchDataArray as _, Sketch as a, extrudeAll as b, compoundSketchLoft as c, sketchFace as d, sketchLoft as f, wrapSketchData as g, sketchWires as h, Sketches as i, compoundSketchRevolve as l, sketchSweep as m, getFont as n, compoundSketchExtrude as o, sketchRevolve as p, loadFont as r, compoundSketchFace as s, textBlueprints as t, sketchExtrude as u, CompoundSketch as v, revolve as x, extrude as y };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { g as wrapSketchData, i as Sketches, n as getFont, t as textBlueprints, v as CompoundSketch } from "./textBlueprints-
|
|
1
|
+
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
2
|
+
import { g as wrapSketchData, i as Sketches, n as getFont, t as textBlueprints, v as CompoundSketch } from "./textBlueprints-ZzYg3XTS.js";
|
|
3
3
|
//#region src/text/sketchText.ts
|
|
4
4
|
/**
|
|
5
5
|
* Render text as 3D sketch outlines on a plane.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
2
|
+
const require_textBlueprints = require("./textBlueprints-BY0FEg59.cjs");
|
|
3
3
|
//#region src/text/sketchText.ts
|
|
4
4
|
/**
|
|
5
5
|
* Render text as 3D sketch outlines on a plane.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { K as
|
|
2
|
-
import {
|
|
1
|
+
import { K as getKernel, M as DisposalScope, P as createKernelHandle, W as _usingCtx, n as castResultShape, x as isShape3D } from "./shapeTypes-t49f64Dx.js";
|
|
2
|
+
import { E as ok, d as validationError, g as err, n as computationError, r as ioError, t as BrepErrorCode, x as isOk } from "./errors-MHLiNE-C.js";
|
|
3
3
|
import { d as vecNormalize, s as vecIsZero } from "./vecOps-SKPRvPH-.js";
|
|
4
|
-
import { b as fromBREP } from "./faceFns-
|
|
5
|
-
import {
|
|
6
|
-
import { h as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { b as fromBREP } from "./faceFns-DJj9Nb6T.js";
|
|
5
|
+
import { h as fuseAll } from "./solidBuilders-DTgqQC3W.js";
|
|
6
|
+
import { E as wire, h as line } from "./primitiveFns-Cxo3xDKY.js";
|
|
7
|
+
import { s as toBREP } from "./shapeFns-BTFx-os7.js";
|
|
8
|
+
import { t as loft } from "./loftFns-BeGJ6dxx.js";
|
|
9
|
+
import { c as resolveRefParams } from "./refResolveFns-BbRLD8LA.js";
|
|
10
10
|
//#region src/utils/uuid.ts
|
|
11
11
|
/** Generate a v4-style UUID string using `crypto.getRandomValues`. */
|
|
12
12
|
function uuidv() {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
3
3
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
4
|
-
const require_faceFns = require("./faceFns-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
4
|
+
const require_faceFns = require("./faceFns-BK4r7Dxk.cjs");
|
|
5
|
+
const require_solidBuilders = require("./solidBuilders-IiIzjKAr.cjs");
|
|
6
|
+
const require_primitiveFns = require("./primitiveFns-B_rflH83.cjs");
|
|
7
|
+
const require_shapeFns = require("./shapeFns-D_5TgiUi.cjs");
|
|
8
|
+
const require_loftFns = require("./loftFns-BdpZ8FMN.cjs");
|
|
9
|
+
const require_refResolveFns = require("./refResolveFns-CVDLwh12.cjs");
|
|
10
10
|
//#region src/utils/uuid.ts
|
|
11
11
|
/** Generate a v4-style UUID string using `crypto.getRandomValues`. */
|
|
12
12
|
function uuidv() {
|
package/dist/topology.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
-
const require_faceFns = require("./faceFns-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
2
|
+
const require_topologyQueryFns = require("./topologyQueryFns-Bia7o8l_.cjs");
|
|
3
|
+
const require_faceFns = require("./faceFns-BK4r7Dxk.cjs");
|
|
4
|
+
const require_solidBuilders = require("./solidBuilders-IiIzjKAr.cjs");
|
|
5
|
+
const require_primitiveFns = require("./primitiveFns-B_rflH83.cjs");
|
|
6
|
+
const require_shapeFns = require("./shapeFns-D_5TgiUi.cjs");
|
|
7
|
+
const require_curveFns = require("./curveFns-GmFnqNo3.cjs");
|
|
8
|
+
const require_meshFns = require("./meshFns-Dqf5QBhQ.cjs");
|
|
9
|
+
const require_healingFns = require("./healingFns-Hx4oTlq8.cjs");
|
|
10
|
+
const require_adjacencyFns = require("./adjacencyFns-DSxuQYnb.cjs");
|
|
11
11
|
exports.addHoles = require_primitiveFns.addHoles;
|
|
12
12
|
exports.adjacentFaces = require_adjacencyFns.adjacentFaces;
|
|
13
13
|
exports.approximateCurve = require_curveFns.approximateCurve;
|
package/dist/topology.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as vertexPosition, _ as iterFaces, b as iterVertices, c as getFaces, f as getVertices, g as iterEdges, m as invalidateShapeCache, n as getBounds, p as getWires, s as getEdges, x as iterWires } from "./topologyQueryFns-
|
|
2
|
-
import { C as shapeType, S as iterTopo, _ as cast, a as faceOrientation, b as fromBREP, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, x as isCompSolid, y as downcast } from "./faceFns-
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
5
|
-
import {
|
|
6
|
-
import { h as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { C as vertexPosition, _ as iterFaces, b as iterVertices, c as getFaces, f as getVertices, g as iterEdges, m as invalidateShapeCache, n as getBounds, p as getWires, s as getEdges, x as iterWires } from "./topologyQueryFns-BkQ6Q7gN.js";
|
|
2
|
+
import { C as shapeType, S as iterTopo, _ as cast, a as faceOrientation, b as fromBREP, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, x as isCompSolid, y as downcast } from "./faceFns-DJj9Nb6T.js";
|
|
3
|
+
import { h as fuseAll, p as cutAll } from "./solidBuilders-DTgqQC3W.js";
|
|
4
|
+
import { C as threePointArc, D as wireLoop, E as wire, S as tangentArc, T as vertex, _ as polygon, a as circle, b as sphere, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, l as ellipse, m as helix, n as bezier, o as compound, p as filledFace, r as box, s as cone, t as addHoles, u as ellipseArc, v as sewShells, w as torus, x as subFace, y as solid } from "./primitiveFns-Cxo3xDKY.js";
|
|
5
|
+
import { a as isSameShape, i as isEqualShape, n as getHashCode } from "./shapeFns-BTFx-os7.js";
|
|
6
|
+
import { a as curveIsPeriodic, c as curvePointAt, d as flipOrientation, f as getCurveType, h as offsetWire2D, i as curveIsClosed, l as curveStartPoint, m as interpolateCurve, n as curveAxis, o as curveLength, p as getOrientation, r as curveEndPoint, s as curvePeriod, t as approximateCurve, u as curveTangentAt } from "./curveFns-DX13KRh2.js";
|
|
7
|
+
import { d as createMeshCache, n as exportSTEP, r as exportSTL, t as exportIGES, u as clearMeshCache } from "./meshFns-Cs5EBsf7.js";
|
|
8
|
+
import { A as toBufferGeometryData, C as shellWithEvolution, D as getNurbsCurveData, E as fuseAllBisect, O as getNurbsSurfaceData, P as toLineGeometryData, S as intersectWithEvolution, T as cutAllBisect, _ as positionOnCurve, a as healFace, b as filletWithEvolution, g as variableFillet, j as toGroupedBufferGeometryData, k as chamferDistAngle, l as solidFromShell, n as fixSelfIntersection, o as healSolid, r as fixShape, s as healWire, t as autoHeal, v as chamferWithEvolution, w as checkBoolean, x as fuseWithEvolution, y as cutWithEvolution } from "./healingFns-DxcRyVCG.js";
|
|
9
|
+
import { i as facesOfEdge, l as wiresOfFace, n as adjacentFaces, o as sharedEdges, r as edgesOfFace, s as verticesOfEdge } from "./adjacencyFns-DLityMyV.js";
|
|
10
10
|
export { addHoles, adjacentFaces, approximateCurve, asTopo, autoHeal, bezier, box, bsplineApprox, cast, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkBoolean, circle, classifyPointOnFace, clearMeshCache, compound, cone, createMeshCache, curveAxis, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cutAll, cutAllBisect, cutWithEvolution, cylinder, fromBREP as deserializeShape, downcast, edgesOfFace, ellipse, ellipseArc, ellipsoid, exportIGES, exportSTEP, exportSTL, face, faceAxis, faceCenter, faceGeomType, faceOrientation, facesOfEdge, filledFace, filletWithEvolution, fixSelfIntersection, fixShape, flipFaceOrientation, flipOrientation, fuseAll, fuseAllBisect, fuseWithEvolution, getBounds, getCurveType, getEdges, getFaces, getHashCode, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getSurfaceType, getVertices, getWires, healFace, healSolid, healWire, helix, innerWires, interpolateCurve, intersectWithEvolution, invalidateShapeCache, isCompSolid, isEqualShape, isSameShape, iterEdges, iterFaces, iterTopo, iterVertices, iterWires, line, normalAt, offsetFace, offsetWire2D, outerWire, pointOnSurface, polygon, positionOnCurve, projectPointOnFace, sewShells, shapeType, sharedEdges, shellWithEvolution, solid, solidFromShell, sphere, subFace, tangentArc, threePointArc, toBufferGeometryData, toGroupedBufferGeometryData, toLineGeometryData, torus, uvBounds, uvCoordinates, variableFillet, vertex, vertexPosition, verticesOfEdge, wire, wireLoop, wiresOfFace };
|
|
@@ -1,6 +1,97 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
3
3
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
4
|
+
//#region src/core/kernelErrorTranslation.ts
|
|
5
|
+
/**
|
|
6
|
+
* Kernel error translation — maps cryptic kernel messages to user-friendly explanations.
|
|
7
|
+
*
|
|
8
|
+
* Extracted from errors.ts to separate pure type/constructor definitions
|
|
9
|
+
* from OCCT-specific regex matching logic.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Common kernel error patterns and their user-friendly translations.
|
|
13
|
+
* Used by kernelCall to provide actionable error messages.
|
|
14
|
+
*/
|
|
15
|
+
var kernel_ERROR_PATTERNS = [
|
|
16
|
+
{
|
|
17
|
+
pattern: /invalid edge configuration|edges?.*(not|fail|invalid)/i,
|
|
18
|
+
translation: "The edges may not form a continuous loop. Check that edges connect end-to-end without gaps."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pattern: /BRepAlgoAPI.*failed|boolean.*operation.*failed/i,
|
|
22
|
+
translation: "Boolean operation failed. Common causes: overlapping faces, zero-thickness geometry, or degenerate shapes. Try healing input shapes first."
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
pattern: /fillet.*radius.*too.*large|fillet.*failed/i,
|
|
26
|
+
translation: "Fillet operation failed. The radius may be too large for the selected edges. Try reducing the radius or check that edges have enough room."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
pattern: /chamfer.*failed|chamfer.*distance.*too.*large/i,
|
|
30
|
+
translation: "Chamfer operation failed. The distance may be too large for the selected edges. Try reducing the distance or check edge geometry."
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pattern: /shell.*failed|offset.*failed/i,
|
|
34
|
+
translation: "Shell/offset operation failed. The thickness may be too large, or the shape may have complex geometry. Try reducing thickness."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
pattern: /sweep.*failed|pipe.*failed/i,
|
|
38
|
+
translation: "Sweep operation failed. Check that the profile and spine are compatible, and that the spine has no sharp twists or self-intersections."
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
pattern: /loft.*failed/i,
|
|
42
|
+
translation: "Loft operation failed. Profiles may be incompatible or have different orientations. Ensure profiles are ordered consistently."
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
pattern: /extrude.*failed|prism.*failed/i,
|
|
46
|
+
translation: "Extrusion failed. The profile may be invalid or self-intersecting. Check that the profile forms a valid closed wire."
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
pattern: /revolve.*failed|revolution.*failed/i,
|
|
50
|
+
translation: "Revolution operation failed. The profile may intersect the axis of revolution, or the angle may be invalid."
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
pattern: /self.*intersect|self-intersect/i,
|
|
54
|
+
translation: "Shape has self-intersections. The operation resulted in overlapping geometry. Simplify the input or adjust parameters."
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
pattern: /degener|degenerat/i,
|
|
58
|
+
translation: "Degenerate geometry detected. The shape has edges or faces with zero length/area. Check input geometry for collapsed elements."
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
pattern: /BRepCheck.*fail|shape.*invalid|shape.*not.*valid/i,
|
|
62
|
+
translation: "Shape validation failed. The resulting shape has invalid topology. Try healing the shape or checking input geometry."
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
var ERROR_CODE_SUGGESTIONS = {
|
|
66
|
+
FUSE_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
|
|
67
|
+
CUT_FAILED: "Try autoHeal() on both operands before the boolean operation. Check for overlapping faces or zero-thickness geometry.",
|
|
68
|
+
FUSE_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
|
|
69
|
+
CUT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
|
|
70
|
+
INTERSECT_NOT_3D: "The boolean result was not a 3D solid. Ensure both input shapes are valid 3D solids, not shells or open surfaces.",
|
|
71
|
+
SWEEP_FAILED: "Ensure the spine curve has no sharp corners or self-intersections. Try simplifying the profile or using a smoother path.",
|
|
72
|
+
LOFT_FAILED: "Check that all profiles have the same number of edges and consistent orientation. Try reordering profiles.",
|
|
73
|
+
FILLET_NOT_3D: "The fillet radius may be too large for the selected edges. Try a smaller radius or check that adjacent faces have enough room.",
|
|
74
|
+
CHAMFER_NOT_3D: "The chamfer distance may be too large. Try a smaller distance or check edge geometry.",
|
|
75
|
+
SHELL_NOT_3D: "The shell thickness may be too large for the shape. Try reducing thickness or removing problematic faces.",
|
|
76
|
+
OFFSET_NOT_3D: "The offset distance may be too large for the shape geometry. Try a smaller distance.",
|
|
77
|
+
DRAFT_FAILED: "The draft angle may be too large or the selected faces incompatible. Try a smaller angle or different faces."
|
|
78
|
+
};
|
|
79
|
+
/** Look up an actionable suggestion for a given error code. */
|
|
80
|
+
function getSuggestionForCode(code) {
|
|
81
|
+
return ERROR_CODE_SUGGESTIONS[code];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Translate an kernel error message into a user-friendly explanation.
|
|
85
|
+
* If no pattern matches, returns the original message.
|
|
86
|
+
*
|
|
87
|
+
* @param kernelMessage - The raw error message from kernel
|
|
88
|
+
* @returns User-friendly error message with actionable guidance
|
|
89
|
+
*/
|
|
90
|
+
function translateKernelError(kernelMessage) {
|
|
91
|
+
for (const { pattern, translation } of kernel_ERROR_PATTERNS) if (pattern.test(kernelMessage)) return `${translation} (kernel: ${kernelMessage})`;
|
|
92
|
+
return kernelMessage;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
4
95
|
//#region src/core/kernelCall.ts
|
|
5
96
|
function buildError(kind, code, message, cause, suggestion) {
|
|
6
97
|
const base = {
|
|
@@ -39,8 +130,8 @@ function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
|
39
130
|
return require_errors.ok(require_shapeTypes.castResultShape(fn()));
|
|
40
131
|
} catch (e) {
|
|
41
132
|
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
42
|
-
const translatedMessage = kind === "KERNEL_OPERATION" ?
|
|
43
|
-
const suggestion =
|
|
133
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
|
|
134
|
+
const suggestion = getSuggestionForCode(code);
|
|
44
135
|
return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
|
|
45
136
|
}
|
|
46
137
|
}
|
|
@@ -56,8 +147,8 @@ function kernelCallRaw(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
|
56
147
|
return require_errors.ok(fn());
|
|
57
148
|
} catch (e) {
|
|
58
149
|
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
59
|
-
const translatedMessage = kind === "KERNEL_OPERATION" ?
|
|
60
|
-
const suggestion =
|
|
150
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
|
|
151
|
+
const suggestion = getSuggestionForCode(code);
|
|
61
152
|
return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e, suggestion));
|
|
62
153
|
}
|
|
63
154
|
}
|