brepjs 12.8.2 → 12.9.1
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/svgPath.d.ts.map +1 -1
- package/dist/2d/lib/vectorOperations.d.ts +4 -1
- package/dist/2d/lib/vectorOperations.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +5 -5
- package/dist/{Blueprint-DbVaf6k7.js → Blueprint-1HGbugaC.js} +33 -63
- package/dist/{Blueprint-CQ28WJhz.cjs → Blueprint-CUyXM6CV.cjs} +15 -45
- package/dist/{boolean2D-0blbVtJ8.cjs → boolean2D-9OnbotKT.cjs} +9 -9
- package/dist/{boolean2D-y3E92F0u.js → boolean2D-CR4efa35.js} +11 -11
- package/dist/{booleanFns-gmsX3Cv2.cjs → booleanFns-BBd2oTvv.cjs} +43 -40
- package/dist/{booleanFns-BCTjYZAg.js → booleanFns-Br2KdGJq.js} +53 -50
- package/dist/brepjs.cjs +379 -284
- package/dist/brepjs.js +1437 -1341
- package/dist/core/definitionMaps.d.ts +2 -7
- package/dist/core/definitionMaps.d.ts.map +1 -1
- package/dist/core/dimensionTypes.d.ts +52 -0
- package/dist/core/dimensionTypes.d.ts.map +1 -0
- package/dist/core/disposal.d.ts +18 -0
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core/errors.d.ts +1 -8
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/kernelErrorTranslation.d.ts +15 -0
- package/dist/core/kernelErrorTranslation.d.ts.map +1 -0
- package/dist/core/planeOps.d.ts +14 -0
- package/dist/core/planeOps.d.ts.map +1 -1
- package/dist/core/result.d.ts +4 -0
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/shapeTypes.d.ts +14 -146
- package/dist/core/shapeTypes.d.ts.map +1 -1
- package/dist/core/typeDiscriminants.d.ts +14 -0
- package/dist/core/typeDiscriminants.d.ts.map +1 -0
- package/dist/core/validityTypes.d.ts +100 -0
- package/dist/core/validityTypes.d.ts.map +1 -0
- package/dist/core.cjs +52 -11
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +118 -75
- package/dist/{curveFns-mROFhiuG.js → curveFns-1u0oZ0u0.js} +14 -14
- package/dist/{curveFns-BZngcnQ1.cjs → curveFns-BwLvO_Ia.cjs} +2 -2
- package/dist/{drawFns-Bwakrq7w.js → drawFns-B0na6sbo.js} +16 -16
- package/dist/{drawFns-CjRc1NfQ.cjs → drawFns-CzlEePor.cjs} +18 -18
- package/dist/{faceFns-DB1Fc5gy.cjs → faceFns-BAKkZG6D.cjs} +2 -2
- package/dist/{faceFns-B8GnxjdY.js → faceFns-DGMp47Os.js} +3 -3
- package/dist/{helpers-C8NoT0Wu.cjs → helpers-DVdscQxW.cjs} +73 -8
- package/dist/{helpers-X0juxnwj.js → helpers-sJjnIXDA.js} +85 -20
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/brepkit/booleanOps.d.ts +23 -0
- package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/constructionOps.d.ts +51 -0
- package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/evolutionOps.d.ts +31 -0
- package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/geometryOps.d.ts +56 -0
- package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/helpers.d.ts +84 -0
- package/dist/kernel/brepkit/helpers.d.ts.map +1 -0
- package/dist/kernel/brepkit/internalOps.d.ts +28 -0
- package/dist/kernel/brepkit/internalOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/ioOps.d.ts +43 -0
- package/dist/kernel/brepkit/ioOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/measureOps.d.ts +30 -0
- package/dist/kernel/brepkit/measureOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/meshOps.d.ts +7 -0
- package/dist/kernel/brepkit/meshOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/modifierOps.d.ts +15 -0
- package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/repairOps.d.ts +14 -0
- package/dist/kernel/brepkit/repairOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/sweepOps.d.ts +27 -0
- package/dist/kernel/brepkit/sweepOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/topologyOps.d.ts +16 -0
- package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/transformOps.d.ts +14 -0
- package/dist/kernel/brepkit/transformOps.d.ts.map +1 -0
- package/dist/kernel/brepkitAdapter.d.ts +1 -1
- package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
- package/dist/kernel/brepkitWasmTypes.d.ts +8 -0
- package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
- package/dist/kernel/defaultAdapter.d.ts.map +1 -1
- package/dist/kernel/extendedConstructorOps.d.ts +9 -1
- package/dist/kernel/extendedConstructorOps.d.ts.map +1 -1
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.d.ts.map +1 -1
- package/dist/kernel/interfaces/boolean-ops.d.ts +25 -0
- package/dist/kernel/interfaces/boolean-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/construction-ops.d.ts +76 -0
- package/dist/kernel/interfaces/construction-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/core.d.ts +45 -0
- package/dist/kernel/interfaces/core.d.ts.map +1 -0
- package/dist/kernel/interfaces/evolution-ops.d.ts +19 -0
- package/dist/kernel/interfaces/evolution-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/geometry-ops.d.ts +77 -0
- package/dist/kernel/interfaces/geometry-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/index.d.ts +29 -0
- package/dist/kernel/interfaces/index.d.ts.map +1 -0
- package/dist/kernel/interfaces/io-ops.d.ts +66 -0
- package/dist/kernel/interfaces/io-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/measure-ops.d.ts +35 -0
- package/dist/kernel/interfaces/measure-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/mesh-ops.d.ts +21 -0
- package/dist/kernel/interfaces/mesh-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/modifier-ops.d.ts +22 -0
- package/dist/kernel/interfaces/modifier-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/repair-ops.d.ts +36 -0
- package/dist/kernel/interfaces/repair-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/sweep-ops.d.ts +49 -0
- package/dist/kernel/interfaces/sweep-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/topology-ops.d.ts +30 -0
- package/dist/kernel/interfaces/topology-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/transform-ops.d.ts +20 -0
- package/dist/kernel/interfaces/transform-ops.d.ts.map +1 -0
- package/dist/kernel/modifierOps.d.ts +2 -2
- package/dist/kernel/modifierOps.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +2 -446
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-hp3pc1M7.cjs → loft-BNvBZzqe.cjs} +5 -5
- package/dist/{loft-Bhw-FMoL.js → loft-D0aCZRaB.js} +7 -7
- package/dist/measurement/measureFns.d.ts +2 -2
- package/dist/measurement/measureFns.d.ts.map +1 -1
- package/dist/{measurement-D8EJ694A.js → measurement-C7o5jE6G.js} +2 -2
- package/dist/{measurement-BoNTUBAp.cjs → measurement-DZcaxo1A.cjs} +2 -2
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BnV0ZR8w.cjs → meshFns-7dgZgNYK.cjs} +4 -4
- package/dist/{meshFns-nQjK38EC.js → meshFns-CtUl9fGY.js} +3 -3
- package/dist/operations/compoundOpsFns.d.ts +38 -0
- package/dist/operations/compoundOpsFns.d.ts.map +1 -0
- package/dist/operations/extrude.d.ts +2 -12
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts +2 -93
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/guidedSweepFns.d.ts +3 -22
- package/dist/operations/guidedSweepFns.d.ts.map +1 -1
- package/dist/operations/loft.d.ts +2 -16
- package/dist/operations/loft.d.ts.map +1 -1
- package/dist/operations/multiSweepFns.d.ts +3 -29
- package/dist/operations/multiSweepFns.d.ts.map +1 -1
- package/dist/operations/roofFns.d.ts +2 -2
- package/dist/operations/roofFns.d.ts.map +1 -1
- package/dist/operations/sweepFns.d.ts +121 -0
- package/dist/operations/sweepFns.d.ts.map +1 -0
- package/dist/{operations-BfbkK6DU.js → operations-DisJ5F8s.js} +110 -57
- package/dist/{operations-CYpmLSC4.cjs → operations-DwZ-RBO1.cjs} +97 -44
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +14 -14
- package/dist/originTrackingFns-NJ1dWoiF.js +137 -0
- package/dist/originTrackingFns-dhaCe8Yb.cjs +136 -0
- package/dist/query/edgeFinder.d.ts +4 -14
- package/dist/query/edgeFinder.d.ts.map +1 -1
- package/dist/query/faceFinder.d.ts +4 -14
- package/dist/query/faceFinder.d.ts.map +1 -1
- package/dist/query/finderCore.d.ts +6 -0
- package/dist/query/finderCore.d.ts.map +1 -1
- package/dist/query/shapeFinders.d.ts +32 -0
- package/dist/query/shapeFinders.d.ts.map +1 -0
- package/dist/query/wireFinder.d.ts +4 -9
- package/dist/query/wireFinder.d.ts.map +1 -1
- package/dist/query.cjs +54 -32
- package/dist/query.js +56 -34
- package/dist/{result-fAX0OZzI.cjs → result-DJAAj1yb.cjs} +8 -59
- package/dist/{result-BaSD1fqR.js → result-DtuwWSUD.js} +38 -89
- package/dist/result.cjs +1 -1
- package/dist/result.js +22 -22
- package/dist/shapeFns-BJbua5kT.js +34 -0
- package/dist/shapeFns-w9tWELHX.cjs +33 -0
- package/dist/{shapeTypes-CpSaBLDv.js → shapeTypes-CAEAyk8j.js} +233 -172
- package/dist/{shapeTypes-7xEam9Ri.cjs → shapeTypes-owrg2MNK.cjs} +421 -360
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-994_MQwB.cjs → solidBuilders-BLQ4I6Ig.cjs} +3 -3
- package/dist/{solidBuilders-DmwhTCCd.js → solidBuilders-BS-1220W.js} +3 -3
- package/dist/{surfaceBuilders-nQdJ56fe.js → surfaceBuilders-Dj6AjhOv.js} +7 -7
- package/dist/{surfaceBuilders-5VA34a3_.cjs → surfaceBuilders-KU_7OD2q.cjs} +3 -3
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/compoundOpsFns.d.ts +3 -35
- package/dist/topology/compoundOpsFns.d.ts.map +1 -1
- package/dist/topology/index.d.ts +0 -1
- package/dist/topology/index.d.ts.map +1 -1
- package/dist/topology/metadataPropagation.d.ts +30 -0
- package/dist/topology/metadataPropagation.d.ts.map +1 -0
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/originTrackingFns.d.ts +23 -0
- package/dist/topology/originTrackingFns.d.ts.map +1 -0
- package/dist/topology/shapeFns.d.ts +6 -120
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/topologyQueryFns.d.ts +67 -0
- package/dist/topology/topologyQueryFns.d.ts.map +1 -0
- package/dist/topology/transformFns.d.ts +49 -0
- package/dist/topology/transformFns.d.ts.map +1 -0
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-ANwCzGL8.cjs → topology-CyPHYYjV.cjs} +205 -20
- package/dist/{topology-C7x98OVn.js → topology-D6LeuhI_.js} +235 -50
- package/dist/topology.cjs +18 -17
- package/dist/topology.js +92 -91
- package/dist/topologyQueryFns-De439iBP.js +119 -0
- package/dist/topologyQueryFns-fz5kz5e1.cjs +118 -0
- package/dist/{types-CWDdqcrq.js → types-CcKqsmd0.js} +2 -2
- package/dist/utils/precisionRound.d.ts +4 -0
- package/dist/utils/precisionRound.d.ts.map +1 -1
- package/dist/utils/vec2d.d.ts +5 -0
- package/dist/utils/vec2d.d.ts.map +1 -1
- package/dist/{vecOps-ZDdZWbwT.js → vecOps-LTN--A58.js} +15 -15
- package/dist/{vectors-D_IiZx0q.cjs → vectors-C8N_QeEX.cjs} +9 -1
- package/dist/{vectors-Bx8wkNui.js → vectors-DTREgnVp.js} +15 -7
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +23 -23
- package/package.json +3 -3
- package/dist/core/geometryHelpers.d.ts +0 -30
- package/dist/core/geometryHelpers.d.ts.map +0 -1
- package/dist/core/memory.d.ts +0 -6
- package/dist/core/memory.d.ts.map +0 -1
- package/dist/core/typeErrors.d.ts +0 -17
- package/dist/core/typeErrors.d.ts.map +0 -1
- package/dist/cornerFinder-Ckz-mPHE.js +0 -59
- package/dist/cornerFinder-ZmOyOOsh.cjs +0 -58
- package/dist/shapeFns-C2SnNvdH.cjs +0 -468
- package/dist/shapeFns-FDuKkrDR.js +0 -469
- package/dist/utils/round2.d.ts +0 -3
- package/dist/utils/round2.d.ts.map +0 -1
- package/dist/utils/round5.d.ts +0 -3
- package/dist/utils/round5.d.ts.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const shapeTypes = require("./shapeTypes-owrg2MNK.cjs");
|
|
3
|
+
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
+
const topologyQueryFns = require("./topologyQueryFns-fz5kz5e1.cjs");
|
|
5
|
+
function setShapeOrigin(shape, origin) {
|
|
6
|
+
const cache = topologyQueryFns.getOrCreateCache(shape);
|
|
7
|
+
const map = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const f of topologyQueryFns.getFaces(shape)) {
|
|
9
|
+
map.set(shapeTypes.getKernel().hashCode(f.wrapped, vecOps.HASH_CODE_MAX), origin);
|
|
10
|
+
}
|
|
11
|
+
cache.faceOrigins = map;
|
|
12
|
+
}
|
|
13
|
+
function getFaceOrigins(shape) {
|
|
14
|
+
return topologyQueryFns.getCacheEntry(shape)?.faceOrigins;
|
|
15
|
+
}
|
|
16
|
+
function propagateOriginsFromEvolution(evolution, inputs, result) {
|
|
17
|
+
const inputOrigins = /* @__PURE__ */ new Map();
|
|
18
|
+
for (const input of inputs) {
|
|
19
|
+
const origins = getFaceOrigins(input);
|
|
20
|
+
if (!origins) continue;
|
|
21
|
+
for (const [hash, origin] of origins) {
|
|
22
|
+
inputOrigins.set(hash, origin);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (inputOrigins.size === 0) return;
|
|
26
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const [hash, origin] of inputOrigins) {
|
|
28
|
+
if (evolution.deleted.has(hash)) continue;
|
|
29
|
+
const modifiedHashes = evolution.modified.get(hash);
|
|
30
|
+
if (modifiedHashes && modifiedHashes.length > 0) {
|
|
31
|
+
for (const modHash of modifiedHashes) {
|
|
32
|
+
resultMap.set(modHash, origin);
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
resultMap.set(hash, origin);
|
|
36
|
+
}
|
|
37
|
+
const generatedHashes = evolution.generated.get(hash);
|
|
38
|
+
if (generatedHashes) {
|
|
39
|
+
for (const genHash of generatedHashes) {
|
|
40
|
+
if (!resultMap.has(genHash)) {
|
|
41
|
+
resultMap.set(genHash, 0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (resultMap.size > 0) {
|
|
47
|
+
const cache = topologyQueryFns.getOrCreateCache(result);
|
|
48
|
+
cache.faceOrigins = resultMap;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function propagateOriginsByHash(inputs, result) {
|
|
52
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const input of inputs) {
|
|
54
|
+
const origins = getFaceOrigins(input);
|
|
55
|
+
if (!origins) continue;
|
|
56
|
+
for (const [hash, origin] of origins) {
|
|
57
|
+
lookup.set(hash, origin);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (lookup.size === 0) return;
|
|
61
|
+
const kernel = shapeTypes.getKernel();
|
|
62
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
63
|
+
const resultFaces = topologyQueryFns.getFaces(result);
|
|
64
|
+
for (const f of resultFaces) {
|
|
65
|
+
const hash = kernel.hashCode(f.wrapped, vecOps.HASH_CODE_MAX);
|
|
66
|
+
const origin = lookup.get(hash);
|
|
67
|
+
if (origin !== void 0) {
|
|
68
|
+
resultMap.set(hash, origin);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (resultMap.size === 0) {
|
|
72
|
+
const inputSigs = [];
|
|
73
|
+
for (const input of inputs) {
|
|
74
|
+
const origins = getFaceOrigins(input);
|
|
75
|
+
if (!origins) continue;
|
|
76
|
+
for (const f of topologyQueryFns.getFaces(input)) {
|
|
77
|
+
const hash = kernel.hashCode(f.wrapped, vecOps.HASH_CODE_MAX);
|
|
78
|
+
const origin = origins.get(hash);
|
|
79
|
+
if (origin === void 0) continue;
|
|
80
|
+
try {
|
|
81
|
+
const bounds = kernel.uvBounds(f.wrapped);
|
|
82
|
+
const normal = kernel.surfaceNormal(
|
|
83
|
+
f.wrapped,
|
|
84
|
+
0.5 * (bounds.uMin + bounds.uMax),
|
|
85
|
+
0.5 * (bounds.vMin + bounds.vMax)
|
|
86
|
+
);
|
|
87
|
+
const centroid = kernel.surfaceCenterOfMass(f.wrapped);
|
|
88
|
+
inputSigs.push({ origin, normal, centroid });
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (inputSigs.length > 0) {
|
|
94
|
+
for (const f of resultFaces) {
|
|
95
|
+
const hash = kernel.hashCode(f.wrapped, vecOps.HASH_CODE_MAX);
|
|
96
|
+
try {
|
|
97
|
+
const outBounds = kernel.uvBounds(f.wrapped);
|
|
98
|
+
const outNormal = kernel.surfaceNormal(
|
|
99
|
+
f.wrapped,
|
|
100
|
+
0.5 * (outBounds.uMin + outBounds.uMax),
|
|
101
|
+
0.5 * (outBounds.vMin + outBounds.vMax)
|
|
102
|
+
);
|
|
103
|
+
const outCentroid = kernel.surfaceCenterOfMass(f.wrapped);
|
|
104
|
+
let bestScore = -Infinity;
|
|
105
|
+
let bestOrigin;
|
|
106
|
+
for (const inp of inputSigs) {
|
|
107
|
+
const dot = outNormal[0] * inp.normal[0] + outNormal[1] * inp.normal[1] + outNormal[2] * inp.normal[2];
|
|
108
|
+
if (dot < 0.707) continue;
|
|
109
|
+
const dx = outCentroid[0] - inp.centroid[0];
|
|
110
|
+
const dy = outCentroid[1] - inp.centroid[1];
|
|
111
|
+
const dz = outCentroid[2] - inp.centroid[2];
|
|
112
|
+
const distSq = dx * dx + dy * dy + dz * dz;
|
|
113
|
+
if (distSq > 100) continue;
|
|
114
|
+
const score = dot - distSq / 100;
|
|
115
|
+
if (score > bestScore) {
|
|
116
|
+
bestScore = score;
|
|
117
|
+
bestOrigin = inp.origin;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (bestOrigin !== void 0) {
|
|
121
|
+
resultMap.set(hash, bestOrigin);
|
|
122
|
+
}
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (resultMap.size > 0) {
|
|
129
|
+
const cache = topologyQueryFns.getOrCreateCache(result);
|
|
130
|
+
cache.faceOrigins = resultMap;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.getFaceOrigins = getFaceOrigins;
|
|
134
|
+
exports.propagateOriginsByHash = propagateOriginsByHash;
|
|
135
|
+
exports.propagateOriginsFromEvolution = propagateOriginsFromEvolution;
|
|
136
|
+
exports.setShapeOrigin = setShapeOrigin;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { DirectionInput } from './directionUtils.js';
|
|
6
|
-
export interface EdgeFinderFn extends ShapeFinder<Edge> {
|
|
7
|
-
readonly inDirection: (dir?: DirectionInput, angle?: number) => EdgeFinderFn;
|
|
8
|
-
readonly ofLength: (length: number, tolerance?: number) => EdgeFinderFn;
|
|
9
|
-
readonly ofCurveType: (curveType: CurveType) => EdgeFinderFn;
|
|
10
|
-
readonly parallelTo: (dir?: DirectionInput) => EdgeFinderFn;
|
|
11
|
-
readonly atDistance: (distance: number, point?: Vec3) => EdgeFinderFn;
|
|
12
|
-
}
|
|
13
|
-
/** Create an immutable edge finder. */
|
|
14
|
-
export declare function edgeFinder(): EdgeFinderFn;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from `./shapeFinders.js` for backward compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { edgeFinder, type EdgeFinderFn } from './shapeFinders.js';
|
|
15
5
|
//# sourceMappingURL=edgeFinder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edgeFinder.d.ts","sourceRoot":"","sources":["../../src/query/edgeFinder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"edgeFinder.d.ts","sourceRoot":"","sources":["../../src/query/edgeFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { DirectionInput } from './directionUtils.js';
|
|
6
|
-
export interface FaceFinderFn extends ShapeFinder<Face> {
|
|
7
|
-
readonly inDirection: (dir?: DirectionInput, angle?: number) => FaceFinderFn;
|
|
8
|
-
readonly parallelTo: (dir?: DirectionInput) => FaceFinderFn;
|
|
9
|
-
readonly ofSurfaceType: (surfaceType: SurfaceType) => FaceFinderFn;
|
|
10
|
-
readonly ofArea: (area: number, tolerance?: number) => FaceFinderFn;
|
|
11
|
-
readonly atDistance: (distance: number, point?: Vec3) => FaceFinderFn;
|
|
12
|
-
}
|
|
13
|
-
/** Create an immutable face finder. */
|
|
14
|
-
export declare function faceFinder(): FaceFinderFn;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from `./shapeFinders.js` for backward compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { faceFinder, type FaceFinderFn } from './shapeFinders.js';
|
|
15
5
|
//# sourceMappingURL=faceFinder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faceFinder.d.ts","sourceRoot":"","sources":["../../src/query/faceFinder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"faceFinder.d.ts","sourceRoot":"","sources":["../../src/query/faceFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -17,6 +17,12 @@ export interface ShapeFinder<T extends AnyShape<Dimension>> {
|
|
|
17
17
|
readonly findUnique: (shape: AnyShape<Dimension>) => Result<T>;
|
|
18
18
|
/** Check if an element passes all filters. */
|
|
19
19
|
readonly shouldKeep: (element: T) => boolean;
|
|
20
|
+
/** Intersect: element must match both this finder AND other. */
|
|
21
|
+
readonly and: (other: ShapeFinder<T>) => ShapeFinder<T>;
|
|
22
|
+
/** Union: element must match this finder OR other. */
|
|
23
|
+
readonly or: (other: ShapeFinder<T>) => ShapeFinder<T>;
|
|
24
|
+
/** Negate: invert all filters on this finder. */
|
|
25
|
+
readonly negate: () => ShapeFinder<T>;
|
|
20
26
|
readonly _filters: ReadonlyArray<Predicate<T>>;
|
|
21
27
|
readonly _topoKind: TopoKind;
|
|
22
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finderCore.d.ts","sourceRoot":"","sources":["../../src/query/finderCore.ts"],"names":[],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AAC,CA6FH"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Vec3 } from '../core/types.js';
|
|
2
|
+
import { Edge, Face, Wire } from '../core/shapeTypes.js';
|
|
3
|
+
import { SurfaceType } from '../topology/faceFns.js';
|
|
4
|
+
import { CurveType } from '../core/definitionMaps.js';
|
|
5
|
+
import { ShapeFinder } from './finderCore.js';
|
|
6
|
+
import { DirectionInput } from './directionUtils.js';
|
|
7
|
+
export interface EdgeFinderFn extends ShapeFinder<Edge> {
|
|
8
|
+
readonly inDirection: (dir?: DirectionInput, angle?: number) => EdgeFinderFn;
|
|
9
|
+
readonly ofLength: (length: number, tolerance?: number) => EdgeFinderFn;
|
|
10
|
+
readonly ofCurveType: (curveType: CurveType) => EdgeFinderFn;
|
|
11
|
+
readonly parallelTo: (dir?: DirectionInput) => EdgeFinderFn;
|
|
12
|
+
readonly atDistance: (distance: number, point?: Vec3) => EdgeFinderFn;
|
|
13
|
+
}
|
|
14
|
+
/** Create an immutable edge finder. */
|
|
15
|
+
export declare function edgeFinder(): EdgeFinderFn;
|
|
16
|
+
export interface FaceFinderFn extends ShapeFinder<Face> {
|
|
17
|
+
readonly inDirection: (dir?: DirectionInput, angle?: number) => FaceFinderFn;
|
|
18
|
+
readonly parallelTo: (dir?: DirectionInput) => FaceFinderFn;
|
|
19
|
+
readonly ofSurfaceType: (surfaceType: SurfaceType) => FaceFinderFn;
|
|
20
|
+
readonly ofArea: (area: number, tolerance?: number) => FaceFinderFn;
|
|
21
|
+
readonly atDistance: (distance: number, point?: Vec3) => FaceFinderFn;
|
|
22
|
+
}
|
|
23
|
+
/** Create an immutable face finder. */
|
|
24
|
+
export declare function faceFinder(): FaceFinderFn;
|
|
25
|
+
export interface WireFinderFn extends ShapeFinder<Wire> {
|
|
26
|
+
readonly isClosed: () => WireFinderFn;
|
|
27
|
+
readonly isOpen: () => WireFinderFn;
|
|
28
|
+
readonly ofEdgeCount: (count: number) => WireFinderFn;
|
|
29
|
+
}
|
|
30
|
+
/** Create an immutable wire finder. */
|
|
31
|
+
export declare function wireFinder(): WireFinderFn;
|
|
32
|
+
//# sourceMappingURL=shapeFinders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapeFinders.d.ts","sourceRoot":"","sources":["../../src/query/shapeFinders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAK9D,OAAO,EAA4C,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,WAAW,EAAqC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAOtE,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7E,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IACxE,QAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,YAAY,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,KAAK,YAAY,CAAC;IAC5D,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC;CACvE;AAqCD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC;AAMD,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IAC7E,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,cAAc,KAAK,YAAY,CAAC;IAC5D,QAAQ,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,YAAY,CAAC;IACnE,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;IACpE,QAAQ,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC;CACvE;AAkCD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC;AAMD,MAAM,WAAW,YAAa,SAAQ,WAAW,CAAC,IAAI,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,YAAY,CAAC;IACpC,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,YAAY,CAAC;CACvD;AAwBD,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,YAAY,CAEzC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly isOpen: () => WireFinderFn;
|
|
6
|
-
readonly ofEdgeCount: (count: number) => WireFinderFn;
|
|
7
|
-
}
|
|
8
|
-
/** Create an immutable wire finder. */
|
|
9
|
-
export declare function wireFinder(): WireFinderFn;
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports from `./shapeFinders.js` for backward compatibility.
|
|
3
|
+
*/
|
|
4
|
+
export { wireFinder, type WireFinderFn } from './shapeFinders.js';
|
|
10
5
|
//# sourceMappingURL=wireFinder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wireFinder.d.ts","sourceRoot":"","sources":["../../src/query/wireFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"wireFinder.d.ts","sourceRoot":"","sources":["../../src/query/wireFinder.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/query.cjs
CHANGED
|
@@ -1,40 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const helpers = require("./helpers-
|
|
4
|
-
const cornerFinder = require("./cornerFinder-ZmOyOOsh.cjs");
|
|
5
|
-
const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
|
|
3
|
+
const helpers = require("./helpers-DVdscQxW.cjs");
|
|
6
4
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const PI_2 = 2 * Math.PI;
|
|
6
|
+
function positiveHalfAngle(angle) {
|
|
7
|
+
const limitedAngle = angle % PI_2;
|
|
8
|
+
const coterminalAngle = limitedAngle < 0 ? limitedAngle + PI_2 : limitedAngle;
|
|
9
|
+
if (coterminalAngle < Math.PI) return coterminalAngle;
|
|
10
|
+
if (coterminalAngle === Math.PI) return 0;
|
|
11
|
+
return Math.abs(coterminalAngle - PI_2);
|
|
12
|
+
}
|
|
13
|
+
function blueprintCorners(blueprint) {
|
|
14
|
+
return blueprint.curves.map((curve, index) => ({
|
|
15
|
+
firstCurve: curve,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- modulo wraps within bounds
|
|
17
|
+
secondCurve: blueprint.curves[(index + 1) % blueprint.curves.length],
|
|
18
|
+
point: curve.lastPoint
|
|
19
|
+
}));
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
function buildCornerFinder(filters) {
|
|
22
|
+
const withFilter = (pred) => buildCornerFinder([...filters, pred]);
|
|
23
|
+
const shouldKeep = (corner) => filters.every((f) => f(corner));
|
|
24
|
+
return {
|
|
25
|
+
shouldKeep,
|
|
26
|
+
when: (pred) => withFilter(pred),
|
|
27
|
+
inList: (points) => withFilter((corner) => points.some((p) => helpers.samePoint(p, corner.point))),
|
|
28
|
+
atDistance: (distance, point = [0, 0]) => withFilter((corner) => Math.abs(helpers.distance2d(point, corner.point) - distance) < 1e-9),
|
|
29
|
+
atPoint: (point) => withFilter((corner) => helpers.samePoint(point, corner.point)),
|
|
30
|
+
inBox: (corner1, corner2) => {
|
|
31
|
+
const minX = Math.min(corner1[0], corner2[0]);
|
|
32
|
+
const maxX = Math.max(corner1[0], corner2[0]);
|
|
33
|
+
const minY = Math.min(corner1[1], corner2[1]);
|
|
34
|
+
const maxY = Math.max(corner1[1], corner2[1]);
|
|
35
|
+
return withFilter((corner) => {
|
|
36
|
+
const [x, y] = corner.point;
|
|
37
|
+
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
ofAngle: (angle) => withFilter((corner) => {
|
|
41
|
+
const tgt1 = corner.firstCurve.tangentAt(1);
|
|
42
|
+
const tgt2 = corner.secondCurve.tangentAt(0);
|
|
43
|
+
return Math.abs(positiveHalfAngle(helpers.angle2d(tgt1, tgt2)) - positiveHalfAngle(vecOps.DEG2RAD * angle)) < 1e-9;
|
|
44
|
+
}),
|
|
45
|
+
not: (fn) => {
|
|
46
|
+
const inner = fn(buildCornerFinder([]));
|
|
47
|
+
return withFilter((corner) => !inner.shouldKeep(corner));
|
|
48
|
+
},
|
|
49
|
+
either: (fns) => {
|
|
50
|
+
const builtFinders = fns.map((fn) => fn(buildCornerFinder([])));
|
|
51
|
+
return withFilter((corner) => builtFinders.some((f) => f.shouldKeep(corner)));
|
|
52
|
+
},
|
|
53
|
+
find: (blueprint) => blueprintCorners(blueprint).filter(shouldKeep)
|
|
54
|
+
};
|
|
33
55
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
56
|
+
function cornerFinder() {
|
|
57
|
+
return buildCornerFinder([]);
|
|
36
58
|
}
|
|
59
|
+
exports.edgeFinder = helpers.edgeFinder;
|
|
37
60
|
exports.faceFinder = helpers.faceFinder;
|
|
38
61
|
exports.getSingleFace = helpers.getSingleFace;
|
|
39
|
-
exports.cornerFinder = cornerFinder
|
|
40
|
-
exports.edgeFinder = edgeFinder;
|
|
62
|
+
exports.cornerFinder = cornerFinder;
|
package/dist/query.js
CHANGED
|
@@ -1,41 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { m, g } from "./helpers-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { o as angle2d, s as samePoint, d as distance2d } from "./helpers-sJjnIXDA.js";
|
|
2
|
+
import { l, m, g } from "./helpers-sJjnIXDA.js";
|
|
3
|
+
import { D as DEG2RAD } from "./vecOps-LTN--A58.js";
|
|
4
|
+
const PI_2 = 2 * Math.PI;
|
|
5
|
+
function positiveHalfAngle(angle) {
|
|
6
|
+
const limitedAngle = angle % PI_2;
|
|
7
|
+
const coterminalAngle = limitedAngle < 0 ? limitedAngle + PI_2 : limitedAngle;
|
|
8
|
+
if (coterminalAngle < Math.PI) return coterminalAngle;
|
|
9
|
+
if (coterminalAngle === Math.PI) return 0;
|
|
10
|
+
return Math.abs(coterminalAngle - PI_2);
|
|
11
|
+
}
|
|
12
|
+
function blueprintCorners(blueprint) {
|
|
13
|
+
return blueprint.curves.map((curve, index) => ({
|
|
14
|
+
firstCurve: curve,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- modulo wraps within bounds
|
|
16
|
+
secondCurve: blueprint.curves[(index + 1) % blueprint.curves.length],
|
|
17
|
+
point: curve.lastPoint
|
|
18
|
+
}));
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
function buildCornerFinder(filters) {
|
|
21
|
+
const withFilter = (pred) => buildCornerFinder([...filters, pred]);
|
|
22
|
+
const shouldKeep = (corner) => filters.every((f) => f(corner));
|
|
23
|
+
return {
|
|
24
|
+
shouldKeep,
|
|
25
|
+
when: (pred) => withFilter(pred),
|
|
26
|
+
inList: (points) => withFilter((corner) => points.some((p) => samePoint(p, corner.point))),
|
|
27
|
+
atDistance: (distance, point = [0, 0]) => withFilter((corner) => Math.abs(distance2d(point, corner.point) - distance) < 1e-9),
|
|
28
|
+
atPoint: (point) => withFilter((corner) => samePoint(point, corner.point)),
|
|
29
|
+
inBox: (corner1, corner2) => {
|
|
30
|
+
const minX = Math.min(corner1[0], corner2[0]);
|
|
31
|
+
const maxX = Math.max(corner1[0], corner2[0]);
|
|
32
|
+
const minY = Math.min(corner1[1], corner2[1]);
|
|
33
|
+
const maxY = Math.max(corner1[1], corner2[1]);
|
|
34
|
+
return withFilter((corner) => {
|
|
35
|
+
const [x, y] = corner.point;
|
|
36
|
+
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
ofAngle: (angle) => withFilter((corner) => {
|
|
40
|
+
const tgt1 = corner.firstCurve.tangentAt(1);
|
|
41
|
+
const tgt2 = corner.secondCurve.tangentAt(0);
|
|
42
|
+
return Math.abs(positiveHalfAngle(angle2d(tgt1, tgt2)) - positiveHalfAngle(DEG2RAD * angle)) < 1e-9;
|
|
43
|
+
}),
|
|
44
|
+
not: (fn) => {
|
|
45
|
+
const inner = fn(buildCornerFinder([]));
|
|
46
|
+
return withFilter((corner) => !inner.shouldKeep(corner));
|
|
47
|
+
},
|
|
48
|
+
either: (fns) => {
|
|
49
|
+
const builtFinders = fns.map((fn) => fn(buildCornerFinder([])));
|
|
50
|
+
return withFilter((corner) => builtFinders.some((f) => f.shouldKeep(corner)));
|
|
51
|
+
},
|
|
52
|
+
find: (blueprint) => blueprintCorners(blueprint).filter(shouldKeep)
|
|
53
|
+
};
|
|
32
54
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
55
|
+
function cornerFinder() {
|
|
56
|
+
return buildCornerFinder([]);
|
|
35
57
|
}
|
|
36
58
|
export {
|
|
37
|
-
|
|
38
|
-
edgeFinder,
|
|
59
|
+
cornerFinder,
|
|
60
|
+
l as edgeFinder,
|
|
39
61
|
m as faceFinder,
|
|
40
62
|
g as getSingleFace
|
|
41
63
|
};
|
|
@@ -47,6 +47,12 @@ function tapErr(result, fn) {
|
|
|
47
47
|
if (!result.ok) fn(result.error);
|
|
48
48
|
return result;
|
|
49
49
|
}
|
|
50
|
+
function flatten(result) {
|
|
51
|
+
return result.ok ? result.value : result;
|
|
52
|
+
}
|
|
53
|
+
function mapBoth(result, okFn, errFn) {
|
|
54
|
+
return result.ok ? ok(okFn(result.value)) : err(errFn(result.error));
|
|
55
|
+
}
|
|
50
56
|
function fromNullable(value, errorFn) {
|
|
51
57
|
if (value === null || value === void 0) return err(errorFn());
|
|
52
58
|
return ok(value);
|
|
@@ -274,64 +280,6 @@ function queryError(code, message, cause, metadata, suggestion) {
|
|
|
274
280
|
function unsupportedError(code, message, cause, metadata, suggestion) {
|
|
275
281
|
return makeError("UNSUPPORTED", code, message, cause, metadata, suggestion);
|
|
276
282
|
}
|
|
277
|
-
const kernel_ERROR_PATTERNS = [
|
|
278
|
-
{
|
|
279
|
-
pattern: /invalid edge configuration|edges?.*(not|fail|invalid)/i,
|
|
280
|
-
translation: "The edges may not form a continuous loop. Check that edges connect end-to-end without gaps."
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
pattern: /BRepAlgoAPI.*failed|boolean.*operation.*failed/i,
|
|
284
|
-
translation: "Boolean operation failed. Common causes: overlapping faces, zero-thickness geometry, or degenerate shapes. Try healing input shapes first."
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
pattern: /fillet.*radius.*too.*large|fillet.*failed/i,
|
|
288
|
-
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."
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
pattern: /chamfer.*failed|chamfer.*distance.*too.*large/i,
|
|
292
|
-
translation: "Chamfer operation failed. The distance may be too large for the selected edges. Try reducing the distance or check edge geometry."
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
pattern: /shell.*failed|offset.*failed/i,
|
|
296
|
-
translation: "Shell/offset operation failed. The thickness may be too large, or the shape may have complex geometry. Try reducing thickness."
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
pattern: /sweep.*failed|pipe.*failed/i,
|
|
300
|
-
translation: "Sweep operation failed. Check that the profile and spine are compatible, and that the spine has no sharp twists or self-intersections."
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
pattern: /loft.*failed/i,
|
|
304
|
-
translation: "Loft operation failed. Profiles may be incompatible or have different orientations. Ensure profiles are ordered consistently."
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
pattern: /extrude.*failed|prism.*failed/i,
|
|
308
|
-
translation: "Extrusion failed. The profile may be invalid or self-intersecting. Check that the profile forms a valid closed wire."
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
pattern: /revolve.*failed|revolution.*failed/i,
|
|
312
|
-
translation: "Revolution operation failed. The profile may intersect the axis of revolution, or the angle may be invalid."
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
pattern: /self.*intersect|self-intersect/i,
|
|
316
|
-
translation: "Shape has self-intersections. The operation resulted in overlapping geometry. Simplify the input or adjust parameters."
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
pattern: /degener|degenerat/i,
|
|
320
|
-
translation: "Degenerate geometry detected. The shape has edges or faces with zero length/area. Check input geometry for collapsed elements."
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
pattern: /BRepCheck.*fail|shape.*invalid|shape.*not.*valid/i,
|
|
324
|
-
translation: "Shape validation failed. The resulting shape has invalid topology. Try healing the shape or checking input geometry."
|
|
325
|
-
}
|
|
326
|
-
];
|
|
327
|
-
function translateKernelError(kernelMessage) {
|
|
328
|
-
for (const { pattern, translation } of kernel_ERROR_PATTERNS) {
|
|
329
|
-
if (pattern.test(kernelMessage)) {
|
|
330
|
-
return `${translation} (kernel: ${kernelMessage})`;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
return kernelMessage;
|
|
334
|
-
}
|
|
335
283
|
function safeIndex(arr, index, context) {
|
|
336
284
|
if (index < 0 || index >= arr.length) {
|
|
337
285
|
bug(context ?? "safeIndex", `Index ${index} is out of bounds (array length ${arr.length})`);
|
|
@@ -348,12 +296,14 @@ exports.collect = collect;
|
|
|
348
296
|
exports.computationError = computationError;
|
|
349
297
|
exports.err = err;
|
|
350
298
|
exports.flatMap = flatMap;
|
|
299
|
+
exports.flatten = flatten;
|
|
351
300
|
exports.fromNullable = fromNullable;
|
|
352
301
|
exports.ioError = ioError;
|
|
353
302
|
exports.isErr = isErr;
|
|
354
303
|
exports.isOk = isOk;
|
|
355
304
|
exports.kernelError = kernelError;
|
|
356
305
|
exports.map = map;
|
|
306
|
+
exports.mapBoth = mapBoth;
|
|
357
307
|
exports.mapErr = mapErr;
|
|
358
308
|
exports.match = match;
|
|
359
309
|
exports.moduleInitError = moduleInitError;
|
|
@@ -366,7 +316,6 @@ exports.safeIndex = safeIndex;
|
|
|
366
316
|
exports.sketcherStateError = sketcherStateError;
|
|
367
317
|
exports.tap = tap;
|
|
368
318
|
exports.tapErr = tapErr;
|
|
369
|
-
exports.translateKernelError = translateKernelError;
|
|
370
319
|
exports.tryCatch = tryCatch;
|
|
371
320
|
exports.tryCatchAsync = tryCatchAsync;
|
|
372
321
|
exports.typeCastError = typeCastError;
|