brepjs 20.2.0 → 20.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d.cjs +7 -7
- package/dist/2d.js +7 -7
- package/dist/{adjacencyFns-DZsPfYIq.cjs → adjacencyFns-1rxgJ6Hw.cjs} +3 -3
- package/dist/{adjacencyFns-k4GWh4n7.js → adjacencyFns-DeyXahej.js} +3 -3
- package/dist/{blueprint-CJuRunkd.cjs → blueprint-Yyoiz-U1.cjs} +7 -7
- package/dist/{blueprint-Dsp4t2ul.js → blueprint-rwJjYPzo.js} +7 -7
- package/dist/{blueprintFns-BRceCeZp.cjs → blueprintFns-Ce6OoPSX.cjs} +3 -3
- package/dist/{blueprintFns-DNyUtopT.js → blueprintFns-Q3Sq-Fse.js} +3 -3
- package/dist/{blueprintSketcher-DRXOTYuD.cjs → blueprintSketcher-CzKbxeTk.cjs} +4 -4
- package/dist/{blueprintSketcher-kV7aFwRS.js → blueprintSketcher-FywUpRiV.js} +4 -4
- package/dist/{boolean2D-DmPqFj_V.cjs → boolean2D-BzZ9iBSn.cjs} +5 -5
- package/dist/{boolean2D-TdJfMS8F.js → boolean2D-D8igCYc9.js} +5 -5
- package/dist/brepjs.cjs +35 -32
- package/dist/brepjs.js +35 -33
- package/dist/{cameraFns-u08iOn7p.js → cameraFns-Cs6v3bWQ.js} +4 -4
- package/dist/{cameraFns-B8Ai6b3Q.cjs → cameraFns-RHCb1F1s.cjs} +4 -4
- package/dist/core/errors.d.ts +3 -0
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{cornerFinder-BVUuCBX-.cjs → cornerFinder-Cji_BK-R.cjs} +1 -1
- package/dist/{cornerFinder-DfoRecV-.js → cornerFinder-Dlae8IX5.js} +1 -1
- package/dist/{curveFns-DciWOppG.cjs → curveFns-6-ULFrEB.cjs} +2 -2
- package/dist/{curveFns-D5V4jm7S.js → curveFns-KS1BWGhF.js} +2 -2
- package/dist/{drawFns-BzuxoLHh.js → drawFns-3yRVBDgI.js} +14 -14
- package/dist/{drawFns-DeUXFpjR.cjs → drawFns-Ddlgp9gQ.cjs} +14 -14
- package/dist/{errors-CDSezF9z.js → errors-Zb3jBa0u.js} +3 -0
- package/dist/{errors-gG-7hA7k.cjs → errors-jwhfQJZK.cjs} +3 -0
- package/dist/{faceFns-DhdweJGk.js → faceFns-CTlJC5IY.js} +3 -3
- package/dist/{faceFns-DaXVpMr5.cjs → faceFns-CZeHWke7.cjs} +3 -3
- package/dist/faceRoleFns-CWU1-Pm8.js +37 -0
- package/dist/faceRoleFns-CtH_48MO.cjs +60 -0
- package/dist/{healingFns-HekFOO_s.js → healingFns-Ct3gEMvk.js} +5 -5
- package/dist/{healingFns-C_f03IV6.cjs → healingFns-DwSpJZfg.cjs} +5 -5
- package/dist/{helpers-BWNXoJz0.js → helpers-BN1mVMuZ.js} +7 -7
- package/dist/{helpers-Dh4qTGcQ.cjs → helpers-NRZVshPb.cjs} +7 -7
- package/dist/{importFns-DGnmgb9G.js → importFns-0kHGg-b8.js} +3 -3
- package/dist/{importFns-CKfKRdiq.cjs → importFns-BEi-HsSw.cjs} +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/interfaces/measureOps.d.ts +19 -0
- package/dist/kernel/occtWasm/measureOps.d.ts +2 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +2 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/occtWasmTypes.d.ts +2 -0
- package/dist/{loftFns-DE1GYW9g.js → loftFns-B5mq1WDh.js} +2 -2
- package/dist/{loftFns-CI8uJc1D.cjs → loftFns-DL9UsQhd.cjs} +2 -2
- package/dist/{measureFns-BoA-Fmwy.js → measureFns-CyDVZomf.js} +5 -5
- package/dist/{measureFns-B8Yj_BMz.cjs → measureFns-D_GpQw5z.cjs} +16 -4
- package/dist/measurement/measureCache.d.ts +2 -1
- package/dist/measurement/measureTypes.d.ts +9 -0
- package/dist/measurement/principalBoxFns.d.ts +33 -0
- package/dist/measurement.cjs +3 -1
- package/dist/measurement.d.ts +1 -0
- package/dist/measurement.js +3 -2
- package/dist/{meshFns-BT7W4b1c.cjs → meshFns-CAxkaRTm.cjs} +4 -4
- package/dist/{meshFns-o9MnZeir.js → meshFns-COlno8TY.js} +4 -4
- package/dist/ns/measurement.d.ts +1 -0
- package/dist/{occtWasmAdapter-D4I0n537.js → occtWasmAdapter-BX10fyla.js} +21 -0
- package/dist/{occtWasmAdapter-wCKnmevS.cjs → occtWasmAdapter-CA6PmIIj.cjs} +21 -0
- package/dist/operations/extrudeFns.d.ts +4 -0
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{originTrackingFns-B3-1bBED.cjs → originTrackingFns-CWo6NWHK.cjs} +2 -2
- package/dist/{originTrackingFns-BFmhk_Up.js → originTrackingFns-DiHy5BZC.js} +2 -2
- package/dist/{planeOps-BO6nvRja.js → planeOps-Cxws4Tiu.js} +1 -1
- package/dist/{planeOps-DqGSxcMr.cjs → planeOps-DJuclNxa.cjs} +1 -1
- package/dist/{primitiveFns-DfhjU_X9.js → primitiveFns-CGJzS4MO.js} +5 -5
- package/dist/{primitiveFns-Ke-n8Bib.cjs → primitiveFns-ZV3aMbqG.cjs} +5 -5
- package/dist/principalBoxFns-5FSbxAj-.cjs +212 -0
- package/dist/principalBoxFns-BJgGEoik.js +207 -0
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-C-6Xa_8k.js → refResolveFns-CpVZoeOT.js} +30 -12
- package/dist/{refResolveFns-BPqbBoxy.cjs → refResolveFns-Ct52Uw7R.cjs} +30 -12
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeFns-CUTM2ZDR.js → shapeFns--1wNlcc_.js} +3 -3
- package/dist/{shapeFns-CmJNoPsh.cjs → shapeFns-C2j6oZ2u.cjs} +3 -3
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-DVpJHhgk.js → shapeTypes-CqNJoSam.js} +1 -1
- package/dist/{shapeTypes-BWsKDxzf.cjs → shapeTypes-DH2ShBU_.cjs} +1 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-B8t5h68e.cjs → solidBuilders-CgicU3le.cjs} +12 -10
- package/dist/{solidBuilders-p_ppeTkc.js → solidBuilders-IstbiWju.js} +12 -10
- package/dist/{surfaceBuilders-Dccm2kQX.js → surfaceBuilders-8nLk2PWk.js} +4 -4
- package/dist/{surfaceBuilders-Bn-c9xVR.cjs → surfaceBuilders-vYgSvgI6.cjs} +4 -4
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-bFsyNLkO.js → textBlueprints-C13NAA3C.js} +169 -10
- package/dist/{textBlueprints-DQi920gG.cjs → textBlueprints-fa7VHJZz.cjs} +168 -9
- package/dist/{textMetrics-DhysRMr7.cjs → textMetrics--cikHkGX.cjs} +2 -2
- package/dist/{textMetrics-CvTwh4tR.js → textMetrics-Dcc63qRm.js} +2 -2
- package/dist/{threadFns-DlGXBSK7.js → threadFns-3U9x4v_M.js} +8 -8
- package/dist/{threadFns-DAKMitvE.cjs → threadFns-BUQPg_vI.cjs} +8 -8
- package/dist/topology/metadata/faceRoleFns.d.ts +15 -0
- package/dist/topology/metadata/metadataPropagation.d.ts +2 -2
- package/dist/topology/shapeRef/extrudeRoleFns.d.ts +9 -0
- package/dist/topology/shapeRef/refResolveFns.d.ts +2 -1
- package/dist/topology/shapeRef/shapeRefFns.d.ts +8 -2
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-fNWsM4Lr.js → topologyQueryFns-DnfjQgP7.js} +3 -3
- package/dist/{topologyQueryFns-CI4j3NTE.cjs → topologyQueryFns-q2bGyuEV.cjs} +8 -2
- package/dist/{validityTypes-D9oxhu4U.cjs → validityTypes-r0A2YdNq.cjs} +2 -2
- package/dist/{validityTypes-2DNKAPEw.js → validityTypes-t7JpS0Ki.js} +2 -2
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
4
|
-
const require_originTrackingFns = require("./originTrackingFns-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DH2ShBU_.cjs");
|
|
2
|
+
const require_errors = require("./errors-jwhfQJZK.cjs");
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-q2bGyuEV.cjs");
|
|
4
|
+
const require_originTrackingFns = require("./originTrackingFns-CWo6NWHK.cjs");
|
|
5
5
|
//#region src/topology/meshCache.ts
|
|
6
6
|
/**
|
|
7
7
|
* Build a parameter key for the inner cache map (excludes shape identity).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-
|
|
2
|
-
import { E as ok, g as err, r as ioError } from "./errors-
|
|
3
|
-
import { d as getSolids, n as getBounds } from "./topologyQueryFns-
|
|
4
|
-
import { t as getFaceOrigins } from "./originTrackingFns-
|
|
1
|
+
import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-CqNJoSam.js";
|
|
2
|
+
import { E as ok, g as err, r as ioError } from "./errors-Zb3jBa0u.js";
|
|
3
|
+
import { d as getSolids, n as getBounds } from "./topologyQueryFns-DnfjQgP7.js";
|
|
4
|
+
import { t as getFaceOrigins } from "./originTrackingFns-DiHy5BZC.js";
|
|
5
5
|
//#region src/topology/meshCache.ts
|
|
6
6
|
/**
|
|
7
7
|
* Build a parameter key for the inner cache map (excludes shape identity).
|
package/dist/ns/measurement.d.ts
CHANGED
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { measureVolume, measureArea, measureLength, measureDistance, measureDistanceProps, createDistanceQuery, measureVolumeProps, measureSurfaceProps, measureLinearProps, measureCurvatureAt, measureCurvatureAtMid, } from '../measurement/measureFns.js';
|
|
5
5
|
export { checkInterference, checkAllInterferences } from '../measurement/interferenceFns.js';
|
|
6
|
+
export { principalBoundingBox } from '../measurement/principalBoxFns.js';
|
|
@@ -2362,6 +2362,24 @@ function linearCenterOfMass(k, shape) {
|
|
|
2362
2362
|
vec.delete();
|
|
2363
2363
|
}
|
|
2364
2364
|
}
|
|
2365
|
+
function inertia(k, shape) {
|
|
2366
|
+
const vec = k.getInertia(unwrap(shape));
|
|
2367
|
+
try {
|
|
2368
|
+
return [
|
|
2369
|
+
vec.get(0),
|
|
2370
|
+
vec.get(1),
|
|
2371
|
+
vec.get(2),
|
|
2372
|
+
vec.get(3),
|
|
2373
|
+
vec.get(4),
|
|
2374
|
+
vec.get(5),
|
|
2375
|
+
vec.get(6),
|
|
2376
|
+
vec.get(7),
|
|
2377
|
+
vec.get(8)
|
|
2378
|
+
];
|
|
2379
|
+
} finally {
|
|
2380
|
+
vec.delete();
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2365
2383
|
function boundingBox(k, shape) {
|
|
2366
2384
|
const bb = k.getBoundingBox(unwrap(shape), true);
|
|
2367
2385
|
return {
|
|
@@ -5435,6 +5453,9 @@ var OcctWasmAdapter = class OcctWasmAdapter {
|
|
|
5435
5453
|
boundingBox(shape) {
|
|
5436
5454
|
return boundingBox(this.k, shape);
|
|
5437
5455
|
}
|
|
5456
|
+
inertia(shape) {
|
|
5457
|
+
return inertia(this.k, shape);
|
|
5458
|
+
}
|
|
5438
5459
|
distance(shape1, shape2) {
|
|
5439
5460
|
return distance(this.k, this.Module, shape1, shape2);
|
|
5440
5461
|
}
|
|
@@ -2362,6 +2362,24 @@ function linearCenterOfMass(k, shape) {
|
|
|
2362
2362
|
vec.delete();
|
|
2363
2363
|
}
|
|
2364
2364
|
}
|
|
2365
|
+
function inertia(k, shape) {
|
|
2366
|
+
const vec = k.getInertia(unwrap(shape));
|
|
2367
|
+
try {
|
|
2368
|
+
return [
|
|
2369
|
+
vec.get(0),
|
|
2370
|
+
vec.get(1),
|
|
2371
|
+
vec.get(2),
|
|
2372
|
+
vec.get(3),
|
|
2373
|
+
vec.get(4),
|
|
2374
|
+
vec.get(5),
|
|
2375
|
+
vec.get(6),
|
|
2376
|
+
vec.get(7),
|
|
2377
|
+
vec.get(8)
|
|
2378
|
+
];
|
|
2379
|
+
} finally {
|
|
2380
|
+
vec.delete();
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2365
2383
|
function boundingBox(k, shape) {
|
|
2366
2384
|
const bb = k.getBoundingBox(unwrap(shape), true);
|
|
2367
2385
|
return {
|
|
@@ -5435,6 +5453,9 @@ var OcctWasmAdapter = class OcctWasmAdapter {
|
|
|
5435
5453
|
boundingBox(shape) {
|
|
5436
5454
|
return boundingBox(this.k, shape);
|
|
5437
5455
|
}
|
|
5456
|
+
inertia(shape) {
|
|
5457
|
+
return inertia(this.k, shape);
|
|
5458
|
+
}
|
|
5438
5459
|
distance(shape1, shape2) {
|
|
5439
5460
|
return distance(this.k, this.Module, shape1, shape2);
|
|
5440
5461
|
}
|
|
@@ -6,6 +6,10 @@ export type { ExtrusionProfile, SweepOptions } from './extrudeUtils.js';
|
|
|
6
6
|
/**
|
|
7
7
|
* Extrude a face along a vector to produce a solid.
|
|
8
8
|
*
|
|
9
|
+
* The result carries semantic face roles (`extrude:start`, `extrude:end`,
|
|
10
|
+
* `extrude:side:<i>`, `extrude:hole<j>:side:<i>`) that
|
|
11
|
+
* `assignRoles(solid, 'extrude')` returns in place of positional names.
|
|
12
|
+
*
|
|
9
13
|
* @param face - The planar face to extrude.
|
|
10
14
|
* @param extrusionVec - Direction and magnitude of the extrusion as `[x, y, z]`.
|
|
11
15
|
* @returns `Result` containing the extruded solid, or an error if validation or operation fails.
|
package/dist/operations.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_threadFns = require("./threadFns-
|
|
3
|
-
const require_loftFns = require("./loftFns-
|
|
2
|
+
const require_threadFns = require("./threadFns-BUQPg_vI.cjs");
|
|
3
|
+
const require_loftFns = require("./loftFns-DL9UsQhd.cjs");
|
|
4
4
|
exports.addChild = require_threadFns.addChild;
|
|
5
5
|
exports.addJoint = require_threadFns.addJoint;
|
|
6
6
|
exports.addStep = require_threadFns.addStep;
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as setJointValue, B as walkAssembly, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, F as countNodes, H as circularPattern, I as createAssemblyNode, L as findNode, M as sphericalJoint, N as addChild, O as prismaticJoint, P as collectShapes, R as removeChild, S as addJoint, T as jointTransform, U as gridPattern, V as exportAssemblySTEP, W as linearPattern, Y as createAssembly, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as updateNode } from "./threadFns-
|
|
2
|
-
import { c as twistExtrude, o as supportExtrude, r as complexExtrude, s as sweep } from "./loftFns-
|
|
1
|
+
import { A as setJointValue, B as walkAssembly, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, F as countNodes, H as circularPattern, I as createAssemblyNode, L as findNode, M as sphericalJoint, N as addChild, O as prismaticJoint, P as collectShapes, R as removeChild, S as addJoint, T as jointTransform, U as gridPattern, V as exportAssemblySTEP, W as linearPattern, Y as createAssembly, _ as exportURDF, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as updateNode } from "./threadFns-3U9x4v_M.js";
|
|
2
|
+
import { c as twistExtrude, o as supportExtrude, r as complexExtrude, s as sweep } from "./loftFns-B5mq1WDh.js";
|
|
3
3
|
export { addChild, addJoint, addStep, circularPattern, collectShapes, complexExtrude, countNodes, createAssembly, createAssemblyNode, createHistory, createRegistry, cylindricalJoint, exportAssemblySTEP, exportURDF, findNode, findStep, forwardKinematics, getShape as getHistoryShape, gridPattern, importURDF, inverseKinematics, jointTrajectory, jointTransform, jointsFromDH, linearPattern, mechanismDOF, modifyStep, planarJoint, prismaticJoint, registerOperation, registerShape, removeChild, replayFrom, replayHistory, revoluteJoint, setJointValue, setJointValues, sphericalJoint, stepCount, stepsFrom, supportExtrude, sweep, thread, twistExtrude, undoLast, updateNode, walkAssembly };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DH2ShBU_.cjs");
|
|
2
|
+
const require_topologyQueryFns = require("./topologyQueryFns-q2bGyuEV.cjs");
|
|
3
3
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
4
4
|
//#region src/topology/metadata/originTrackingFns.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { q as getKernel } from "./shapeTypes-
|
|
2
|
-
import {
|
|
1
|
+
import { q as getKernel } from "./shapeTypes-CqNJoSam.js";
|
|
2
|
+
import { C as subShapeHashes, c as getFaces, l as getOrCreateCache, r as getCacheEntry } from "./topologyQueryFns-DnfjQgP7.js";
|
|
3
3
|
import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
|
|
4
4
|
//#region src/topology/metadata/originTrackingFns.ts
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as ok, P as unwrap, d as validationError, g as err } from "./errors-
|
|
1
|
+
import { E as ok, P as unwrap, d as validationError, g as err } from "./errors-Zb3jBa0u.js";
|
|
2
2
|
import { t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
3
3
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
4
4
|
import { d as vecNormalize, h as vecScale, m as vecRotate, r as vecCross, s as vecIsZero, t as vecAdd } from "./vecOps-SKPRvPH-.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_errors = require("./errors-
|
|
1
|
+
const require_errors = require("./errors-jwhfQJZK.cjs");
|
|
2
2
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
3
3
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
4
4
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as GeometryCleanupError, G as _usingCtx, d as createSolid, n as castResultShape, q as getKernel } from "./shapeTypes-
|
|
2
|
-
import { E as ok, d as validationError, g as err, m as andThen, t as BrepErrorCode } from "./errors-
|
|
3
|
-
import { n as isClosedWire } from "./validityTypes-
|
|
1
|
+
import { E as GeometryCleanupError, G as _usingCtx, d as createSolid, n as castResultShape, q as getKernel } from "./shapeTypes-CqNJoSam.js";
|
|
2
|
+
import { E as ok, d as validationError, g as err, m as andThen, t as BrepErrorCode } from "./errors-Zb3jBa0u.js";
|
|
3
|
+
import { n as isClosedWire } from "./validityTypes-t7JpS0Ki.js";
|
|
4
4
|
import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
|
-
import { C as propagateAllMetadata, S as hasAnyMetadata, T as propagateMetadataThroughRelocation, a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces, w as propagateMetadataByHash, x as collectInputFaceHashes } from "./solidBuilders-
|
|
6
|
-
import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-
|
|
5
|
+
import { C as propagateAllMetadata, S as hasAnyMetadata, T as propagateMetadataThroughRelocation, a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces, w as propagateMetadataByHash, x as collectInputFaceHashes } from "./solidBuilders-IstbiWju.js";
|
|
6
|
+
import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-8nLk2PWk.js";
|
|
7
7
|
//#region src/topology/transformFns.ts
|
|
8
8
|
/**
|
|
9
9
|
* Immutable shape transforms — translate, rotate, scale, mirror, applyMatrix.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_validityTypes = require("./validityTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DH2ShBU_.cjs");
|
|
2
|
+
const require_errors = require("./errors-jwhfQJZK.cjs");
|
|
3
|
+
const require_validityTypes = require("./validityTypes-r0A2YdNq.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
6
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
5
|
+
const require_solidBuilders = require("./solidBuilders-CgicU3le.cjs");
|
|
6
|
+
const require_surfaceBuilders = require("./surfaceBuilders-vYgSvgI6.cjs");
|
|
7
7
|
//#region src/topology/transformFns.ts
|
|
8
8
|
/**
|
|
9
9
|
* Immutable shape transforms — translate, rotate, scale, mirror, applyMatrix.
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DH2ShBU_.cjs");
|
|
2
|
+
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
|
+
const require_errors = require("./errors-jwhfQJZK.cjs");
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-q2bGyuEV.cjs");
|
|
5
|
+
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
6
|
+
const require_measureFns = require("./measureFns-D_GpQw5z.cjs");
|
|
7
|
+
//#region src/measurement/principalBoxFns.ts
|
|
8
|
+
/**
|
|
9
|
+
* Principal-axes bounding box: a solid's extent measured in the frame of its
|
|
10
|
+
* principal axes of inertia instead of the world axes.
|
|
11
|
+
*/
|
|
12
|
+
var ZERO_VOLUME_TOLERANCE = 1e-9;
|
|
13
|
+
var OFF_DIAGONAL_TOLERANCE = 1e-12;
|
|
14
|
+
var JACOBI_MAX_SWEEPS = 32;
|
|
15
|
+
var JACOBI_PLANES = [
|
|
16
|
+
[0, 1],
|
|
17
|
+
[0, 2],
|
|
18
|
+
[1, 2]
|
|
19
|
+
];
|
|
20
|
+
var ORIGIN = [
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0
|
|
24
|
+
];
|
|
25
|
+
function validatePrincipalBoxInput(shape) {
|
|
26
|
+
const kernel = require_shapeTypes.getKernel();
|
|
27
|
+
if (kernel.isNull(shape.wrapped)) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.NULL_SHAPE_INPUT, "principalBoundingBox: shape is a null shape"));
|
|
28
|
+
const type = kernel.shapeType(shape.wrapped);
|
|
29
|
+
if (type !== "solid" && type !== "compsolid" && type !== "compound") return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.NOT_A_SOLID, `principalBoundingBox: expected a solid, got a ${type}`, void 0, { shapeType: type }, "Use getBounds() for faces, wires, and shells"));
|
|
30
|
+
const volume = require_topologyQueryFns.kernelCallRaw(() => type === "solid" || require_topologyQueryFns.subShapeCount(shape, "solid") > 0 ? kernel.volume(shape.wrapped) : 0, require_errors.BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to measure volume");
|
|
31
|
+
if (!volume.ok) return volume;
|
|
32
|
+
if (volume.value <= ZERO_VOLUME_TOLERANCE) return require_errors.err(require_errors.validationError(require_errors.BrepErrorCode.ZERO_VOLUME, "principalBoundingBox: shape encloses no volume", void 0, { volume: volume.value }, "Use getBounds() for shapes without volume, or build a solid first"));
|
|
33
|
+
}
|
|
34
|
+
/** One cyclic-Jacobi rotation that zeroes `a[p][q]`, accumulated into the eigenvector matrix `v`. */
|
|
35
|
+
function jacobiRotate(a, v, p, q) {
|
|
36
|
+
const apq = require_bug.wasmIndex(a, p * 3 + q);
|
|
37
|
+
const theta = (require_bug.wasmIndex(a, q * 3 + q) - require_bug.wasmIndex(a, p * 3 + p)) / (2 * apq);
|
|
38
|
+
const t = (theta >= 0 ? 1 : -1) / (Math.abs(theta) + Math.sqrt(theta * theta + 1));
|
|
39
|
+
const c = 1 / Math.sqrt(t * t + 1);
|
|
40
|
+
const s = t * c;
|
|
41
|
+
for (let k = 0; k < 3; k++) {
|
|
42
|
+
const akp = require_bug.wasmIndex(a, k * 3 + p);
|
|
43
|
+
const akq = require_bug.wasmIndex(a, k * 3 + q);
|
|
44
|
+
a[k * 3 + p] = c * akp - s * akq;
|
|
45
|
+
a[k * 3 + q] = s * akp + c * akq;
|
|
46
|
+
}
|
|
47
|
+
for (let k = 0; k < 3; k++) {
|
|
48
|
+
const apk = require_bug.wasmIndex(a, p * 3 + k);
|
|
49
|
+
const aqk = require_bug.wasmIndex(a, q * 3 + k);
|
|
50
|
+
a[p * 3 + k] = c * apk - s * aqk;
|
|
51
|
+
a[q * 3 + k] = s * apk + c * aqk;
|
|
52
|
+
const vkp = require_bug.wasmIndex(v, k * 3 + p);
|
|
53
|
+
const vkq = require_bug.wasmIndex(v, k * 3 + q);
|
|
54
|
+
v[k * 3 + p] = c * vkp - s * vkq;
|
|
55
|
+
v[k * 3 + q] = s * vkp + c * vkq;
|
|
56
|
+
}
|
|
57
|
+
a[p * 3 + q] = 0;
|
|
58
|
+
a[q * 3 + p] = 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Eigenvectors of a symmetric 3x3 matrix by cyclic Jacobi. Every rotation is
|
|
62
|
+
* proper, so the returned axes form a right-handed orthonormal frame.
|
|
63
|
+
*/
|
|
64
|
+
function principalAxes(m) {
|
|
65
|
+
const a = [...m];
|
|
66
|
+
const v = [
|
|
67
|
+
1,
|
|
68
|
+
0,
|
|
69
|
+
0,
|
|
70
|
+
0,
|
|
71
|
+
1,
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
0,
|
|
75
|
+
1
|
|
76
|
+
];
|
|
77
|
+
const threshold = OFF_DIAGONAL_TOLERANCE * Math.hypot(...m);
|
|
78
|
+
for (let sweep = 0; sweep < JACOBI_MAX_SWEEPS; sweep++) {
|
|
79
|
+
let rotated = false;
|
|
80
|
+
for (const [p, q] of JACOBI_PLANES) {
|
|
81
|
+
if (Math.abs(require_bug.wasmIndex(a, p * 3 + q)) <= threshold) continue;
|
|
82
|
+
jacobiRotate(a, v, p, q);
|
|
83
|
+
rotated = true;
|
|
84
|
+
}
|
|
85
|
+
if (!rotated) break;
|
|
86
|
+
}
|
|
87
|
+
const column = (j) => [
|
|
88
|
+
require_bug.wasmIndex(v, j),
|
|
89
|
+
require_bug.wasmIndex(v, 3 + j),
|
|
90
|
+
require_bug.wasmIndex(v, 6 + j)
|
|
91
|
+
];
|
|
92
|
+
return [
|
|
93
|
+
column(0),
|
|
94
|
+
column(1),
|
|
95
|
+
column(2)
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/** Flip `v` so its largest-magnitude component is positive. */
|
|
99
|
+
function canonicalSign(v) {
|
|
100
|
+
const x = Math.abs(v[0]);
|
|
101
|
+
const y = Math.abs(v[1]);
|
|
102
|
+
const z = Math.abs(v[2]);
|
|
103
|
+
return (x >= y && x >= z ? v[0] : y >= z ? v[1] : v[2]) < 0 ? [
|
|
104
|
+
-v[0],
|
|
105
|
+
-v[1],
|
|
106
|
+
-v[2]
|
|
107
|
+
] : v;
|
|
108
|
+
}
|
|
109
|
+
function withoutNegativeZero(v) {
|
|
110
|
+
return [
|
|
111
|
+
v[0] + 0,
|
|
112
|
+
v[1] + 0,
|
|
113
|
+
v[2] + 0
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
function boundsInFrame(shape, axes) {
|
|
117
|
+
try {
|
|
118
|
+
var _usingCtx$1 = require_shapeTypes._usingCtx();
|
|
119
|
+
const kernel = require_shapeTypes.getKernel();
|
|
120
|
+
const [a0, a1, a2] = axes;
|
|
121
|
+
const framed = _usingCtx$1.u(require_shapeTypes.castResultShape(kernel.generalTransform(shape.wrapped, [
|
|
122
|
+
...a0,
|
|
123
|
+
...a1,
|
|
124
|
+
...a2
|
|
125
|
+
], ORIGIN, true)));
|
|
126
|
+
return kernel.boundingBox(framed.wrapped);
|
|
127
|
+
} catch (_) {
|
|
128
|
+
_usingCtx$1.e = _;
|
|
129
|
+
} finally {
|
|
130
|
+
_usingCtx$1.d();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function assembleBox(axes, bounds) {
|
|
134
|
+
const extents = axes.map((axis, i) => ({
|
|
135
|
+
axis,
|
|
136
|
+
size: require_bug.wasmIndex(bounds.max, i) - require_bug.wasmIndex(bounds.min, i),
|
|
137
|
+
mid: (require_bug.wasmIndex(bounds.min, i) + require_bug.wasmIndex(bounds.max, i)) / 2
|
|
138
|
+
}));
|
|
139
|
+
const centerAlong = (c) => extents.reduce((sum, e) => sum + e.mid * require_bug.wasmIndex(e.axis, c), 0);
|
|
140
|
+
const sorted = [...extents].sort((p, q) => q.size - p.size);
|
|
141
|
+
const major = canonicalSign(require_bug.wasmIndex(sorted, 0).axis);
|
|
142
|
+
const middle = canonicalSign(require_bug.wasmIndex(sorted, 1).axis);
|
|
143
|
+
return {
|
|
144
|
+
center: [
|
|
145
|
+
centerAlong(0),
|
|
146
|
+
centerAlong(1),
|
|
147
|
+
centerAlong(2)
|
|
148
|
+
],
|
|
149
|
+
axes: [
|
|
150
|
+
withoutNegativeZero(major),
|
|
151
|
+
withoutNegativeZero(middle),
|
|
152
|
+
withoutNegativeZero(require_vecOps.vecCross(major, middle))
|
|
153
|
+
],
|
|
154
|
+
size: [
|
|
155
|
+
require_bug.wasmIndex(sorted, 0).size,
|
|
156
|
+
require_bug.wasmIndex(sorted, 1).size,
|
|
157
|
+
require_bug.wasmIndex(sorted, 2).size
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Measure a solid's bounding box on its principal axes of inertia.
|
|
163
|
+
*
|
|
164
|
+
* `getBounds` answers in world axes, so a board turned 30 degrees reports an
|
|
165
|
+
* inflated box with no frame. This box follows the part's own frame instead:
|
|
166
|
+
* it is the axis-aligned box in the frame of the principal axes of the volume
|
|
167
|
+
* inertia tensor about the center of mass.
|
|
168
|
+
*
|
|
169
|
+
* This is NOT a minimum-volume oriented bounding box. When principal moments
|
|
170
|
+
* coincide, the principal axes in that plane are not unique and the box can be
|
|
171
|
+
* larger than the tightest one: a 100 x 100 x 2 plate rotated 30 degrees about
|
|
172
|
+
* Z reports 136.6 x 136.6 x 2, because any in-plane pair of axes is principal
|
|
173
|
+
* for a square plate.
|
|
174
|
+
*
|
|
175
|
+
* @param shape - A solid, compsolid, or compound containing solids.
|
|
176
|
+
* @returns `Result` with the box center in world coordinates, orthonormal
|
|
177
|
+
* right-handed axes ordered by decreasing extent, and the full edge lengths
|
|
178
|
+
* along those axes. Fails with `NOT_A_SOLID` for any other shape type
|
|
179
|
+
* (face, wire, shell, ...), `ZERO_VOLUME` when the shape encloses no volume
|
|
180
|
+
* (e.g. a compound of faces), and an `UNSUPPORTED` error on kernels without
|
|
181
|
+
* an inertia query.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const { size, axes, center } = unwrap(principalBoundingBox(board));
|
|
186
|
+
* // size: [length, width, thickness]; axes[2] is the board's normal
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
function principalBoundingBox(shape) {
|
|
190
|
+
const cached = require_measureFns.getCachedMeasurement(shape.wrapped, "principal");
|
|
191
|
+
if (cached) return require_errors.ok(cached);
|
|
192
|
+
const invalid = validatePrincipalBoxInput(shape);
|
|
193
|
+
if (invalid) return invalid;
|
|
194
|
+
const kernel = require_shapeTypes.getKernel();
|
|
195
|
+
const inertiaOf = kernel.inertia?.bind(kernel);
|
|
196
|
+
if (!inertiaOf) return require_errors.err(require_errors.unsupportedError(require_errors.BrepErrorCode.UNSUPPORTED_CAPABILITY, `principalBoundingBox: the ${kernel.kernelId} kernel has no inertia query`, void 0, { kernel: kernel.kernelId }, "Use the occt-wasm kernel, which provides the inertia query"));
|
|
197
|
+
const inertia = require_topologyQueryFns.kernelCallRaw(() => inertiaOf(shape.wrapped), require_errors.BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to compute the matrix of inertia");
|
|
198
|
+
if (!inertia.ok) return inertia;
|
|
199
|
+
const axes = principalAxes(inertia.value);
|
|
200
|
+
const bounds = require_topologyQueryFns.kernelCallRaw(() => boundsInFrame(shape, axes), require_errors.BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to measure bounds in the principal frame");
|
|
201
|
+
if (!bounds.ok) return bounds;
|
|
202
|
+
const result = assembleBox(axes, bounds.value);
|
|
203
|
+
require_measureFns.setCachedMeasurement(shape.wrapped, "principal", result);
|
|
204
|
+
return require_errors.ok(result);
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
Object.defineProperty(exports, "principalBoundingBox", {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
get: function() {
|
|
210
|
+
return principalBoundingBox;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { G as _usingCtx, n as castResultShape, q as getKernel } from "./shapeTypes-CqNJoSam.js";
|
|
2
|
+
import { i as wasmIndex } from "./bug-BdOHwn_e.js";
|
|
3
|
+
import { E as ok, d as validationError, g as err, t as BrepErrorCode, u as unsupportedError } from "./errors-Zb3jBa0u.js";
|
|
4
|
+
import { E as kernelCallRaw, S as subShapeCount } from "./topologyQueryFns-DnfjQgP7.js";
|
|
5
|
+
import { r as vecCross } from "./vecOps-SKPRvPH-.js";
|
|
6
|
+
import { f as getCachedMeasurement, p as setCachedMeasurement } from "./measureFns-CyDVZomf.js";
|
|
7
|
+
//#region src/measurement/principalBoxFns.ts
|
|
8
|
+
/**
|
|
9
|
+
* Principal-axes bounding box: a solid's extent measured in the frame of its
|
|
10
|
+
* principal axes of inertia instead of the world axes.
|
|
11
|
+
*/
|
|
12
|
+
var ZERO_VOLUME_TOLERANCE = 1e-9;
|
|
13
|
+
var OFF_DIAGONAL_TOLERANCE = 1e-12;
|
|
14
|
+
var JACOBI_MAX_SWEEPS = 32;
|
|
15
|
+
var JACOBI_PLANES = [
|
|
16
|
+
[0, 1],
|
|
17
|
+
[0, 2],
|
|
18
|
+
[1, 2]
|
|
19
|
+
];
|
|
20
|
+
var ORIGIN = [
|
|
21
|
+
0,
|
|
22
|
+
0,
|
|
23
|
+
0
|
|
24
|
+
];
|
|
25
|
+
function validatePrincipalBoxInput(shape) {
|
|
26
|
+
const kernel = getKernel();
|
|
27
|
+
if (kernel.isNull(shape.wrapped)) return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "principalBoundingBox: shape is a null shape"));
|
|
28
|
+
const type = kernel.shapeType(shape.wrapped);
|
|
29
|
+
if (type !== "solid" && type !== "compsolid" && type !== "compound") return err(validationError(BrepErrorCode.NOT_A_SOLID, `principalBoundingBox: expected a solid, got a ${type}`, void 0, { shapeType: type }, "Use getBounds() for faces, wires, and shells"));
|
|
30
|
+
const volume = kernelCallRaw(() => type === "solid" || subShapeCount(shape, "solid") > 0 ? kernel.volume(shape.wrapped) : 0, BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to measure volume");
|
|
31
|
+
if (!volume.ok) return volume;
|
|
32
|
+
if (volume.value <= ZERO_VOLUME_TOLERANCE) return err(validationError(BrepErrorCode.ZERO_VOLUME, "principalBoundingBox: shape encloses no volume", void 0, { volume: volume.value }, "Use getBounds() for shapes without volume, or build a solid first"));
|
|
33
|
+
}
|
|
34
|
+
/** One cyclic-Jacobi rotation that zeroes `a[p][q]`, accumulated into the eigenvector matrix `v`. */
|
|
35
|
+
function jacobiRotate(a, v, p, q) {
|
|
36
|
+
const apq = wasmIndex(a, p * 3 + q);
|
|
37
|
+
const theta = (wasmIndex(a, q * 3 + q) - wasmIndex(a, p * 3 + p)) / (2 * apq);
|
|
38
|
+
const t = (theta >= 0 ? 1 : -1) / (Math.abs(theta) + Math.sqrt(theta * theta + 1));
|
|
39
|
+
const c = 1 / Math.sqrt(t * t + 1);
|
|
40
|
+
const s = t * c;
|
|
41
|
+
for (let k = 0; k < 3; k++) {
|
|
42
|
+
const akp = wasmIndex(a, k * 3 + p);
|
|
43
|
+
const akq = wasmIndex(a, k * 3 + q);
|
|
44
|
+
a[k * 3 + p] = c * akp - s * akq;
|
|
45
|
+
a[k * 3 + q] = s * akp + c * akq;
|
|
46
|
+
}
|
|
47
|
+
for (let k = 0; k < 3; k++) {
|
|
48
|
+
const apk = wasmIndex(a, p * 3 + k);
|
|
49
|
+
const aqk = wasmIndex(a, q * 3 + k);
|
|
50
|
+
a[p * 3 + k] = c * apk - s * aqk;
|
|
51
|
+
a[q * 3 + k] = s * apk + c * aqk;
|
|
52
|
+
const vkp = wasmIndex(v, k * 3 + p);
|
|
53
|
+
const vkq = wasmIndex(v, k * 3 + q);
|
|
54
|
+
v[k * 3 + p] = c * vkp - s * vkq;
|
|
55
|
+
v[k * 3 + q] = s * vkp + c * vkq;
|
|
56
|
+
}
|
|
57
|
+
a[p * 3 + q] = 0;
|
|
58
|
+
a[q * 3 + p] = 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Eigenvectors of a symmetric 3x3 matrix by cyclic Jacobi. Every rotation is
|
|
62
|
+
* proper, so the returned axes form a right-handed orthonormal frame.
|
|
63
|
+
*/
|
|
64
|
+
function principalAxes(m) {
|
|
65
|
+
const a = [...m];
|
|
66
|
+
const v = [
|
|
67
|
+
1,
|
|
68
|
+
0,
|
|
69
|
+
0,
|
|
70
|
+
0,
|
|
71
|
+
1,
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
0,
|
|
75
|
+
1
|
|
76
|
+
];
|
|
77
|
+
const threshold = OFF_DIAGONAL_TOLERANCE * Math.hypot(...m);
|
|
78
|
+
for (let sweep = 0; sweep < JACOBI_MAX_SWEEPS; sweep++) {
|
|
79
|
+
let rotated = false;
|
|
80
|
+
for (const [p, q] of JACOBI_PLANES) {
|
|
81
|
+
if (Math.abs(wasmIndex(a, p * 3 + q)) <= threshold) continue;
|
|
82
|
+
jacobiRotate(a, v, p, q);
|
|
83
|
+
rotated = true;
|
|
84
|
+
}
|
|
85
|
+
if (!rotated) break;
|
|
86
|
+
}
|
|
87
|
+
const column = (j) => [
|
|
88
|
+
wasmIndex(v, j),
|
|
89
|
+
wasmIndex(v, 3 + j),
|
|
90
|
+
wasmIndex(v, 6 + j)
|
|
91
|
+
];
|
|
92
|
+
return [
|
|
93
|
+
column(0),
|
|
94
|
+
column(1),
|
|
95
|
+
column(2)
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/** Flip `v` so its largest-magnitude component is positive. */
|
|
99
|
+
function canonicalSign(v) {
|
|
100
|
+
const x = Math.abs(v[0]);
|
|
101
|
+
const y = Math.abs(v[1]);
|
|
102
|
+
const z = Math.abs(v[2]);
|
|
103
|
+
return (x >= y && x >= z ? v[0] : y >= z ? v[1] : v[2]) < 0 ? [
|
|
104
|
+
-v[0],
|
|
105
|
+
-v[1],
|
|
106
|
+
-v[2]
|
|
107
|
+
] : v;
|
|
108
|
+
}
|
|
109
|
+
function withoutNegativeZero(v) {
|
|
110
|
+
return [
|
|
111
|
+
v[0] + 0,
|
|
112
|
+
v[1] + 0,
|
|
113
|
+
v[2] + 0
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
function boundsInFrame(shape, axes) {
|
|
117
|
+
try {
|
|
118
|
+
var _usingCtx$1 = _usingCtx();
|
|
119
|
+
const kernel = getKernel();
|
|
120
|
+
const [a0, a1, a2] = axes;
|
|
121
|
+
const framed = _usingCtx$1.u(castResultShape(kernel.generalTransform(shape.wrapped, [
|
|
122
|
+
...a0,
|
|
123
|
+
...a1,
|
|
124
|
+
...a2
|
|
125
|
+
], ORIGIN, true)));
|
|
126
|
+
return kernel.boundingBox(framed.wrapped);
|
|
127
|
+
} catch (_) {
|
|
128
|
+
_usingCtx$1.e = _;
|
|
129
|
+
} finally {
|
|
130
|
+
_usingCtx$1.d();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function assembleBox(axes, bounds) {
|
|
134
|
+
const extents = axes.map((axis, i) => ({
|
|
135
|
+
axis,
|
|
136
|
+
size: wasmIndex(bounds.max, i) - wasmIndex(bounds.min, i),
|
|
137
|
+
mid: (wasmIndex(bounds.min, i) + wasmIndex(bounds.max, i)) / 2
|
|
138
|
+
}));
|
|
139
|
+
const centerAlong = (c) => extents.reduce((sum, e) => sum + e.mid * wasmIndex(e.axis, c), 0);
|
|
140
|
+
const sorted = [...extents].sort((p, q) => q.size - p.size);
|
|
141
|
+
const major = canonicalSign(wasmIndex(sorted, 0).axis);
|
|
142
|
+
const middle = canonicalSign(wasmIndex(sorted, 1).axis);
|
|
143
|
+
return {
|
|
144
|
+
center: [
|
|
145
|
+
centerAlong(0),
|
|
146
|
+
centerAlong(1),
|
|
147
|
+
centerAlong(2)
|
|
148
|
+
],
|
|
149
|
+
axes: [
|
|
150
|
+
withoutNegativeZero(major),
|
|
151
|
+
withoutNegativeZero(middle),
|
|
152
|
+
withoutNegativeZero(vecCross(major, middle))
|
|
153
|
+
],
|
|
154
|
+
size: [
|
|
155
|
+
wasmIndex(sorted, 0).size,
|
|
156
|
+
wasmIndex(sorted, 1).size,
|
|
157
|
+
wasmIndex(sorted, 2).size
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Measure a solid's bounding box on its principal axes of inertia.
|
|
163
|
+
*
|
|
164
|
+
* `getBounds` answers in world axes, so a board turned 30 degrees reports an
|
|
165
|
+
* inflated box with no frame. This box follows the part's own frame instead:
|
|
166
|
+
* it is the axis-aligned box in the frame of the principal axes of the volume
|
|
167
|
+
* inertia tensor about the center of mass.
|
|
168
|
+
*
|
|
169
|
+
* This is NOT a minimum-volume oriented bounding box. When principal moments
|
|
170
|
+
* coincide, the principal axes in that plane are not unique and the box can be
|
|
171
|
+
* larger than the tightest one: a 100 x 100 x 2 plate rotated 30 degrees about
|
|
172
|
+
* Z reports 136.6 x 136.6 x 2, because any in-plane pair of axes is principal
|
|
173
|
+
* for a square plate.
|
|
174
|
+
*
|
|
175
|
+
* @param shape - A solid, compsolid, or compound containing solids.
|
|
176
|
+
* @returns `Result` with the box center in world coordinates, orthonormal
|
|
177
|
+
* right-handed axes ordered by decreasing extent, and the full edge lengths
|
|
178
|
+
* along those axes. Fails with `NOT_A_SOLID` for any other shape type
|
|
179
|
+
* (face, wire, shell, ...), `ZERO_VOLUME` when the shape encloses no volume
|
|
180
|
+
* (e.g. a compound of faces), and an `UNSUPPORTED` error on kernels without
|
|
181
|
+
* an inertia query.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const { size, axes, center } = unwrap(principalBoundingBox(board));
|
|
186
|
+
* // size: [length, width, thickness]; axes[2] is the board's normal
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
function principalBoundingBox(shape) {
|
|
190
|
+
const cached = getCachedMeasurement(shape.wrapped, "principal");
|
|
191
|
+
if (cached) return ok(cached);
|
|
192
|
+
const invalid = validatePrincipalBoxInput(shape);
|
|
193
|
+
if (invalid) return invalid;
|
|
194
|
+
const kernel = getKernel();
|
|
195
|
+
const inertiaOf = kernel.inertia?.bind(kernel);
|
|
196
|
+
if (!inertiaOf) return err(unsupportedError(BrepErrorCode.UNSUPPORTED_CAPABILITY, `principalBoundingBox: the ${kernel.kernelId} kernel has no inertia query`, void 0, { kernel: kernel.kernelId }, "Use the occt-wasm kernel, which provides the inertia query"));
|
|
197
|
+
const inertia = kernelCallRaw(() => inertiaOf(shape.wrapped), BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to compute the matrix of inertia");
|
|
198
|
+
if (!inertia.ok) return inertia;
|
|
199
|
+
const axes = principalAxes(inertia.value);
|
|
200
|
+
const bounds = kernelCallRaw(() => boundsInFrame(shape, axes), BrepErrorCode.PRINCIPAL_BOX_FAILED, "principalBoundingBox: failed to measure bounds in the principal frame");
|
|
201
|
+
if (!bounds.ok) return bounds;
|
|
202
|
+
const result = assembleBox(axes, bounds.value);
|
|
203
|
+
setCachedMeasurement(shape.wrapped, "principal", result);
|
|
204
|
+
return ok(result);
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
export { principalBoundingBox as t };
|
package/dist/projection.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cameraFns = require("./cameraFns-
|
|
2
|
+
const require_cameraFns = require("./cameraFns-RHCb1F1s.cjs");
|
|
3
3
|
exports.PROJECTION_PLANES = require_cameraFns.PROJECTION_PLANES;
|
|
4
4
|
exports.cameraFromPlane = require_cameraFns.cameraFromPlane;
|
|
5
5
|
exports.cameraLookAt = require_cameraFns.cameraLookAt;
|
package/dist/projection.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-
|
|
1
|
+
import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-Cs6v3bWQ.js";
|
|
2
2
|
export { PROJECTION_PLANES, cameraFromPlane, cameraLookAt, createCamera, isProjectionPlane, makeProjectedEdges, projectEdges };
|
package/dist/query.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_helpers = require("./helpers-
|
|
3
|
-
const require_cornerFinder = require("./cornerFinder-
|
|
2
|
+
const require_helpers = require("./helpers-NRZVshPb.cjs");
|
|
3
|
+
const require_cornerFinder = require("./cornerFinder-Cji_BK-R.cjs");
|
|
4
4
|
exports.cornerFinder = require_cornerFinder.cornerFinder;
|
|
5
5
|
exports.edgeFinder = require_helpers.edgeFinder;
|
|
6
6
|
exports.faceFinder = require_helpers.faceFinder;
|
package/dist/query.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-
|
|
2
|
-
import { t as cornerFinder } from "./cornerFinder-
|
|
1
|
+
import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-BN1mVMuZ.js";
|
|
2
|
+
import { t as cornerFinder } from "./cornerFinder-Dlae8IX5.js";
|
|
3
3
|
export { cornerFinder, edgeFinder, faceFinder, getSingleFace };
|