brepjs 20.12.7 → 20.12.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{adjacencyFns-mMmTBUBY.cjs → adjacencyFns-BfgFo-Rh.cjs} +3 -3
- package/dist/{adjacencyFns-hMihivxC.js → adjacencyFns-Bl109A3Z.js} +3 -3
- package/dist/{blueprint-17RUHsoP.cjs → blueprint-DTDSztfd.cjs} +5 -5
- package/dist/{blueprint-BS50D3J_.js → blueprint-RqemOtg5.js} +5 -5
- package/dist/{blueprintFns-zy5lo2IF.js → blueprintFns-B9_PhTr8.js} +2 -2
- package/dist/{blueprintFns-Dw5_4_Bk.cjs → blueprintFns-C7E5R89N.cjs} +2 -2
- package/dist/{blueprintSketcher-C1WCI6E0.js → blueprintSketcher-B15522Kr.js} +3 -3
- package/dist/{blueprintSketcher-BG--DxWB.cjs → blueprintSketcher-Brj4lXjj.cjs} +3 -3
- package/dist/{boolean2D-7SQ3B0pC.cjs → boolean2D-DZ8aJbI-.cjs} +4 -4
- package/dist/{boolean2D-CsdyfjFE.js → boolean2D-_eiIiNw1.js} +4 -4
- package/dist/{solidBuilders-DdG4NPHM.cjs → booleanFns-D5nQ1nWS.cjs} +11 -217
- package/dist/{solidBuilders-Bmr59cGp.js → booleanFns-cNfXGqMX.js} +10 -156
- package/dist/brepjs.cjs +325 -168
- package/dist/brepjs.js +282 -125
- package/dist/{cameraFns-BAtzhCYM.cjs → cameraFns-6Er2lhp5.cjs} +3 -3
- package/dist/{cameraFns-BVWyAscu.js → cameraFns-YhB7A_Zc.js} +3 -3
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-e4Wc7_yp.cjs → cornerFinder-D9Wx3DWu.cjs} +1 -1
- package/dist/{cornerFinder-Dv_2rmaY.js → cornerFinder-G1WkSkVl.js} +1 -1
- package/dist/{curveFns-BAM7QHrP.cjs → curveFns-B5_N-gMj.cjs} +1 -1
- package/dist/{curveFns-CEI-rouh.js → curveFns-C4CqthJp.js} +1 -1
- package/dist/{drawFns-Cl1i8B_B.js → drawFns-DU5fewKl.js} +12 -12
- package/dist/{drawFns-d-RvC6u6.cjs → drawFns-UPbO2heB.cjs} +12 -12
- package/dist/{faceFns-Q87HCJrp.js → faceFns-BgRNa5vx.js} +2 -2
- package/dist/{faceFns-C-2ttg8X.cjs → faceFns-C4NOGZBg.cjs} +2 -2
- package/dist/{healingFns-Cm4NkKD8.js → healingFns-BzOo0yyz.js} +5 -5
- package/dist/{healingFns-DZkO5okn.cjs → healingFns-i5gV3BMG.cjs} +29 -29
- package/dist/{helpers-BdGGaLhF.cjs → helpers-DJQeDf_5.cjs} +6 -6
- package/dist/{helpers-DpGcM2qZ.js → helpers-DPHQt2Kr.js} +6 -6
- package/dist/{importFns-DLiP26NW.cjs → importFns-BiRpt227.cjs} +319 -14
- package/dist/{importFns-Bp-p0jiP.js → importFns-CwrJsNvg.js} +314 -15
- package/dist/io/igesSupport.d.ts +6 -0
- package/dist/io/importFns.d.ts +15 -5
- package/dist/io/ioUtils.d.ts +15 -3
- package/dist/io/meshNesting.d.ts +11 -0
- package/dist/io/threemfImportFns.d.ts +6 -3
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/occtWasmTypes.d.ts +4 -2
- package/dist/{loftFns-DGV1z2NJ.cjs → loftFns-DgkK4Kj_.cjs} +1 -1
- package/dist/{loftFns-DQ7Z29n3.js → loftFns-lwzTh1fI.js} +1 -1
- package/dist/{measureFns-BdSjw5fr.cjs → measureFns-D_RRjCZg.cjs} +3 -3
- package/dist/{measureFns-BrdCH4cH.js → measureFns-Q3K25IfN.js} +3 -3
- package/dist/measurement.cjs +2 -2
- package/dist/measurement.js +2 -2
- package/dist/{meshFns-UE8tByyw.js → meshFns-BGoJU6_P.js} +20 -6
- package/dist/{meshFns-BeubBqEI.cjs → meshFns-Djbb4PUC.cjs} +25 -5
- package/dist/{occtWasmAdapter-DA7oMgcQ.js → occtWasmAdapter-BCCwaYkq.js} +7 -5
- package/dist/{occtWasmAdapter-D3qerQTq.cjs → occtWasmAdapter-UcYZRi-w.cjs} +7 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{primitiveFns-CLGVLwG8.cjs → primitiveFns-CfSnex9P.cjs} +19 -18
- package/dist/{primitiveFns-3-gs-FUX.js → primitiveFns-D-aYcwt2.js} +5 -4
- package/dist/{principalBoxFns-RMZItjfR.js → principalBoxFns-Dcp9gg5e.js} +3 -3
- package/dist/{principalBoxFns-CiXzjOkr.cjs → principalBoxFns-IY8FfPVj.cjs} +3 -3
- 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-kJg2iCad.js → refResolveFns-BPge7T5w.js} +6 -6
- package/dist/{refResolveFns-DNX0bCrP.cjs → refResolveFns-gZQ1o5XK.cjs} +6 -6
- package/dist/{shapeFns-SgIrOjN4.cjs → shapeFns-Bs92VrZh.cjs} +2 -2
- package/dist/{shapeFns-CZ6VF1yd.js → shapeFns-TWdr4Dv4.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-BNGu103j.js → shapeTypes-CIH-8d_a.js} +1 -1
- package/dist/{shapeTypes-MUEH4XuH.cjs → shapeTypes-DmThK_oa.cjs} +1 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{originTrackingFns-rEKOAP65.cjs → solidBuilders-DGskMugU.cjs} +209 -2
- package/dist/{originTrackingFns-c2qgRZ_9.js → solidBuilders-q_hwYsdo.js} +150 -3
- package/dist/{surfaceBuilders-DI376ai0.js → surfaceBuilders-DXo4N7wQ.js} +3 -3
- package/dist/{surfaceBuilders-DOmDVuMs.cjs → surfaceBuilders-DeSLKg73.cjs} +3 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-CE0oxB43.js → textBlueprints-BYWZho_c.js} +8 -7
- package/dist/{textBlueprints-B7Vhr0xu.cjs → textBlueprints-Dz6wNgve.cjs} +9 -8
- package/dist/{textMetrics-C6_kSht6.cjs → textMetrics-bKoFTj3m.cjs} +1 -1
- package/dist/{textMetrics-_VGqdewQ.js → textMetrics-k_rGqib2.js} +1 -1
- package/dist/{threadFns-CHdY-4Cz.js → threadFns-BeB8s0tA.js} +7 -7
- package/dist/{threadFns-1H60LrFX.cjs → threadFns-CoGAFHHt.cjs} +9 -9
- package/dist/topology/meshFns.d.ts +3 -0
- package/dist/topology.cjs +11 -11
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-C_fXO6xL.cjs → topologyQueryFns-CXbCFaU2.cjs} +1 -1
- package/dist/{topologyQueryFns-CltEv7Pi.js → topologyQueryFns-Cp0yekBh.js} +1 -1
- package/dist/{validityTypes-GanLrmvY.js → validityTypes-DlrWkrSR.js} +1 -1
- package/dist/{validityTypes-CGX2ES81.cjs → validityTypes-m6eLRTYE.cjs} +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { n as castResultShape, q as getKernel } from "./shapeTypes-
|
|
1
|
+
import { C as isSolid, G as _usingCtx, n as castResultShape, q as getKernel } from "./shapeTypes-CIH-8d_a.js";
|
|
2
2
|
import { i as wasmIndex, r as vec3At$1 } from "./bug-ClMTAJhe.js";
|
|
3
3
|
import { E as ok, g as err, r as ioError, t as BrepErrorCode } from "./errors-BTccWbtE.js";
|
|
4
|
+
import { S as subShapeCount, c as getFaces, u as getShells } from "./topologyQueryFns-Cp0yekBh.js";
|
|
5
|
+
import { n as HASH_CODE_MAX } from "./constants-iraOnb2p.js";
|
|
6
|
+
import { t as makeCompound } from "./solidBuilders-q_hwYsdo.js";
|
|
7
|
+
import { u as igesUnsupportedError } from "./meshFns-BGoJU6_P.js";
|
|
4
8
|
import { n as getAtOrThrow } from "./arrayAccess-BpgouNir.js";
|
|
5
|
-
import { c as make2dBezierCurve, h as make2dThreePointArc, p as make2dSegmentCurve, t as Blueprint } from "./blueprint-
|
|
9
|
+
import { c as make2dBezierCurve, h as make2dThreePointArc, p as make2dSegmentCurve, t as Blueprint } from "./blueprint-RqemOtg5.js";
|
|
6
10
|
// src/io/objExportFns.ts
|
|
7
11
|
/** Read a vec3 from a typed array at the given vertex index. */
|
|
8
12
|
function vec3At(arr, i) {
|
|
@@ -1248,13 +1252,17 @@ function importSVGPathD(pathD) {
|
|
|
1248
1252
|
*/
|
|
1249
1253
|
function importSVG(svgString) {
|
|
1250
1254
|
try {
|
|
1251
|
-
const dAttrRe = /\
|
|
1255
|
+
const dAttrRe = /\sd\s*=\s*(?:"([^"]*)"|'([^']*)')/;
|
|
1252
1256
|
const blueprints = [];
|
|
1253
1257
|
const lower = svgString.toLowerCase();
|
|
1254
1258
|
let pos = 0;
|
|
1255
1259
|
while (pos < lower.length) {
|
|
1256
|
-
const tagStart = lower.indexOf("<path
|
|
1260
|
+
const tagStart = lower.indexOf("<path", pos);
|
|
1257
1261
|
if (tagStart === -1) break;
|
|
1262
|
+
if (!/\s/.test(lower.charAt(tagStart + 5))) {
|
|
1263
|
+
pos = tagStart + 5;
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1258
1266
|
const tagEnd = svgString.indexOf(">", tagStart);
|
|
1259
1267
|
if (tagEnd === -1) break;
|
|
1260
1268
|
const tag = svgString.slice(tagStart, tagEnd + 1);
|
|
@@ -1297,6 +1305,275 @@ function exportSTEPConfigured(parts, options) {
|
|
|
1297
1305
|
return err(ioError(BrepErrorCode.STEP_EXPORT_CONFIGURED_FAILED, "Configured STEP export failed", e));
|
|
1298
1306
|
}
|
|
1299
1307
|
}
|
|
1308
|
+
// src/io/meshNesting.ts
|
|
1309
|
+
/**
|
|
1310
|
+
* Cavities in sewn mesh bodies.
|
|
1311
|
+
*
|
|
1312
|
+
* A hollow mesh is an outer shell plus inward-facing inner shells, and sewing makes
|
|
1313
|
+
* each of them a closed body of its own. A cavity is a shell whose triangles face
|
|
1314
|
+
* inward (negative signed volume, read before solidifying reorients it) that lies
|
|
1315
|
+
* inside another body; it is cut from the innermost body around it. An outward-facing
|
|
1316
|
+
* shell inside another is a separate part and stays one. Containment comes from ray
|
|
1317
|
+
* casts against each body's tessellation, because no kernel here can classify a
|
|
1318
|
+
* point against a solid.
|
|
1319
|
+
*/
|
|
1320
|
+
var RAY_LENGTH = Math.hypot(.5389, .6213, .5689);
|
|
1321
|
+
var RAY = [
|
|
1322
|
+
.5389 / RAY_LENGTH,
|
|
1323
|
+
.6213 / RAY_LENGTH,
|
|
1324
|
+
.5689 / RAY_LENGTH
|
|
1325
|
+
];
|
|
1326
|
+
/**
|
|
1327
|
+
* The parts to keep: `bodies` (each built from the same-index shell of `shells`)
|
|
1328
|
+
* with every cavity cut from the body around it and left out. Cut results are
|
|
1329
|
+
* pushed to `owned` for the caller to dispose; no input is disposed here.
|
|
1330
|
+
*
|
|
1331
|
+
* @throws When meshing or a cut fails, rather than leave a cavity filled.
|
|
1332
|
+
*/
|
|
1333
|
+
function carveCavities(bodies, shells, owned) {
|
|
1334
|
+
const solids = bodies.flatMap((body, i) => isSolid(body) ? [{
|
|
1335
|
+
body,
|
|
1336
|
+
shell: shells[i]
|
|
1337
|
+
}] : []);
|
|
1338
|
+
if (solids.length < 2) return [...bodies];
|
|
1339
|
+
const voids = findVoids(solids);
|
|
1340
|
+
const carved = /* @__PURE__ */ new Map();
|
|
1341
|
+
for (const [body, inner] of voids) {
|
|
1342
|
+
const result = cutVoids(body, inner);
|
|
1343
|
+
owned.push(result);
|
|
1344
|
+
carved.set(body, result);
|
|
1345
|
+
}
|
|
1346
|
+
const consumed = new Set([...carved.keys()].flatMap((body) => voids.get(body) ?? []));
|
|
1347
|
+
return bodies.filter((body) => !consumed.has(body)).map((body) => carved.get(body) ?? body);
|
|
1348
|
+
}
|
|
1349
|
+
/** The cavities of each body that has any, keyed by that body. */
|
|
1350
|
+
function findVoids(solids) {
|
|
1351
|
+
const kernel = getKernel();
|
|
1352
|
+
const boxes = solids.map(({ body }) => kernel.boundingBox(body.wrapped));
|
|
1353
|
+
const meshes = /* @__PURE__ */ new Map();
|
|
1354
|
+
const meshOf = (i) => {
|
|
1355
|
+
let mesh = meshes.get(i);
|
|
1356
|
+
if (mesh === void 0) {
|
|
1357
|
+
mesh = meshShape(solids[i].body, boxes[i]);
|
|
1358
|
+
meshes.set(i, mesh);
|
|
1359
|
+
}
|
|
1360
|
+
return mesh;
|
|
1361
|
+
};
|
|
1362
|
+
const containers = solids.map((_inner, j) => solids.map((_outer, i) => i).filter((i) => i !== j && boxInside(boxes[j], boxes[i]) && insideMesh(firstVertex(meshOf(j)), meshOf(i))));
|
|
1363
|
+
const isVoid = containers.map((around, j) => {
|
|
1364
|
+
const shell = solids[j]?.shell;
|
|
1365
|
+
return around.length > 0 && shell !== void 0 && facesInward(shell, boxes[j]);
|
|
1366
|
+
});
|
|
1367
|
+
const voids = /* @__PURE__ */ new Map();
|
|
1368
|
+
containers.forEach((around, j) => {
|
|
1369
|
+
if (!isVoid[j]) return;
|
|
1370
|
+
const bodiesAround = around.filter((i) => !isVoid[i]);
|
|
1371
|
+
if (bodiesAround.length === 0) return;
|
|
1372
|
+
const body = solids[bodiesAround.reduce((a, b) => (containers[b]?.length ?? 0) > (containers[a]?.length ?? 0) ? b : a)].body;
|
|
1373
|
+
voids.set(body, [...voids.get(body) ?? [], solids[j].body]);
|
|
1374
|
+
});
|
|
1375
|
+
return voids;
|
|
1376
|
+
}
|
|
1377
|
+
/** Whether a closed shell's triangles face inward, by the sign of its enclosed volume. */
|
|
1378
|
+
function facesInward(shell, box) {
|
|
1379
|
+
const mesh = meshShape(shell, box);
|
|
1380
|
+
const t = mesh.triangles;
|
|
1381
|
+
let volume = 0;
|
|
1382
|
+
for (let i = 0; i + 2 < t.length; i += 3) {
|
|
1383
|
+
const a = vertexAt(mesh, t[i]);
|
|
1384
|
+
volume += dot(a, cross(vertexAt(mesh, t[i + 1]), vertexAt(mesh, t[i + 2])));
|
|
1385
|
+
}
|
|
1386
|
+
return volume < 0;
|
|
1387
|
+
}
|
|
1388
|
+
function cutVoids(body, voids) {
|
|
1389
|
+
const kernel = getKernel();
|
|
1390
|
+
let current = body;
|
|
1391
|
+
for (const inner of voids) try {
|
|
1392
|
+
const next = castResultShape(kernel.cut(current.wrapped, inner.wrapped));
|
|
1393
|
+
if (current !== body) current[Symbol.dispose]();
|
|
1394
|
+
current = next;
|
|
1395
|
+
} catch (e) {
|
|
1396
|
+
if (current !== body) current[Symbol.dispose]();
|
|
1397
|
+
throw e;
|
|
1398
|
+
}
|
|
1399
|
+
return current;
|
|
1400
|
+
}
|
|
1401
|
+
function meshShape(shape, box) {
|
|
1402
|
+
const diagonal = Math.hypot(...box.max.map((v, i) => v - (box.min[i] ?? 0)));
|
|
1403
|
+
return getKernel().mesh(shape.wrapped, {
|
|
1404
|
+
tolerance: Math.max(diagonal * .001, 1e-6),
|
|
1405
|
+
angularTolerance: .5,
|
|
1406
|
+
skipNormals: true
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
function boxInside(inner, outer) {
|
|
1410
|
+
return inner.min.every((v, i) => v >= (outer.min[i] ?? 0) && (inner.max[i] ?? 0) <= (outer.max[i] ?? 0));
|
|
1411
|
+
}
|
|
1412
|
+
function firstVertex(mesh) {
|
|
1413
|
+
return [
|
|
1414
|
+
mesh.vertices[0] ?? 0,
|
|
1415
|
+
mesh.vertices[1] ?? 0,
|
|
1416
|
+
mesh.vertices[2] ?? 0
|
|
1417
|
+
];
|
|
1418
|
+
}
|
|
1419
|
+
function vertexAt(mesh, index) {
|
|
1420
|
+
const i = (index ?? 0) * 3;
|
|
1421
|
+
return [
|
|
1422
|
+
mesh.vertices[i] ?? 0,
|
|
1423
|
+
mesh.vertices[i + 1] ?? 0,
|
|
1424
|
+
mesh.vertices[i + 2] ?? 0
|
|
1425
|
+
];
|
|
1426
|
+
}
|
|
1427
|
+
/** Whether `p` is inside the closed mesh, by the parity of a ray's crossings. */
|
|
1428
|
+
function insideMesh(p, mesh) {
|
|
1429
|
+
const t = mesh.triangles;
|
|
1430
|
+
let crossings = 0;
|
|
1431
|
+
for (let i = 0; i + 2 < t.length; i += 3) if (rayHits(p, vertexAt(mesh, t[i]), vertexAt(mesh, t[i + 1]), vertexAt(mesh, t[i + 2]))) crossings++;
|
|
1432
|
+
return crossings % 2 === 1;
|
|
1433
|
+
}
|
|
1434
|
+
var sub = (a, b) => [
|
|
1435
|
+
a[0] - b[0],
|
|
1436
|
+
a[1] - b[1],
|
|
1437
|
+
a[2] - b[2]
|
|
1438
|
+
];
|
|
1439
|
+
var dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
1440
|
+
var cross = (a, b) => [
|
|
1441
|
+
a[1] * b[2] - a[2] * b[1],
|
|
1442
|
+
a[2] * b[0] - a[0] * b[2],
|
|
1443
|
+
a[0] * b[1] - a[1] * b[0]
|
|
1444
|
+
];
|
|
1445
|
+
/** Moller-Trumbore: does the ray from `p` along RAY cross triangle abc ahead of `p`? */
|
|
1446
|
+
function rayHits(p, a, b, c) {
|
|
1447
|
+
const e1 = sub(b, a);
|
|
1448
|
+
const e2 = sub(c, a);
|
|
1449
|
+
const h = cross(RAY, e2);
|
|
1450
|
+
const det = dot(e1, h);
|
|
1451
|
+
if (det === 0) return false;
|
|
1452
|
+
const s = sub(p, a);
|
|
1453
|
+
const u = dot(s, h) / det;
|
|
1454
|
+
if (u < 0 || u > 1) return false;
|
|
1455
|
+
const q = cross(s, e1);
|
|
1456
|
+
const v = dot(RAY, q) / det;
|
|
1457
|
+
if (v < 0 || u + v > 1) return false;
|
|
1458
|
+
return dot(e2, q) / det > 0;
|
|
1459
|
+
}
|
|
1460
|
+
// src/io/ioUtils.ts
|
|
1461
|
+
/**
|
|
1462
|
+
* Shared mesh-to-solid sewing utilities for mesh importers.
|
|
1463
|
+
*
|
|
1464
|
+
* Builds triangular B-Rep faces from vertex/index data and sews them into one
|
|
1465
|
+
* solid per closed body, keeping any open body as a shell.
|
|
1466
|
+
*/
|
|
1467
|
+
/**
|
|
1468
|
+
* Sew faces into one solid per closed body.
|
|
1469
|
+
*
|
|
1470
|
+
* A single body comes back on its own: a `Solid` when closed, a `Shell` when
|
|
1471
|
+
* open. Several bodies come back as a `Compound` holding a `Solid` per closed
|
|
1472
|
+
* body, a `Shell` per open one, and any face that joined no shell. An
|
|
1473
|
+
* inward-facing closed shell inside another body is a cavity, cut from that
|
|
1474
|
+
* body. The caller keeps ownership of `faces`.
|
|
1475
|
+
*
|
|
1476
|
+
* @throws When the kernel cannot sew the faces at all.
|
|
1477
|
+
*/
|
|
1478
|
+
function sewFacesIntoSolids(faces, tolerance) {
|
|
1479
|
+
try {
|
|
1480
|
+
var _usingCtx$2 = _usingCtx();
|
|
1481
|
+
const kernel = getKernel();
|
|
1482
|
+
const solid = solidify(faces, tolerance);
|
|
1483
|
+
if (solid !== null) return solid;
|
|
1484
|
+
const sewn = castResultShape(kernel.sew(faces, tolerance));
|
|
1485
|
+
const shells = getShells(sewn);
|
|
1486
|
+
const hasLooseFaces = shells.reduce((n, shell) => n + subShapeCount(shell, "face"), 0) !== subShapeCount(sewn, "face");
|
|
1487
|
+
if (shells.length === 0 || shells.length === 1 && !hasLooseFaces) return sewn;
|
|
1488
|
+
_usingCtx$2.u(sewn);
|
|
1489
|
+
const owned = [];
|
|
1490
|
+
try {
|
|
1491
|
+
const parts = carveCavities(shells.map((shell) => {
|
|
1492
|
+
const body = solidifyShell(shell.wrapped, tolerance);
|
|
1493
|
+
owned.push(body);
|
|
1494
|
+
return body;
|
|
1495
|
+
}), shells, owned);
|
|
1496
|
+
if (hasLooseFaces) for (const face of facesOutsideShells(sewn, shells)) {
|
|
1497
|
+
const copy = castResultShape(kernel.copyShape(face.wrapped));
|
|
1498
|
+
owned.push(copy);
|
|
1499
|
+
parts.push(copy);
|
|
1500
|
+
}
|
|
1501
|
+
return makeCompound(parts);
|
|
1502
|
+
} finally {
|
|
1503
|
+
for (const shape of owned) shape[Symbol.dispose]();
|
|
1504
|
+
}
|
|
1505
|
+
} catch (_) {
|
|
1506
|
+
_usingCtx$2.e = _;
|
|
1507
|
+
} finally {
|
|
1508
|
+
_usingCtx$2.d();
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
function facesOutsideShells(sewn, shells) {
|
|
1512
|
+
const kernel = getKernel();
|
|
1513
|
+
const inShells = /* @__PURE__ */ new Map();
|
|
1514
|
+
for (const shell of shells) for (const face of getFaces(shell)) {
|
|
1515
|
+
const hash = kernel.hashCode(face.wrapped, HASH_CODE_MAX);
|
|
1516
|
+
const bucket = inShells.get(hash);
|
|
1517
|
+
if (bucket) bucket.push(face.wrapped);
|
|
1518
|
+
else inShells.set(hash, [face.wrapped]);
|
|
1519
|
+
}
|
|
1520
|
+
return getFaces(sewn).filter((face) => {
|
|
1521
|
+
return !inShells.get(kernel.hashCode(face.wrapped, HASH_CODE_MAX))?.some((other) => kernel.isSame(face.wrapped, other));
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* `sewAndSolidify` when it yields a single solid, else `null`. Kernels signal
|
|
1526
|
+
* "not one closed body" differently: occt-wasm's solid downcast throws (and
|
|
1527
|
+
* castResultShape releases the slot), while opencascade.js returns the sewn
|
|
1528
|
+
* shell or compound, so the result's type decides.
|
|
1529
|
+
*/
|
|
1530
|
+
function solidify(faces, tolerance) {
|
|
1531
|
+
let shape;
|
|
1532
|
+
try {
|
|
1533
|
+
shape = castResultShape(getKernel().sewAndSolidify(faces, tolerance));
|
|
1534
|
+
} catch {
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
if (isSolid(shape)) return shape;
|
|
1538
|
+
shape[Symbol.dispose]();
|
|
1539
|
+
return null;
|
|
1540
|
+
}
|
|
1541
|
+
function solidifyShell(shell, tolerance) {
|
|
1542
|
+
const kernel = getKernel();
|
|
1543
|
+
const faces = kernel.iterShapes(shell, "face");
|
|
1544
|
+
try {
|
|
1545
|
+
return solidify(faces, tolerance) ?? castResultShape(kernel.copyShape(shell));
|
|
1546
|
+
} finally {
|
|
1547
|
+
for (const face of faces) kernel.dispose(face);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Build triangular B-Rep faces from vertex data and sew them into solids.
|
|
1552
|
+
*
|
|
1553
|
+
* For each triple of vertex coordinates, calls `kernel.buildTriFace` to create
|
|
1554
|
+
* a planar triangular face, then sews them with {@link sewFacesIntoSolids}.
|
|
1555
|
+
*
|
|
1556
|
+
* @param triangles - Array of vertex triples, each triple being three [x,y,z] tuples.
|
|
1557
|
+
* @param errorCode - The error code to use in any returned errors.
|
|
1558
|
+
* @param tolerance - Sewing tolerance (default 1e-6).
|
|
1559
|
+
* @returns A `Result` wrapping the sewn shape, or an error.
|
|
1560
|
+
*/
|
|
1561
|
+
function sewMeshToSolid(triangles, errorCode, tolerance = 1e-6) {
|
|
1562
|
+
const kernel = getKernel();
|
|
1563
|
+
const triFaces = [];
|
|
1564
|
+
for (const [va, vb, vc] of triangles) {
|
|
1565
|
+
const triFace = kernel.buildTriFace(va, vb, vc);
|
|
1566
|
+
if (triFace !== null) triFaces.push(triFace);
|
|
1567
|
+
}
|
|
1568
|
+
if (triFaces.length === 0) return err(ioError(errorCode, "No valid triangular faces could be built"));
|
|
1569
|
+
try {
|
|
1570
|
+
return ok(sewFacesIntoSolids(triFaces, tolerance));
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
return err(ioError(errorCode, "Failed to sew triangular faces", e));
|
|
1573
|
+
} finally {
|
|
1574
|
+
for (const triFace of triFaces) kernel.dispose(triFace);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1300
1577
|
// src/io/importFns.ts
|
|
1301
1578
|
/**
|
|
1302
1579
|
* Functional file import operations using branded shape types.
|
|
@@ -1333,16 +1610,25 @@ async function importSTEP(blob) {
|
|
|
1333
1610
|
return err(ioError("STEP_IMPORT_FAILED", "Failed to load STEP file", e));
|
|
1334
1611
|
}
|
|
1335
1612
|
}
|
|
1613
|
+
var STL_SEW_TOLERANCE = 1e-6;
|
|
1336
1614
|
/**
|
|
1337
1615
|
* Import an STL file from a Blob.
|
|
1338
1616
|
*
|
|
1339
|
-
* Reads the mesh
|
|
1340
|
-
*
|
|
1617
|
+
* Reads the triangle mesh and sews its facets together. A closed mesh becomes a
|
|
1618
|
+
* `Solid` (one planar face per facet), so booleans and volume measurement work on
|
|
1619
|
+
* it directly. An open mesh has no interior, so it comes back as a sewn `Shell`.
|
|
1620
|
+
* A file with several bodies comes back as a `Compound` holding a `Solid` per
|
|
1621
|
+
* closed body and a `Shell` per open one.
|
|
1341
1622
|
*
|
|
1342
1623
|
* @param blob - A Blob or File containing STL data (binary or ASCII).
|
|
1343
|
-
* @returns A `Result` wrapping the imported solid
|
|
1624
|
+
* @returns A `Result` wrapping the imported solid (a shell for an open mesh, a
|
|
1625
|
+
* compound for several bodies), or an error if parsing fails.
|
|
1344
1626
|
*
|
|
1345
|
-
* @remarks
|
|
1627
|
+
* @remarks Every triangle becomes its own B-Rep face, so import time grows with
|
|
1628
|
+
* the triangle count: on the default occt-wasm kernel, roughly 2.5 seconds per
|
|
1629
|
+
* 10,000 triangles (about 15 seconds for 50,000), and up to about twice that
|
|
1630
|
+
* when the file holds several bodies. The temporary file on the WASM FS is
|
|
1631
|
+
* cleaned up automatically.
|
|
1346
1632
|
*
|
|
1347
1633
|
* @example
|
|
1348
1634
|
* ```ts
|
|
@@ -1351,10 +1637,21 @@ async function importSTEP(blob) {
|
|
|
1351
1637
|
*/
|
|
1352
1638
|
async function importSTL(blob) {
|
|
1353
1639
|
try {
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1640
|
+
try {
|
|
1641
|
+
var _usingCtx$1 = _usingCtx();
|
|
1642
|
+
const data = await blob.arrayBuffer();
|
|
1643
|
+
const raw = getKernel().importSTL(data);
|
|
1644
|
+
if (raw.IsNull()) return err(ioError("STL_IMPORT_FAILED", "Failed to create solid from STL mesh"));
|
|
1645
|
+
const shape = castResultShape(raw);
|
|
1646
|
+
if (isSolid(shape)) return ok(shape);
|
|
1647
|
+
const facets = _usingCtx$1.u(shape);
|
|
1648
|
+
const faces = getFaces(facets).map((f) => f.wrapped);
|
|
1649
|
+
return ok(sewFacesIntoSolids(faces, STL_SEW_TOLERANCE));
|
|
1650
|
+
} catch (_) {
|
|
1651
|
+
_usingCtx$1.e = _;
|
|
1652
|
+
} finally {
|
|
1653
|
+
_usingCtx$1.d();
|
|
1654
|
+
}
|
|
1358
1655
|
} catch (e) {
|
|
1359
1656
|
return err(ioError("STL_IMPORT_FAILED", "Failed to load STL file", e));
|
|
1360
1657
|
}
|
|
@@ -1365,7 +1662,9 @@ async function importSTL(blob) {
|
|
|
1365
1662
|
* @param blob - A Blob or File containing IGES data (.iges / .igs).
|
|
1366
1663
|
* @returns A `Result` wrapping the imported shape, or an error if parsing fails.
|
|
1367
1664
|
*
|
|
1368
|
-
* @remarks The temporary file on the WASM FS is cleaned up automatically.
|
|
1665
|
+
* @remarks The temporary file on the WASM FS is cleaned up automatically. The
|
|
1666
|
+
* default occt-wasm kernel is built without an IGES translator, so there this
|
|
1667
|
+
* returns an `UNSUPPORTED_CAPABILITY` error; import STEP instead.
|
|
1369
1668
|
*
|
|
1370
1669
|
* @example
|
|
1371
1670
|
* ```ts
|
|
@@ -1383,7 +1682,7 @@ async function importIGES(blob) {
|
|
|
1383
1682
|
}
|
|
1384
1683
|
return ok(castResultShape(shapes[0]));
|
|
1385
1684
|
} catch (e) {
|
|
1386
|
-
return err(ioError("IGES_IMPORT_FAILED", "Failed to load IGES file", e));
|
|
1685
|
+
return err(igesUnsupportedError("importIGES", e) ?? ioError("IGES_IMPORT_FAILED", "Failed to load IGES file", e));
|
|
1387
1686
|
}
|
|
1388
1687
|
}
|
|
1389
|
-
export {
|
|
1688
|
+
export { exportSTEPConfigured as a, exportThreeMF as c, exportGlb as d, exportGltf as f, sewMeshToSolid as i, blueprintToDXF as l, importSTEP as n, importSVG as o, exportOBJ as p, importSTL as r, importSVGPathD as s, importIGES as t, exportDXF as u };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BrepError } from '../core/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* The capability error for an IGES call on a kernel built without an IGES
|
|
4
|
+
* translator (occt-wasm), or `null` when `cause` is any other failure.
|
|
5
|
+
*/
|
|
6
|
+
export declare function igesUnsupportedError(operation: 'importIGES' | 'exportIGES', cause: unknown): BrepError | null;
|
package/dist/io/importFns.d.ts
CHANGED
|
@@ -21,13 +21,21 @@ export declare function importSTEP(blob: Blob): Promise<Result<UnknownDimShape>>
|
|
|
21
21
|
/**
|
|
22
22
|
* Import an STL file from a Blob.
|
|
23
23
|
*
|
|
24
|
-
* Reads the mesh
|
|
25
|
-
*
|
|
24
|
+
* Reads the triangle mesh and sews its facets together. A closed mesh becomes a
|
|
25
|
+
* `Solid` (one planar face per facet), so booleans and volume measurement work on
|
|
26
|
+
* it directly. An open mesh has no interior, so it comes back as a sewn `Shell`.
|
|
27
|
+
* A file with several bodies comes back as a `Compound` holding a `Solid` per
|
|
28
|
+
* closed body and a `Shell` per open one.
|
|
26
29
|
*
|
|
27
30
|
* @param blob - A Blob or File containing STL data (binary or ASCII).
|
|
28
|
-
* @returns A `Result` wrapping the imported solid
|
|
31
|
+
* @returns A `Result` wrapping the imported solid (a shell for an open mesh, a
|
|
32
|
+
* compound for several bodies), or an error if parsing fails.
|
|
29
33
|
*
|
|
30
|
-
* @remarks
|
|
34
|
+
* @remarks Every triangle becomes its own B-Rep face, so import time grows with
|
|
35
|
+
* the triangle count: on the default occt-wasm kernel, roughly 2.5 seconds per
|
|
36
|
+
* 10,000 triangles (about 15 seconds for 50,000), and up to about twice that
|
|
37
|
+
* when the file holds several bodies. The temporary file on the WASM FS is
|
|
38
|
+
* cleaned up automatically.
|
|
31
39
|
*
|
|
32
40
|
* @example
|
|
33
41
|
* ```ts
|
|
@@ -41,7 +49,9 @@ export declare function importSTL(blob: Blob): Promise<Result<UnknownDimShape>>;
|
|
|
41
49
|
* @param blob - A Blob or File containing IGES data (.iges / .igs).
|
|
42
50
|
* @returns A `Result` wrapping the imported shape, or an error if parsing fails.
|
|
43
51
|
*
|
|
44
|
-
* @remarks The temporary file on the WASM FS is cleaned up automatically.
|
|
52
|
+
* @remarks The temporary file on the WASM FS is cleaned up automatically. The
|
|
53
|
+
* default occt-wasm kernel is built without an IGES translator, so there this
|
|
54
|
+
* returns an `UNSUPPORTED_CAPABILITY` error; import STEP instead.
|
|
45
55
|
*
|
|
46
56
|
* @example
|
|
47
57
|
* ```ts
|
package/dist/io/ioUtils.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import { KernelShape } from '../kernel/types.js';
|
|
1
2
|
import { UnknownDimShape } from '../core/shapeTypes.js';
|
|
2
3
|
import { Result } from '../core/result.js';
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* Sew faces into one solid per closed body.
|
|
6
|
+
*
|
|
7
|
+
* A single body comes back on its own: a `Solid` when closed, a `Shell` when
|
|
8
|
+
* open. Several bodies come back as a `Compound` holding a `Solid` per closed
|
|
9
|
+
* body, a `Shell` per open one, and any face that joined no shell. An
|
|
10
|
+
* inward-facing closed shell inside another body is a cavity, cut from that
|
|
11
|
+
* body. The caller keeps ownership of `faces`.
|
|
12
|
+
*
|
|
13
|
+
* @throws When the kernel cannot sew the faces at all.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sewFacesIntoSolids(faces: KernelShape[], tolerance: number): UnknownDimShape;
|
|
16
|
+
/**
|
|
17
|
+
* Build triangular B-Rep faces from vertex data and sew them into solids.
|
|
5
18
|
*
|
|
6
19
|
* For each triple of vertex coordinates, calls `kernel.buildTriFace` to create
|
|
7
|
-
* a planar triangular face, then
|
|
8
|
-
* fails, falls back to `sew` (returning a shell or compound).
|
|
20
|
+
* a planar triangular face, then sews them with {@link sewFacesIntoSolids}.
|
|
9
21
|
*
|
|
10
22
|
* @param triangles - Array of vertex triples, each triple being three [x,y,z] tuples.
|
|
11
23
|
* @param errorCode - The error code to use in any returned errors.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AnyShape, Dimension, Shell } from '../core/shapeTypes.js';
|
|
2
|
+
type Body = AnyShape<Dimension>;
|
|
3
|
+
/**
|
|
4
|
+
* The parts to keep: `bodies` (each built from the same-index shell of `shells`)
|
|
5
|
+
* with every cavity cut from the body around it and left out. Cut results are
|
|
6
|
+
* pushed to `owned` for the caller to dispose; no input is disposed here.
|
|
7
|
+
*
|
|
8
|
+
* @throws When meshing or a cut fails, rather than leave a cavity filled.
|
|
9
|
+
*/
|
|
10
|
+
export declare function carveCavities(bodies: Body[], shells: Shell[], owned: Body[]): Body[];
|
|
11
|
+
export {};
|
|
@@ -3,11 +3,14 @@ import { Result } from '../core/result.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Import a 3MF file from a Blob.
|
|
5
5
|
*
|
|
6
|
-
* Extracts the model XML from the ZIP archive
|
|
7
|
-
*
|
|
6
|
+
* Extracts the model XML from the ZIP archive and builds one solid per placed
|
|
7
|
+
* object by sewing its triangles. Build-item and component transforms are
|
|
8
|
+
* applied, and coordinates are scaled from the model `unit` to millimeters.
|
|
8
9
|
*
|
|
9
10
|
* @param blob - A Blob or File containing 3MF data (.3mf).
|
|
10
|
-
* @returns A `Result` wrapping the imported solid
|
|
11
|
+
* @returns A `Result` wrapping the imported solid (a `Compound` of solids when the
|
|
12
|
+
* build places several objects), or an error if parsing fails or the build
|
|
13
|
+
* expands to more than 100,000 placed objects or 2,000,000 triangles.
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
13
16
|
* ```ts
|
package/dist/io.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_meshFns = require("./meshFns-
|
|
3
|
-
const require_importFns = require("./importFns-
|
|
2
|
+
const require_meshFns = require("./meshFns-Djbb4PUC.cjs");
|
|
3
|
+
const require_importFns = require("./importFns-BiRpt227.cjs");
|
|
4
4
|
exports.blueprintToDXF = require_importFns.blueprintToDXF;
|
|
5
5
|
exports.exportDXF = require_importFns.exportDXF;
|
|
6
6
|
exports.exportGlb = require_importFns.exportGlb;
|
package/dist/io.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-
|
|
2
|
-
import { a as
|
|
1
|
+
import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-BGoJU6_P.js";
|
|
2
|
+
import { a as exportSTEPConfigured, c as exportThreeMF, d as exportGlb, f as exportGltf, l as blueprintToDXF, n as importSTEP, o as importSVG, p as exportOBJ, r as importSTL, s as importSVGPathD, t as importIGES, u as exportDXF } from "./importFns-CwrJsNvg.js";
|
|
3
3
|
export { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_occtWasmAdapter = require("../../occtWasmAdapter-
|
|
2
|
+
const require_occtWasmAdapter = require("../../occtWasmAdapter-UcYZRi-w.cjs");
|
|
3
3
|
exports.OcctWasmAdapter = require_occtWasmAdapter.OcctWasmAdapter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as OcctWasmAdapter } from "../../occtWasmAdapter-
|
|
1
|
+
export { t as OcctWasmAdapter } from "../../occtWasmAdapter-BCCwaYkq.js";
|
|
@@ -229,8 +229,10 @@ export interface OcctKernelWasm {
|
|
|
229
229
|
importStep(data: string): number;
|
|
230
230
|
exportStep(id: number): string;
|
|
231
231
|
importStl(data: string): number;
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
/** Absent from published occt-wasm builds (no IGES translator), so callers feature-detect. */
|
|
233
|
+
importIges?(data: string): number;
|
|
234
|
+
/** Absent from published occt-wasm builds (no IGES translator), so callers feature-detect. */
|
|
235
|
+
exportIges?(id: number): string;
|
|
234
236
|
exportStl(id: number, linearDeflection: number, ascii: boolean): string;
|
|
235
237
|
toBREP(id: number): string;
|
|
236
238
|
fromBREP(data: string): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DmThK_oa.cjs");
|
|
2
2
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
3
3
|
const require_types = require("./types-CjF9Rofr.cjs");
|
|
4
4
|
const require_vecOps = require("./vecOps-CrGEPPQM.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as _usingCtx, T as isWire, h as disposeResultShape, n as castResultShape, q as getKernel, x as isShape3D } from "./shapeTypes-
|
|
1
|
+
import { G as _usingCtx, T as isWire, h as disposeResultShape, n as castResultShape, q as getKernel, x as isShape3D } from "./shapeTypes-CIH-8d_a.js";
|
|
2
2
|
import { E as ok, b as isErr, d as validationError, g as err, i as kernelError, l as typeCastError, t as BrepErrorCode } from "./errors-BTccWbtE.js";
|
|
3
3
|
import { r as toVec3 } from "./types-CKXsIm9-.js";
|
|
4
4
|
import { c as vecLength, t as vecAdd } from "./vecOps-S-m9H_fe.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DmThK_oa.cjs");
|
|
2
2
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
4
|
-
const require_faceFns = require("./faceFns-
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-CXbCFaU2.cjs");
|
|
4
|
+
const require_faceFns = require("./faceFns-C4NOGZBg.cjs");
|
|
5
5
|
// src/measurement/measureCache.ts
|
|
6
6
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
function getCachedMeasurement(shape, key) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { q as getKernel } from "./shapeTypes-
|
|
1
|
+
import { q as getKernel } from "./shapeTypes-CIH-8d_a.js";
|
|
2
2
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-BTccWbtE.js";
|
|
3
|
-
import { E as kernelCallRaw } from "./topologyQueryFns-
|
|
4
|
-
import { m as uvBounds } from "./faceFns-
|
|
3
|
+
import { E as kernelCallRaw } from "./topologyQueryFns-Cp0yekBh.js";
|
|
4
|
+
import { m as uvBounds } from "./faceFns-BgRNa5vx.js";
|
|
5
5
|
// src/measurement/measureCache.ts
|
|
6
6
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
7
7
|
function getCachedMeasurement(shape, key) {
|
package/dist/measurement.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_measureFns = require("./measureFns-
|
|
3
|
-
const require_principalBoxFns = require("./principalBoxFns-
|
|
2
|
+
const require_measureFns = require("./measureFns-D_RRjCZg.cjs");
|
|
3
|
+
const require_principalBoxFns = require("./principalBoxFns-IY8FfPVj.cjs");
|
|
4
4
|
exports.createDistanceQuery = require_measureFns.createDistanceQuery;
|
|
5
5
|
exports.measureArea = require_measureFns.measureArea;
|
|
6
6
|
exports.measureDistance = require_measureFns.measureDistance;
|
package/dist/measurement.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-
|
|
2
|
-
import { t as principalBoundingBox } from "./principalBoxFns-
|
|
1
|
+
import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-Q3K25IfN.js";
|
|
2
|
+
import { t as principalBoundingBox } from "./principalBoxFns-Dcp9gg5e.js";
|
|
3
3
|
export { createDistanceQuery, measureArea, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, principalBoundingBox };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-CIH-8d_a.js";
|
|
2
|
+
import { j as isUnsupportedKernelOperationError } from "./occtWasmAdapter-BCCwaYkq.js";
|
|
3
|
+
import { E as ok, g as err, r as ioError, t as BrepErrorCode, u as unsupportedError } from "./errors-BTccWbtE.js";
|
|
4
|
+
import { d as getSolids, n as getBounds } from "./topologyQueryFns-Cp0yekBh.js";
|
|
5
|
+
import { d as getFaceOrigins } from "./solidBuilders-q_hwYsdo.js";
|
|
5
6
|
// src/topology/meshCache.ts
|
|
6
7
|
/**
|
|
7
8
|
* Build a parameter key for the inner cache map (excludes shape identity).
|
|
@@ -107,6 +108,16 @@ function createMeshCache() {
|
|
|
107
108
|
}
|
|
108
109
|
};
|
|
109
110
|
}
|
|
111
|
+
// src/io/igesSupport.ts
|
|
112
|
+
/**
|
|
113
|
+
* The capability error for an IGES call on a kernel built without an IGES
|
|
114
|
+
* translator (occt-wasm), or `null` when `cause` is any other failure.
|
|
115
|
+
*/
|
|
116
|
+
function igesUnsupportedError(operation, cause) {
|
|
117
|
+
if (!isUnsupportedKernelOperationError(cause)) return null;
|
|
118
|
+
const kernel = getKernel().kernelId;
|
|
119
|
+
return unsupportedError(BrepErrorCode.UNSUPPORTED_CAPABILITY, `${operation}: the ${kernel} kernel has no IGES support`, cause, { kernel }, "Exchange the model as STEP (importSTEP / exportSTEP) instead");
|
|
120
|
+
}
|
|
110
121
|
// src/topology/meshFns.ts
|
|
111
122
|
/**
|
|
112
123
|
* Meshing and export functions — functional replacements for Shape mesh/export methods.
|
|
@@ -297,13 +308,16 @@ function exportSTL(shape, opts = {}) {
|
|
|
297
308
|
* Export a shape as an IGES file Blob.
|
|
298
309
|
*
|
|
299
310
|
* @returns Ok with a Blob (MIME type `application/iges`), or Err on failure.
|
|
311
|
+
*
|
|
312
|
+
* @remarks The default occt-wasm kernel is built without an IGES translator, so
|
|
313
|
+
* there this returns an `UNSUPPORTED_CAPABILITY` error; export STEP instead.
|
|
300
314
|
*/
|
|
301
315
|
function exportIGES(shape) {
|
|
302
316
|
try {
|
|
303
317
|
const igesString = getKernel().exportIGES([shape.wrapped]);
|
|
304
318
|
return ok(new Blob([igesString], { type: "application/iges" }));
|
|
305
319
|
} catch (e) {
|
|
306
|
-
return err(ioError("IGES_EXPORT_FAILED", "Failed to write IGES file", e));
|
|
320
|
+
return err(igesUnsupportedError("exportIGES", e) ?? ioError("IGES_EXPORT_FAILED", "Failed to write IGES file", e));
|
|
307
321
|
}
|
|
308
322
|
}
|
|
309
323
|
/**
|
|
@@ -436,4 +450,4 @@ async function meshLODsProgressive(shape, options = {}) {
|
|
|
436
450
|
}
|
|
437
451
|
return results;
|
|
438
452
|
}
|
|
439
|
-
export { meshEdges as a, meshMultiLOD as c,
|
|
453
|
+
export { meshEdges as a, meshMultiLOD as c, buildMeshCacheKey as d, clearMeshCache as f, mesh as i, scaleDefaultTolerance as l, exportSTEP as n, meshLODs as o, createMeshCache as p, exportSTL as r, meshLODsProgressive as s, exportIGES as t, igesUnsupportedError as u };
|