brepjs 18.119.2 → 18.119.3
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/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-DTNT4qYJ.cjs → blueprint-BGcBMy3b.cjs} +39 -9
- package/dist/{blueprint-DJJo8WkI.js → blueprint-CAG6jseD.js} +33 -9
- package/dist/{blueprintFns-CcpboZ80.js → blueprintFns-B4C3zH7N.js} +9 -4
- package/dist/{blueprintFns-2XDZfCxX.cjs → blueprintFns-CnoqynzI.cjs} +9 -4
- package/dist/{blueprintSketcher-C0EXFVb2.cjs → blueprintSketcher-BNz6f36D.cjs} +166 -61
- package/dist/{blueprintSketcher-DDPyypmC.js → blueprintSketcher-CKKxvxB-.js} +159 -54
- package/dist/{boolean2D-Ddfo_dd0.cjs → boolean2D-B-0xobBP.cjs} +5 -5
- package/dist/{boolean2D-C_PVz8xT.js → boolean2D-C_1gMcZ6.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-B14M5M68.cjs} +14 -14
- package/dist/{drawFns-B9HbtAoc.js → drawFns-BShGVVXW.js} +14 -14
- 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-BHs19muu.js} +3 -3
- package/dist/{importFns-DS4J1xLv.cjs → importFns-GySbuvVv.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.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-8EcWreab.cjs} +138 -51
- package/dist/{textBlueprints-igbNvKcd.js → textBlueprints-rA1HT6j1.js} +116 -11
- package/dist/{textMetrics-CJvtpbc3.js → textMetrics-Bcbso1Ns.js} +2 -2
- package/dist/{textMetrics-08fF0QNf.cjs → textMetrics-GPBu9JKi.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,6 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { D as getOrQueryType, K as getKernel, M as DisposalScope, W as _usingCtx, n as castResultShape, r as castResultShapeWithKnownType } from "./shapeTypes-t49f64Dx.js";
|
|
2
|
+
import { E as ok, g as err } from "./errors-MHLiNE-C.js";
|
|
3
3
|
import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
|
|
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 = {
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { K as getKernel } from "./shapeTypes-t49f64Dx.js";
|
|
2
|
+
import { E as ok, g as err } from "./errors-MHLiNE-C.js";
|
|
3
|
+
//#region src/core/validityTypes.ts
|
|
4
|
+
/**
|
|
5
|
+
* Type guard — check if a wire is closed (forms a loop).
|
|
6
|
+
* Uses the kernel's `curveIsClosed` to verify at runtime.
|
|
7
|
+
*/
|
|
8
|
+
function isClosedWire(wire) {
|
|
9
|
+
return getKernel().curveIsClosed(wire.wrapped);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard — check if a face is valid and thus safe to use in operations.
|
|
13
|
+
*
|
|
14
|
+
* Uses kernel validity (BRepCheck_Analyzer) which verifies geometric and
|
|
15
|
+
* topological correctness. Faces produced by kernel operations (makeFace,
|
|
16
|
+
* extrude, revolve, boolean ops) are oriented by construction. For faces
|
|
17
|
+
* from STEP/IGES imports or external sources, validity does not guarantee
|
|
18
|
+
* consistent normal orientation — use with caution or re-orient first.
|
|
19
|
+
*/
|
|
20
|
+
function isOrientedFace(face) {
|
|
21
|
+
return getKernel().isValid(face.wrapped);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard — check if a shell is manifold (watertight, no dangling faces).
|
|
25
|
+
* Checks kernel validity, then attempts `solidFromShell` — if the shell
|
|
26
|
+
* can form a valid solid, it is manifold by definition.
|
|
27
|
+
*
|
|
28
|
+
* The temporary solid created for the proof is disposed immediately to avoid
|
|
29
|
+
* WASM memory leaks.
|
|
30
|
+
*/
|
|
31
|
+
function isManifoldShell(shell) {
|
|
32
|
+
const kernel = getKernel();
|
|
33
|
+
if (!kernel.isValid(shell.wrapped)) return false;
|
|
34
|
+
const validate = kernel.isValidStrict?.bind(kernel) ?? kernel.isValid.bind(kernel);
|
|
35
|
+
try {
|
|
36
|
+
const solid = kernel.solidFromShell(shell.wrapped);
|
|
37
|
+
const valid = validate(solid);
|
|
38
|
+
try {
|
|
39
|
+
kernel.dispose(solid);
|
|
40
|
+
} catch {}
|
|
41
|
+
return valid;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Type guard — check if a solid passes BRepCheck validation.
|
|
48
|
+
*/
|
|
49
|
+
function isValidSolid(solid) {
|
|
50
|
+
return getKernel().isValid(solid.wrapped);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Prove that a wire is closed, returning a branded `ClosedWire` on success.
|
|
54
|
+
* This is the primary smart constructor for `ClosedWire`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const w = wire([e1, e2, e3]);
|
|
59
|
+
* const closed = closedWire(unwrap(w));
|
|
60
|
+
* if (isOk(closed)) {
|
|
61
|
+
* const f = face(closed.value); // ClosedWire accepted
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
function closedWire(wire) {
|
|
66
|
+
if (isClosedWire(wire)) return ok(wire);
|
|
67
|
+
return err("Wire is not closed: start and end points do not coincide");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prove that a face is oriented, returning a branded `OrientedFace` on success.
|
|
71
|
+
*/
|
|
72
|
+
function orientedFace(face) {
|
|
73
|
+
if (isOrientedFace(face)) return ok(face);
|
|
74
|
+
return err("Face orientation is inconsistent or face is invalid");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Prove that a shell is manifold, returning a branded `ManifoldShell` on success.
|
|
78
|
+
*/
|
|
79
|
+
function manifoldShell(shell) {
|
|
80
|
+
if (isManifoldShell(shell)) return ok(shell);
|
|
81
|
+
return err("Shell is not manifold: has free edges or is invalid");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Prove that a solid is valid, returning a branded `ValidSolid` on success.
|
|
85
|
+
*/
|
|
86
|
+
function validSolid(solid) {
|
|
87
|
+
if (isValidSolid(solid)) return ok(solid);
|
|
88
|
+
return err("Solid failed BRepCheck validation");
|
|
89
|
+
}
|
|
90
|
+
/** Type guard — check if a face is planar (underlying surface is a plane). */
|
|
91
|
+
function isPlanarFace(face) {
|
|
92
|
+
return getKernel().surfaceType(face.wrapped) === "plane";
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Type guard — check if a wire is planar (all edges lie in a common plane).
|
|
96
|
+
* Strategy: try planar-only face construction first (fast path on OCCT — throws
|
|
97
|
+
* for non-planar wires). If that succeeds, verify the surface type. If it
|
|
98
|
+
* fails, fall back to general mode and check whether the resulting surface is
|
|
99
|
+
* a plane. This handles kernel-specific differences in the planar flag.
|
|
100
|
+
*/
|
|
101
|
+
function isPlanarWire(wire) {
|
|
102
|
+
const kernel = getKernel();
|
|
103
|
+
const checkFace = (onlyPlane) => {
|
|
104
|
+
try {
|
|
105
|
+
const tempFace = kernel.makeFace(wire.wrapped, onlyPlane);
|
|
106
|
+
const stype = kernel.surfaceType(tempFace);
|
|
107
|
+
try {
|
|
108
|
+
kernel.dispose(tempFace);
|
|
109
|
+
} catch {}
|
|
110
|
+
return stype === "plane";
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
if (checkFace(true)) return true;
|
|
116
|
+
return checkFace(false);
|
|
117
|
+
}
|
|
118
|
+
/** Prove that a face is planar, returning a branded `PlanarFace` on success. */
|
|
119
|
+
function planarFace(face) {
|
|
120
|
+
if (isPlanarFace(face)) return ok(face);
|
|
121
|
+
return err("Face is not planar: underlying surface is not a geometric plane");
|
|
122
|
+
}
|
|
123
|
+
/** Prove that a wire is planar, returning a branded `PlanarWire` on success. */
|
|
124
|
+
function planarWire(wire) {
|
|
125
|
+
if (isPlanarWire(wire)) return ok(wire);
|
|
126
|
+
return err("Wire is not planar: edges do not lie in a common plane");
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { isPlanarFace as a, manifoldShell as c, planarWire as d, validSolid as f, isOrientedFace as i, orientedFace as l, isClosedWire as n, isPlanarWire as o, isManifoldShell as r, isValidSolid as s, closedWire as t, planarFace as u };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
3
|
+
//#region src/core/validityTypes.ts
|
|
4
|
+
/**
|
|
5
|
+
* Type guard — check if a wire is closed (forms a loop).
|
|
6
|
+
* Uses the kernel's `curveIsClosed` to verify at runtime.
|
|
7
|
+
*/
|
|
8
|
+
function isClosedWire(wire) {
|
|
9
|
+
return require_shapeTypes.getKernel().curveIsClosed(wire.wrapped);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard — check if a face is valid and thus safe to use in operations.
|
|
13
|
+
*
|
|
14
|
+
* Uses kernel validity (BRepCheck_Analyzer) which verifies geometric and
|
|
15
|
+
* topological correctness. Faces produced by kernel operations (makeFace,
|
|
16
|
+
* extrude, revolve, boolean ops) are oriented by construction. For faces
|
|
17
|
+
* from STEP/IGES imports or external sources, validity does not guarantee
|
|
18
|
+
* consistent normal orientation — use with caution or re-orient first.
|
|
19
|
+
*/
|
|
20
|
+
function isOrientedFace(face) {
|
|
21
|
+
return require_shapeTypes.getKernel().isValid(face.wrapped);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard — check if a shell is manifold (watertight, no dangling faces).
|
|
25
|
+
* Checks kernel validity, then attempts `solidFromShell` — if the shell
|
|
26
|
+
* can form a valid solid, it is manifold by definition.
|
|
27
|
+
*
|
|
28
|
+
* The temporary solid created for the proof is disposed immediately to avoid
|
|
29
|
+
* WASM memory leaks.
|
|
30
|
+
*/
|
|
31
|
+
function isManifoldShell(shell) {
|
|
32
|
+
const kernel = require_shapeTypes.getKernel();
|
|
33
|
+
if (!kernel.isValid(shell.wrapped)) return false;
|
|
34
|
+
const validate = kernel.isValidStrict?.bind(kernel) ?? kernel.isValid.bind(kernel);
|
|
35
|
+
try {
|
|
36
|
+
const solid = kernel.solidFromShell(shell.wrapped);
|
|
37
|
+
const valid = validate(solid);
|
|
38
|
+
try {
|
|
39
|
+
kernel.dispose(solid);
|
|
40
|
+
} catch {}
|
|
41
|
+
return valid;
|
|
42
|
+
} catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Type guard — check if a solid passes BRepCheck validation.
|
|
48
|
+
*/
|
|
49
|
+
function isValidSolid(solid) {
|
|
50
|
+
return require_shapeTypes.getKernel().isValid(solid.wrapped);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Prove that a wire is closed, returning a branded `ClosedWire` on success.
|
|
54
|
+
* This is the primary smart constructor for `ClosedWire`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const w = wire([e1, e2, e3]);
|
|
59
|
+
* const closed = closedWire(unwrap(w));
|
|
60
|
+
* if (isOk(closed)) {
|
|
61
|
+
* const f = face(closed.value); // ClosedWire accepted
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
function closedWire(wire) {
|
|
66
|
+
if (isClosedWire(wire)) return require_errors.ok(wire);
|
|
67
|
+
return require_errors.err("Wire is not closed: start and end points do not coincide");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Prove that a face is oriented, returning a branded `OrientedFace` on success.
|
|
71
|
+
*/
|
|
72
|
+
function orientedFace(face) {
|
|
73
|
+
if (isOrientedFace(face)) return require_errors.ok(face);
|
|
74
|
+
return require_errors.err("Face orientation is inconsistent or face is invalid");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Prove that a shell is manifold, returning a branded `ManifoldShell` on success.
|
|
78
|
+
*/
|
|
79
|
+
function manifoldShell(shell) {
|
|
80
|
+
if (isManifoldShell(shell)) return require_errors.ok(shell);
|
|
81
|
+
return require_errors.err("Shell is not manifold: has free edges or is invalid");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Prove that a solid is valid, returning a branded `ValidSolid` on success.
|
|
85
|
+
*/
|
|
86
|
+
function validSolid(solid) {
|
|
87
|
+
if (isValidSolid(solid)) return require_errors.ok(solid);
|
|
88
|
+
return require_errors.err("Solid failed BRepCheck validation");
|
|
89
|
+
}
|
|
90
|
+
/** Type guard — check if a face is planar (underlying surface is a plane). */
|
|
91
|
+
function isPlanarFace(face) {
|
|
92
|
+
return require_shapeTypes.getKernel().surfaceType(face.wrapped) === "plane";
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Type guard — check if a wire is planar (all edges lie in a common plane).
|
|
96
|
+
* Strategy: try planar-only face construction first (fast path on OCCT — throws
|
|
97
|
+
* for non-planar wires). If that succeeds, verify the surface type. If it
|
|
98
|
+
* fails, fall back to general mode and check whether the resulting surface is
|
|
99
|
+
* a plane. This handles kernel-specific differences in the planar flag.
|
|
100
|
+
*/
|
|
101
|
+
function isPlanarWire(wire) {
|
|
102
|
+
const kernel = require_shapeTypes.getKernel();
|
|
103
|
+
const checkFace = (onlyPlane) => {
|
|
104
|
+
try {
|
|
105
|
+
const tempFace = kernel.makeFace(wire.wrapped, onlyPlane);
|
|
106
|
+
const stype = kernel.surfaceType(tempFace);
|
|
107
|
+
try {
|
|
108
|
+
kernel.dispose(tempFace);
|
|
109
|
+
} catch {}
|
|
110
|
+
return stype === "plane";
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
if (checkFace(true)) return true;
|
|
116
|
+
return checkFace(false);
|
|
117
|
+
}
|
|
118
|
+
/** Prove that a face is planar, returning a branded `PlanarFace` on success. */
|
|
119
|
+
function planarFace(face) {
|
|
120
|
+
if (isPlanarFace(face)) return require_errors.ok(face);
|
|
121
|
+
return require_errors.err("Face is not planar: underlying surface is not a geometric plane");
|
|
122
|
+
}
|
|
123
|
+
/** Prove that a wire is planar, returning a branded `PlanarWire` on success. */
|
|
124
|
+
function planarWire(wire) {
|
|
125
|
+
if (isPlanarWire(wire)) return require_errors.ok(wire);
|
|
126
|
+
return require_errors.err("Wire is not planar: edges do not lie in a common plane");
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
Object.defineProperty(exports, "closedWire", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function() {
|
|
132
|
+
return closedWire;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(exports, "isClosedWire", {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function() {
|
|
138
|
+
return isClosedWire;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(exports, "isManifoldShell", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function() {
|
|
144
|
+
return isManifoldShell;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
Object.defineProperty(exports, "isOrientedFace", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
get: function() {
|
|
150
|
+
return isOrientedFace;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(exports, "isPlanarFace", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function() {
|
|
156
|
+
return isPlanarFace;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
Object.defineProperty(exports, "isPlanarWire", {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function() {
|
|
162
|
+
return isPlanarWire;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
Object.defineProperty(exports, "isValidSolid", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
get: function() {
|
|
168
|
+
return isValidSolid;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(exports, "manifoldShell", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function() {
|
|
174
|
+
return manifoldShell;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(exports, "orientedFace", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
get: function() {
|
|
180
|
+
return orientedFace;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
Object.defineProperty(exports, "planarFace", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
get: function() {
|
|
186
|
+
return planarFace;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(exports, "planarWire", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function() {
|
|
192
|
+
return planarWire;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(exports, "validSolid", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function() {
|
|
198
|
+
return validSolid;
|
|
199
|
+
}
|
|
200
|
+
});
|
package/dist/vectors.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
3
3
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
4
4
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
5
|
-
const require_planeOps = require("./planeOps-
|
|
5
|
+
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
6
6
|
exports.DEG2RAD = require_constants.DEG2RAD;
|
|
7
7
|
exports.RAD2DEG = require_constants.RAD2DEG;
|
|
8
8
|
exports.createNamedPlane = require_planeOps.createNamedPlane;
|
package/dist/vectors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
2
2
|
import { n as toVec2, r as toVec3, t as resolveDirection } from "./types-D24Y27N0.js";
|
|
3
3
|
import { a as vecDot, c as vecLength, d as vecNormalize, f as vecProjectToPlane, g as vecSub, h as vecScale, i as vecDistance, l as vecLengthSq, m as vecRotate, n as vecAngle, o as vecEquals, p as vecRepr, r as vecCross, s as vecIsZero, t as vecAdd, u as vecNegate } from "./vecOps-SKPRvPH-.js";
|
|
4
|
-
import { i as pivotPlane, n as createPlane, o as resolvePlane, s as translatePlane, t as createNamedPlane } from "./planeOps-
|
|
4
|
+
import { i as pivotPlane, n as createPlane, o as resolvePlane, s as translatePlane, t as createNamedPlane } from "./planeOps-CQahLrCx.js";
|
|
5
5
|
export { DEG2RAD, RAD2DEG, createNamedPlane, createPlane, pivotPlane, resolveDirection, resolvePlane, toVec2, toVec3, translatePlane, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs",
|
|
3
|
-
"version": "18.119.
|
|
3
|
+
"version": "18.119.3",
|
|
4
4
|
"description": "Web CAD library with pluggable geometry kernel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cad",
|
|
@@ -265,23 +265,23 @@
|
|
|
265
265
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
266
266
|
"@vitest/coverage-v8": "4.1.10",
|
|
267
267
|
"brepjs-opencascade": "*",
|
|
268
|
-
"brepkit-wasm": "2.
|
|
268
|
+
"brepkit-wasm": "2.127.10",
|
|
269
269
|
"eslint": "10.7.0",
|
|
270
270
|
"fast-check": "4.9.0",
|
|
271
271
|
"husky": "9.1.7",
|
|
272
|
-
"knip": "6.
|
|
273
|
-
"lint-staged": "17.0
|
|
272
|
+
"knip": "6.27.0",
|
|
273
|
+
"lint-staged": "17.1.0",
|
|
274
274
|
"lz-string": "1.5.0",
|
|
275
275
|
"occt-wasm": "3.8.0",
|
|
276
|
-
"prettier": "3.9.
|
|
276
|
+
"prettier": "3.9.6",
|
|
277
277
|
"puppeteer": "25.3.0",
|
|
278
278
|
"size-limit": "12.1.0",
|
|
279
279
|
"sucrase": "3.35.1",
|
|
280
|
-
"tsx": "4.23.
|
|
280
|
+
"tsx": "4.23.1",
|
|
281
281
|
"typedoc": "0.28.20",
|
|
282
282
|
"typescript": "6.0.3",
|
|
283
|
-
"typescript-eslint": "8.
|
|
284
|
-
"vite": "8.1.
|
|
283
|
+
"typescript-eslint": "8.65.0",
|
|
284
|
+
"vite": "8.1.5",
|
|
285
285
|
"vite-plugin-dts": "5.0.3",
|
|
286
286
|
"vitest": "4.1.10"
|
|
287
287
|
},
|