brepjs 20.12.7 → 20.12.9
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-hMihivxC.js → adjacencyFns-1Cmjb2ot.js} +3 -3
- package/dist/{adjacencyFns-mMmTBUBY.cjs → adjacencyFns-CfhGIMeR.cjs} +3 -3
- package/dist/{blueprint-BS50D3J_.js → blueprint-BVcuEefs.js} +5 -5
- package/dist/{blueprint-17RUHsoP.cjs → blueprint-DbJVzU9F.cjs} +5 -5
- package/dist/{blueprintFns-Dw5_4_Bk.cjs → blueprintFns-DePTHG1I.cjs} +2 -2
- package/dist/{blueprintFns-zy5lo2IF.js → blueprintFns-mD4pDyFP.js} +2 -2
- package/dist/{blueprintSketcher-BG--DxWB.cjs → blueprintSketcher-B5CFmhjg.cjs} +3 -3
- package/dist/{blueprintSketcher-C1WCI6E0.js → blueprintSketcher-BrGmq-65.js} +3 -3
- package/dist/{boolean2D-CsdyfjFE.js → boolean2D-BrHrY60M.js} +4 -4
- package/dist/{boolean2D-7SQ3B0pC.cjs → boolean2D-CFKg1FJ_.cjs} +4 -4
- package/dist/{solidBuilders-DdG4NPHM.cjs → booleanFns-C640CeaY.cjs} +11 -217
- package/dist/{solidBuilders-Bmr59cGp.js → booleanFns-CKDyqKz0.js} +10 -156
- package/dist/brepjs.cjs +325 -168
- package/dist/brepjs.js +282 -125
- package/dist/{cameraFns-BVWyAscu.js → cameraFns-DIbua1lC.js} +3 -3
- package/dist/{cameraFns-BAtzhCYM.cjs → cameraFns-hXUKJkLg.cjs} +3 -3
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-Dv_2rmaY.js → cornerFinder-BYDkloVc.js} +1 -1
- package/dist/{cornerFinder-e4Wc7_yp.cjs → cornerFinder-ByBGU0r7.cjs} +1 -1
- package/dist/{curveFns-BAM7QHrP.cjs → curveFns-Cqgtmhr0.cjs} +1 -1
- package/dist/{curveFns-CEI-rouh.js → curveFns-DphpaoQ4.js} +1 -1
- package/dist/{drawFns-Cl1i8B_B.js → drawFns-Ch3ah8K9.js} +12 -12
- package/dist/{drawFns-d-RvC6u6.cjs → drawFns-GwVZX47o.cjs} +12 -12
- package/dist/{faceFns-C-2ttg8X.cjs → faceFns-BDqVGEoB.cjs} +2 -2
- package/dist/{faceFns-Q87HCJrp.js → faceFns-D4cDeMRf.js} +2 -2
- package/dist/{healingFns-Cm4NkKD8.js → healingFns--vBKh5pa.js} +5 -5
- package/dist/{healingFns-DZkO5okn.cjs → healingFns-Fu7Xl8fu.cjs} +29 -29
- package/dist/{helpers-DpGcM2qZ.js → helpers-CroIo2SI.js} +6 -6
- package/dist/{helpers-BdGGaLhF.cjs → helpers-Wnq-YPWv.cjs} +6 -6
- package/dist/{importFns-Bp-p0jiP.js → importFns-D5Bt_44J.js} +314 -15
- package/dist/{importFns-DLiP26NW.cjs → importFns-tHr15Lhm.cjs} +319 -14
- 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/evolutionOps.d.ts +4 -3
- package/dist/kernel/occtWasm/helpers.d.ts +14 -3
- package/dist/kernel/occtWasm/ioOps.d.ts +13 -13
- package/dist/kernel/occtWasm/modifierOps.d.ts +5 -3
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/occtWasmTypes.d.ts +37 -2
- package/dist/{loftFns-DQ7Z29n3.js → loftFns-Bh_RuF7a.js} +1 -1
- package/dist/{loftFns-DGV1z2NJ.cjs → loftFns-T0GxcPlB.cjs} +1 -1
- package/dist/{measureFns-BrdCH4cH.js → measureFns-C3TZ5Fj9.js} +3 -3
- package/dist/{measureFns-BdSjw5fr.cjs → measureFns-DGm6ndQY.cjs} +3 -3
- package/dist/measurement.cjs +2 -2
- package/dist/measurement.js +2 -2
- package/dist/{meshFns-BeubBqEI.cjs → meshFns-DDgZ3vpr.cjs} +25 -5
- package/dist/{meshFns-UE8tByyw.js → meshFns-Go1XSyUh.js} +20 -6
- package/dist/{occtWasmAdapter-D3qerQTq.cjs → occtWasmAdapter-CZPZnpCe.cjs} +297 -85
- package/dist/{occtWasmAdapter-DA7oMgcQ.js → occtWasmAdapter-EM3EhKwk.js} +297 -85
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{primitiveFns-3-gs-FUX.js → primitiveFns-CeRc4Sls.js} +5 -4
- package/dist/{primitiveFns-CLGVLwG8.cjs → primitiveFns-Dg_XWYtp.cjs} +19 -18
- package/dist/{principalBoxFns-CiXzjOkr.cjs → principalBoxFns-B5zdek3y.cjs} +3 -3
- package/dist/{principalBoxFns-RMZItjfR.js → principalBoxFns-BuK-ueAB.js} +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-DNX0bCrP.cjs → refResolveFns-CFwsYCKA.cjs} +6 -6
- package/dist/{refResolveFns-kJg2iCad.js → refResolveFns-WRcvVhV-.js} +6 -6
- package/dist/{shapeFns-CZ6VF1yd.js → shapeFns-CYjU8PsF.js} +2 -2
- package/dist/{shapeFns-SgIrOjN4.cjs → shapeFns-DuxfaqTw.cjs} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-MUEH4XuH.cjs → shapeTypes--7XBFlOD.cjs} +1 -1
- package/dist/{shapeTypes-BNGu103j.js → shapeTypes-DvzbSivn.js} +1 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{originTrackingFns-c2qgRZ_9.js → solidBuilders-BqSVC4cB.js} +150 -3
- package/dist/{originTrackingFns-rEKOAP65.cjs → solidBuilders-D0bIZX9K.cjs} +209 -2
- package/dist/{surfaceBuilders-DI376ai0.js → surfaceBuilders--HOoTQad.js} +3 -3
- package/dist/{surfaceBuilders-DOmDVuMs.cjs → surfaceBuilders-CPQHyL_5.cjs} +3 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-B7Vhr0xu.cjs → textBlueprints-B4HzJzZM.cjs} +9 -8
- package/dist/{textBlueprints-CE0oxB43.js → textBlueprints-plsbHqiI.js} +8 -7
- package/dist/{textMetrics-C6_kSht6.cjs → textMetrics-CBwUIDI7.cjs} +1 -1
- package/dist/{textMetrics-_VGqdewQ.js → textMetrics-IIS6DUTr.js} +1 -1
- package/dist/{threadFns-CHdY-4Cz.js → threadFns-CmZFykpi.js} +7 -7
- package/dist/{threadFns-1H60LrFX.cjs → threadFns-e8_26ZYw.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-CltEv7Pi.js → topologyQueryFns-BUzMuIs5.js} +1 -1
- package/dist/{topologyQueryFns-C_fXO6xL.cjs → topologyQueryFns-NszVx8a0.cjs} +1 -1
- package/dist/{validityTypes-GanLrmvY.js → validityTypes-CdY06B8c.js} +1 -1
- package/dist/{validityTypes-CGX2ES81.cjs → validityTypes-Ds4zNICF.cjs} +1 -1
- package/package.json +2 -2
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes--7XBFlOD.cjs");
|
|
2
2
|
const require_bug = require("./bug-CBcpIPuf.cjs");
|
|
3
3
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-NszVx8a0.cjs");
|
|
5
|
+
const require_constants = require("./constants-oee0S_x6.cjs");
|
|
6
|
+
const require_solidBuilders = require("./solidBuilders-D0bIZX9K.cjs");
|
|
7
|
+
const require_meshFns = require("./meshFns-DDgZ3vpr.cjs");
|
|
4
8
|
const require_arrayAccess = require("./arrayAccess-DpJYARwv.cjs");
|
|
5
|
-
const require_blueprint = require("./blueprint-
|
|
9
|
+
const require_blueprint = require("./blueprint-DbJVzU9F.cjs");
|
|
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 require_errors.err(require_errors.ioError(require_errors.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) => require_shapeTypes.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 = require_shapeTypes.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 = require_shapeTypes.getKernel();
|
|
1390
|
+
let current = body;
|
|
1391
|
+
for (const inner of voids) try {
|
|
1392
|
+
const next = require_shapeTypes.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 require_shapeTypes.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 = require_shapeTypes._usingCtx();
|
|
1481
|
+
const kernel = require_shapeTypes.getKernel();
|
|
1482
|
+
const solid = solidify(faces, tolerance);
|
|
1483
|
+
if (solid !== null) return solid;
|
|
1484
|
+
const sewn = require_shapeTypes.castResultShape(kernel.sew(faces, tolerance));
|
|
1485
|
+
const shells = require_topologyQueryFns.getShells(sewn);
|
|
1486
|
+
const hasLooseFaces = shells.reduce((n, shell) => n + require_topologyQueryFns.subShapeCount(shell, "face"), 0) !== require_topologyQueryFns.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 = require_shapeTypes.castResultShape(kernel.copyShape(face.wrapped));
|
|
1498
|
+
owned.push(copy);
|
|
1499
|
+
parts.push(copy);
|
|
1500
|
+
}
|
|
1501
|
+
return require_solidBuilders.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 = require_shapeTypes.getKernel();
|
|
1513
|
+
const inShells = /* @__PURE__ */ new Map();
|
|
1514
|
+
for (const shell of shells) for (const face of require_topologyQueryFns.getFaces(shell)) {
|
|
1515
|
+
const hash = kernel.hashCode(face.wrapped, require_constants.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 require_topologyQueryFns.getFaces(sewn).filter((face) => {
|
|
1521
|
+
return !inShells.get(kernel.hashCode(face.wrapped, require_constants.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 = require_shapeTypes.castResultShape(require_shapeTypes.getKernel().sewAndSolidify(faces, tolerance));
|
|
1534
|
+
} catch {
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
if (require_shapeTypes.isSolid(shape)) return shape;
|
|
1538
|
+
shape[Symbol.dispose]();
|
|
1539
|
+
return null;
|
|
1540
|
+
}
|
|
1541
|
+
function solidifyShell(shell, tolerance) {
|
|
1542
|
+
const kernel = require_shapeTypes.getKernel();
|
|
1543
|
+
const faces = kernel.iterShapes(shell, "face");
|
|
1544
|
+
try {
|
|
1545
|
+
return solidify(faces, tolerance) ?? require_shapeTypes.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 = require_shapeTypes.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 require_errors.err(require_errors.ioError(errorCode, "No valid triangular faces could be built"));
|
|
1569
|
+
try {
|
|
1570
|
+
return require_errors.ok(sewFacesIntoSolids(triFaces, tolerance));
|
|
1571
|
+
} catch (e) {
|
|
1572
|
+
return require_errors.err(require_errors.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 require_errors.err(require_errors.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 = require_shapeTypes._usingCtx();
|
|
1642
|
+
const data = await blob.arrayBuffer();
|
|
1643
|
+
const raw = require_shapeTypes.getKernel().importSTL(data);
|
|
1644
|
+
if (raw.IsNull()) return require_errors.err(require_errors.ioError("STL_IMPORT_FAILED", "Failed to create solid from STL mesh"));
|
|
1645
|
+
const shape = require_shapeTypes.castResultShape(raw);
|
|
1646
|
+
if (require_shapeTypes.isSolid(shape)) return require_errors.ok(shape);
|
|
1647
|
+
const facets = _usingCtx$1.u(shape);
|
|
1648
|
+
const faces = require_topologyQueryFns.getFaces(facets).map((f) => f.wrapped);
|
|
1649
|
+
return require_errors.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 require_errors.err(require_errors.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 require_errors.ok(require_shapeTypes.castResultShape(shapes[0]));
|
|
1385
1684
|
} catch (e) {
|
|
1386
|
-
return require_errors.err(require_errors.ioError("IGES_IMPORT_FAILED", "Failed to load IGES file", e));
|
|
1685
|
+
return require_errors.err(require_meshFns.igesUnsupportedError("importIGES", e) ?? require_errors.ioError("IGES_IMPORT_FAILED", "Failed to load IGES file", e));
|
|
1387
1686
|
}
|
|
1388
1687
|
}
|
|
1389
1688
|
Object.defineProperty(exports, "blueprintToDXF", {
|
|
@@ -1458,3 +1757,9 @@ Object.defineProperty(exports, "importSVGPathD", {
|
|
|
1458
1757
|
return importSVGPathD;
|
|
1459
1758
|
}
|
|
1460
1759
|
});
|
|
1760
|
+
Object.defineProperty(exports, "sewMeshToSolid", {
|
|
1761
|
+
enumerable: true,
|
|
1762
|
+
get: function() {
|
|
1763
|
+
return sewMeshToSolid;
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
@@ -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-DDgZ3vpr.cjs");
|
|
3
|
+
const require_importFns = require("./importFns-tHr15Lhm.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-Go1XSyUh.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-D5Bt_44J.js";
|
|
3
3
|
export { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BooleanOptions, DiagnosticOperationResult, KernelShape, KernelType, OperationResult } from '../types.js';
|
|
2
2
|
import { OcctKernelWasm, OcctWasmModule } from './occtWasmTypes.js';
|
|
3
|
+
import { EdgeValueSpec } from './helpers.js';
|
|
3
4
|
/**
|
|
4
5
|
* Parse an EvolutionData result from the WASM kernel into a ShapeEvolution.
|
|
5
6
|
* The C++ facade returns flat vectors of [inputHash, count, out1, out2, ..., inputHash, count, ...].
|
|
@@ -16,10 +17,10 @@ export declare function intersectWithHistory(k: OcctKernelWasm, Module: OcctWasm
|
|
|
16
17
|
export declare function fuseAllWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shapes: KernelShape[], inputFaceHashes: number[], hashUpperBound: number, options?: BooleanOptions): DiagnosticOperationResult;
|
|
17
18
|
/** N-way cut with face history over the base and every tool. Needs `booleanOp`. */
|
|
18
19
|
export declare function cutAllWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, tools: KernelShape[], inputFaceHashes: number[], hashUpperBound: number, options?: BooleanOptions): DiagnosticOperationResult;
|
|
19
|
-
export declare function filletWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], radius:
|
|
20
|
-
export declare function chamferWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], distance:
|
|
20
|
+
export declare function filletWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], radius: EdgeValueSpec, inputFaceHashes: number[], hashUpperBound: number): OperationResult;
|
|
21
|
+
export declare function chamferWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], distance: EdgeValueSpec, inputFaceHashes: number[], hashUpperBound: number): OperationResult;
|
|
21
22
|
export declare function shellWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, faces: KernelShape[], thickness: number, inputFaceHashes: number[], hashUpperBound: number, tolerance?: number): OperationResult;
|
|
22
23
|
export declare function thickenWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, thickness: number, inputFaceHashes: number[], hashUpperBound: number): OperationResult;
|
|
23
24
|
export declare function offsetWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, distance: number, inputFaceHashes: number[], hashUpperBound: number, tolerance?: number): OperationResult;
|
|
24
|
-
export declare function draftWithHistory(k: OcctKernelWasm, shape: KernelShape, faces: KernelShape[], pullDirection: [number, number, number], angleDeg: number | ((face: KernelShape) => number)): OperationResult;
|
|
25
|
+
export declare function draftWithHistory(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, faces: KernelShape[], pullDirection: [number, number, number], neutralPlane: [number, number, number], angleDeg: number | ((face: KernelShape) => number), inputFaceHashes: number[], hashUpperBound: number): OperationResult;
|
|
25
26
|
export declare function applyComposedTransformWithHistory(transformFn: (shape: KernelShape, trsf: KernelType) => KernelShape, iterShapesFn: (shape: KernelShape, type: 'face') => KernelShape[], hashCodeFn: (shape: KernelShape, upperBound: number) => number, shape: KernelShape, transformHandle: KernelType, inputFaceHashes: number[], hashUpperBound: number): OperationResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { KernelShape, ShapeEvolution, ShapeType } from '../types.js';
|
|
2
|
+
import { UnsupportedKernelOperationError } from '../unsupported.js';
|
|
2
3
|
import { EmEvolutionData, OcctWasmHandle, OcctWasmModule, OcctKernelWasm, EmVectorUint32, EmVectorInt, EmVectorDouble } from './occtWasmTypes.js';
|
|
3
4
|
export declare const noop: () => void;
|
|
4
5
|
/** Build an opaque kernel handle for an arena-allocated WASM shape. */
|
|
@@ -24,11 +25,20 @@ export declare function readVecInt(vec: EmVectorInt): number[];
|
|
|
24
25
|
* and any other transform-stack composition.
|
|
25
26
|
*/
|
|
26
27
|
export declare function multiplyMatrices4x4(a: number[], b: number[]): number[];
|
|
28
|
+
/** A fillet's start and end radius, or a chamfer's two setbacks. A number is both. */
|
|
29
|
+
type EdgeValue = number | [number, number];
|
|
30
|
+
export type EdgeValueSpec = EdgeValue | ((edge: KernelShape) => EdgeValue);
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
32
|
+
* Run a fillet or chamfer over `edges`, naming the edges it fails on. Edges
|
|
33
|
+
* that all take one value go to `uniform`, the single-value entry point every
|
|
34
|
+
* occt-wasm build has; otherwise `perEdge` gets each edge's pair as `first`
|
|
35
|
+
* and `second`.
|
|
30
36
|
*/
|
|
31
|
-
export declare function
|
|
37
|
+
export declare function runEdgeTreatment<T>(Module: OcctWasmModule, edges: KernelShape[], value: EdgeValueSpec, uniform: (edgeVec: EmVectorUint32, value: number) => T, perEdge: (edgeVec: EmVectorUint32, first: EmVectorDouble, second: EmVectorDouble) => T): T;
|
|
38
|
+
/** Each face's draft angle, in radians. */
|
|
39
|
+
export declare function draftAnglesRad(faces: readonly KernelShape[], angleDeg: number | ((face: KernelShape) => number)): number[];
|
|
40
|
+
/** The peer range still admits older builds, which lack the per-edge and unit entry points. */
|
|
41
|
+
export declare function needsOcctWasm59(what: string): UnsupportedKernelOperationError;
|
|
32
42
|
/**
|
|
33
43
|
* Rotate a shape from the kernel's default Z-axis to an arbitrary direction.
|
|
34
44
|
* Used by primitives whose creation API only takes a Z-aligned form.
|
|
@@ -39,3 +49,4 @@ export declare function parseEvolution(evo: EmEvolutionData): {
|
|
|
39
49
|
id: number;
|
|
40
50
|
evolution: ShapeEvolution;
|
|
41
51
|
};
|
|
52
|
+
export {};
|
|
@@ -17,13 +17,17 @@ type MeshFn = (shape: KernelShape, options: {
|
|
|
17
17
|
faceHash: number;
|
|
18
18
|
}>;
|
|
19
19
|
};
|
|
20
|
+
interface StepUnitOptions {
|
|
21
|
+
unit?: string | undefined;
|
|
22
|
+
modelUnit?: string | undefined;
|
|
23
|
+
}
|
|
20
24
|
export declare function exportSTEP(k: OcctKernelWasm, makeCompound: CompoundFn, shapes: KernelShape[]): string;
|
|
21
25
|
export declare function exportSTL(mesh: MeshFn, shape: KernelShape, binary?: boolean, tolerance?: number, angularTolerance?: number): string | ArrayBuffer;
|
|
22
26
|
export declare function importSTEP(k: OcctKernelWasm, data: string | ArrayBuffer): KernelShape[];
|
|
23
27
|
export declare function importSTL(k: OcctKernelWasm, Module: OcctWasmModule, data: string | ArrayBuffer): KernelShape;
|
|
24
28
|
export declare function exportIGES(k: OcctKernelWasm, makeCompound: CompoundFn, shapes: KernelShape[]): string;
|
|
25
29
|
export declare function importIGES(k: OcctKernelWasm, data: string | ArrayBuffer): KernelShape[];
|
|
26
|
-
export declare function exportSTEPAssembly(k: OcctKernelWasm,
|
|
30
|
+
export declare function exportSTEPAssembly(k: OcctKernelWasm, parts: StepAssemblyPart[], options?: {
|
|
27
31
|
unit?: string;
|
|
28
32
|
}): string;
|
|
29
33
|
export declare function exportGLB(mesh: MeshFn, shape: KernelShape, tolerance: number): ArrayBuffer;
|
|
@@ -31,22 +35,18 @@ export declare function exportOBJ(mesh: MeshFn, shape: KernelShape, tolerance: n
|
|
|
31
35
|
export declare function exportPLY(mesh: MeshFn, shape: KernelShape, tolerance: number): ArrayBuffer;
|
|
32
36
|
export declare function toBREP(k: OcctKernelWasm, shape: KernelShape): string;
|
|
33
37
|
export declare function fromBREP(k: OcctKernelWasm, data: string): KernelShape;
|
|
34
|
-
|
|
38
|
+
interface XcafPart {
|
|
39
|
+
readonly shape: KernelShape;
|
|
40
|
+
readonly name?: string | undefined;
|
|
41
|
+
readonly color?: [number, number, number, number] | undefined;
|
|
42
|
+
}
|
|
43
|
+
export declare function createXCAFDocument(k: OcctKernelWasm, makeCompound: CompoundFn, shapes: Array<{
|
|
35
44
|
shape: KernelShape;
|
|
36
45
|
name: string;
|
|
37
46
|
color?: [number, number, number, number] | undefined;
|
|
38
47
|
}>): KernelType;
|
|
39
|
-
export declare function writeXCAFToSTEP(k: OcctKernelWasm, doc: KernelType,
|
|
40
|
-
|
|
41
|
-
modelUnit?: string | undefined;
|
|
42
|
-
}): string;
|
|
43
|
-
export declare function exportSTEPConfigured(k: OcctKernelWasm, Module: OcctWasmModule, shapes: Array<{
|
|
44
|
-
shape: KernelShape;
|
|
45
|
-
name?: string | undefined;
|
|
46
|
-
color?: [number, number, number, number] | undefined;
|
|
47
|
-
}>, _options?: {
|
|
48
|
-
unit?: string | undefined;
|
|
49
|
-
modelUnit?: string | undefined;
|
|
48
|
+
export declare function writeXCAFToSTEP(k: OcctKernelWasm, doc: KernelType, options?: StepUnitOptions): string;
|
|
49
|
+
export declare function exportSTEPConfigured(k: OcctKernelWasm, makeCompound: CompoundFn, shapes: XcafPart[], options?: StepUnitOptions & {
|
|
50
50
|
schema?: number | undefined;
|
|
51
51
|
}): string;
|
|
52
52
|
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { KernelShape } from '../types.js';
|
|
2
2
|
import { OcctKernelWasm, OcctWasmModule } from './occtWasmTypes.js';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
3
|
+
import { EdgeValueSpec } from './helpers.js';
|
|
4
|
+
export declare function fillet(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], radius: EdgeValueSpec): KernelShape;
|
|
5
|
+
export declare function chamfer(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], distance: EdgeValueSpec): KernelShape;
|
|
5
6
|
export declare function chamferDistAngle(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, edges: KernelShape[], distance: number, angleDeg: number): KernelShape;
|
|
6
7
|
export declare function shell(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, faces: KernelShape[], thickness: number, tolerance?: number): KernelShape;
|
|
7
8
|
export declare function thicken(k: OcctKernelWasm, shape: KernelShape, thickness: number): KernelShape;
|
|
8
9
|
export declare function offset(k: OcctKernelWasm, shape: KernelShape, distance: number, tolerance?: number): KernelShape;
|
|
9
10
|
export declare function filletVariable(k: OcctKernelWasm, shape: KernelShape, spec: string): KernelShape;
|
|
10
|
-
|
|
11
|
+
/** Draft every face in one operation about the plane through `neutralPlane` normal to the pull. */
|
|
12
|
+
export declare function draft(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, faces: KernelShape[], pullDirection: [number, number, number], neutralPlane: [number, number, number], angleDeg: number | ((face: KernelShape) => number)): KernelShape;
|
|
11
13
|
export declare function defeature(k: OcctKernelWasm, Module: OcctWasmModule, shape: KernelShape, faces: KernelShape[]): KernelShape;
|
|
12
14
|
export declare function offsetWire2D(k: OcctKernelWasm, wire: KernelShape, offset: number, joinType?: number | 'arc' | 'intersection' | 'tangent'): KernelShape;
|
|
13
15
|
export declare function simplify(k: OcctKernelWasm, shape: KernelShape): KernelShape;
|