brepjs 13.1.0 → 13.4.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/curve2dGeometryFns.d.ts +107 -0
- package/dist/2d/curve2dGeometryFns.d.ts.map +1 -0
- package/dist/2d.cjs +229 -3
- package/dist/2d.d.ts +2 -0
- package/dist/2d.d.ts.map +1 -1
- package/dist/2d.js +206 -4
- package/dist/{arrayAccess-Bz2OkAF_.js → arrayAccess-B5LgmXBo.js} +4 -4
- package/dist/{arrayAccess-FwdVX3Nh.cjs → arrayAccess-t2dlxGSK.cjs} +4 -4
- package/dist/{blueprint-Bpa-w3WF.js → blueprint-CB_85Lz_.js} +10 -10
- package/dist/{blueprint-YPV8lQqg.cjs → blueprint-CDnBM-tA.cjs} +10 -10
- package/dist/{blueprintFns-iQsyPfTY.cjs → blueprintFns-D4YucGaQ.cjs} +142 -3
- package/dist/{blueprintFns-D0RopDZS.js → blueprintFns-DVDommWB.js} +125 -4
- package/dist/{boolean2D-D_yuF0kT.js → boolean2D-Mzp-0g7o.js} +12 -12
- package/dist/{boolean2D-CMXMxTgD.cjs → boolean2D-lqfKJKUY.cjs} +12 -12
- package/dist/{booleanFns-omB4YLGU.js → booleanFns-B46fgObh.js} +26 -14
- package/dist/{booleanFns-o7EsqNGM.cjs → booleanFns-Bw8sAMgI.cjs} +26 -14
- package/dist/brepjs.cjs +28 -145
- package/dist/brepjs.js +23 -143
- package/dist/core/curve2dHandle.d.ts +27 -0
- package/dist/core/curve2dHandle.d.ts.map +1 -0
- package/dist/core/errors.d.ts +7 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core.cjs +5 -5
- package/dist/core.js +5 -5
- package/dist/{cornerFinder-E2w1gRI3.cjs → cornerFinder-BszIcLqj.cjs} +3 -3
- package/dist/{cornerFinder-nn_mma6p.js → cornerFinder-aBLykolI.js} +3 -3
- package/dist/{curveFns-DHFAK2lD.cjs → curveFns-CZszKLQB.cjs} +2 -2
- package/dist/{curveFns-CzcOFFDX.js → curveFns-DY4dFcP-.js} +2 -2
- package/dist/{drawFns-DLPEVSbK.cjs → drawFns-BHNDF8hb.cjs} +15 -15
- package/dist/{drawFns-4x9wOpZ3.js → drawFns-l5CY2s-l.js} +15 -15
- package/dist/{errors-D7ZQfeqv.js → errors-BVOlxlIA.js} +7 -0
- package/dist/{errors-BDTFTJ22.cjs → errors-BlC5ZWv4.cjs} +7 -0
- package/dist/{extrudeFns-CqKzY5BT.cjs → extrudeFns-GpCB_Uzs.cjs} +3 -3
- package/dist/{extrudeFns-CDWViQSe.js → extrudeFns-b0uLn4E4.js} +3 -3
- package/dist/{faceFns-DSUZvptN.cjs → faceFns-BywUjlJ7.cjs} +3 -3
- package/dist/{faceFns-6mY9O_5h.js → faceFns-Cat-4X74.js} +3 -3
- package/dist/{helpers-BWZ7h12W.cjs → helpers-1iCCEElA.cjs} +7 -7
- package/dist/{helpers-C9PtrI6D.js → helpers-DgX1UucG.js} +7 -7
- package/dist/{historyFns-r1owwcvA.js → historyFns-BFwp8NLX.js} +6 -6
- package/dist/{historyFns-DIUNWvA3.cjs → historyFns-DqxDtXIZ.cjs} +6 -6
- package/dist/{importFns-xg7LSAv6.js → importFns-Cb8fcldB.js} +4 -4
- package/dist/{importFns-CeDf0HmX.cjs → importFns-ChXEJAvu.cjs} +4 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/booleanOps.d.ts +7 -1
- package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/brepkitAdapter.d.ts +7 -4
- package/dist/kernel/brepkit/brepkitAdapter.d.ts.map +1 -1
- package/dist/kernel/brepkit/evolutionOps.d.ts +4 -4
- package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
- package/dist/kernel/interfaces/booleanOps.d.ts +3 -1
- package/dist/kernel/interfaces/booleanOps.d.ts.map +1 -1
- package/dist/kernel/interfaces/curveOps.d.ts +3 -1
- package/dist/kernel/interfaces/curveOps.d.ts.map +1 -1
- package/dist/kernel/interfaces/evolutionOps.d.ts +4 -4
- package/dist/kernel/interfaces/evolutionOps.d.ts.map +1 -1
- package/dist/kernel/interfaces/surfaceOps.d.ts +3 -1
- package/dist/kernel/interfaces/surfaceOps.d.ts.map +1 -1
- package/dist/kernel/occt/booleanOps.d.ts +7 -1
- package/dist/kernel/occt/booleanOps.d.ts.map +1 -1
- package/dist/kernel/occt/defaultAdapter.d.ts +7 -4
- package/dist/kernel/occt/defaultAdapter.d.ts.map +1 -1
- package/dist/kernel/occt/evolutionOps.d.ts +2 -2
- package/dist/kernel/occt/evolutionOps.d.ts.map +1 -1
- package/dist/kernel/occt/historyOps.d.ts +4 -4
- package/dist/kernel/occt/historyOps.d.ts.map +1 -1
- package/dist/kernel/occt/nurbsQueryOps.d.ts +12 -0
- package/dist/kernel/occt/nurbsQueryOps.d.ts.map +1 -0
- package/dist/kernel/occt/wasmTypes/occtBuilders.d.ts +4 -0
- package/dist/kernel/occt/wasmTypes/occtBuilders.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +56 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{measureFns-Dp2Znpf_.cjs → measureFns-Bx-kl7_g.cjs} +3 -3
- package/dist/{measureFns-B7pm7ulJ.js → measureFns-D3rAp1X1.js} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-1ARDwoZ4.js → meshFns-BPi0bhm9.js} +3 -3
- package/dist/{meshFns-DHS9gepE.cjs → meshFns-D3KAZ_ma.cjs} +3 -3
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{planeOps-DA5DmML2.cjs → planeOps-BqLav0Ir.cjs} +3 -3
- package/dist/{planeOps-D4THn1al.js → planeOps-D88tfyJs.js} +3 -3
- package/dist/{primitiveFns-DtAy6t6n.cjs → primitiveFns-BGh9A9jR.cjs} +67 -7
- package/dist/{primitiveFns-CfCgkRwY.js → primitiveFns-CnZkW6Bi.js} +50 -8
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeTypes-Du2qyM2n.cjs → shapeTypes-8eK48l-X.cjs} +258 -9
- package/dist/{shapeTypes-Beo7ikOL.js → shapeTypes-Di6GlhPk.js} +258 -9
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-BePRwqfJ.cjs → solidBuilders-D9KYP9sL.cjs} +3 -3
- package/dist/{solidBuilders-8CBjeBfT.js → solidBuilders-ctO_wFrm.js} +3 -3
- package/dist/{surfaceBuilders-BC0MvMK1.js → surfaceBuilders-BaqeZa0x.js} +3 -3
- package/dist/{surfaceBuilders-BCiMuuGV.cjs → surfaceBuilders-CZzipftq.cjs} +3 -3
- package/dist/topology/booleanDiagnosticFns.d.ts +18 -0
- package/dist/topology/booleanDiagnosticFns.d.ts.map +1 -0
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/nurbsFns.d.ts +13 -0
- package/dist/topology/nurbsFns.d.ts.map +1 -0
- package/dist/topology.cjs +9 -6
- package/dist/topology.d.ts +2 -0
- package/dist/topology.d.ts.map +1 -1
- package/dist/topology.js +7 -7
- package/dist/vectors.cjs +3 -3
- package/dist/vectors.js +3 -3
- package/package.json +1 -1
- /package/dist/{types-Bb4KK_iG.js → types-BWBlwp6w.js} +0 -0
- /package/dist/{types-BD-VVaWB.cjs → types-BjDcsS7l.cjs} +0 -0
- /package/dist/{vecOps-B9-MTeC8.js → vecOps-DFfUfsmc.js} +0 -0
- /package/dist/{vecOps-4iBMiet9.cjs → vecOps-DKGelwGL.cjs} +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { H as registerForCleanup, W as unregisterFromCleanup, X as getKernel2D, Y as getKernel, a as createEdge, u as createWire } from "./shapeTypes-
|
|
2
|
-
import { L as unwrap, d as validationError, k as ok, m as bug, n as computationError, y as err } from "./errors-
|
|
3
|
-
import { _ as DEG2RAD, y as RAD2DEG } from "./vecOps-
|
|
4
|
-
import { r as toVec3 } from "./types-
|
|
5
|
-
import { r as makePlane } from "./planeOps-
|
|
6
|
-
import { g as cast, m as uvCoordinates, n as faceCenter, p as uvBounds, r as faceGeomType } from "./faceFns-
|
|
7
|
-
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-
|
|
8
|
-
import { f as getOrientation } from "./curveFns-
|
|
9
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
10
|
-
import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-
|
|
1
|
+
import { H as registerForCleanup, W as unregisterFromCleanup, X as getKernel2D, Y as getKernel, a as createEdge, u as createWire } from "./shapeTypes-Di6GlhPk.js";
|
|
2
|
+
import { L as unwrap, d as validationError, k as ok, m as bug, n as computationError, y as err } from "./errors-BVOlxlIA.js";
|
|
3
|
+
import { _ as DEG2RAD, y as RAD2DEG } from "./vecOps-DFfUfsmc.js";
|
|
4
|
+
import { r as toVec3 } from "./types-BWBlwp6w.js";
|
|
5
|
+
import { r as makePlane } from "./planeOps-D88tfyJs.js";
|
|
6
|
+
import { g as cast, m as uvCoordinates, n as faceCenter, p as uvBounds, r as faceGeomType } from "./faceFns-Cat-4X74.js";
|
|
7
|
+
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-B5LgmXBo.js";
|
|
8
|
+
import { f as getOrientation } from "./curveFns-DY4dFcP-.js";
|
|
9
|
+
import { r as makeFace } from "./surfaceBuilders-BaqeZa0x.js";
|
|
10
|
+
import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-DgX1UucG.js";
|
|
11
11
|
//#region src/2d/lib/definitions.ts
|
|
12
12
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
13
13
|
function isPoint2D(point) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_vecOps = require("./vecOps-
|
|
4
|
-
const require_types = require("./types-
|
|
5
|
-
const require_planeOps = require("./planeOps-
|
|
6
|
-
const require_faceFns = require("./faceFns-
|
|
7
|
-
const require_arrayAccess = require("./arrayAccess-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
9
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
10
|
-
const require_helpers = require("./helpers-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
|
|
2
|
+
const require_errors = require("./errors-BlC5ZWv4.cjs");
|
|
3
|
+
const require_vecOps = require("./vecOps-DKGelwGL.cjs");
|
|
4
|
+
const require_types = require("./types-BjDcsS7l.cjs");
|
|
5
|
+
const require_planeOps = require("./planeOps-BqLav0Ir.cjs");
|
|
6
|
+
const require_faceFns = require("./faceFns-BywUjlJ7.cjs");
|
|
7
|
+
const require_arrayAccess = require("./arrayAccess-t2dlxGSK.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-CZszKLQB.cjs");
|
|
9
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CZzipftq.cjs");
|
|
10
|
+
const require_helpers = require("./helpers-1iCCEElA.cjs");
|
|
11
11
|
//#region src/2d/lib/definitions.ts
|
|
12
12
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
13
13
|
function isPoint2D(point) {
|
|
@@ -1,6 +1,127 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
|
|
2
|
+
const require_errors = require("./errors-BlC5ZWv4.cjs");
|
|
3
|
+
const require_boolean2D = require("./boolean2D-lqfKJKUY.cjs");
|
|
4
|
+
const require_blueprint = require("./blueprint-CDnBM-tA.cjs");
|
|
5
|
+
//#region src/core/kernelCall.ts
|
|
6
|
+
var errorFactories = {
|
|
7
|
+
KERNEL_OPERATION: (code, message, cause) => ({
|
|
8
|
+
kind: "KERNEL_OPERATION",
|
|
9
|
+
code,
|
|
10
|
+
message,
|
|
11
|
+
cause
|
|
12
|
+
}),
|
|
13
|
+
VALIDATION: (code, message, cause) => ({
|
|
14
|
+
kind: "VALIDATION",
|
|
15
|
+
code,
|
|
16
|
+
message,
|
|
17
|
+
cause
|
|
18
|
+
}),
|
|
19
|
+
TYPE_CAST: (code, message, cause) => ({
|
|
20
|
+
kind: "TYPE_CAST",
|
|
21
|
+
code,
|
|
22
|
+
message,
|
|
23
|
+
cause
|
|
24
|
+
}),
|
|
25
|
+
SKETCHER_STATE: (code, message, cause) => ({
|
|
26
|
+
kind: "SKETCHER_STATE",
|
|
27
|
+
code,
|
|
28
|
+
message,
|
|
29
|
+
cause
|
|
30
|
+
}),
|
|
31
|
+
MODULE_INIT: (code, message, cause) => ({
|
|
32
|
+
kind: "MODULE_INIT",
|
|
33
|
+
code,
|
|
34
|
+
message,
|
|
35
|
+
cause
|
|
36
|
+
}),
|
|
37
|
+
COMPUTATION: (code, message, cause) => ({
|
|
38
|
+
kind: "COMPUTATION",
|
|
39
|
+
code,
|
|
40
|
+
message,
|
|
41
|
+
cause
|
|
42
|
+
}),
|
|
43
|
+
IO: (code, message, cause) => ({
|
|
44
|
+
kind: "IO",
|
|
45
|
+
code,
|
|
46
|
+
message,
|
|
47
|
+
cause
|
|
48
|
+
}),
|
|
49
|
+
QUERY: (code, message, cause) => ({
|
|
50
|
+
kind: "QUERY",
|
|
51
|
+
code,
|
|
52
|
+
message,
|
|
53
|
+
cause
|
|
54
|
+
}),
|
|
55
|
+
UNSUPPORTED: (code, message, cause) => ({
|
|
56
|
+
kind: "UNSUPPORTED",
|
|
57
|
+
code,
|
|
58
|
+
message,
|
|
59
|
+
cause
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Wrap a kernel call that returns an KernelShape, automatically casting
|
|
64
|
+
* the result into a branded AnyShape. On exception, returns an Err
|
|
65
|
+
* with the given error code and message.
|
|
66
|
+
*
|
|
67
|
+
* kernel error messages are automatically translated into user-friendly
|
|
68
|
+
* explanations when the error kind is KERNEL_OPERATION.
|
|
69
|
+
*/
|
|
70
|
+
function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
71
|
+
try {
|
|
72
|
+
return require_errors.ok(require_shapeTypes.castShape(fn()));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
75
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? require_errors.translateKernelError(rawMessage) : rawMessage;
|
|
76
|
+
return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Wrap a kernel call that returns an arbitrary value. On exception,
|
|
81
|
+
* returns an Err with the given error code and message.
|
|
82
|
+
*
|
|
83
|
+
* kernel error messages are automatically translated into user-friendly
|
|
84
|
+
* explanations when the error kind is KERNEL_OPERATION.
|
|
85
|
+
*/
|
|
86
|
+
function kernelCallRaw(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
87
|
+
try {
|
|
88
|
+
return require_errors.ok(fn());
|
|
89
|
+
} catch (e) {
|
|
90
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
91
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? require_errors.translateKernelError(rawMessage) : rawMessage;
|
|
92
|
+
return require_errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap a kernel call that needs intermediate kernel allocations.
|
|
97
|
+
*
|
|
98
|
+
* A DisposalScope is created and passed to fn. The scope is disposed
|
|
99
|
+
* deterministically after fn returns or throws — ensuring no intermediate
|
|
100
|
+
* handles are leaked even on error paths.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* return kernelCallScoped(
|
|
104
|
+
* (scope) => {
|
|
105
|
+
* const axis = scope.register(makeKernelAx1(origin, dir));
|
|
106
|
+
* return getKernel().revolveVec(...) // was: oc.BRepBuilderAPI_MakeRevol_1(shape.wrapped, axis).Shape();
|
|
107
|
+
* },
|
|
108
|
+
* BrepErrorCode.REVOLUTION_NOT_3D,
|
|
109
|
+
* 'Revolution failed'
|
|
110
|
+
* );
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function kernelCallScoped(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
114
|
+
try {
|
|
115
|
+
var _usingCtx$1 = require_shapeTypes._usingCtx();
|
|
116
|
+
const scope = _usingCtx$1.u(new require_shapeTypes.DisposalScope());
|
|
117
|
+
return kernelCall(() => fn(scope), code, message, kind);
|
|
118
|
+
} catch (_) {
|
|
119
|
+
_usingCtx$1.e = _;
|
|
120
|
+
} finally {
|
|
121
|
+
_usingCtx$1.d();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
4
125
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
126
|
/**
|
|
6
127
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -206,6 +327,24 @@ Object.defineProperty(exports, "isInside2D", {
|
|
|
206
327
|
return isInside2D;
|
|
207
328
|
}
|
|
208
329
|
});
|
|
330
|
+
Object.defineProperty(exports, "kernelCall", {
|
|
331
|
+
enumerable: true,
|
|
332
|
+
get: function() {
|
|
333
|
+
return kernelCall;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
Object.defineProperty(exports, "kernelCallRaw", {
|
|
337
|
+
enumerable: true,
|
|
338
|
+
get: function() {
|
|
339
|
+
return kernelCallRaw;
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
Object.defineProperty(exports, "kernelCallScoped", {
|
|
343
|
+
enumerable: true,
|
|
344
|
+
get: function() {
|
|
345
|
+
return kernelCallScoped;
|
|
346
|
+
}
|
|
347
|
+
});
|
|
209
348
|
Object.defineProperty(exports, "mirror2D", {
|
|
210
349
|
enumerable: true,
|
|
211
350
|
get: function() {
|
|
@@ -1,6 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { J as _usingCtx, L as DisposalScope, t as castShape } from "./shapeTypes-Di6GlhPk.js";
|
|
2
|
+
import { d as validationError, f as translateKernelError, k as ok, t as BrepErrorCode, y as err } from "./errors-BVOlxlIA.js";
|
|
3
|
+
import { h as CompoundBlueprint } from "./boolean2D-Mzp-0g7o.js";
|
|
4
|
+
import { t as Blueprint } from "./blueprint-CB_85Lz_.js";
|
|
5
|
+
//#region src/core/kernelCall.ts
|
|
6
|
+
var errorFactories = {
|
|
7
|
+
KERNEL_OPERATION: (code, message, cause) => ({
|
|
8
|
+
kind: "KERNEL_OPERATION",
|
|
9
|
+
code,
|
|
10
|
+
message,
|
|
11
|
+
cause
|
|
12
|
+
}),
|
|
13
|
+
VALIDATION: (code, message, cause) => ({
|
|
14
|
+
kind: "VALIDATION",
|
|
15
|
+
code,
|
|
16
|
+
message,
|
|
17
|
+
cause
|
|
18
|
+
}),
|
|
19
|
+
TYPE_CAST: (code, message, cause) => ({
|
|
20
|
+
kind: "TYPE_CAST",
|
|
21
|
+
code,
|
|
22
|
+
message,
|
|
23
|
+
cause
|
|
24
|
+
}),
|
|
25
|
+
SKETCHER_STATE: (code, message, cause) => ({
|
|
26
|
+
kind: "SKETCHER_STATE",
|
|
27
|
+
code,
|
|
28
|
+
message,
|
|
29
|
+
cause
|
|
30
|
+
}),
|
|
31
|
+
MODULE_INIT: (code, message, cause) => ({
|
|
32
|
+
kind: "MODULE_INIT",
|
|
33
|
+
code,
|
|
34
|
+
message,
|
|
35
|
+
cause
|
|
36
|
+
}),
|
|
37
|
+
COMPUTATION: (code, message, cause) => ({
|
|
38
|
+
kind: "COMPUTATION",
|
|
39
|
+
code,
|
|
40
|
+
message,
|
|
41
|
+
cause
|
|
42
|
+
}),
|
|
43
|
+
IO: (code, message, cause) => ({
|
|
44
|
+
kind: "IO",
|
|
45
|
+
code,
|
|
46
|
+
message,
|
|
47
|
+
cause
|
|
48
|
+
}),
|
|
49
|
+
QUERY: (code, message, cause) => ({
|
|
50
|
+
kind: "QUERY",
|
|
51
|
+
code,
|
|
52
|
+
message,
|
|
53
|
+
cause
|
|
54
|
+
}),
|
|
55
|
+
UNSUPPORTED: (code, message, cause) => ({
|
|
56
|
+
kind: "UNSUPPORTED",
|
|
57
|
+
code,
|
|
58
|
+
message,
|
|
59
|
+
cause
|
|
60
|
+
})
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Wrap a kernel call that returns an KernelShape, automatically casting
|
|
64
|
+
* the result into a branded AnyShape. On exception, returns an Err
|
|
65
|
+
* with the given error code and message.
|
|
66
|
+
*
|
|
67
|
+
* kernel error messages are automatically translated into user-friendly
|
|
68
|
+
* explanations when the error kind is KERNEL_OPERATION.
|
|
69
|
+
*/
|
|
70
|
+
function kernelCall(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
71
|
+
try {
|
|
72
|
+
return ok(castShape(fn()));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
75
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
|
|
76
|
+
return err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Wrap a kernel call that returns an arbitrary value. On exception,
|
|
81
|
+
* returns an Err with the given error code and message.
|
|
82
|
+
*
|
|
83
|
+
* kernel error messages are automatically translated into user-friendly
|
|
84
|
+
* explanations when the error kind is KERNEL_OPERATION.
|
|
85
|
+
*/
|
|
86
|
+
function kernelCallRaw(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
87
|
+
try {
|
|
88
|
+
return ok(fn());
|
|
89
|
+
} catch (e) {
|
|
90
|
+
const rawMessage = e instanceof Error ? e.message : String(e);
|
|
91
|
+
const translatedMessage = kind === "KERNEL_OPERATION" ? translateKernelError(rawMessage) : rawMessage;
|
|
92
|
+
return err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wrap a kernel call that needs intermediate kernel allocations.
|
|
97
|
+
*
|
|
98
|
+
* A DisposalScope is created and passed to fn. The scope is disposed
|
|
99
|
+
* deterministically after fn returns or throws — ensuring no intermediate
|
|
100
|
+
* handles are leaked even on error paths.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* return kernelCallScoped(
|
|
104
|
+
* (scope) => {
|
|
105
|
+
* const axis = scope.register(makeKernelAx1(origin, dir));
|
|
106
|
+
* return getKernel().revolveVec(...) // was: oc.BRepBuilderAPI_MakeRevol_1(shape.wrapped, axis).Shape();
|
|
107
|
+
* },
|
|
108
|
+
* BrepErrorCode.REVOLUTION_NOT_3D,
|
|
109
|
+
* 'Revolution failed'
|
|
110
|
+
* );
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function kernelCallScoped(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
114
|
+
try {
|
|
115
|
+
var _usingCtx$1 = _usingCtx();
|
|
116
|
+
const scope = _usingCtx$1.u(new DisposalScope());
|
|
117
|
+
return kernelCall(() => fn(scope), code, message, kind);
|
|
118
|
+
} catch (_) {
|
|
119
|
+
_usingCtx$1.e = _;
|
|
120
|
+
} finally {
|
|
121
|
+
_usingCtx$1.d();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
4
125
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
126
|
/**
|
|
6
127
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -128,4 +249,4 @@ function sketchOnFace2D(bp, face, scaleMode) {
|
|
|
128
249
|
return bp.sketchOnFace(face, scaleMode);
|
|
129
250
|
}
|
|
130
251
|
//#endregion
|
|
131
|
-
export { reverseCurve as S, curve2dIsOnCurve as _, isInside2D as a, curve2dSplitAt as b, scale2D as c, stretch2D as d, toSVGPathD as f, curve2dFirstPoint as g, curve2dDistanceFrom as h, getOrientation2D as i, sketchOnFace2D as l, curve2dBoundingBox as m, createCompoundBlueprint as n, mirror2D as o, translate2D as p, getBounds2D as r, rotate2D as s, createBlueprint as t, sketchOnPlane2D as u, curve2dLastPoint as v, curve2dTangentAt as x, curve2dParameter as y };
|
|
252
|
+
export { kernelCall as C, reverseCurve as S, kernelCallScoped as T, curve2dIsOnCurve as _, isInside2D as a, curve2dSplitAt as b, scale2D as c, stretch2D as d, toSVGPathD as f, curve2dFirstPoint as g, curve2dDistanceFrom as h, getOrientation2D as i, sketchOnFace2D as l, curve2dBoundingBox as m, createCompoundBlueprint as n, mirror2D as o, translate2D as p, getBounds2D as r, rotate2D as s, createBlueprint as t, sketchOnPlane2D as u, curve2dLastPoint as v, kernelCallRaw as w, curve2dTangentAt as x, curve2dParameter as y };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { J as _usingCtx, L as DisposalScope, X as getKernel2D, Y as getKernel, a as createEdge, h as isShape3D, o as createFace, t as castShape, u as createWire } from "./shapeTypes-
|
|
2
|
-
import { L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, m as bug, n as computationError, s as safeIndex, w as isOk, y as err } from "./errors-
|
|
3
|
-
import { _ as DEG2RAD, d as vecNormalize, h as vecScale, r as vecCross, y as RAD2DEG } from "./vecOps-
|
|
4
|
-
import { r as toVec3 } from "./types-
|
|
5
|
-
import { n as createPlane } from "./planeOps-
|
|
6
|
-
import { _ as downcast, c as normalAt, p as uvBounds, u as pointOnSurface } from "./faceFns-
|
|
7
|
-
import { r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-
|
|
8
|
-
import { c as curveStartPoint, l as curveTangentAt, r as curveIsClosed } from "./curveFns-
|
|
9
|
-
import { _ as zip, i as makeNewFaceWithinFace, r as makeFace, s as assembleWire } from "./surfaceBuilders-
|
|
10
|
-
import { _ as samePoint$1, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, s as PRECISION_INTERSECTION, v as scalarMultiply2d } from "./helpers-
|
|
11
|
-
import { _ as Curve2D, b as removeDuplicatePoints, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-
|
|
12
|
-
import { c as twistExtrude, n as revolve, r as complexExtrude, s as sweep, t as extrude } from "./extrudeFns-
|
|
1
|
+
import { J as _usingCtx, L as DisposalScope, X as getKernel2D, Y as getKernel, a as createEdge, h as isShape3D, o as createFace, t as castShape, u as createWire } from "./shapeTypes-Di6GlhPk.js";
|
|
2
|
+
import { L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, m as bug, n as computationError, s as safeIndex, w as isOk, y as err } from "./errors-BVOlxlIA.js";
|
|
3
|
+
import { _ as DEG2RAD, d as vecNormalize, h as vecScale, r as vecCross, y as RAD2DEG } from "./vecOps-DFfUfsmc.js";
|
|
4
|
+
import { r as toVec3 } from "./types-BWBlwp6w.js";
|
|
5
|
+
import { n as createPlane } from "./planeOps-D88tfyJs.js";
|
|
6
|
+
import { _ as downcast, c as normalAt, p as uvBounds, u as pointOnSurface } from "./faceFns-Cat-4X74.js";
|
|
7
|
+
import { r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-B5LgmXBo.js";
|
|
8
|
+
import { c as curveStartPoint, l as curveTangentAt, r as curveIsClosed } from "./curveFns-DY4dFcP-.js";
|
|
9
|
+
import { _ as zip, i as makeNewFaceWithinFace, r as makeFace, s as assembleWire } from "./surfaceBuilders-BaqeZa0x.js";
|
|
10
|
+
import { _ as samePoint$1, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, s as PRECISION_INTERSECTION, v as scalarMultiply2d } from "./helpers-DgX1UucG.js";
|
|
11
|
+
import { _ as Curve2D, b as removeDuplicatePoints, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-CB_85Lz_.js";
|
|
12
|
+
import { c as twistExtrude, n as revolve, r as complexExtrude, s as sweep, t as extrude } from "./extrudeFns-b0uLn4E4.js";
|
|
13
13
|
//#region node_modules/flatqueue/index.js
|
|
14
14
|
/** @template T */
|
|
15
15
|
var FlatQueue = class {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_vecOps = require("./vecOps-
|
|
4
|
-
const require_types = require("./types-
|
|
5
|
-
const require_planeOps = require("./planeOps-
|
|
6
|
-
const require_faceFns = require("./faceFns-
|
|
7
|
-
const require_arrayAccess = require("./arrayAccess-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
9
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
10
|
-
const require_helpers = require("./helpers-
|
|
11
|
-
const require_blueprint = require("./blueprint-
|
|
12
|
-
const require_extrudeFns = require("./extrudeFns-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
|
|
2
|
+
const require_errors = require("./errors-BlC5ZWv4.cjs");
|
|
3
|
+
const require_vecOps = require("./vecOps-DKGelwGL.cjs");
|
|
4
|
+
const require_types = require("./types-BjDcsS7l.cjs");
|
|
5
|
+
const require_planeOps = require("./planeOps-BqLav0Ir.cjs");
|
|
6
|
+
const require_faceFns = require("./faceFns-BywUjlJ7.cjs");
|
|
7
|
+
const require_arrayAccess = require("./arrayAccess-t2dlxGSK.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-CZszKLQB.cjs");
|
|
9
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CZzipftq.cjs");
|
|
10
|
+
const require_helpers = require("./helpers-1iCCEElA.cjs");
|
|
11
|
+
const require_blueprint = require("./blueprint-CDnBM-tA.cjs");
|
|
12
|
+
const require_extrudeFns = require("./extrudeFns-GpCB_Uzs.cjs");
|
|
13
13
|
//#region node_modules/flatqueue/index.js
|
|
14
14
|
/** @template T */
|
|
15
15
|
var FlatQueue = class {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Y as getKernel, h as isShape3D, t as castShape } from "./shapeTypes-
|
|
2
|
-
import { C as isErr, L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, t as BrepErrorCode, y as err } from "./errors-
|
|
3
|
-
import { h as vecScale, t as vecAdd, v as HASH_CODE_MAX } from "./vecOps-
|
|
4
|
-
import { o as resolvePlane } from "./planeOps-
|
|
5
|
-
import { F as getEdges, R as getVertices, b as propagateAllMetadata, n as getAtOrThrow, t as firstOrThrow, x as propagateMetadataByHash, y as collectInputFaceHashes, z as getWires } from "./arrayAccess-
|
|
6
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
1
|
+
import { Y as getKernel, h as isShape3D, t as castShape } from "./shapeTypes-Di6GlhPk.js";
|
|
2
|
+
import { C as isErr, L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, t as BrepErrorCode, y as err } from "./errors-BVOlxlIA.js";
|
|
3
|
+
import { h as vecScale, t as vecAdd, v as HASH_CODE_MAX } from "./vecOps-DFfUfsmc.js";
|
|
4
|
+
import { o as resolvePlane } from "./planeOps-D88tfyJs.js";
|
|
5
|
+
import { F as getEdges, R as getVertices, b as propagateAllMetadata, n as getAtOrThrow, t as firstOrThrow, x as propagateMetadataByHash, y as collectInputFaceHashes, z as getWires } from "./arrayAccess-B5LgmXBo.js";
|
|
6
|
+
import { r as makeFace } from "./surfaceBuilders-BaqeZa0x.js";
|
|
7
7
|
//#region src/topology/booleanFns.ts
|
|
8
8
|
/**
|
|
9
9
|
* Boolean and compound operations — functional replacements for _3DShape boolean methods.
|
|
@@ -13,7 +13,7 @@ function validateShape3D(shape, label) {
|
|
|
13
13
|
if (getKernel().isNull(shape.wrapped)) return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, `${label} is a null shape`));
|
|
14
14
|
return ok(void 0);
|
|
15
15
|
}
|
|
16
|
-
function castToShape3D(shape, errorCode, errorMsg, suggestion) {
|
|
16
|
+
function castToShape3D(shape, errorCode, errorMsg, suggestion, diagnostics) {
|
|
17
17
|
const wrapped = castShape(shape);
|
|
18
18
|
if (!isShape3D(wrapped)) {
|
|
19
19
|
const shapeType = shape.ShapeType();
|
|
@@ -29,7 +29,7 @@ function castToShape3D(shape, errorCode, errorMsg, suggestion) {
|
|
|
29
29
|
"SHAPE"
|
|
30
30
|
][shapeType] ?? `UNKNOWN(${shapeType})`;
|
|
31
31
|
wrapped[Symbol.dispose]();
|
|
32
|
-
return err(typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`, void 0, void 0, suggestion));
|
|
32
|
+
return err(typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`, void 0, diagnostics ? { diagnostics } : void 0, suggestion));
|
|
33
33
|
}
|
|
34
34
|
return ok(wrapped);
|
|
35
35
|
}
|
|
@@ -40,12 +40,16 @@ function fuse(a, b, { optimisation = "none", simplify = false, signal, fuzzyValu
|
|
|
40
40
|
const checkB = validateShape3D(b, "fuse: second operand");
|
|
41
41
|
if (isErr(checkB)) return checkB;
|
|
42
42
|
const inputFaceHashes = collectInputFaceHashes([a, b]);
|
|
43
|
-
const { shape: resultShape, evolution } = getKernel().fuseWithHistory(a.wrapped, b.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
43
|
+
const { shape: resultShape, evolution, diagnostics } = getKernel().fuseWithHistory(a.wrapped, b.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
44
44
|
optimisation,
|
|
45
45
|
simplify,
|
|
46
46
|
fuzzyValue
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
if (diagnostics.hasErrors) {
|
|
49
|
+
getKernel().dispose(resultShape);
|
|
50
|
+
return err(kernelError(BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
51
|
+
}
|
|
52
|
+
const fuseResult = castToShape3D(resultShape, "FUSE_NOT_3D", "Fuse did not produce a 3D shape", "Common causes: overlapping coplanar faces, zero-thickness geometry, or non-manifold input. Try autoHeal() on inputs first.", diagnostics);
|
|
49
53
|
if (fuseResult.ok) propagateAllMetadata(evolution, [a, b], fuseResult.value);
|
|
50
54
|
return fuseResult;
|
|
51
55
|
}
|
|
@@ -56,12 +60,16 @@ function cut(base, tool, { optimisation = "none", simplify = false, signal, fuzz
|
|
|
56
60
|
const checkTool = validateShape3D(tool, "cut: tool");
|
|
57
61
|
if (isErr(checkTool)) return checkTool;
|
|
58
62
|
const inputFaceHashes = collectInputFaceHashes([base, tool]);
|
|
59
|
-
const { shape: resultShape, evolution } = getKernel().cutWithHistory(base.wrapped, tool.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
63
|
+
const { shape: resultShape, evolution, diagnostics } = getKernel().cutWithHistory(base.wrapped, tool.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
60
64
|
optimisation,
|
|
61
65
|
simplify,
|
|
62
66
|
fuzzyValue
|
|
63
67
|
});
|
|
64
|
-
|
|
68
|
+
if (diagnostics.hasErrors) {
|
|
69
|
+
getKernel().dispose(resultShape);
|
|
70
|
+
return err(kernelError(BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
71
|
+
}
|
|
72
|
+
const cutResult = castToShape3D(resultShape, "CUT_NOT_3D", "Cut did not produce a 3D shape", "Common causes: tool does not fully intersect the base, or produces a zero-thickness sliver. Ensure the tool extends through the shape.", diagnostics);
|
|
65
73
|
if (cutResult.ok) propagateAllMetadata(evolution, [base, tool], cutResult.value);
|
|
66
74
|
return cutResult;
|
|
67
75
|
}
|
|
@@ -72,11 +80,15 @@ function intersect(a, b, { simplify = false, signal, fuzzyValue, unsafe: _unsafe
|
|
|
72
80
|
const checkB = validateShape3D(b, "intersect: second operand");
|
|
73
81
|
if (isErr(checkB)) return checkB;
|
|
74
82
|
const inputFaceHashes = collectInputFaceHashes([a, b]);
|
|
75
|
-
const { shape: resultShape, evolution } = getKernel().intersectWithHistory(a.wrapped, b.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
83
|
+
const { shape: resultShape, evolution, diagnostics } = getKernel().intersectWithHistory(a.wrapped, b.wrapped, inputFaceHashes, HASH_CODE_MAX, {
|
|
76
84
|
simplify,
|
|
77
85
|
fuzzyValue
|
|
78
86
|
});
|
|
79
|
-
|
|
87
|
+
if (diagnostics.hasErrors) {
|
|
88
|
+
getKernel().dispose(resultShape);
|
|
89
|
+
return err(kernelError(BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
90
|
+
}
|
|
91
|
+
const intResult = castToShape3D(resultShape, "INTERSECT_NOT_3D", "Intersect did not produce a 3D shape", "Shapes may not overlap. Verify they share a common volume before intersecting.", diagnostics);
|
|
80
92
|
if (intResult.ok) propagateAllMetadata(evolution, [a, b], intResult.value);
|
|
81
93
|
return intResult;
|
|
82
94
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_vecOps = require("./vecOps-
|
|
4
|
-
const require_planeOps = require("./planeOps-
|
|
5
|
-
const require_arrayAccess = require("./arrayAccess-
|
|
6
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-8eK48l-X.cjs");
|
|
2
|
+
const require_errors = require("./errors-BlC5ZWv4.cjs");
|
|
3
|
+
const require_vecOps = require("./vecOps-DKGelwGL.cjs");
|
|
4
|
+
const require_planeOps = require("./planeOps-BqLav0Ir.cjs");
|
|
5
|
+
const require_arrayAccess = require("./arrayAccess-t2dlxGSK.cjs");
|
|
6
|
+
const require_surfaceBuilders = require("./surfaceBuilders-CZzipftq.cjs");
|
|
7
7
|
//#region src/topology/booleanFns.ts
|
|
8
8
|
/**
|
|
9
9
|
* Boolean and compound operations — functional replacements for _3DShape boolean methods.
|
|
@@ -13,7 +13,7 @@ function validateShape3D(shape, label) {
|
|
|
13
13
|
if (require_shapeTypes.getKernel().isNull(shape.wrapped)) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.NULL_SHAPE_INPUT, `${label} is a null shape`));
|
|
14
14
|
return require_errors.ok(void 0);
|
|
15
15
|
}
|
|
16
|
-
function castToShape3D(shape, errorCode, errorMsg, suggestion) {
|
|
16
|
+
function castToShape3D(shape, errorCode, errorMsg, suggestion, diagnostics) {
|
|
17
17
|
const wrapped = require_shapeTypes.castShape(shape);
|
|
18
18
|
if (!require_shapeTypes.isShape3D(wrapped)) {
|
|
19
19
|
const shapeType = shape.ShapeType();
|
|
@@ -29,7 +29,7 @@ function castToShape3D(shape, errorCode, errorMsg, suggestion) {
|
|
|
29
29
|
"SHAPE"
|
|
30
30
|
][shapeType] ?? `UNKNOWN(${shapeType})`;
|
|
31
31
|
wrapped[Symbol.dispose]();
|
|
32
|
-
return require_errors.err(require_errors.typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`, void 0, void 0, suggestion));
|
|
32
|
+
return require_errors.err(require_errors.typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`, void 0, diagnostics ? { diagnostics } : void 0, suggestion));
|
|
33
33
|
}
|
|
34
34
|
return require_errors.ok(wrapped);
|
|
35
35
|
}
|
|
@@ -40,12 +40,16 @@ function fuse(a, b, { optimisation = "none", simplify = false, signal, fuzzyValu
|
|
|
40
40
|
const checkB = validateShape3D(b, "fuse: second operand");
|
|
41
41
|
if (require_errors.isErr(checkB)) return checkB;
|
|
42
42
|
const inputFaceHashes = require_arrayAccess.collectInputFaceHashes([a, b]);
|
|
43
|
-
const { shape: resultShape, evolution } = require_shapeTypes.getKernel().fuseWithHistory(a.wrapped, b.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
43
|
+
const { shape: resultShape, evolution, diagnostics } = require_shapeTypes.getKernel().fuseWithHistory(a.wrapped, b.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
44
44
|
optimisation,
|
|
45
45
|
simplify,
|
|
46
46
|
fuzzyValue
|
|
47
47
|
});
|
|
48
|
-
|
|
48
|
+
if (diagnostics.hasErrors) {
|
|
49
|
+
require_shapeTypes.getKernel().dispose(resultShape);
|
|
50
|
+
return require_errors.err(require_errors.kernelError(require_errors.BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
51
|
+
}
|
|
52
|
+
const fuseResult = castToShape3D(resultShape, "FUSE_NOT_3D", "Fuse did not produce a 3D shape", "Common causes: overlapping coplanar faces, zero-thickness geometry, or non-manifold input. Try autoHeal() on inputs first.", diagnostics);
|
|
49
53
|
if (fuseResult.ok) require_arrayAccess.propagateAllMetadata(evolution, [a, b], fuseResult.value);
|
|
50
54
|
return fuseResult;
|
|
51
55
|
}
|
|
@@ -56,12 +60,16 @@ function cut(base, tool, { optimisation = "none", simplify = false, signal, fuzz
|
|
|
56
60
|
const checkTool = validateShape3D(tool, "cut: tool");
|
|
57
61
|
if (require_errors.isErr(checkTool)) return checkTool;
|
|
58
62
|
const inputFaceHashes = require_arrayAccess.collectInputFaceHashes([base, tool]);
|
|
59
|
-
const { shape: resultShape, evolution } = require_shapeTypes.getKernel().cutWithHistory(base.wrapped, tool.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
63
|
+
const { shape: resultShape, evolution, diagnostics } = require_shapeTypes.getKernel().cutWithHistory(base.wrapped, tool.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
60
64
|
optimisation,
|
|
61
65
|
simplify,
|
|
62
66
|
fuzzyValue
|
|
63
67
|
});
|
|
64
|
-
|
|
68
|
+
if (diagnostics.hasErrors) {
|
|
69
|
+
require_shapeTypes.getKernel().dispose(resultShape);
|
|
70
|
+
return require_errors.err(require_errors.kernelError(require_errors.BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
71
|
+
}
|
|
72
|
+
const cutResult = castToShape3D(resultShape, "CUT_NOT_3D", "Cut did not produce a 3D shape", "Common causes: tool does not fully intersect the base, or produces a zero-thickness sliver. Ensure the tool extends through the shape.", diagnostics);
|
|
65
73
|
if (cutResult.ok) require_arrayAccess.propagateAllMetadata(evolution, [base, tool], cutResult.value);
|
|
66
74
|
return cutResult;
|
|
67
75
|
}
|
|
@@ -72,11 +80,15 @@ function intersect(a, b, { simplify = false, signal, fuzzyValue, unsafe: _unsafe
|
|
|
72
80
|
const checkB = validateShape3D(b, "intersect: second operand");
|
|
73
81
|
if (require_errors.isErr(checkB)) return checkB;
|
|
74
82
|
const inputFaceHashes = require_arrayAccess.collectInputFaceHashes([a, b]);
|
|
75
|
-
const { shape: resultShape, evolution } = require_shapeTypes.getKernel().intersectWithHistory(a.wrapped, b.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
83
|
+
const { shape: resultShape, evolution, diagnostics } = require_shapeTypes.getKernel().intersectWithHistory(a.wrapped, b.wrapped, inputFaceHashes, require_vecOps.HASH_CODE_MAX, {
|
|
76
84
|
simplify,
|
|
77
85
|
fuzzyValue
|
|
78
86
|
});
|
|
79
|
-
|
|
87
|
+
if (diagnostics.hasErrors) {
|
|
88
|
+
require_shapeTypes.getKernel().dispose(resultShape);
|
|
89
|
+
return require_errors.err(require_errors.kernelError(require_errors.BrepErrorCode.BOOLEAN_HAS_ERRORS, "Boolean operation reported internal errors. The result may be invalid.", void 0, { diagnostics }, "Use checkBoolean() to pre-validate operands, or try autoHeal() on inputs."));
|
|
90
|
+
}
|
|
91
|
+
const intResult = castToShape3D(resultShape, "INTERSECT_NOT_3D", "Intersect did not produce a 3D shape", "Shapes may not overlap. Verify they share a common volume before intersecting.", diagnostics);
|
|
80
92
|
if (intResult.ok) require_arrayAccess.propagateAllMetadata(evolution, [a, b], intResult.value);
|
|
81
93
|
return intResult;
|
|
82
94
|
}
|