brepjs 18.5.3 → 18.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d/blueprints/blueprintOffset.d.ts.map +1 -1
- package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -1
- package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -1
- package/dist/2d/lib/curve2D.d.ts.map +1 -1
- package/dist/2d/lib/customCorners.d.ts.map +1 -1
- package/dist/2d/lib/stitching.d.ts.map +1 -1
- package/dist/2d/lib/svgPath.d.ts.map +1 -1
- package/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{blueprint-BKo2Z5P_.cjs → blueprint-C5LxqHCa.cjs} +16 -15
- package/dist/{blueprint-DXNeal2M.js → blueprint-CBairprN.js} +16 -15
- package/dist/{blueprintFns-DLmNAtH4.cjs → blueprintFns-CwbDuLxf.cjs} +3 -3
- package/dist/{blueprintFns-DwKTTALX.js → blueprintFns-D8ST0Cf4.js} +3 -3
- package/dist/{boolean2D-C8DlibdA.js → boolean2D-A5u9tJYl.js} +26 -24
- package/dist/{boolean2D-CvirfeVA.cjs → boolean2D-DxZ3Kwlq.cjs} +26 -24
- package/dist/{booleanFns-BTmOI2IT.cjs → booleanFns-DWQMtFDN.cjs} +9 -9
- package/dist/{booleanFns-BvRK1Oi2.js → booleanFns-DjZF4MJ5.js} +9 -9
- package/dist/brepjs.cjs +51 -41
- package/dist/brepjs.js +51 -41
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core.cjs +6 -6
- package/dist/core.js +6 -6
- package/dist/{cornerFinder-D3eGMa24.cjs → cornerFinder-B2CpcVV9.cjs} +3 -3
- package/dist/{cornerFinder-BwE0co98.js → cornerFinder-DGvOt2ab.js} +3 -3
- package/dist/{curveFns-CkhBj1Ot.cjs → curveFns-B8KJKr8-.cjs} +2 -2
- package/dist/{curveFns-DOtvwQN1.js → curveFns-DZYE3BGO.js} +2 -2
- package/dist/{drawFns-ChZrX59C.js → drawFns-Bl865kUL.js} +21 -20
- package/dist/{drawFns-CFqr2BFZ.cjs → drawFns-h8gJBx-H.cjs} +21 -20
- package/dist/{errors-DboJwVCf.js → errors-0fYW_YnO.js} +2 -1
- package/dist/{errors-CXRNVCec.cjs → errors-Dv6pfNct.cjs} +2 -1
- package/dist/{extrudeFns-sFXnQ0GR.cjs → extrudeFns-BlJKAnW8.cjs} +3 -3
- package/dist/{extrudeFns-9m-r4epC.js → extrudeFns-O2s-SFf-.js} +3 -3
- package/dist/{faceFns-9yuvhlzD.cjs → faceFns-B1H43mZ_.cjs} +3 -3
- package/dist/{faceFns-CoVqCTcx.js → faceFns-acz86gqR.js} +3 -3
- package/dist/{helpers-BPqm4AyF.cjs → helpers-C3smxDtp.cjs} +8 -8
- package/dist/{helpers-thCB-5I7.js → helpers-DL1f3xp0.js} +8 -8
- package/dist/{historyFns-DlyOFijD.js → historyFns-CD9qXw5j.js} +6 -6
- package/dist/{historyFns-C8RKuoZR.cjs → historyFns-DBdWeo7Y.cjs} +6 -6
- package/dist/{importFns-C9KoV6Q2.cjs → importFns-5tcN3-fK.cjs} +11 -19
- package/dist/{importFns-TsXZed73.js → importFns-B1p3FiGS.js} +11 -19
- package/dist/io/gltfExportFns.d.ts.map +1 -1
- package/dist/io/objExportFns.d.ts.map +1 -1
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/constructionOps.d.ts +3 -2
- package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/helpers.d.ts.map +1 -1
- package/dist/kernel/brepkit/internalOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/ioOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/kernel2dOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/measureOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/meshOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -1
- package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -1
- package/dist/kernel/occt/advancedOps.d.ts.map +1 -1
- package/dist/kernel/occt/booleanOps.d.ts.map +1 -1
- package/dist/kernel/occt/extendedConstructorOps.d.ts.map +1 -1
- package/dist/kernel/occt/kernel2dOps.d.ts.map +1 -1
- package/dist/kernel/occtWasm/adapterShims.d.ts +5 -0
- package/dist/kernel/occtWasm/adapterShims.d.ts.map +1 -0
- package/dist/kernel/occtWasm/booleanOps.d.ts +12 -0
- package/dist/kernel/occtWasm/booleanOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/constructionOps.d.ts +37 -0
- package/dist/kernel/occtWasm/constructionOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/curveOps.d.ts +24 -0
- package/dist/kernel/occtWasm/curveOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/evolutionOps.d.ts +18 -0
- package/dist/kernel/occtWasm/evolutionOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/helpers.d.ts +32 -0
- package/dist/kernel/occtWasm/helpers.d.ts.map +1 -0
- package/dist/kernel/occtWasm/hullOps.d.ts +13 -0
- package/dist/kernel/occtWasm/hullOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/ioOps.d.ts +53 -0
- package/dist/kernel/occtWasm/ioOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/kernel2dOps.d.ts +91 -0
- package/dist/kernel/occtWasm/kernel2dOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/measureOps.d.ts +32 -0
- package/dist/kernel/occtWasm/measureOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/meshOps.d.ts +7 -0
- package/dist/kernel/occtWasm/meshOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/modifierOps.d.ts +15 -0
- package/dist/kernel/occtWasm/modifierOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +30 -30
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts.map +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/primitiveOps.d.ts +11 -0
- package/dist/kernel/occtWasm/primitiveOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/repairOps.d.ts +11 -0
- package/dist/kernel/occtWasm/repairOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/surfaceOps.d.ts +29 -0
- package/dist/kernel/occtWasm/surfaceOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/sweepOps.d.ts +39 -0
- package/dist/kernel/occtWasm/sweepOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/topologyOps.d.ts +15 -0
- package/dist/kernel/occtWasm/topologyOps.d.ts.map +1 -0
- package/dist/kernel/occtWasm/transformOps.d.ts +28 -0
- package/dist/kernel/occtWasm/transformOps.d.ts.map +1 -0
- package/dist/{measureFns-DXLTUwTN.cjs → measureFns-CHmy_Inq.cjs} +3 -3
- package/dist/{measureFns-CkhDfqzu.js → measureFns-CJi8erDL.js} +3 -3
- package/dist/measurement/interferenceFns.d.ts.map +1 -1
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CAUI3r1d.js → meshFns-BkY1RAoC.js} +3 -3
- package/dist/{meshFns-DzGr_wxJ.cjs → meshFns-t2lR4BDS.cjs} +3 -3
- package/dist/occtWasmAdapter--TZGP9DX.js +4606 -0
- package/dist/occtWasmAdapter-C2VW-uYg.cjs +4719 -0
- package/dist/operations/compoundOpsFns.d.ts.map +1 -1
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{planeOps-sTrM3dcQ.js → planeOps-4i2qEraD.js} +4 -4
- package/dist/{planeOps-BJOIbn4K.cjs → planeOps-CH4ruLuj.cjs} +4 -4
- package/dist/{primitiveFns-ClBrBsj6.cjs → primitiveFns-DwhN--zB.cjs} +7 -7
- package/dist/{primitiveFns-DEIibX8G.js → primitiveFns-Emvge_71.js} +7 -7
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeFns-c2eak2sT.cjs → shapeFns-CObBAJoQ.cjs} +4 -4
- package/dist/{shapeFns-Cwt0CMNm.js → shapeFns-DThjHtJI.js} +4 -4
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-D-JLpn7D.cjs → shapeRefFns-I0MHjRAq.cjs} +5 -4
- package/dist/{shapeRefFns-Cx61pDhQ.js → shapeRefFns-WMhIFuGW.js} +5 -4
- package/dist/{shapeTypes-Xnk670Cd.cjs → shapeTypes-8vB31RfA.cjs} +290 -418
- package/dist/{shapeTypes-uibK1QHY.js → shapeTypes-AyL8vv_O.js} +290 -418
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-BnTtq4g1.js → solidBuilders-C7Xp_ikW.js} +3 -3
- package/dist/{solidBuilders-23LDxzEn.cjs → solidBuilders-Djwgx2mj.cjs} +3 -3
- package/dist/{surfaceBuilders-CUn-cmah.cjs → surfaceBuilders-BEnsewN9.cjs} +3 -3
- package/dist/{surfaceBuilders-DeNnAJb3.js → surfaceBuilders-Con0IpLf.js} +3 -3
- package/dist/topology/minkowskiFns.d.ts.map +1 -1
- package/dist/topology/shapeRef/shapeRefFns.d.ts.map +1 -1
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +6 -6
- package/dist/utils/vec3.d.ts +32 -0
- package/dist/utils/vec3.d.ts.map +1 -0
- package/dist/vec3-BRj3eI54.js +25 -0
- package/dist/vec3-S4Oh59IX.cjs +36 -0
- package/dist/vectors.cjs +4 -4
- package/dist/vectors.js +4 -4
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +1 -1
- package/package.json +2 -2
- package/dist/occtWasmAdapter-CuZRRioz.cjs +0 -3947
- package/dist/occtWasmAdapter-DIhUXubY.js +0 -3834
- /package/dist/{arrayAccess-tCIbjLs5.js → arrayAccess-2G0pRoaC.js} +0 -0
- /package/dist/{arrayAccess-DsnQpdSD.cjs → arrayAccess-Br-m2PP7.cjs} +0 -0
- /package/dist/{constants-csSEYddm.js → constants-Ci5CA3aZ.js} +0 -0
- /package/dist/{constants-BNP_xnBN.cjs → constants-DTorLmes.cjs} +0 -0
- /package/dist/{types--GD-LVc6.js → types-BIdk_GJY.js} +0 -0
- /package/dist/{types-gLi9wL0N.cjs → types-CDkxah-M.cjs} +0 -0
- /package/dist/{vecOps-CODplJp3.cjs → vecOps-D7xplSx8.cjs} +0 -0
- /package/dist/{vecOps-B-PCHgyB.js → vecOps-DVROrqTV.js} +0 -0
- /package/dist/{workerHandler-Dm0_0F8Z.js → workerHandler-BndMJVx6.js} +0 -0
- /package/dist/{workerHandler-C-3cFcsQ.cjs → workerHandler-sCf818XJ.cjs} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_vec3 = require("./vec3-S4Oh59IX.cjs");
|
|
2
|
+
const require_occtWasmAdapter = require("./occtWasmAdapter-C2VW-uYg.cjs");
|
|
3
|
+
const require_errors = require("./errors-Dv6pfNct.cjs");
|
|
3
4
|
//#region src/kernel/kernel2dTypes.ts
|
|
4
5
|
/** Check if the kernel supports 2D geometry operations. */
|
|
5
6
|
function supportsKernel2D(kernel) {
|
|
@@ -812,7 +813,7 @@ function fuseAllNative(oc, shapes, options = {}) {
|
|
|
812
813
|
function fuseAllPairwiseRange(oc, shapes, start, end, options) {
|
|
813
814
|
options.signal?.throwIfAborted();
|
|
814
815
|
const count = end - start;
|
|
815
|
-
if (count === 1) return shapes
|
|
816
|
+
if (count === 1) return require_vec3.wasmIndex(shapes, start);
|
|
816
817
|
if (count === 2) return fuse$1(oc, shapes[start], shapes[start + 1], {
|
|
817
818
|
...options,
|
|
818
819
|
simplify: false
|
|
@@ -842,7 +843,7 @@ function fuseAllPairwise(oc, shapes, options = {}) {
|
|
|
842
843
|
*/
|
|
843
844
|
function fuseAll$1(oc, shapes, options = {}) {
|
|
844
845
|
if (shapes.length === 0) throw new Error("fuseAll requires at least one shape");
|
|
845
|
-
if (shapes.length === 1) return shapes
|
|
846
|
+
if (shapes.length === 1) return require_vec3.wasmIndex(shapes, 0);
|
|
846
847
|
const { strategy = "native" } = options;
|
|
847
848
|
if (strategy === "pairwise") return fuseAllPairwise(oc, shapes, options);
|
|
848
849
|
return fuseAllNative(oc, shapes, options);
|
|
@@ -2841,7 +2842,7 @@ function makeEllipseArc$1(oc, center, normal, majorRadius, minorRadius, startAng
|
|
|
2841
2842
|
function makeBezierEdge$1(oc, points) {
|
|
2842
2843
|
const arr = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
2843
2844
|
for (let i = 0; i < points.length; i++) {
|
|
2844
|
-
const p = points
|
|
2845
|
+
const p = require_vec3.wasmIndex(points, i);
|
|
2845
2846
|
const pnt = new oc.gp_Pnt_3(p[0], p[1], p[2]);
|
|
2846
2847
|
arr.SetValue_1(i + 1, pnt);
|
|
2847
2848
|
pnt.delete();
|
|
@@ -3430,7 +3431,7 @@ function createAffinityGTrsf2d$1(ox, oy, dx, dy, ratio) {
|
|
|
3430
3431
|
0,
|
|
3431
3432
|
1
|
|
3432
3433
|
];
|
|
3433
|
-
return _gtrsf$1(m, ox - m
|
|
3434
|
+
return _gtrsf$1(m, ox - require_vec3.wasmIndex(m, 0) * ox - require_vec3.wasmIndex(m, 1) * oy, oy - require_vec3.wasmIndex(m, 3) * ox - require_vec3.wasmIndex(m, 4) * oy);
|
|
3434
3435
|
}
|
|
3435
3436
|
function createTranslationGTrsf2d$1(dx, dy) {
|
|
3436
3437
|
return _gtrsf$1([
|
|
@@ -3461,7 +3462,7 @@ function createMirrorGTrsf2d$1(cx, cy, mode, ox, oy, dx, dy) {
|
|
|
3461
3462
|
1
|
|
3462
3463
|
];
|
|
3463
3464
|
const apx = ox ?? cx, apy = oy ?? cy;
|
|
3464
|
-
return _gtrsf$1(m, apx - m
|
|
3465
|
+
return _gtrsf$1(m, apx - require_vec3.wasmIndex(m, 0) * apx - require_vec3.wasmIndex(m, 1) * apy, apy - require_vec3.wasmIndex(m, 3) * apx - require_vec3.wasmIndex(m, 4) * apy);
|
|
3465
3466
|
}
|
|
3466
3467
|
return _gtrsf$1([
|
|
3467
3468
|
-1,
|
|
@@ -3508,21 +3509,23 @@ function setGTrsf2dTranslationPart$1(gtrsf, dx, dy) {
|
|
|
3508
3509
|
}
|
|
3509
3510
|
function multiplyGTrsf2d$1(base, other) {
|
|
3510
3511
|
const a = base.m, b = other.m;
|
|
3512
|
+
const ai = (i) => require_vec3.wasmIndex(a, i);
|
|
3513
|
+
const bi = (i) => require_vec3.wasmIndex(b, i);
|
|
3511
3514
|
base.m = [
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3515
|
+
ai(0) * bi(0) + ai(1) * bi(3) + ai(2) * bi(6),
|
|
3516
|
+
ai(0) * bi(1) + ai(1) * bi(4) + ai(2) * bi(7),
|
|
3517
|
+
ai(0) * bi(2) + ai(1) * bi(5) + ai(2) * bi(8),
|
|
3518
|
+
ai(3) * bi(0) + ai(4) * bi(3) + ai(5) * bi(6),
|
|
3519
|
+
ai(3) * bi(1) + ai(4) * bi(4) + ai(5) * bi(7),
|
|
3520
|
+
ai(3) * bi(2) + ai(4) * bi(5) + ai(5) * bi(8),
|
|
3521
|
+
ai(6) * bi(0) + ai(7) * bi(3) + ai(8) * bi(6),
|
|
3522
|
+
ai(6) * bi(1) + ai(7) * bi(4) + ai(8) * bi(7),
|
|
3523
|
+
ai(6) * bi(2) + ai(7) * bi(5) + ai(8) * bi(8)
|
|
3521
3524
|
];
|
|
3522
3525
|
const oldTx = base.tx, oldTy = base.ty;
|
|
3523
3526
|
const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
|
|
3524
|
-
base.tx =
|
|
3525
|
-
base.ty =
|
|
3527
|
+
base.tx = ai(0) * otx + ai(1) * oty + oldTx;
|
|
3528
|
+
base.ty = ai(3) * otx + ai(4) * oty + oldTy;
|
|
3526
3529
|
}
|
|
3527
3530
|
function transformCurve2dGeneral$1(curve, gtrsf) {
|
|
3528
3531
|
const c = c2d$1(curve);
|
|
@@ -3538,14 +3541,15 @@ function transformCurve2dGeneral$1(curve, gtrsf) {
|
|
|
3538
3541
|
1
|
|
3539
3542
|
];
|
|
3540
3543
|
const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
|
|
3541
|
-
|
|
3544
|
+
const m0 = require_vec3.wasmIndex(m, 0), m1 = require_vec3.wasmIndex(m, 1), m3 = require_vec3.wasmIndex(m, 3), m4 = require_vec3.wasmIndex(m, 4);
|
|
3545
|
+
if (Math.abs(m0 - 1) < 1e-12 && Math.abs(m4 - 1) < 1e-12 && Math.abs(m1) < 1e-12 && Math.abs(m3) < 1e-12) return require_occtWasmAdapter.translateCurve2d(c, tx, ty);
|
|
3542
3546
|
const bounds = require_occtWasmAdapter.curveBounds(c);
|
|
3543
3547
|
const N = 20;
|
|
3544
3548
|
const pts = [];
|
|
3545
3549
|
for (let i = 0; i <= N; i++) {
|
|
3546
3550
|
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
3547
3551
|
const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
|
|
3548
|
-
pts.push([
|
|
3552
|
+
pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
|
|
3549
3553
|
}
|
|
3550
3554
|
return require_occtWasmAdapter.makeBezier2d(pts);
|
|
3551
3555
|
}
|
|
@@ -3679,8 +3683,8 @@ function approximateCurve2dAsBSpline$1(curve, tol, cont, maxSeg) {
|
|
|
3679
3683
|
for (let i = 0; i < curN; i++) {
|
|
3680
3684
|
const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / curN;
|
|
3681
3685
|
const [ex, ey] = require_occtWasmAdapter.evaluateCurve2d(c, tMid);
|
|
3682
|
-
const p0 = poles
|
|
3683
|
-
const p1 = poles
|
|
3686
|
+
const p0 = require_vec3.wasmIndex(poles, i);
|
|
3687
|
+
const p1 = require_vec3.wasmIndex(poles, i + 1);
|
|
3684
3688
|
const mx = (p0[0] + p1[0]) / 2;
|
|
3685
3689
|
const my = (p0[1] + p1[1]) / 2;
|
|
3686
3690
|
const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
|
|
@@ -3706,8 +3710,8 @@ function decomposeBSpline2dToBeziers$1(curve) {
|
|
|
3706
3710
|
];
|
|
3707
3711
|
const result = [];
|
|
3708
3712
|
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
3709
|
-
const t0 = breakpoints
|
|
3710
|
-
const t1 = breakpoints
|
|
3713
|
+
const t0 = require_vec3.wasmIndex(breakpoints, i);
|
|
3714
|
+
const t1 = require_vec3.wasmIndex(breakpoints, i + 1);
|
|
3711
3715
|
const span = t1 - t0;
|
|
3712
3716
|
if (span < 1e-15) continue;
|
|
3713
3717
|
const p0 = require_occtWasmAdapter.evaluateCurve2d(c, t0);
|
|
@@ -3854,7 +3858,7 @@ function interpolatePoints3d(oc, points) {
|
|
|
3854
3858
|
const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
3855
3859
|
const reusePnt = new oc.gp_Pnt_1();
|
|
3856
3860
|
for (let i = 0; i < points.length; i++) {
|
|
3857
|
-
const p = points
|
|
3861
|
+
const p = require_vec3.wasmIndex(points, i);
|
|
3858
3862
|
reusePnt.SetCoord_2(p[0], p[1], p[2]);
|
|
3859
3863
|
pnts.SetValue_1(i + 1, reusePnt);
|
|
3860
3864
|
}
|
|
@@ -3920,7 +3924,7 @@ function liftCurve2dToPlane$1(oc, curve, planeOrigin, planeZ, planeX) {
|
|
|
3920
3924
|
}
|
|
3921
3925
|
if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
|
|
3922
3926
|
const pts3d = c.poles.map(([u, v]) => lift(u, v));
|
|
3923
|
-
if (pts3d.length === 2) return makeLineEdge3d(oc, pts3d
|
|
3927
|
+
if (pts3d.length === 2) return makeLineEdge3d(oc, require_vec3.wasmIndex(pts3d, 0), require_vec3.wasmIndex(pts3d, 1));
|
|
3924
3928
|
return interpolatePoints3d(oc, pts3d);
|
|
3925
3929
|
}
|
|
3926
3930
|
const bounds = require_occtWasmAdapter.curveBounds(c);
|
|
@@ -4465,7 +4469,7 @@ function makeFaceOnSurface$1(oc, surfaceOrFace, wire) {
|
|
|
4465
4469
|
function bsplineSurface$1(oc, points, rows, cols) {
|
|
4466
4470
|
const arr = new oc.TColgp_Array2OfPnt_2(1, rows, 1, cols);
|
|
4467
4471
|
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
|
|
4468
|
-
const pt = points
|
|
4472
|
+
const pt = require_vec3.wasmIndex(points, r * cols + c);
|
|
4469
4473
|
const pnt = new oc.gp_Pnt_3(pt[0], pt[1], pt[2]);
|
|
4470
4474
|
arr.SetValue_1(r + 1, c + 1, pnt);
|
|
4471
4475
|
pnt.delete();
|
|
@@ -4487,10 +4491,10 @@ function triangulatedSurface$1(oc, points, rows, cols) {
|
|
|
4487
4491
|
const i10 = (r + 1) * cols + c;
|
|
4488
4492
|
const i01 = r * cols + (c + 1);
|
|
4489
4493
|
const i11 = (r + 1) * cols + (c + 1);
|
|
4490
|
-
const p00 = points
|
|
4491
|
-
const p10 = points
|
|
4492
|
-
const p01 = points
|
|
4493
|
-
const p11 = points
|
|
4494
|
+
const p00 = require_vec3.wasmIndex(points, i00);
|
|
4495
|
+
const p10 = require_vec3.wasmIndex(points, i10);
|
|
4496
|
+
const p01 = require_vec3.wasmIndex(points, i01);
|
|
4497
|
+
const p11 = require_vec3.wasmIndex(points, i11);
|
|
4494
4498
|
const face1 = makeTriFace(oc, p00, p10, p01);
|
|
4495
4499
|
sewing.Add(face1);
|
|
4496
4500
|
const face2 = makeTriFace(oc, p10, p11, p01);
|
|
@@ -6165,18 +6169,19 @@ function scaleMatrix(center, factor) {
|
|
|
6165
6169
|
}
|
|
6166
6170
|
/** Build a row-major 4x4 matrix from a 3x3 linear part + translation. */
|
|
6167
6171
|
function affineMatrix(linear, translation) {
|
|
6172
|
+
const li = (i) => require_vec3.wasmIndex(linear, i);
|
|
6168
6173
|
return [
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6174
|
+
li(0),
|
|
6175
|
+
li(1),
|
|
6176
|
+
li(2),
|
|
6172
6177
|
translation[0],
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6178
|
+
li(3),
|
|
6179
|
+
li(4),
|
|
6180
|
+
li(5),
|
|
6176
6181
|
translation[1],
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6182
|
+
li(6),
|
|
6183
|
+
li(7),
|
|
6184
|
+
li(8),
|
|
6180
6185
|
translation[2],
|
|
6181
6186
|
0,
|
|
6182
6187
|
0,
|
|
@@ -6311,13 +6316,13 @@ function iterShapes(bk, shape, type) {
|
|
|
6311
6316
|
for (const eid of edgeIds) {
|
|
6312
6317
|
const verts = bk.getEdgeVertices(eid);
|
|
6313
6318
|
const coords = [[
|
|
6314
|
-
verts
|
|
6315
|
-
verts
|
|
6316
|
-
verts
|
|
6319
|
+
require_vec3.wasmIndex(verts, 0),
|
|
6320
|
+
require_vec3.wasmIndex(verts, 1),
|
|
6321
|
+
require_vec3.wasmIndex(verts, 2)
|
|
6317
6322
|
], [
|
|
6318
|
-
verts
|
|
6319
|
-
verts
|
|
6320
|
-
verts
|
|
6323
|
+
require_vec3.wasmIndex(verts, 3),
|
|
6324
|
+
require_vec3.wasmIndex(verts, 4),
|
|
6325
|
+
require_vec3.wasmIndex(verts, 5)
|
|
6321
6326
|
]];
|
|
6322
6327
|
for (const [x, y, z] of coords) {
|
|
6323
6328
|
const key = `${x},${y},${z}`;
|
|
@@ -6334,8 +6339,8 @@ function iterShapes(bk, shape, type) {
|
|
|
6334
6339
|
if (type === "edge") return [shape];
|
|
6335
6340
|
if (type === "vertex") {
|
|
6336
6341
|
const verts = bk.getEdgeVertices(h);
|
|
6337
|
-
const v1 = bk.makeVertex(verts
|
|
6338
|
-
const v2 = bk.makeVertex(verts
|
|
6342
|
+
const v1 = bk.makeVertex(require_vec3.wasmIndex(verts, 0), require_vec3.wasmIndex(verts, 1), require_vec3.wasmIndex(verts, 2));
|
|
6343
|
+
const v2 = bk.makeVertex(require_vec3.wasmIndex(verts, 3), require_vec3.wasmIndex(verts, 4), require_vec3.wasmIndex(verts, 5));
|
|
6339
6344
|
return [vertexHandle(v1), vertexHandle(v2)];
|
|
6340
6345
|
}
|
|
6341
6346
|
return [];
|
|
@@ -6402,12 +6407,7 @@ function sew(bk, shapes, tolerance) {
|
|
|
6402
6407
|
//#endregion
|
|
6403
6408
|
//#region src/kernel/brepkit/geometryOps.ts
|
|
6404
6409
|
function vertexPosition(bk, vertex) {
|
|
6405
|
-
|
|
6406
|
-
return [
|
|
6407
|
-
pos[0],
|
|
6408
|
-
pos[1],
|
|
6409
|
-
pos[2]
|
|
6410
|
-
];
|
|
6410
|
+
return require_vec3.vec3At(bk.getVertexPosition(unwrap(vertex, "vertex")));
|
|
6411
6411
|
}
|
|
6412
6412
|
function surfaceType(bk, face) {
|
|
6413
6413
|
return bk.getSurfaceType(unwrap(face, "face"));
|
|
@@ -6415,47 +6415,32 @@ function surfaceType(bk, face) {
|
|
|
6415
6415
|
function uvBounds(bk, face) {
|
|
6416
6416
|
const domain = bk.getSurfaceDomain(unwrap(face, "face"));
|
|
6417
6417
|
return {
|
|
6418
|
-
uMin: domain
|
|
6419
|
-
uMax: domain
|
|
6420
|
-
vMin: domain
|
|
6421
|
-
vMax: domain
|
|
6418
|
+
uMin: require_vec3.wasmIndex(domain, 0),
|
|
6419
|
+
uMax: require_vec3.wasmIndex(domain, 1),
|
|
6420
|
+
vMin: require_vec3.wasmIndex(domain, 2),
|
|
6421
|
+
vMax: require_vec3.wasmIndex(domain, 3)
|
|
6422
6422
|
};
|
|
6423
6423
|
}
|
|
6424
6424
|
function outerWire(bk, face) {
|
|
6425
6425
|
return wireHandle(bk.getFaceOuterWire(unwrap(face, "face")));
|
|
6426
6426
|
}
|
|
6427
6427
|
function surfaceNormal(bk, face, u, v) {
|
|
6428
|
-
|
|
6429
|
-
return [
|
|
6430
|
-
n[0],
|
|
6431
|
-
n[1],
|
|
6432
|
-
n[2]
|
|
6433
|
-
];
|
|
6428
|
+
return require_vec3.vec3At(bk.evaluateSurfaceNormal(unwrap(face, "face"), u, v));
|
|
6434
6429
|
}
|
|
6435
6430
|
function pointOnSurface(bk, face, u, v) {
|
|
6436
|
-
|
|
6437
|
-
return [
|
|
6438
|
-
p[0],
|
|
6439
|
-
p[1],
|
|
6440
|
-
p[2]
|
|
6441
|
-
];
|
|
6431
|
+
return require_vec3.vec3At(bk.evaluateSurface(unwrap(face, "face"), u, v));
|
|
6442
6432
|
}
|
|
6443
6433
|
function uvFromPoint(bk, face, point) {
|
|
6444
6434
|
try {
|
|
6445
6435
|
const result = bk.projectPointOnSurface(unwrap(face, "face"), point[0], point[1], point[2]);
|
|
6446
|
-
return [result
|
|
6436
|
+
return [require_vec3.wasmIndex(result, 0), require_vec3.wasmIndex(result, 1)];
|
|
6447
6437
|
} catch (e) {
|
|
6448
6438
|
console.warn("brepkit: uvFromPoint failed:", e);
|
|
6449
6439
|
return null;
|
|
6450
6440
|
}
|
|
6451
6441
|
}
|
|
6452
6442
|
function projectPointOnFace(bk, face, point) {
|
|
6453
|
-
|
|
6454
|
-
return [
|
|
6455
|
-
result[2],
|
|
6456
|
-
result[3],
|
|
6457
|
-
result[4]
|
|
6458
|
-
];
|
|
6443
|
+
return require_vec3.vec3At(bk.projectPointOnSurface(unwrap(face, "face"), point[0], point[1], point[2]), 2);
|
|
6459
6444
|
}
|
|
6460
6445
|
function curveTangent(bk, shape, param) {
|
|
6461
6446
|
const h = shape;
|
|
@@ -6463,14 +6448,14 @@ function curveTangent(bk, shape, param) {
|
|
|
6463
6448
|
let evalParam = param;
|
|
6464
6449
|
if (h.type === "wire") {
|
|
6465
6450
|
const edgeIds = toArray(bk.getWireEdges(h.id));
|
|
6466
|
-
edgeId = edgeIds
|
|
6451
|
+
edgeId = require_vec3.wasmIndex(edgeIds, edgeIds.length - 1);
|
|
6467
6452
|
let cumulative = 0;
|
|
6468
6453
|
for (const eid of edgeIds) {
|
|
6469
6454
|
const p = bk.getEdgeCurveParameters(eid);
|
|
6470
|
-
const span = p
|
|
6455
|
+
const span = require_vec3.wasmIndex(p, 1) - require_vec3.wasmIndex(p, 0);
|
|
6471
6456
|
if (param <= cumulative + span || eid === edgeId) {
|
|
6472
6457
|
edgeId = eid;
|
|
6473
|
-
evalParam = Math.min(p
|
|
6458
|
+
evalParam = Math.min(require_vec3.wasmIndex(p, 0) + (param - cumulative), require_vec3.wasmIndex(p, 1));
|
|
6474
6459
|
break;
|
|
6475
6460
|
}
|
|
6476
6461
|
cumulative += span;
|
|
@@ -6478,16 +6463,8 @@ function curveTangent(bk, shape, param) {
|
|
|
6478
6463
|
} else edgeId = unwrap(shape, "edge");
|
|
6479
6464
|
const result = bk.evaluateEdgeCurveD1(edgeId, evalParam);
|
|
6480
6465
|
return {
|
|
6481
|
-
point:
|
|
6482
|
-
|
|
6483
|
-
result[1],
|
|
6484
|
-
result[2]
|
|
6485
|
-
],
|
|
6486
|
-
tangent: [
|
|
6487
|
-
result[3],
|
|
6488
|
-
result[4],
|
|
6489
|
-
result[5]
|
|
6490
|
-
]
|
|
6466
|
+
point: require_vec3.vec3At(result, 0),
|
|
6467
|
+
tangent: require_vec3.vec3At(result, 3)
|
|
6491
6468
|
};
|
|
6492
6469
|
}
|
|
6493
6470
|
function curveParameters(bk, shape) {
|
|
@@ -6498,13 +6475,12 @@ function curveParameters(bk, shape) {
|
|
|
6498
6475
|
let total = 0;
|
|
6499
6476
|
for (const eid of edgeIds) {
|
|
6500
6477
|
const p = bk.getEdgeCurveParameters(eid);
|
|
6501
|
-
total += p
|
|
6478
|
+
total += require_vec3.wasmIndex(p, 1) - require_vec3.wasmIndex(p, 0);
|
|
6502
6479
|
}
|
|
6503
6480
|
return [0, total];
|
|
6504
6481
|
}
|
|
6505
|
-
const
|
|
6506
|
-
|
|
6507
|
-
return [params[0], params[1]];
|
|
6482
|
+
const params = bk.getEdgeCurveParameters(unwrap(shape, "edge"));
|
|
6483
|
+
return [require_vec3.wasmIndex(params, 0), require_vec3.wasmIndex(params, 1)];
|
|
6508
6484
|
}
|
|
6509
6485
|
function curvePointAtParam(bk, shape, param) {
|
|
6510
6486
|
const h = shape;
|
|
@@ -6513,55 +6489,28 @@ function curvePointAtParam(bk, shape, param) {
|
|
|
6513
6489
|
let cumulative = 0;
|
|
6514
6490
|
for (const eid of edgeIds) {
|
|
6515
6491
|
const p = bk.getEdgeCurveParameters(eid);
|
|
6516
|
-
const span = p
|
|
6492
|
+
const span = require_vec3.wasmIndex(p, 1) - require_vec3.wasmIndex(p, 0);
|
|
6517
6493
|
if (param <= cumulative + span || eid === edgeIds[edgeIds.length - 1]) {
|
|
6518
|
-
const localParam = p
|
|
6519
|
-
|
|
6520
|
-
return [
|
|
6521
|
-
pt[0],
|
|
6522
|
-
pt[1],
|
|
6523
|
-
pt[2]
|
|
6524
|
-
];
|
|
6494
|
+
const localParam = require_vec3.wasmIndex(p, 0) + (param - cumulative);
|
|
6495
|
+
return require_vec3.vec3At(bk.evaluateEdgeCurve(eid, Math.min(localParam, require_vec3.wasmIndex(p, 1))));
|
|
6525
6496
|
}
|
|
6526
6497
|
cumulative += span;
|
|
6527
6498
|
}
|
|
6528
|
-
|
|
6529
|
-
return [
|
|
6530
|
-
pt[0],
|
|
6531
|
-
pt[1],
|
|
6532
|
-
pt[2]
|
|
6533
|
-
];
|
|
6499
|
+
return require_vec3.vec3At(bk.evaluateEdgeCurve(require_vec3.wasmIndex(edgeIds, 0), param));
|
|
6534
6500
|
}
|
|
6535
|
-
|
|
6536
|
-
const p = bk.evaluateEdgeCurve(edgeId, param);
|
|
6537
|
-
return [
|
|
6538
|
-
p[0],
|
|
6539
|
-
p[1],
|
|
6540
|
-
p[2]
|
|
6541
|
-
];
|
|
6501
|
+
return require_vec3.vec3At(bk.evaluateEdgeCurve(unwrap(shape, "edge"), param));
|
|
6542
6502
|
}
|
|
6543
6503
|
function curveIsClosed(bk, shape) {
|
|
6544
6504
|
const h = shape;
|
|
6545
6505
|
if (h.type === "wire") {
|
|
6546
6506
|
const edgeIds = toArray(bk.getWireEdges(h.id));
|
|
6547
6507
|
if (edgeIds.length === 0) return false;
|
|
6548
|
-
if (edgeIds.length === 1)
|
|
6549
|
-
const verts = bk.getEdgeVertices(edgeIds[0]);
|
|
6550
|
-
return dist3(verts[0], verts[1], verts[2], verts[3], verts[4], verts[5]) < 1e-7;
|
|
6551
|
-
}
|
|
6508
|
+
if (edgeIds.length === 1) return edgeIsClosed(bk.getEdgeVertices(require_vec3.wasmIndex(edgeIds, 0)));
|
|
6552
6509
|
const endpoints = [];
|
|
6553
6510
|
for (const eid of edgeIds) {
|
|
6554
6511
|
const verts = bk.getEdgeVertices(eid);
|
|
6555
|
-
endpoints.push(
|
|
6556
|
-
|
|
6557
|
-
verts[1],
|
|
6558
|
-
verts[2]
|
|
6559
|
-
]);
|
|
6560
|
-
endpoints.push([
|
|
6561
|
-
verts[3],
|
|
6562
|
-
verts[4],
|
|
6563
|
-
verts[5]
|
|
6564
|
-
]);
|
|
6512
|
+
endpoints.push(require_vec3.vec3At(verts, 0));
|
|
6513
|
+
endpoints.push(require_vec3.vec3At(verts, 3));
|
|
6565
6514
|
}
|
|
6566
6515
|
const unmatched = [];
|
|
6567
6516
|
for (const pt of endpoints) {
|
|
@@ -6571,8 +6520,10 @@ function curveIsClosed(bk, shape) {
|
|
|
6571
6520
|
}
|
|
6572
6521
|
return unmatched.length === 0;
|
|
6573
6522
|
}
|
|
6574
|
-
|
|
6575
|
-
|
|
6523
|
+
return edgeIsClosed(bk.getEdgeVertices(unwrap(shape, "edge")));
|
|
6524
|
+
}
|
|
6525
|
+
function edgeIsClosed(verts) {
|
|
6526
|
+
return dist3(require_vec3.wasmIndex(verts, 0), require_vec3.wasmIndex(verts, 1), require_vec3.wasmIndex(verts, 2), require_vec3.wasmIndex(verts, 3), require_vec3.wasmIndex(verts, 4), require_vec3.wasmIndex(verts, 5)) < 1e-7;
|
|
6576
6527
|
}
|
|
6577
6528
|
function curveIsPeriodic(bk, shape) {
|
|
6578
6529
|
const h = shape;
|
|
@@ -6616,7 +6567,7 @@ function curveKnotRemove(bk, edge, knot, tolerance) {
|
|
|
6616
6567
|
function curveSplit(bk, edge, param) {
|
|
6617
6568
|
const edgeId = unwrap(edge, "edge");
|
|
6618
6569
|
const result = bk.curveSplit(edgeId, param);
|
|
6619
|
-
return [edgeHandle(result
|
|
6570
|
+
return [edgeHandle(require_vec3.wasmIndex(result, 0)), edgeHandle(require_vec3.wasmIndex(result, 1))];
|
|
6620
6571
|
}
|
|
6621
6572
|
function approximateSurfaceLspia(bk, coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations) {
|
|
6622
6573
|
return faceHandle(bk.approximateSurfaceLspia(coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations));
|
|
@@ -6631,12 +6582,7 @@ function createCurveAdaptor(_bk, shape) {
|
|
|
6631
6582
|
function getBezierPenultimatePole(bk, edge) {
|
|
6632
6583
|
const nurbsData = extractNurbsFromEdge(bk, edge);
|
|
6633
6584
|
if (!nurbsData || nurbsData.controlPoints.length < 6) return null;
|
|
6634
|
-
|
|
6635
|
-
return [
|
|
6636
|
-
nurbsData.controlPoints[n - 6],
|
|
6637
|
-
nurbsData.controlPoints[n - 5],
|
|
6638
|
-
nurbsData.controlPoints[n - 4]
|
|
6639
|
-
];
|
|
6585
|
+
return require_vec3.vec3At(nurbsData.controlPoints, nurbsData.controlPoints.length - 6);
|
|
6640
6586
|
}
|
|
6641
6587
|
function getSurfaceCylinderData(bk, surface) {
|
|
6642
6588
|
if (isBrepkitHandle(surface) && surface.type === "face") {
|
|
@@ -6656,7 +6602,7 @@ function classifyPointOnFace(bk, face, u, v, tolerance) {
|
|
|
6656
6602
|
if (tolerance !== void 0) warnOnce("classify-tolerance", "classifyPointOnFace() tolerance parameter is not supported; brepkit uses domain-based classification.");
|
|
6657
6603
|
const faceId = unwrap(face, "face");
|
|
6658
6604
|
const domain = bk.getSurfaceDomain(faceId);
|
|
6659
|
-
if (u < domain
|
|
6605
|
+
if (u < require_vec3.wasmIndex(domain, 0) || u > require_vec3.wasmIndex(domain, 1) || v < require_vec3.wasmIndex(domain, 2) || v > require_vec3.wasmIndex(domain, 3)) return "out";
|
|
6660
6606
|
return "in";
|
|
6661
6607
|
}
|
|
6662
6608
|
function classifyPointRobust(bk, shape, point, tolerance) {
|
|
@@ -6849,19 +6795,10 @@ function extractPlaneFromFace(bk, faceShape) {
|
|
|
6849
6795
|
}
|
|
6850
6796
|
faceId = bestId;
|
|
6851
6797
|
} else faceId = unwrap(faceShape, "face");
|
|
6852
|
-
const
|
|
6853
|
-
const normal = [
|
|
6854
|
-
n[0],
|
|
6855
|
-
n[1],
|
|
6856
|
-
n[2]
|
|
6857
|
-
];
|
|
6798
|
+
const normal = require_vec3.vec3At(bk.getFaceNormal(faceId));
|
|
6858
6799
|
const positions = bk.tessellateFace(faceId, 1).positions;
|
|
6859
6800
|
if (positions.length >= 3) return {
|
|
6860
|
-
point:
|
|
6861
|
-
positions[0],
|
|
6862
|
-
positions[1],
|
|
6863
|
-
positions[2]
|
|
6864
|
-
],
|
|
6801
|
+
point: require_vec3.vec3At(positions),
|
|
6865
6802
|
normal
|
|
6866
6803
|
};
|
|
6867
6804
|
return {
|
|
@@ -6901,12 +6838,12 @@ function extractNurbsFromEdge(bk, shape) {
|
|
|
6901
6838
|
1
|
|
6902
6839
|
],
|
|
6903
6840
|
controlPoints: [
|
|
6904
|
-
verts
|
|
6905
|
-
verts
|
|
6906
|
-
verts
|
|
6907
|
-
verts
|
|
6908
|
-
verts
|
|
6909
|
-
verts
|
|
6841
|
+
require_vec3.wasmIndex(verts, 0),
|
|
6842
|
+
require_vec3.wasmIndex(verts, 1),
|
|
6843
|
+
require_vec3.wasmIndex(verts, 2),
|
|
6844
|
+
require_vec3.wasmIndex(verts, 3),
|
|
6845
|
+
require_vec3.wasmIndex(verts, 4),
|
|
6846
|
+
require_vec3.wasmIndex(verts, 5)
|
|
6910
6847
|
],
|
|
6911
6848
|
weights: [1, 1]
|
|
6912
6849
|
};
|
|
@@ -7081,8 +7018,8 @@ function makeBezierEdge(bk, points) {
|
|
|
7081
7018
|
y,
|
|
7082
7019
|
z
|
|
7083
7020
|
]);
|
|
7084
|
-
const startPt = points
|
|
7085
|
-
const endPt = points
|
|
7021
|
+
const startPt = require_vec3.wasmIndex(points, 0);
|
|
7022
|
+
const endPt = require_vec3.wasmIndex(points, n - 1);
|
|
7086
7023
|
return edgeHandle(bk.makeNurbsEdge(startPt[0], startPt[1], startPt[2], endPt[0], endPt[1], endPt[2], degree, knots, flatCp, weights));
|
|
7087
7024
|
}
|
|
7088
7025
|
function makeTangentArc(bk, startPoint, startTangent, endPoint) {
|
|
@@ -7176,31 +7113,21 @@ function triangulatedSurface(bk, points, rows, cols) {
|
|
|
7176
7113
|
const i10 = (r + 1) * cols + c;
|
|
7177
7114
|
const i01 = r * cols + (c + 1);
|
|
7178
7115
|
const i11 = (r + 1) * cols + (c + 1);
|
|
7179
|
-
const f1 = buildTriFace(bk, points
|
|
7116
|
+
const f1 = buildTriFace(bk, require_vec3.wasmIndex(points, i00), require_vec3.wasmIndex(points, i10), require_vec3.wasmIndex(points, i01));
|
|
7180
7117
|
if (f1) faces.push(f1);
|
|
7181
|
-
const f2 = buildTriFace(bk, points
|
|
7118
|
+
const f2 = buildTriFace(bk, require_vec3.wasmIndex(points, i10), require_vec3.wasmIndex(points, i11), require_vec3.wasmIndex(points, i01));
|
|
7182
7119
|
if (f2) faces.push(f2);
|
|
7183
7120
|
}
|
|
7184
7121
|
if (faces.length === 0) throw new Error("brepkit: no valid faces in surface grid");
|
|
7185
7122
|
return sew(bk, faces, 1e-6);
|
|
7186
7123
|
}
|
|
7187
7124
|
function buildTriFace(bk, a, b, c) {
|
|
7188
|
-
const
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
c[0] - a[0],
|
|
7195
|
-
c[1] - a[1],
|
|
7196
|
-
c[2] - a[2]
|
|
7197
|
-
];
|
|
7198
|
-
const cross = [
|
|
7199
|
-
ab[1] * ac[2] - ab[2] * ac[1],
|
|
7200
|
-
ab[2] * ac[0] - ab[0] * ac[2],
|
|
7201
|
-
ab[0] * ac[1] - ab[1] * ac[0]
|
|
7202
|
-
];
|
|
7203
|
-
if (Math.sqrt(cross[0] ** 2 + cross[1] ** 2 + cross[2] ** 2) < 1e-12) return null;
|
|
7125
|
+
const abx = b[0] - a[0], aby = b[1] - a[1], abz = b[2] - a[2];
|
|
7126
|
+
const acx = c[0] - a[0], acy = c[1] - a[1], acz = c[2] - a[2];
|
|
7127
|
+
const cx = aby * acz - abz * acy;
|
|
7128
|
+
const cy = abz * acx - abx * acz;
|
|
7129
|
+
const cz = abx * acy - aby * acx;
|
|
7130
|
+
if (Math.sqrt(cx * cx + cy * cy + cz * cz) < 1e-12) return null;
|
|
7204
7131
|
try {
|
|
7205
7132
|
return makeFace(bk, makeWire(bk, [
|
|
7206
7133
|
makeLineEdge(bk, a, b),
|
|
@@ -7219,7 +7146,7 @@ function sewAndSolidify(bk, faces, tolerance) {
|
|
|
7219
7146
|
function interpolatePoints(bk, points, options) {
|
|
7220
7147
|
if (options?.tolerance !== void 0) warnOnce("interpolate-tolerance", "interpolatePoints() tolerance parameter is not supported; brepkit uses chord-length parameterisation.");
|
|
7221
7148
|
if (points.length < 2) throw new Error("brepkit: need at least 2 points");
|
|
7222
|
-
if (points.length === 2) return makeLineEdge(bk, points
|
|
7149
|
+
if (points.length === 2) return makeLineEdge(bk, require_vec3.wasmIndex(points, 0), require_vec3.wasmIndex(points, 1));
|
|
7223
7150
|
const degree = Math.min(3, points.length - 1);
|
|
7224
7151
|
const coords = points.flatMap(([x, y, z]) => [
|
|
7225
7152
|
x,
|
|
@@ -7311,11 +7238,11 @@ function createAxis3(_bk, ox, oy, oz, zx, zy, zz, xx, xy, xz) {
|
|
|
7311
7238
|
};
|
|
7312
7239
|
}
|
|
7313
7240
|
function makeCircleNurbs(bk, center, normal, radius, startAngle, endAngle) {
|
|
7314
|
-
const
|
|
7241
|
+
const nLen = Math.sqrt(normal[0] ** 2 + normal[1] ** 2 + normal[2] ** 2);
|
|
7315
7242
|
const nz = [
|
|
7316
|
-
normal[0] /
|
|
7317
|
-
normal[1] /
|
|
7318
|
-
normal[2] /
|
|
7243
|
+
normal[0] / nLen,
|
|
7244
|
+
normal[1] / nLen,
|
|
7245
|
+
normal[2] / nLen
|
|
7319
7246
|
];
|
|
7320
7247
|
const ref = Math.abs(nz[0]) < .9 ? [
|
|
7321
7248
|
1,
|
|
@@ -7326,15 +7253,17 @@ function makeCircleNurbs(bk, center, normal, radius, startAngle, endAngle) {
|
|
|
7326
7253
|
1,
|
|
7327
7254
|
0
|
|
7328
7255
|
];
|
|
7329
|
-
const
|
|
7256
|
+
const xRaw = [
|
|
7330
7257
|
nz[1] * ref[2] - nz[2] * ref[1],
|
|
7331
7258
|
nz[2] * ref[0] - nz[0] * ref[2],
|
|
7332
7259
|
nz[0] * ref[1] - nz[1] * ref[0]
|
|
7333
7260
|
];
|
|
7334
|
-
const xLen = Math.sqrt(
|
|
7335
|
-
xAxis
|
|
7336
|
-
|
|
7337
|
-
|
|
7261
|
+
const xLen = Math.sqrt(xRaw[0] ** 2 + xRaw[1] ** 2 + xRaw[2] ** 2);
|
|
7262
|
+
const xAxis = [
|
|
7263
|
+
xRaw[0] / xLen,
|
|
7264
|
+
xRaw[1] / xLen,
|
|
7265
|
+
xRaw[2] / xLen
|
|
7266
|
+
];
|
|
7338
7267
|
const yAxis = [
|
|
7339
7268
|
nz[1] * xAxis[2] - nz[2] * xAxis[1],
|
|
7340
7269
|
nz[2] * xAxis[0] - nz[0] * xAxis[2],
|
|
@@ -7369,18 +7298,22 @@ function makeCircleNurbs(bk, center, normal, radius, startAngle, endAngle) {
|
|
|
7369
7298
|
const knots = Array(degree + 1).fill(0);
|
|
7370
7299
|
for (let i = 1; i < nSegments; i++) knots.push(i, i);
|
|
7371
7300
|
knots.push(...Array(degree + 1).fill(nSegments));
|
|
7372
|
-
const kMax = knots
|
|
7373
|
-
for (let i = 0; i < knots.length; i++) knots[i] = knots
|
|
7374
|
-
const
|
|
7375
|
-
const
|
|
7376
|
-
|
|
7301
|
+
const kMax = require_vec3.wasmIndex(knots, knots.length - 1);
|
|
7302
|
+
for (let i = 0; i < knots.length; i++) knots[i] = require_vec3.wasmIndex(knots, i) / kMax;
|
|
7303
|
+
const sx = require_vec3.wasmIndex(controlPoints, 0);
|
|
7304
|
+
const sy = require_vec3.wasmIndex(controlPoints, 1);
|
|
7305
|
+
const sz = require_vec3.wasmIndex(controlPoints, 2);
|
|
7306
|
+
const ex = require_vec3.wasmIndex(controlPoints, controlPoints.length - 3);
|
|
7307
|
+
const ey = require_vec3.wasmIndex(controlPoints, controlPoints.length - 2);
|
|
7308
|
+
const ez = require_vec3.wasmIndex(controlPoints, controlPoints.length - 1);
|
|
7309
|
+
return edgeHandle(bk.makeNurbsEdge(sx, sy, sz, ex, ey, ez, degree, knots, controlPoints, weights));
|
|
7377
7310
|
}
|
|
7378
7311
|
function makeEllipseNurbs(bk, center, normal, majorRadius, minorRadius, startAngle, endAngle, xDir) {
|
|
7379
|
-
const
|
|
7312
|
+
const nLen = Math.sqrt(normal[0] ** 2 + normal[1] ** 2 + normal[2] ** 2);
|
|
7380
7313
|
const nz = [
|
|
7381
|
-
normal[0] /
|
|
7382
|
-
normal[1] /
|
|
7383
|
-
normal[2] /
|
|
7314
|
+
normal[0] / nLen,
|
|
7315
|
+
normal[1] / nLen,
|
|
7316
|
+
normal[2] / nLen
|
|
7384
7317
|
];
|
|
7385
7318
|
let xAxis;
|
|
7386
7319
|
if (xDir) {
|
|
@@ -7400,15 +7333,17 @@ function makeEllipseNurbs(bk, center, normal, majorRadius, minorRadius, startAng
|
|
|
7400
7333
|
1,
|
|
7401
7334
|
0
|
|
7402
7335
|
];
|
|
7403
|
-
|
|
7336
|
+
const xRaw = [
|
|
7404
7337
|
nz[1] * ref[2] - nz[2] * ref[1],
|
|
7405
7338
|
nz[2] * ref[0] - nz[0] * ref[2],
|
|
7406
7339
|
nz[0] * ref[1] - nz[1] * ref[0]
|
|
7407
7340
|
];
|
|
7408
|
-
const
|
|
7409
|
-
xAxis
|
|
7410
|
-
|
|
7411
|
-
|
|
7341
|
+
const xLen = Math.sqrt(xRaw[0] ** 2 + xRaw[1] ** 2 + xRaw[2] ** 2);
|
|
7342
|
+
xAxis = [
|
|
7343
|
+
xRaw[0] / xLen,
|
|
7344
|
+
xRaw[1] / xLen,
|
|
7345
|
+
xRaw[2] / xLen
|
|
7346
|
+
];
|
|
7412
7347
|
}
|
|
7413
7348
|
const yAxis = [
|
|
7414
7349
|
nz[1] * xAxis[2] - nz[2] * xAxis[1],
|
|
@@ -7444,11 +7379,15 @@ function makeEllipseNurbs(bk, center, normal, majorRadius, minorRadius, startAng
|
|
|
7444
7379
|
const knots = Array(degree + 1).fill(0);
|
|
7445
7380
|
for (let i = 1; i < nSegments; i++) knots.push(i, i);
|
|
7446
7381
|
knots.push(...Array(degree + 1).fill(nSegments));
|
|
7447
|
-
const kMax = knots
|
|
7448
|
-
for (let i = 0; i < knots.length; i++) knots[i] = knots
|
|
7449
|
-
const
|
|
7450
|
-
const
|
|
7451
|
-
|
|
7382
|
+
const kMax = require_vec3.wasmIndex(knots, knots.length - 1);
|
|
7383
|
+
for (let i = 0; i < knots.length; i++) knots[i] = require_vec3.wasmIndex(knots, i) / kMax;
|
|
7384
|
+
const sx = require_vec3.wasmIndex(controlPoints, 0);
|
|
7385
|
+
const sy = require_vec3.wasmIndex(controlPoints, 1);
|
|
7386
|
+
const sz = require_vec3.wasmIndex(controlPoints, 2);
|
|
7387
|
+
const ex = require_vec3.wasmIndex(controlPoints, controlPoints.length - 3);
|
|
7388
|
+
const ey = require_vec3.wasmIndex(controlPoints, controlPoints.length - 2);
|
|
7389
|
+
const ez = require_vec3.wasmIndex(controlPoints, controlPoints.length - 1);
|
|
7390
|
+
return edgeHandle(bk.makeNurbsEdge(sx, sy, sz, ex, ey, ez, degree, knots, controlPoints, weights));
|
|
7452
7391
|
}
|
|
7453
7392
|
//#endregion
|
|
7454
7393
|
//#region src/kernel/brepkit/booleanOps.ts
|
|
@@ -7485,11 +7424,11 @@ function section(bk, shape, plane, _approximation) {
|
|
|
7485
7424
|
const solidId = isBrepkitHandle(shape) && shape.type === "solid" ? shape.id : unwrap(shape, "solid");
|
|
7486
7425
|
const faceIds = toArray(bk.section(solidId, point[0], point[1], point[2], normal[0], normal[1], normal[2]));
|
|
7487
7426
|
if (faceIds.length === 0) return compoundHandle(bk.makeCompound([]));
|
|
7488
|
-
return wireHandle(bk.getFaceOuterWire(faceIds
|
|
7427
|
+
return wireHandle(bk.getFaceOuterWire(require_vec3.wasmIndex(faceIds, 0)));
|
|
7489
7428
|
}
|
|
7490
7429
|
function fuseAll(bk, shapes, options) {
|
|
7491
7430
|
if (shapes.length === 0) throw new Error("brepkit: fuseAll requires at least one shape");
|
|
7492
|
-
if (shapes.length === 1) return shapes
|
|
7431
|
+
if (shapes.length === 1) return require_vec3.wasmIndex(shapes, 0);
|
|
7493
7432
|
if (bk.compoundFuse) {
|
|
7494
7433
|
const solidIds = [];
|
|
7495
7434
|
for (const shape of shapes) {
|
|
@@ -7507,7 +7446,7 @@ function fuseAll(bk, shapes, options) {
|
|
|
7507
7446
|
else next.push(current[i]);
|
|
7508
7447
|
current = next;
|
|
7509
7448
|
}
|
|
7510
|
-
return current
|
|
7449
|
+
return require_vec3.wasmIndex(current, 0);
|
|
7511
7450
|
}
|
|
7512
7451
|
function cutAll(bk, shape, tools, options) {
|
|
7513
7452
|
if (tools.length === 0) return shape;
|
|
@@ -7586,11 +7525,11 @@ function hull(bk, shapes, _tolerance) {
|
|
|
7586
7525
|
const vertIds = toArray(bk.getSolidVertices(h.id));
|
|
7587
7526
|
for (const vid of vertIds) {
|
|
7588
7527
|
const pos = bk.getVertexPosition(vid);
|
|
7589
|
-
coords.push(pos
|
|
7528
|
+
coords.push(require_vec3.wasmIndex(pos, 0), require_vec3.wasmIndex(pos, 1), require_vec3.wasmIndex(pos, 2));
|
|
7590
7529
|
}
|
|
7591
7530
|
} else if (h.type === "vertex") {
|
|
7592
7531
|
const pos = bk.getVertexPosition(h.id);
|
|
7593
|
-
coords.push(pos
|
|
7532
|
+
coords.push(require_vec3.wasmIndex(pos, 0), require_vec3.wasmIndex(pos, 1), require_vec3.wasmIndex(pos, 2));
|
|
7594
7533
|
}
|
|
7595
7534
|
}
|
|
7596
7535
|
if (coords.length < 12) throw new Error("brepkit: hull requires enough points");
|
|
@@ -7605,14 +7544,14 @@ function hullFromPoints(bk, points, _tolerance) {
|
|
|
7605
7544
|
function buildSolidFromFaces(bk, points, faces, _tolerance) {
|
|
7606
7545
|
const positions = new Float64Array(points.length * 3);
|
|
7607
7546
|
for (let i = 0; i < points.length; i++) {
|
|
7608
|
-
const p = points
|
|
7547
|
+
const p = require_vec3.wasmIndex(points, i);
|
|
7609
7548
|
positions[i * 3] = p.x;
|
|
7610
7549
|
positions[i * 3 + 1] = p.y;
|
|
7611
7550
|
positions[i * 3 + 2] = p.z;
|
|
7612
7551
|
}
|
|
7613
7552
|
const indices = new Uint32Array(faces.length * 3);
|
|
7614
7553
|
for (let i = 0; i < faces.length; i++) {
|
|
7615
|
-
const f = faces
|
|
7554
|
+
const f = require_vec3.wasmIndex(faces, i);
|
|
7616
7555
|
indices[i * 3] = f[0];
|
|
7617
7556
|
indices[i * 3 + 1] = f[1];
|
|
7618
7557
|
indices[i * 3 + 2] = f[2];
|
|
@@ -7910,9 +7849,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
|
|
|
7910
7849
|
let ox = 0, oy = 0, oz = 0;
|
|
7911
7850
|
for (const vid of origVerts) {
|
|
7912
7851
|
const pos = bk.getVertexPosition(vid);
|
|
7913
|
-
ox += pos
|
|
7914
|
-
oy += pos
|
|
7915
|
-
oz += pos
|
|
7852
|
+
ox += require_vec3.wasmIndex(pos, 0);
|
|
7853
|
+
oy += require_vec3.wasmIndex(pos, 1);
|
|
7854
|
+
oz += require_vec3.wasmIndex(pos, 2);
|
|
7916
7855
|
}
|
|
7917
7856
|
const n = origVerts.length;
|
|
7918
7857
|
ox /= n;
|
|
@@ -7926,9 +7865,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
|
|
|
7926
7865
|
let sx = 0, sy = 0, sz = 0;
|
|
7927
7866
|
for (const svid of sv) {
|
|
7928
7867
|
const spos = bk.getVertexPosition(svid);
|
|
7929
|
-
sx += spos
|
|
7930
|
-
sy += spos
|
|
7931
|
-
sz += spos
|
|
7868
|
+
sx += require_vec3.wasmIndex(spos, 0);
|
|
7869
|
+
sy += require_vec3.wasmIndex(spos, 1);
|
|
7870
|
+
sz += require_vec3.wasmIndex(spos, 2);
|
|
7932
7871
|
}
|
|
7933
7872
|
const sn = sv.length;
|
|
7934
7873
|
sx /= sn;
|
|
@@ -7979,12 +7918,12 @@ function offsetWire2D(bk, wire, offsetVal, _joinType) {
|
|
|
7979
7918
|
const coords2d = [];
|
|
7980
7919
|
for (const edge of edges) {
|
|
7981
7920
|
const verts = bk.getEdgeVertices(unwrap(edge, "edge"));
|
|
7982
|
-
coords2d.push(verts
|
|
7921
|
+
coords2d.push(require_vec3.wasmIndex(verts, 0), require_vec3.wasmIndex(verts, 1));
|
|
7983
7922
|
}
|
|
7984
7923
|
if (coords2d.length < 6) return wire;
|
|
7985
7924
|
const result = bk.offsetPolygon2d(coords2d, offsetVal, 1e-10);
|
|
7986
7925
|
const coords3d = [];
|
|
7987
|
-
for (let i = 0; i < result.length; i += 2) coords3d.push(result
|
|
7926
|
+
for (let i = 0; i < result.length; i += 2) coords3d.push(require_vec3.wasmIndex(result, i), require_vec3.wasmIndex(result, i + 1), 0);
|
|
7988
7927
|
return wireHandle(bk.makePolygonWire(coords3d));
|
|
7989
7928
|
}
|
|
7990
7929
|
function simplify(bk, shape) {
|
|
@@ -8121,8 +8060,8 @@ function exportSTEP(bk, shapes) {
|
|
|
8121
8060
|
}
|
|
8122
8061
|
function exportSTL(bk, shape, binary) {
|
|
8123
8062
|
const solidIds = unwrapSolidsForExport(bk, shape, "exportSTL");
|
|
8124
|
-
if (binary) return bk.exportStl(solidIds
|
|
8125
|
-
const bytes = bk.exportStlAscii(solidIds
|
|
8063
|
+
if (binary) return bk.exportStl(require_vec3.wasmIndex(solidIds, 0), DEFAULT_DEFLECTION).buffer;
|
|
8064
|
+
const bytes = bk.exportStlAscii(require_vec3.wasmIndex(solidIds, 0), DEFAULT_DEFLECTION);
|
|
8126
8065
|
return new TextDecoder().decode(bytes);
|
|
8127
8066
|
}
|
|
8128
8067
|
function importSTEP(bk, data) {
|
|
@@ -8232,8 +8171,8 @@ function meshEdges(bk, shape, tolerance, angularTolerance) {
|
|
|
8232
8171
|
const edgeCount = edgeLines.edgeCount;
|
|
8233
8172
|
const edgeGroups = [];
|
|
8234
8173
|
for (let i = 0; i < edgeCount; i++) {
|
|
8235
|
-
const startIdx = offsets
|
|
8236
|
-
const pointCount = ((i + 1 < edgeCount ? offsets
|
|
8174
|
+
const startIdx = require_vec3.wasmIndex(offsets, i);
|
|
8175
|
+
const pointCount = ((i + 1 < edgeCount ? require_vec3.wasmIndex(offsets, i + 1) : positions.length) - startIdx) / 3;
|
|
8237
8176
|
edgeGroups.push({
|
|
8238
8177
|
start: startIdx / 3,
|
|
8239
8178
|
count: pointCount,
|
|
@@ -8272,8 +8211,8 @@ function meshSolidGrouped(bk, solidId, deflection, includeUVs) {
|
|
|
8272
8211
|
if (groupCount !== faceIds.length) throw new Error(`faceOffsets/faceIds length mismatch: ${groupCount} groups vs ${faceIds.length} faces`);
|
|
8273
8212
|
const faceGroups = [];
|
|
8274
8213
|
for (let i = 0; i < data.faceOffsets.length - 1; i++) {
|
|
8275
|
-
const start = data.faceOffsets
|
|
8276
|
-
const count = data.faceOffsets
|
|
8214
|
+
const start = require_vec3.wasmIndex(data.faceOffsets, i);
|
|
8215
|
+
const count = require_vec3.wasmIndex(data.faceOffsets, i + 1) - start;
|
|
8277
8216
|
if (count === 0) continue;
|
|
8278
8217
|
faceGroups.push({
|
|
8279
8218
|
start,
|
|
@@ -8392,28 +8331,22 @@ function length(bk, shape) {
|
|
|
8392
8331
|
if (h.type === "wire") return bk.wireLength(h.id);
|
|
8393
8332
|
throw new Error("brepkit: length() requires an edge, wire, or face");
|
|
8394
8333
|
}
|
|
8334
|
+
function edgeMidpoint(bk, edgeId) {
|
|
8335
|
+
const v = bk.getEdgeVertices(edgeId);
|
|
8336
|
+
return [
|
|
8337
|
+
(require_vec3.wasmIndex(v, 0) + require_vec3.wasmIndex(v, 3)) / 2,
|
|
8338
|
+
(require_vec3.wasmIndex(v, 1) + require_vec3.wasmIndex(v, 4)) / 2,
|
|
8339
|
+
(require_vec3.wasmIndex(v, 2) + require_vec3.wasmIndex(v, 5)) / 2
|
|
8340
|
+
];
|
|
8341
|
+
}
|
|
8395
8342
|
function centerOfMass(bk, shape) {
|
|
8396
8343
|
const h = shape;
|
|
8397
|
-
if (h.type === "solid")
|
|
8398
|
-
const result = bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION);
|
|
8399
|
-
return [
|
|
8400
|
-
result[0],
|
|
8401
|
-
result[1],
|
|
8402
|
-
result[2]
|
|
8403
|
-
];
|
|
8404
|
-
}
|
|
8344
|
+
if (h.type === "solid") return require_vec3.vec3At(bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION));
|
|
8405
8345
|
if (h.type === "face") {
|
|
8406
8346
|
const domain = uvBounds(bk, shape);
|
|
8407
8347
|
return pointOnSurface(bk, shape, (domain.uMin + domain.uMax) / 2, (domain.vMin + domain.vMax) / 2);
|
|
8408
8348
|
}
|
|
8409
|
-
if (h.type === "edge")
|
|
8410
|
-
const verts = bk.getEdgeVertices(h.id);
|
|
8411
|
-
return [
|
|
8412
|
-
(verts[0] + verts[3]) / 2,
|
|
8413
|
-
(verts[1] + verts[4]) / 2,
|
|
8414
|
-
(verts[2] + verts[5]) / 2
|
|
8415
|
-
];
|
|
8416
|
-
}
|
|
8349
|
+
if (h.type === "edge") return edgeMidpoint(bk, h.id);
|
|
8417
8350
|
if (h.type === "vertex") return vertexPosition(bk, shape);
|
|
8418
8351
|
const vertices = iterShapes(bk, shape, "vertex");
|
|
8419
8352
|
if (vertices.length > 0) {
|
|
@@ -8438,14 +8371,7 @@ function centerOfMass(bk, shape) {
|
|
|
8438
8371
|
}
|
|
8439
8372
|
function linearCenterOfMass(bk, shape) {
|
|
8440
8373
|
const h = shape;
|
|
8441
|
-
if (h.type === "edge")
|
|
8442
|
-
const verts = bk.getEdgeVertices(h.id);
|
|
8443
|
-
return [
|
|
8444
|
-
(verts[0] + verts[3]) / 2,
|
|
8445
|
-
(verts[1] + verts[4]) / 2,
|
|
8446
|
-
(verts[2] + verts[5]) / 2
|
|
8447
|
-
];
|
|
8448
|
-
}
|
|
8374
|
+
if (h.type === "edge") return edgeMidpoint(bk, h.id);
|
|
8449
8375
|
return centerOfMass(bk, shape);
|
|
8450
8376
|
}
|
|
8451
8377
|
function boundingBox(bk, shape) {
|
|
@@ -8453,16 +8379,8 @@ function boundingBox(bk, shape) {
|
|
|
8453
8379
|
if (h.type === "solid") {
|
|
8454
8380
|
const bb = bk.boundingBox(unwrap(shape));
|
|
8455
8381
|
return {
|
|
8456
|
-
min:
|
|
8457
|
-
|
|
8458
|
-
bb[1],
|
|
8459
|
-
bb[2]
|
|
8460
|
-
],
|
|
8461
|
-
max: [
|
|
8462
|
-
bb[3],
|
|
8463
|
-
bb[4],
|
|
8464
|
-
bb[5]
|
|
8465
|
-
]
|
|
8382
|
+
min: require_vec3.vec3At(bb, 0),
|
|
8383
|
+
max: require_vec3.vec3At(bb, 3)
|
|
8466
8384
|
};
|
|
8467
8385
|
}
|
|
8468
8386
|
if (h.type === "vertex") {
|
|
@@ -8516,85 +8434,28 @@ function distance(bk, shape1, shape2) {
|
|
|
8516
8434
|
if (h1.type === "solid" && h2.type === "solid") {
|
|
8517
8435
|
const buf = bk.solidToSolidDistance(h1.id, h2.id);
|
|
8518
8436
|
return {
|
|
8519
|
-
value: buf
|
|
8520
|
-
point1:
|
|
8521
|
-
|
|
8522
|
-
buf[2],
|
|
8523
|
-
buf[3]
|
|
8524
|
-
],
|
|
8525
|
-
point2: [
|
|
8526
|
-
buf[4],
|
|
8527
|
-
buf[5],
|
|
8528
|
-
buf[6]
|
|
8529
|
-
]
|
|
8530
|
-
};
|
|
8531
|
-
}
|
|
8532
|
-
if (h1.type === "vertex" && h2.type === "solid") {
|
|
8533
|
-
const pos = bk.getVertexPosition(h1.id);
|
|
8534
|
-
const result = bk.pointToSolidDistance(pos[0], pos[1], pos[2], h2.id);
|
|
8535
|
-
return {
|
|
8536
|
-
value: result[0],
|
|
8537
|
-
point1: [
|
|
8538
|
-
pos[0],
|
|
8539
|
-
pos[1],
|
|
8540
|
-
pos[2]
|
|
8541
|
-
],
|
|
8542
|
-
point2: [
|
|
8543
|
-
result[1],
|
|
8544
|
-
result[2],
|
|
8545
|
-
result[3]
|
|
8546
|
-
]
|
|
8437
|
+
value: require_vec3.wasmIndex(buf, 0),
|
|
8438
|
+
point1: require_vec3.vec3At(buf, 1),
|
|
8439
|
+
point2: require_vec3.vec3At(buf, 4)
|
|
8547
8440
|
};
|
|
8548
8441
|
}
|
|
8549
|
-
if (h1.type === "vertex" && h2.type === "face") {
|
|
8550
|
-
const
|
|
8551
|
-
const result = bk.pointToFaceDistance(
|
|
8442
|
+
if (h1.type === "vertex" && (h2.type === "solid" || h2.type === "face" || h2.type === "edge")) {
|
|
8443
|
+
const point1 = require_vec3.vec3At(bk.getVertexPosition(h1.id));
|
|
8444
|
+
const result = h2.type === "solid" ? bk.pointToSolidDistance(point1[0], point1[1], point1[2], h2.id) : h2.type === "face" ? bk.pointToFaceDistance(point1[0], point1[1], point1[2], h2.id) : bk.pointToEdgeDistance(point1[0], point1[1], point1[2], h2.id);
|
|
8552
8445
|
return {
|
|
8553
|
-
value: result
|
|
8554
|
-
point1
|
|
8555
|
-
|
|
8556
|
-
pos[1],
|
|
8557
|
-
pos[2]
|
|
8558
|
-
],
|
|
8559
|
-
point2: [
|
|
8560
|
-
result[1],
|
|
8561
|
-
result[2],
|
|
8562
|
-
result[3]
|
|
8563
|
-
]
|
|
8564
|
-
};
|
|
8565
|
-
}
|
|
8566
|
-
if (h1.type === "vertex" && h2.type === "edge") {
|
|
8567
|
-
const pos = bk.getVertexPosition(h1.id);
|
|
8568
|
-
const result = bk.pointToEdgeDistance(pos[0], pos[1], pos[2], h2.id);
|
|
8569
|
-
return {
|
|
8570
|
-
value: result[0],
|
|
8571
|
-
point1: [
|
|
8572
|
-
pos[0],
|
|
8573
|
-
pos[1],
|
|
8574
|
-
pos[2]
|
|
8575
|
-
],
|
|
8576
|
-
point2: [
|
|
8577
|
-
result[1],
|
|
8578
|
-
result[2],
|
|
8579
|
-
result[3]
|
|
8580
|
-
]
|
|
8446
|
+
value: require_vec3.wasmIndex(result, 0),
|
|
8447
|
+
point1,
|
|
8448
|
+
point2: require_vec3.vec3At(result, 1)
|
|
8581
8449
|
};
|
|
8582
8450
|
}
|
|
8583
8451
|
const getPos = (s) => {
|
|
8584
|
-
if (s.type === "vertex")
|
|
8585
|
-
const p = bk.getVertexPosition(s.id);
|
|
8586
|
-
return [
|
|
8587
|
-
p[0],
|
|
8588
|
-
p[1],
|
|
8589
|
-
p[2]
|
|
8590
|
-
];
|
|
8591
|
-
}
|
|
8452
|
+
if (s.type === "vertex") return require_vec3.vec3At(bk.getVertexPosition(s.id));
|
|
8592
8453
|
if (s.type === "solid") {
|
|
8593
8454
|
const bb = bk.boundingBox(s.id);
|
|
8594
8455
|
return [
|
|
8595
|
-
(bb
|
|
8596
|
-
(bb
|
|
8597
|
-
(bb
|
|
8456
|
+
(require_vec3.wasmIndex(bb, 0) + require_vec3.wasmIndex(bb, 3)) / 2,
|
|
8457
|
+
(require_vec3.wasmIndex(bb, 1) + require_vec3.wasmIndex(bb, 4)) / 2,
|
|
8458
|
+
(require_vec3.wasmIndex(bb, 2) + require_vec3.wasmIndex(bb, 5)) / 2
|
|
8598
8459
|
];
|
|
8599
8460
|
}
|
|
8600
8461
|
return [
|
|
@@ -8618,23 +8479,15 @@ function surfaceCurvature(bk, face, u, v) {
|
|
|
8618
8479
|
const fid = unwrap(face, "face");
|
|
8619
8480
|
const data = bk.measureCurvatureAtSurface(fid, u, v);
|
|
8620
8481
|
if (data.length < 8) throw new Error(`brepkit: measureCurvatureAtSurface returned ${data.length} values, expected 8`);
|
|
8621
|
-
const k1 = data
|
|
8622
|
-
const k2 = data
|
|
8482
|
+
const k1 = require_vec3.wasmIndex(data, 0);
|
|
8483
|
+
const k2 = require_vec3.wasmIndex(data, 1);
|
|
8623
8484
|
return {
|
|
8624
8485
|
gaussian: k1 * k2,
|
|
8625
8486
|
mean: (k1 + k2) / 2,
|
|
8626
8487
|
max: Math.max(k1, k2),
|
|
8627
8488
|
min: Math.min(k1, k2),
|
|
8628
|
-
maxDirection:
|
|
8629
|
-
|
|
8630
|
-
data[3],
|
|
8631
|
-
data[4]
|
|
8632
|
-
],
|
|
8633
|
-
minDirection: [
|
|
8634
|
-
data[5],
|
|
8635
|
-
data[6],
|
|
8636
|
-
data[7]
|
|
8637
|
-
]
|
|
8489
|
+
maxDirection: require_vec3.vec3At(data, 2),
|
|
8490
|
+
minDirection: require_vec3.vec3At(data, 5)
|
|
8638
8491
|
};
|
|
8639
8492
|
}
|
|
8640
8493
|
function surfaceCenterOfMass(bk, face) {
|
|
@@ -8643,12 +8496,23 @@ function surfaceCenterOfMass(bk, face) {
|
|
|
8643
8496
|
const idx = mesh.indices;
|
|
8644
8497
|
let cx = 0, cy = 0, cz = 0, totalArea = 0;
|
|
8645
8498
|
for (let t = 0; t < idx.length; t += 3) {
|
|
8646
|
-
const i0 = idx
|
|
8647
|
-
const
|
|
8648
|
-
const
|
|
8649
|
-
const
|
|
8650
|
-
const
|
|
8651
|
-
const
|
|
8499
|
+
const i0 = require_vec3.wasmIndex(idx, t) * 3;
|
|
8500
|
+
const i1 = require_vec3.wasmIndex(idx, t + 1) * 3;
|
|
8501
|
+
const i2 = require_vec3.wasmIndex(idx, t + 2) * 3;
|
|
8502
|
+
const p0x = require_vec3.wasmIndex(pos, i0);
|
|
8503
|
+
const p0y = require_vec3.wasmIndex(pos, i0 + 1);
|
|
8504
|
+
const p0z = require_vec3.wasmIndex(pos, i0 + 2);
|
|
8505
|
+
const p1x = require_vec3.wasmIndex(pos, i1);
|
|
8506
|
+
const p1y = require_vec3.wasmIndex(pos, i1 + 1);
|
|
8507
|
+
const p1z = require_vec3.wasmIndex(pos, i1 + 2);
|
|
8508
|
+
const p2x = require_vec3.wasmIndex(pos, i2);
|
|
8509
|
+
const p2y = require_vec3.wasmIndex(pos, i2 + 1);
|
|
8510
|
+
const p2z = require_vec3.wasmIndex(pos, i2 + 2);
|
|
8511
|
+
const tcx = (p0x + p1x + p2x) / 3;
|
|
8512
|
+
const tcy = (p0y + p1y + p2y) / 3;
|
|
8513
|
+
const tcz = (p0z + p1z + p2z) / 3;
|
|
8514
|
+
const ux = p1x - p0x, uy = p1y - p0y, uz = p1z - p0z;
|
|
8515
|
+
const vx = p2x - p0x, vy = p2y - p0y, vz = p2z - p0z;
|
|
8652
8516
|
const faceArea = .5 * Math.sqrt((uy * vz - uz * vy) ** 2 + (uz * vx - ux * vz) ** 2 + (ux * vy - uy * vx) ** 2);
|
|
8653
8517
|
cx += tcx * faceArea;
|
|
8654
8518
|
cy += tcy * faceArea;
|
|
@@ -8736,9 +8600,9 @@ function faceCentroidById(bk, faceId) {
|
|
|
8736
8600
|
let cz = 0;
|
|
8737
8601
|
const nVerts = pos.length / 3;
|
|
8738
8602
|
for (let i = 0; i < pos.length; i += 3) {
|
|
8739
|
-
cx += pos
|
|
8740
|
-
cy += pos
|
|
8741
|
-
cz += pos
|
|
8603
|
+
cx += require_vec3.wasmIndex(pos, i);
|
|
8604
|
+
cy += require_vec3.wasmIndex(pos, i + 1);
|
|
8605
|
+
cz += require_vec3.wasmIndex(pos, i + 2);
|
|
8742
8606
|
}
|
|
8743
8607
|
return [
|
|
8744
8608
|
cx / nVerts,
|
|
@@ -8764,7 +8628,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8764
8628
|
const hashCount = Math.min(inputFaceIds.length, inputFaceHashes.length);
|
|
8765
8629
|
const inputSigs = [];
|
|
8766
8630
|
for (let i = 0; i < hashCount; i++) {
|
|
8767
|
-
const fid = inputFaceIds
|
|
8631
|
+
const fid = require_vec3.wasmIndex(inputFaceIds, i);
|
|
8768
8632
|
try {
|
|
8769
8633
|
const normal = bk.getFaceNormal(fid);
|
|
8770
8634
|
const centroid = faceCentroidById(bk, fid);
|
|
@@ -8812,7 +8676,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8812
8676
|
let bestScore = -Infinity;
|
|
8813
8677
|
let bestIdx = -1;
|
|
8814
8678
|
for (let i = 0; i < inputSigs.length; i++) {
|
|
8815
|
-
const inp = inputSigs
|
|
8679
|
+
const inp = require_vec3.wasmIndex(inputSigs, i);
|
|
8816
8680
|
const dot = (out.normal[0] ?? 0) * (inp.normal[0] ?? 0) + (out.normal[1] ?? 0) * (inp.normal[1] ?? 0) + (out.normal[2] ?? 0) * (inp.normal[2] ?? 0);
|
|
8817
8681
|
if (dot < NORMAL_THRESHOLD) continue;
|
|
8818
8682
|
const distSq = centroidDistSq(out.centroid, inp.centroid);
|
|
@@ -8824,7 +8688,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8824
8688
|
}
|
|
8825
8689
|
}
|
|
8826
8690
|
if (bestIdx >= 0) {
|
|
8827
|
-
const bestInput = inputSigs
|
|
8691
|
+
const bestInput = require_vec3.wasmIndex(inputSigs, bestIdx);
|
|
8828
8692
|
const existing = modified.get(bestInput.hash) ?? [];
|
|
8829
8693
|
existing.push(out.hash);
|
|
8830
8694
|
modified.set(bestInput.hash, existing);
|
|
@@ -8846,7 +8710,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8846
8710
|
}
|
|
8847
8711
|
}
|
|
8848
8712
|
}
|
|
8849
|
-
for (let i = 0; i < inputSigs.length; i++) if (!matchedInputIndices.has(i)) deleted.add(inputSigs
|
|
8713
|
+
for (let i = 0; i < inputSigs.length; i++) if (!matchedInputIndices.has(i)) deleted.add(require_vec3.wasmIndex(inputSigs, i).hash);
|
|
8850
8714
|
}
|
|
8851
8715
|
/**
|
|
8852
8716
|
* Build a ShapeEvolution by comparing input face hashes to output face hashes.
|
|
@@ -8863,7 +8727,7 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
|
|
|
8863
8727
|
if (h.type === "solid") {
|
|
8864
8728
|
const outputFaces = toArray(bk.getSolidFaces(h.id));
|
|
8865
8729
|
const outputHashes = outputFaces.map((fid) => fid % hashUpperBound);
|
|
8866
|
-
if (isTransform) for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(inputFaceHashes
|
|
8730
|
+
if (isTransform) for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(require_vec3.wasmIndex(inputFaceHashes, i), [require_vec3.wasmIndex(outputHashes, i)]);
|
|
8867
8731
|
else {
|
|
8868
8732
|
const inputSet = new Set(inputFaceHashes);
|
|
8869
8733
|
let hasOverlap = false;
|
|
@@ -8875,12 +8739,12 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
|
|
|
8875
8739
|
const outputSet = new Set(outputHashes);
|
|
8876
8740
|
for (const hash of outputHashes) if (inputSet.has(hash)) modified.set(hash, [hash]);
|
|
8877
8741
|
const newFaces = outputHashes.filter((fh) => !inputSet.has(fh));
|
|
8878
|
-
if (newFaces.length > 0 && inputFaceHashes.length > 0) generated.set(inputFaceHashes
|
|
8742
|
+
if (newFaces.length > 0 && inputFaceHashes.length > 0) generated.set(require_vec3.wasmIndex(inputFaceHashes, 0), newFaces);
|
|
8879
8743
|
for (const hash of inputFaceHashes) if (!outputSet.has(hash)) deleted.add(hash);
|
|
8880
8744
|
} else if (originalShape) matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaces, hashUpperBound, modified, generated, deleted);
|
|
8881
8745
|
else {
|
|
8882
|
-
for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(inputFaceHashes
|
|
8883
|
-
if (outputHashes.length > inputFaceHashes.length && inputFaceHashes.length > 0) generated.set(inputFaceHashes
|
|
8746
|
+
for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(require_vec3.wasmIndex(inputFaceHashes, i), [require_vec3.wasmIndex(outputHashes, i)]);
|
|
8747
|
+
if (outputHashes.length > inputFaceHashes.length && inputFaceHashes.length > 0) generated.set(require_vec3.wasmIndex(inputFaceHashes, 0), outputHashes.slice(inputFaceHashes.length));
|
|
8884
8748
|
}
|
|
8885
8749
|
}
|
|
8886
8750
|
}
|
|
@@ -9282,7 +9146,7 @@ function createAffinityGTrsf2d(ox, oy, dx, dy, ratio) {
|
|
|
9282
9146
|
0,
|
|
9283
9147
|
1
|
|
9284
9148
|
];
|
|
9285
|
-
return _gtrsf(m, ox - m
|
|
9149
|
+
return _gtrsf(m, ox - require_vec3.wasmIndex(m, 0) * ox - require_vec3.wasmIndex(m, 1) * oy, oy - require_vec3.wasmIndex(m, 3) * ox - require_vec3.wasmIndex(m, 4) * oy);
|
|
9286
9150
|
}
|
|
9287
9151
|
function createTranslationGTrsf2d(dx, dy) {
|
|
9288
9152
|
return _gtrsf([
|
|
@@ -9313,7 +9177,7 @@ function createMirrorGTrsf2d(cx, cy, mode, ox, oy, dx, dy) {
|
|
|
9313
9177
|
1
|
|
9314
9178
|
];
|
|
9315
9179
|
const px = ox ?? cx, py = oy ?? cy;
|
|
9316
|
-
return _gtrsf(m, px - m
|
|
9180
|
+
return _gtrsf(m, px - require_vec3.wasmIndex(m, 0) * px - require_vec3.wasmIndex(m, 1) * py, py - require_vec3.wasmIndex(m, 3) * px - require_vec3.wasmIndex(m, 4) * py);
|
|
9317
9181
|
}
|
|
9318
9182
|
return _gtrsf([
|
|
9319
9183
|
-1,
|
|
@@ -9360,21 +9224,23 @@ function setGTrsf2dTranslationPart(gtrsf, dx, dy) {
|
|
|
9360
9224
|
}
|
|
9361
9225
|
function multiplyGTrsf2d(base, other) {
|
|
9362
9226
|
const a = base.m, b = other.m;
|
|
9227
|
+
const ai = (i) => require_vec3.wasmIndex(a, i);
|
|
9228
|
+
const bi = (i) => require_vec3.wasmIndex(b, i);
|
|
9363
9229
|
base.m = [
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9230
|
+
ai(0) * bi(0) + ai(1) * bi(3) + ai(2) * bi(6),
|
|
9231
|
+
ai(0) * bi(1) + ai(1) * bi(4) + ai(2) * bi(7),
|
|
9232
|
+
ai(0) * bi(2) + ai(1) * bi(5) + ai(2) * bi(8),
|
|
9233
|
+
ai(3) * bi(0) + ai(4) * bi(3) + ai(5) * bi(6),
|
|
9234
|
+
ai(3) * bi(1) + ai(4) * bi(4) + ai(5) * bi(7),
|
|
9235
|
+
ai(3) * bi(2) + ai(4) * bi(5) + ai(5) * bi(8),
|
|
9236
|
+
ai(6) * bi(0) + ai(7) * bi(3) + ai(8) * bi(6),
|
|
9237
|
+
ai(6) * bi(1) + ai(7) * bi(4) + ai(8) * bi(7),
|
|
9238
|
+
ai(6) * bi(2) + ai(7) * bi(5) + ai(8) * bi(8)
|
|
9373
9239
|
];
|
|
9374
9240
|
const oldTx = base.tx, oldTy = base.ty;
|
|
9375
9241
|
const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
|
|
9376
|
-
base.tx =
|
|
9377
|
-
base.ty =
|
|
9242
|
+
base.tx = ai(0) * otx + ai(1) * oty + oldTx;
|
|
9243
|
+
base.ty = ai(3) * otx + ai(4) * oty + oldTy;
|
|
9378
9244
|
}
|
|
9379
9245
|
function transformCurve2dGeneral(curve, gtrsf) {
|
|
9380
9246
|
const c = c2d(curve);
|
|
@@ -9390,14 +9256,15 @@ function transformCurve2dGeneral(curve, gtrsf) {
|
|
|
9390
9256
|
1
|
|
9391
9257
|
];
|
|
9392
9258
|
const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
|
|
9393
|
-
|
|
9259
|
+
const m0 = require_vec3.wasmIndex(m, 0), m1 = require_vec3.wasmIndex(m, 1), m3 = require_vec3.wasmIndex(m, 3), m4 = require_vec3.wasmIndex(m, 4);
|
|
9260
|
+
if (Math.abs(m0 - 1) < 1e-12 && Math.abs(m4 - 1) < 1e-12 && Math.abs(m1) < 1e-12 && Math.abs(m3) < 1e-12) return require_occtWasmAdapter.translateCurve2d(c, tx, ty);
|
|
9394
9261
|
const bounds = require_occtWasmAdapter.curveBounds(c);
|
|
9395
9262
|
const N = 20;
|
|
9396
9263
|
const pts = [];
|
|
9397
9264
|
for (let i = 0; i <= N; i++) {
|
|
9398
9265
|
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
9399
9266
|
const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
|
|
9400
|
-
pts.push([
|
|
9267
|
+
pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
|
|
9401
9268
|
}
|
|
9402
9269
|
return require_occtWasmAdapter.makeBezier2d(pts);
|
|
9403
9270
|
}
|
|
@@ -9531,8 +9398,8 @@ function approximateCurve2dAsBSpline(curve, tol, cont, maxSeg) {
|
|
|
9531
9398
|
for (let i = 0; i < N; i++) {
|
|
9532
9399
|
const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / N;
|
|
9533
9400
|
const [ex, ey] = require_occtWasmAdapter.evaluateCurve2d(c, tMid);
|
|
9534
|
-
const p0 = poles
|
|
9535
|
-
const p1 = poles
|
|
9401
|
+
const p0 = require_vec3.wasmIndex(poles, i);
|
|
9402
|
+
const p1 = require_vec3.wasmIndex(poles, i + 1);
|
|
9536
9403
|
const mx = (p0[0] + p1[0]) / 2;
|
|
9537
9404
|
const my = (p0[1] + p1[1]) / 2;
|
|
9538
9405
|
const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
|
|
@@ -9558,8 +9425,8 @@ function decomposeBSpline2dToBeziers(curve) {
|
|
|
9558
9425
|
];
|
|
9559
9426
|
const result = [];
|
|
9560
9427
|
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
9561
|
-
const t0 = breakpoints
|
|
9562
|
-
const t1 = breakpoints
|
|
9428
|
+
const t0 = require_vec3.wasmIndex(breakpoints, i);
|
|
9429
|
+
const t1 = require_vec3.wasmIndex(breakpoints, i + 1);
|
|
9563
9430
|
const span = t1 - t0;
|
|
9564
9431
|
if (span < 1e-15) continue;
|
|
9565
9432
|
const p0 = require_occtWasmAdapter.evaluateCurve2d(c, t0);
|
|
@@ -9710,13 +9577,13 @@ function liftCurve2dToPlane(bk, curve, origin, planeZ, planeX) {
|
|
|
9710
9577
|
const [eu, ev] = require_occtWasmAdapter.evaluateCurve2d(c, bounds.first + (seg + 1) * segmentSpan);
|
|
9711
9578
|
edgeIds.push(bk.makeCircleArc3d(...lift(su, sv), ...lift(eu, ev), ...center3d, ...axis));
|
|
9712
9579
|
}
|
|
9713
|
-
if (edgeIds.length === 1) return edgeHandle(edgeIds
|
|
9580
|
+
if (edgeIds.length === 1) return edgeHandle(require_vec3.wasmIndex(edgeIds, 0));
|
|
9714
9581
|
return wireHandle(bk.makeWire(edgeIds, false));
|
|
9715
9582
|
}
|
|
9716
9583
|
}
|
|
9717
9584
|
if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
|
|
9718
9585
|
const points3d = c.poles.map(([u, v]) => lift(u, v));
|
|
9719
|
-
if (points3d.length === 2) return makeLineEdge(bk, points3d
|
|
9586
|
+
if (points3d.length === 2) return makeLineEdge(bk, require_vec3.wasmIndex(points3d, 0), require_vec3.wasmIndex(points3d, 1));
|
|
9720
9587
|
const degree = Math.min(3, points3d.length - 1);
|
|
9721
9588
|
const coords = points3d.flatMap(([px, py, pz]) => [
|
|
9722
9589
|
px,
|
|
@@ -9745,58 +9612,40 @@ function buildEdgeOnSurface(bk, curve, surface) {
|
|
|
9745
9612
|
for (let i = 0; i <= N; i++) {
|
|
9746
9613
|
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
9747
9614
|
const [u, v] = require_occtWasmAdapter.evaluateCurve2d(c, t);
|
|
9748
|
-
|
|
9749
|
-
points.push([
|
|
9750
|
-
p[0],
|
|
9751
|
-
p[1],
|
|
9752
|
-
p[2]
|
|
9753
|
-
]);
|
|
9615
|
+
points.push(require_vec3.vec3At(bk.evaluateSurface(fid, u, v)));
|
|
9754
9616
|
}
|
|
9755
9617
|
return interpolatePoints(bk, points);
|
|
9756
9618
|
}
|
|
9757
9619
|
function extractSurfaceFromFace(face) {
|
|
9758
9620
|
return face;
|
|
9759
9621
|
}
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
const MAX_N = 80;
|
|
9768
|
-
const REFINE_THRESHOLD = .05;
|
|
9769
|
-
const tValues = [];
|
|
9770
|
-
for (let i = 0; i <= BASE_N; i++) tValues.push(tMin + (tMax - tMin) * i / BASE_N);
|
|
9771
|
-
const evaluateUV = (t) => {
|
|
9772
|
-
const pt = bk.evaluateEdgeCurve(eid, t);
|
|
9773
|
-
const uv = bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
|
|
9774
|
-
return [uv[0], uv[1]];
|
|
9775
|
-
};
|
|
9776
|
-
const uvSamples = tValues.map((t) => ({
|
|
9777
|
-
t,
|
|
9778
|
-
uv: evaluateUV(t)
|
|
9779
|
-
}));
|
|
9622
|
+
/**
|
|
9623
|
+
* Adaptively refine a UV sample list by inserting midpoints whenever the
|
|
9624
|
+
* sampled UV midpoint deviates from the linear interpolation of its
|
|
9625
|
+
* neighbors by more than `threshold`. Stops at `maxSamples` or when no
|
|
9626
|
+
* pair exceeds the threshold; cap of 3 refinement passes overall.
|
|
9627
|
+
*/
|
|
9628
|
+
function refineUVSamples(uvSamples, evaluateUV, maxSamples, threshold) {
|
|
9780
9629
|
let refinements = 0;
|
|
9781
|
-
while (uvSamples.length <
|
|
9630
|
+
while (uvSamples.length < maxSamples) {
|
|
9782
9631
|
const insertions = [];
|
|
9783
9632
|
for (let i = 0; i < uvSamples.length - 1; i++) {
|
|
9784
|
-
const a = uvSamples
|
|
9785
|
-
const b = uvSamples
|
|
9633
|
+
const a = require_vec3.wasmIndex(uvSamples, i);
|
|
9634
|
+
const b = require_vec3.wasmIndex(uvSamples, i + 1);
|
|
9786
9635
|
const tMid = (a.t + b.t) / 2;
|
|
9787
9636
|
const uvMid = evaluateUV(tMid);
|
|
9788
9637
|
const interpU = (a.uv[0] + b.uv[0]) / 2;
|
|
9789
9638
|
const interpV = (a.uv[1] + b.uv[1]) / 2;
|
|
9790
|
-
if (Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2) >
|
|
9639
|
+
if (Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2) > threshold) insertions.push({
|
|
9791
9640
|
index: i + 1,
|
|
9792
9641
|
t: tMid,
|
|
9793
9642
|
uv: uvMid
|
|
9794
9643
|
});
|
|
9795
9644
|
}
|
|
9796
9645
|
if (insertions.length === 0) break;
|
|
9797
|
-
let budget =
|
|
9646
|
+
let budget = maxSamples - uvSamples.length;
|
|
9798
9647
|
for (let j = insertions.length - 1; j >= 0 && budget > 0; j--) {
|
|
9799
|
-
const ins = insertions
|
|
9648
|
+
const ins = require_vec3.wasmIndex(insertions, j);
|
|
9800
9649
|
uvSamples.splice(ins.index, 0, {
|
|
9801
9650
|
t: ins.t,
|
|
9802
9651
|
uv: ins.uv
|
|
@@ -9806,13 +9655,35 @@ function extractCurve2dFromEdge(bk, edge, face) {
|
|
|
9806
9655
|
refinements++;
|
|
9807
9656
|
if (refinements > 3) break;
|
|
9808
9657
|
}
|
|
9658
|
+
}
|
|
9659
|
+
function extractCurve2dFromEdge(bk, edge, face) {
|
|
9660
|
+
const eid = unwrap(edge, "edge");
|
|
9661
|
+
const fid = unwrap(face, "face");
|
|
9662
|
+
const params = bk.getEdgeCurveParameters(eid);
|
|
9663
|
+
const tMin = params[0] ?? 0;
|
|
9664
|
+
const tMax = params[1] ?? 1;
|
|
9665
|
+
const BASE_N = 20;
|
|
9666
|
+
const MAX_N = 80;
|
|
9667
|
+
const REFINE_THRESHOLD = .05;
|
|
9668
|
+
const tValues = [];
|
|
9669
|
+
for (let i = 0; i <= BASE_N; i++) tValues.push(tMin + (tMax - tMin) * i / BASE_N);
|
|
9670
|
+
const evaluateUV = (t) => {
|
|
9671
|
+
const pt = bk.evaluateEdgeCurve(eid, t);
|
|
9672
|
+
const uv = bk.projectPointOnSurface(fid, require_vec3.wasmIndex(pt, 0), require_vec3.wasmIndex(pt, 1), require_vec3.wasmIndex(pt, 2));
|
|
9673
|
+
return [require_vec3.wasmIndex(uv, 0), require_vec3.wasmIndex(uv, 1)];
|
|
9674
|
+
};
|
|
9675
|
+
const uvSamples = tValues.map((t) => ({
|
|
9676
|
+
t,
|
|
9677
|
+
uv: evaluateUV(t)
|
|
9678
|
+
}));
|
|
9679
|
+
refineUVSamples(uvSamples, evaluateUV, MAX_N, REFINE_THRESHOLD);
|
|
9809
9680
|
const uvPoints = uvSamples.map((s) => s.uv);
|
|
9810
9681
|
if (uvPoints.length >= 2) return makeBSpline2d(uvPoints);
|
|
9811
9682
|
const verts = bk.getEdgeVertices(eid);
|
|
9812
9683
|
if (verts.length >= 6) {
|
|
9813
|
-
const uv1 = bk.projectPointOnSurface(fid, verts
|
|
9814
|
-
const uv2 = bk.projectPointOnSurface(fid, verts
|
|
9815
|
-
return require_occtWasmAdapter.makeLine2d(uv1
|
|
9684
|
+
const uv1 = bk.projectPointOnSurface(fid, require_vec3.wasmIndex(verts, 0), require_vec3.wasmIndex(verts, 1), require_vec3.wasmIndex(verts, 2));
|
|
9685
|
+
const uv2 = bk.projectPointOnSurface(fid, require_vec3.wasmIndex(verts, 3), require_vec3.wasmIndex(verts, 4), require_vec3.wasmIndex(verts, 5));
|
|
9686
|
+
return require_occtWasmAdapter.makeLine2d(require_vec3.wasmIndex(uv1, 0), require_vec3.wasmIndex(uv1, 1), require_vec3.wasmIndex(uv2, 0), require_vec3.wasmIndex(uv2, 1));
|
|
9816
9687
|
}
|
|
9817
9688
|
throw new Error(`brepkit: extractCurve2dFromEdge: degenerate edge (${verts.length} coords)`);
|
|
9818
9689
|
}
|
|
@@ -9828,13 +9699,14 @@ function fillSurface(bk, wires, _options) {
|
|
|
9828
9699
|
for (const edge of wireEdges) {
|
|
9829
9700
|
const edgeId = unwrap(edge, "edge");
|
|
9830
9701
|
const params = bk.getEdgeCurveParameters(edgeId);
|
|
9831
|
-
const tMin = params
|
|
9702
|
+
const tMin = require_vec3.wasmIndex(params, 0);
|
|
9703
|
+
const tMax = require_vec3.wasmIndex(params, 1);
|
|
9832
9704
|
const N = 10;
|
|
9833
9705
|
const pts = [];
|
|
9834
9706
|
for (let i = 0; i <= N; i++) {
|
|
9835
9707
|
const t = tMin + (tMax - tMin) * i / N;
|
|
9836
9708
|
const p = bk.evaluateEdgeCurve(edgeId, t);
|
|
9837
|
-
pts.push(p
|
|
9709
|
+
pts.push(require_vec3.wasmIndex(p, 0), require_vec3.wasmIndex(p, 1), require_vec3.wasmIndex(p, 2));
|
|
9838
9710
|
}
|
|
9839
9711
|
allCoords.push(...pts);
|
|
9840
9712
|
curveLengths.push(N + 1);
|
|
@@ -10856,7 +10728,7 @@ async function init() {
|
|
|
10856
10728
|
throw new Error("brepjs: no kernel package found. Install one of:\n npm install brepjs-opencascade (recommended)\n npm install brepkit-wasm\n npm install occt-wasm (requires manual registerKernel)");
|
|
10857
10729
|
}
|
|
10858
10730
|
//#endregion
|
|
10859
|
-
//#region \0@oxc-project+runtime@0.
|
|
10731
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/usingCtx.js
|
|
10860
10732
|
function _usingCtx() {
|
|
10861
10733
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
10862
10734
|
var n = Error();
|