brepjs 18.6.0 → 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-CscZ0-wr.cjs → blueprint-C5LxqHCa.cjs} +16 -15
- package/dist/{blueprint-BCoJbaQN.js → blueprint-CBairprN.js} +16 -15
- package/dist/{blueprintFns-DQP4KQHE.cjs → blueprintFns-CwbDuLxf.cjs} +3 -3
- package/dist/{blueprintFns-BZlx6BjG.js → blueprintFns-D8ST0Cf4.js} +3 -3
- package/dist/{boolean2D-JvgjbESt.js → boolean2D-A5u9tJYl.js} +26 -24
- package/dist/{boolean2D-k1AJmCMp.cjs → boolean2D-DxZ3Kwlq.cjs} +26 -24
- package/dist/{booleanFns-DQW4lt7H.cjs → booleanFns-DWQMtFDN.cjs} +9 -9
- package/dist/{booleanFns-D13Pb-NO.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-5BYE2cbd.cjs → cornerFinder-B2CpcVV9.cjs} +3 -3
- package/dist/{cornerFinder-Zg7pf2s0.js → cornerFinder-DGvOt2ab.js} +3 -3
- package/dist/{curveFns-DrT54cm8.cjs → curveFns-B8KJKr8-.cjs} +2 -2
- package/dist/{curveFns-DhqUp0EI.js → curveFns-DZYE3BGO.js} +2 -2
- package/dist/{drawFns-lUXjhTYL.js → drawFns-Bl865kUL.js} +21 -20
- package/dist/{drawFns-DmP2o1oF.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-BtblHdaJ.cjs → extrudeFns-BlJKAnW8.cjs} +3 -3
- package/dist/{extrudeFns-B9bVCt3C.js → extrudeFns-O2s-SFf-.js} +3 -3
- package/dist/{faceFns-22idS-ht.cjs → faceFns-B1H43mZ_.cjs} +3 -3
- package/dist/{faceFns-NbWd8-iR.js → faceFns-acz86gqR.js} +3 -3
- package/dist/{helpers-BpXNcxuJ.cjs → helpers-C3smxDtp.cjs} +8 -8
- package/dist/{helpers-S_Ht6gwX.js → helpers-DL1f3xp0.js} +8 -8
- package/dist/{historyFns-B01hrkcJ.js → historyFns-CD9qXw5j.js} +6 -6
- package/dist/{historyFns-RHO-QvEZ.cjs → historyFns-DBdWeo7Y.cjs} +6 -6
- package/dist/{importFns-CG49lyTm.cjs → importFns-5tcN3-fK.cjs} +11 -19
- package/dist/{importFns-C0tUyeiW.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/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-C751QGI1.cjs → measureFns-CHmy_Inq.cjs} +3 -3
- package/dist/{measureFns-B8C85hbT.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-BgvsA-xA.js → meshFns-BkY1RAoC.js} +3 -3
- package/dist/{meshFns-Cdhtbrhm.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-BLxaJ40A.cjs → primitiveFns-DwhN--zB.cjs} +7 -7
- package/dist/{primitiveFns-fR9sWOEb.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-183zCtMc.cjs → shapeFns-CObBAJoQ.cjs} +4 -4
- package/dist/{shapeFns-2X3VOi1a.js → shapeFns-DThjHtJI.js} +4 -4
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-CFyv5cdW.cjs → shapeRefFns-I0MHjRAq.cjs} +5 -4
- package/dist/{shapeRefFns-CU1Jwq9C.js → shapeRefFns-WMhIFuGW.js} +5 -4
- package/dist/{shapeTypes-C0MDggKf.cjs → shapeTypes-8vB31RfA.cjs} +260 -400
- package/dist/{shapeTypes-CN0GUoHr.js → shapeTypes-AyL8vv_O.js} +239 -379
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-BuS5ByIl.js → solidBuilders-C7Xp_ikW.js} +3 -3
- package/dist/{solidBuilders-DACzFqvX.cjs → solidBuilders-Djwgx2mj.cjs} +3 -3
- package/dist/{surfaceBuilders-CbH4FIW5.cjs → surfaceBuilders-BEnsewN9.cjs} +3 -3
- package/dist/{surfaceBuilders-BVH2SL-z.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 +8 -0
- package/dist/utils/vec3.d.ts.map +1 -1
- 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,27 +6838,17 @@ 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
|
};
|
|
6913
6850
|
}
|
|
6914
6851
|
//#endregion
|
|
6915
|
-
//#region src/utils/vec3.ts
|
|
6916
|
-
/**
|
|
6917
|
-
* Index into a typed/regular array at a position the caller has structurally
|
|
6918
|
-
* guaranteed (WASM ABI fixed-length arrays, post-bounds-check loops, etc.).
|
|
6919
|
-
* Equivalent to `arr[i]!` but typed as `T` directly — no eslint-disable needed.
|
|
6920
|
-
*/
|
|
6921
|
-
function wasmIndex(arr, i) {
|
|
6922
|
-
return arr[i];
|
|
6923
|
-
}
|
|
6924
|
-
//#endregion
|
|
6925
6852
|
//#region src/kernel/brepkit/constructionOps.ts
|
|
6926
6853
|
function makeVertex(bk, x, y, z) {
|
|
6927
6854
|
return vertexHandle(bk.makeVertex(x, y, z));
|
|
@@ -7091,8 +7018,8 @@ function makeBezierEdge(bk, points) {
|
|
|
7091
7018
|
y,
|
|
7092
7019
|
z
|
|
7093
7020
|
]);
|
|
7094
|
-
const startPt = wasmIndex(points, 0);
|
|
7095
|
-
const endPt = wasmIndex(points, n - 1);
|
|
7021
|
+
const startPt = require_vec3.wasmIndex(points, 0);
|
|
7022
|
+
const endPt = require_vec3.wasmIndex(points, n - 1);
|
|
7096
7023
|
return edgeHandle(bk.makeNurbsEdge(startPt[0], startPt[1], startPt[2], endPt[0], endPt[1], endPt[2], degree, knots, flatCp, weights));
|
|
7097
7024
|
}
|
|
7098
7025
|
function makeTangentArc(bk, startPoint, startTangent, endPoint) {
|
|
@@ -7186,9 +7113,9 @@ function triangulatedSurface(bk, points, rows, cols) {
|
|
|
7186
7113
|
const i10 = (r + 1) * cols + c;
|
|
7187
7114
|
const i01 = r * cols + (c + 1);
|
|
7188
7115
|
const i11 = (r + 1) * cols + (c + 1);
|
|
7189
|
-
const f1 = buildTriFace(bk, wasmIndex(points, i00), wasmIndex(points, i10), wasmIndex(points, i01));
|
|
7116
|
+
const f1 = buildTriFace(bk, require_vec3.wasmIndex(points, i00), require_vec3.wasmIndex(points, i10), require_vec3.wasmIndex(points, i01));
|
|
7190
7117
|
if (f1) faces.push(f1);
|
|
7191
|
-
const f2 = buildTriFace(bk, wasmIndex(points, i10), wasmIndex(points, i11), wasmIndex(points, i01));
|
|
7118
|
+
const f2 = buildTriFace(bk, require_vec3.wasmIndex(points, i10), require_vec3.wasmIndex(points, i11), require_vec3.wasmIndex(points, i01));
|
|
7192
7119
|
if (f2) faces.push(f2);
|
|
7193
7120
|
}
|
|
7194
7121
|
if (faces.length === 0) throw new Error("brepkit: no valid faces in surface grid");
|
|
@@ -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, wasmIndex(points, 0), wasmIndex(points, 1));
|
|
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,
|
|
@@ -7371,14 +7298,14 @@ function makeCircleNurbs(bk, center, normal, radius, startAngle, endAngle) {
|
|
|
7371
7298
|
const knots = Array(degree + 1).fill(0);
|
|
7372
7299
|
for (let i = 1; i < nSegments; i++) knots.push(i, i);
|
|
7373
7300
|
knots.push(...Array(degree + 1).fill(nSegments));
|
|
7374
|
-
const kMax = wasmIndex(knots, knots.length - 1);
|
|
7375
|
-
for (let i = 0; i < knots.length; i++) knots[i] = wasmIndex(knots, i) / kMax;
|
|
7376
|
-
const sx = wasmIndex(controlPoints, 0);
|
|
7377
|
-
const sy = wasmIndex(controlPoints, 1);
|
|
7378
|
-
const sz = wasmIndex(controlPoints, 2);
|
|
7379
|
-
const ex = wasmIndex(controlPoints, controlPoints.length - 3);
|
|
7380
|
-
const ey = wasmIndex(controlPoints, controlPoints.length - 2);
|
|
7381
|
-
const ez = wasmIndex(controlPoints, controlPoints.length - 1);
|
|
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);
|
|
7382
7309
|
return edgeHandle(bk.makeNurbsEdge(sx, sy, sz, ex, ey, ez, degree, knots, controlPoints, weights));
|
|
7383
7310
|
}
|
|
7384
7311
|
function makeEllipseNurbs(bk, center, normal, majorRadius, minorRadius, startAngle, endAngle, xDir) {
|
|
@@ -7452,14 +7379,14 @@ function makeEllipseNurbs(bk, center, normal, majorRadius, minorRadius, startAng
|
|
|
7452
7379
|
const knots = Array(degree + 1).fill(0);
|
|
7453
7380
|
for (let i = 1; i < nSegments; i++) knots.push(i, i);
|
|
7454
7381
|
knots.push(...Array(degree + 1).fill(nSegments));
|
|
7455
|
-
const kMax = wasmIndex(knots, knots.length - 1);
|
|
7456
|
-
for (let i = 0; i < knots.length; i++) knots[i] = wasmIndex(knots, i) / kMax;
|
|
7457
|
-
const sx = wasmIndex(controlPoints, 0);
|
|
7458
|
-
const sy = wasmIndex(controlPoints, 1);
|
|
7459
|
-
const sz = wasmIndex(controlPoints, 2);
|
|
7460
|
-
const ex = wasmIndex(controlPoints, controlPoints.length - 3);
|
|
7461
|
-
const ey = wasmIndex(controlPoints, controlPoints.length - 2);
|
|
7462
|
-
const ez = wasmIndex(controlPoints, controlPoints.length - 1);
|
|
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);
|
|
7463
7390
|
return edgeHandle(bk.makeNurbsEdge(sx, sy, sz, ex, ey, ez, degree, knots, controlPoints, weights));
|
|
7464
7391
|
}
|
|
7465
7392
|
//#endregion
|
|
@@ -7497,11 +7424,11 @@ function section(bk, shape, plane, _approximation) {
|
|
|
7497
7424
|
const solidId = isBrepkitHandle(shape) && shape.type === "solid" ? shape.id : unwrap(shape, "solid");
|
|
7498
7425
|
const faceIds = toArray(bk.section(solidId, point[0], point[1], point[2], normal[0], normal[1], normal[2]));
|
|
7499
7426
|
if (faceIds.length === 0) return compoundHandle(bk.makeCompound([]));
|
|
7500
|
-
return wireHandle(bk.getFaceOuterWire(faceIds
|
|
7427
|
+
return wireHandle(bk.getFaceOuterWire(require_vec3.wasmIndex(faceIds, 0)));
|
|
7501
7428
|
}
|
|
7502
7429
|
function fuseAll(bk, shapes, options) {
|
|
7503
7430
|
if (shapes.length === 0) throw new Error("brepkit: fuseAll requires at least one shape");
|
|
7504
|
-
if (shapes.length === 1) return shapes
|
|
7431
|
+
if (shapes.length === 1) return require_vec3.wasmIndex(shapes, 0);
|
|
7505
7432
|
if (bk.compoundFuse) {
|
|
7506
7433
|
const solidIds = [];
|
|
7507
7434
|
for (const shape of shapes) {
|
|
@@ -7519,7 +7446,7 @@ function fuseAll(bk, shapes, options) {
|
|
|
7519
7446
|
else next.push(current[i]);
|
|
7520
7447
|
current = next;
|
|
7521
7448
|
}
|
|
7522
|
-
return current
|
|
7449
|
+
return require_vec3.wasmIndex(current, 0);
|
|
7523
7450
|
}
|
|
7524
7451
|
function cutAll(bk, shape, tools, options) {
|
|
7525
7452
|
if (tools.length === 0) return shape;
|
|
@@ -7598,11 +7525,11 @@ function hull(bk, shapes, _tolerance) {
|
|
|
7598
7525
|
const vertIds = toArray(bk.getSolidVertices(h.id));
|
|
7599
7526
|
for (const vid of vertIds) {
|
|
7600
7527
|
const pos = bk.getVertexPosition(vid);
|
|
7601
|
-
coords.push(pos
|
|
7528
|
+
coords.push(require_vec3.wasmIndex(pos, 0), require_vec3.wasmIndex(pos, 1), require_vec3.wasmIndex(pos, 2));
|
|
7602
7529
|
}
|
|
7603
7530
|
} else if (h.type === "vertex") {
|
|
7604
7531
|
const pos = bk.getVertexPosition(h.id);
|
|
7605
|
-
coords.push(pos
|
|
7532
|
+
coords.push(require_vec3.wasmIndex(pos, 0), require_vec3.wasmIndex(pos, 1), require_vec3.wasmIndex(pos, 2));
|
|
7606
7533
|
}
|
|
7607
7534
|
}
|
|
7608
7535
|
if (coords.length < 12) throw new Error("brepkit: hull requires enough points");
|
|
@@ -7617,14 +7544,14 @@ function hullFromPoints(bk, points, _tolerance) {
|
|
|
7617
7544
|
function buildSolidFromFaces(bk, points, faces, _tolerance) {
|
|
7618
7545
|
const positions = new Float64Array(points.length * 3);
|
|
7619
7546
|
for (let i = 0; i < points.length; i++) {
|
|
7620
|
-
const p = points
|
|
7547
|
+
const p = require_vec3.wasmIndex(points, i);
|
|
7621
7548
|
positions[i * 3] = p.x;
|
|
7622
7549
|
positions[i * 3 + 1] = p.y;
|
|
7623
7550
|
positions[i * 3 + 2] = p.z;
|
|
7624
7551
|
}
|
|
7625
7552
|
const indices = new Uint32Array(faces.length * 3);
|
|
7626
7553
|
for (let i = 0; i < faces.length; i++) {
|
|
7627
|
-
const f = faces
|
|
7554
|
+
const f = require_vec3.wasmIndex(faces, i);
|
|
7628
7555
|
indices[i * 3] = f[0];
|
|
7629
7556
|
indices[i * 3 + 1] = f[1];
|
|
7630
7557
|
indices[i * 3 + 2] = f[2];
|
|
@@ -7922,9 +7849,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
|
|
|
7922
7849
|
let ox = 0, oy = 0, oz = 0;
|
|
7923
7850
|
for (const vid of origVerts) {
|
|
7924
7851
|
const pos = bk.getVertexPosition(vid);
|
|
7925
|
-
ox += pos
|
|
7926
|
-
oy += pos
|
|
7927
|
-
oz += pos
|
|
7852
|
+
ox += require_vec3.wasmIndex(pos, 0);
|
|
7853
|
+
oy += require_vec3.wasmIndex(pos, 1);
|
|
7854
|
+
oz += require_vec3.wasmIndex(pos, 2);
|
|
7928
7855
|
}
|
|
7929
7856
|
const n = origVerts.length;
|
|
7930
7857
|
ox /= n;
|
|
@@ -7938,9 +7865,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
|
|
|
7938
7865
|
let sx = 0, sy = 0, sz = 0;
|
|
7939
7866
|
for (const svid of sv) {
|
|
7940
7867
|
const spos = bk.getVertexPosition(svid);
|
|
7941
|
-
sx += spos
|
|
7942
|
-
sy += spos
|
|
7943
|
-
sz += spos
|
|
7868
|
+
sx += require_vec3.wasmIndex(spos, 0);
|
|
7869
|
+
sy += require_vec3.wasmIndex(spos, 1);
|
|
7870
|
+
sz += require_vec3.wasmIndex(spos, 2);
|
|
7944
7871
|
}
|
|
7945
7872
|
const sn = sv.length;
|
|
7946
7873
|
sx /= sn;
|
|
@@ -7991,12 +7918,12 @@ function offsetWire2D(bk, wire, offsetVal, _joinType) {
|
|
|
7991
7918
|
const coords2d = [];
|
|
7992
7919
|
for (const edge of edges) {
|
|
7993
7920
|
const verts = bk.getEdgeVertices(unwrap(edge, "edge"));
|
|
7994
|
-
coords2d.push(verts
|
|
7921
|
+
coords2d.push(require_vec3.wasmIndex(verts, 0), require_vec3.wasmIndex(verts, 1));
|
|
7995
7922
|
}
|
|
7996
7923
|
if (coords2d.length < 6) return wire;
|
|
7997
7924
|
const result = bk.offsetPolygon2d(coords2d, offsetVal, 1e-10);
|
|
7998
7925
|
const coords3d = [];
|
|
7999
|
-
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);
|
|
8000
7927
|
return wireHandle(bk.makePolygonWire(coords3d));
|
|
8001
7928
|
}
|
|
8002
7929
|
function simplify(bk, shape) {
|
|
@@ -8133,8 +8060,8 @@ function exportSTEP(bk, shapes) {
|
|
|
8133
8060
|
}
|
|
8134
8061
|
function exportSTL(bk, shape, binary) {
|
|
8135
8062
|
const solidIds = unwrapSolidsForExport(bk, shape, "exportSTL");
|
|
8136
|
-
if (binary) return bk.exportStl(solidIds
|
|
8137
|
-
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);
|
|
8138
8065
|
return new TextDecoder().decode(bytes);
|
|
8139
8066
|
}
|
|
8140
8067
|
function importSTEP(bk, data) {
|
|
@@ -8244,8 +8171,8 @@ function meshEdges(bk, shape, tolerance, angularTolerance) {
|
|
|
8244
8171
|
const edgeCount = edgeLines.edgeCount;
|
|
8245
8172
|
const edgeGroups = [];
|
|
8246
8173
|
for (let i = 0; i < edgeCount; i++) {
|
|
8247
|
-
const startIdx = offsets
|
|
8248
|
-
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;
|
|
8249
8176
|
edgeGroups.push({
|
|
8250
8177
|
start: startIdx / 3,
|
|
8251
8178
|
count: pointCount,
|
|
@@ -8284,8 +8211,8 @@ function meshSolidGrouped(bk, solidId, deflection, includeUVs) {
|
|
|
8284
8211
|
if (groupCount !== faceIds.length) throw new Error(`faceOffsets/faceIds length mismatch: ${groupCount} groups vs ${faceIds.length} faces`);
|
|
8285
8212
|
const faceGroups = [];
|
|
8286
8213
|
for (let i = 0; i < data.faceOffsets.length - 1; i++) {
|
|
8287
|
-
const start = data.faceOffsets
|
|
8288
|
-
const count = data.faceOffsets
|
|
8214
|
+
const start = require_vec3.wasmIndex(data.faceOffsets, i);
|
|
8215
|
+
const count = require_vec3.wasmIndex(data.faceOffsets, i + 1) - start;
|
|
8289
8216
|
if (count === 0) continue;
|
|
8290
8217
|
faceGroups.push({
|
|
8291
8218
|
start,
|
|
@@ -8404,28 +8331,22 @@ function length(bk, shape) {
|
|
|
8404
8331
|
if (h.type === "wire") return bk.wireLength(h.id);
|
|
8405
8332
|
throw new Error("brepkit: length() requires an edge, wire, or face");
|
|
8406
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
|
+
}
|
|
8407
8342
|
function centerOfMass(bk, shape) {
|
|
8408
8343
|
const h = shape;
|
|
8409
|
-
if (h.type === "solid")
|
|
8410
|
-
const result = bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION);
|
|
8411
|
-
return [
|
|
8412
|
-
result[0],
|
|
8413
|
-
result[1],
|
|
8414
|
-
result[2]
|
|
8415
|
-
];
|
|
8416
|
-
}
|
|
8344
|
+
if (h.type === "solid") return require_vec3.vec3At(bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION));
|
|
8417
8345
|
if (h.type === "face") {
|
|
8418
8346
|
const domain = uvBounds(bk, shape);
|
|
8419
8347
|
return pointOnSurface(bk, shape, (domain.uMin + domain.uMax) / 2, (domain.vMin + domain.vMax) / 2);
|
|
8420
8348
|
}
|
|
8421
|
-
if (h.type === "edge")
|
|
8422
|
-
const verts = bk.getEdgeVertices(h.id);
|
|
8423
|
-
return [
|
|
8424
|
-
(verts[0] + verts[3]) / 2,
|
|
8425
|
-
(verts[1] + verts[4]) / 2,
|
|
8426
|
-
(verts[2] + verts[5]) / 2
|
|
8427
|
-
];
|
|
8428
|
-
}
|
|
8349
|
+
if (h.type === "edge") return edgeMidpoint(bk, h.id);
|
|
8429
8350
|
if (h.type === "vertex") return vertexPosition(bk, shape);
|
|
8430
8351
|
const vertices = iterShapes(bk, shape, "vertex");
|
|
8431
8352
|
if (vertices.length > 0) {
|
|
@@ -8450,14 +8371,7 @@ function centerOfMass(bk, shape) {
|
|
|
8450
8371
|
}
|
|
8451
8372
|
function linearCenterOfMass(bk, shape) {
|
|
8452
8373
|
const h = shape;
|
|
8453
|
-
if (h.type === "edge")
|
|
8454
|
-
const verts = bk.getEdgeVertices(h.id);
|
|
8455
|
-
return [
|
|
8456
|
-
(verts[0] + verts[3]) / 2,
|
|
8457
|
-
(verts[1] + verts[4]) / 2,
|
|
8458
|
-
(verts[2] + verts[5]) / 2
|
|
8459
|
-
];
|
|
8460
|
-
}
|
|
8374
|
+
if (h.type === "edge") return edgeMidpoint(bk, h.id);
|
|
8461
8375
|
return centerOfMass(bk, shape);
|
|
8462
8376
|
}
|
|
8463
8377
|
function boundingBox(bk, shape) {
|
|
@@ -8465,16 +8379,8 @@ function boundingBox(bk, shape) {
|
|
|
8465
8379
|
if (h.type === "solid") {
|
|
8466
8380
|
const bb = bk.boundingBox(unwrap(shape));
|
|
8467
8381
|
return {
|
|
8468
|
-
min:
|
|
8469
|
-
|
|
8470
|
-
bb[1],
|
|
8471
|
-
bb[2]
|
|
8472
|
-
],
|
|
8473
|
-
max: [
|
|
8474
|
-
bb[3],
|
|
8475
|
-
bb[4],
|
|
8476
|
-
bb[5]
|
|
8477
|
-
]
|
|
8382
|
+
min: require_vec3.vec3At(bb, 0),
|
|
8383
|
+
max: require_vec3.vec3At(bb, 3)
|
|
8478
8384
|
};
|
|
8479
8385
|
}
|
|
8480
8386
|
if (h.type === "vertex") {
|
|
@@ -8528,85 +8434,28 @@ function distance(bk, shape1, shape2) {
|
|
|
8528
8434
|
if (h1.type === "solid" && h2.type === "solid") {
|
|
8529
8435
|
const buf = bk.solidToSolidDistance(h1.id, h2.id);
|
|
8530
8436
|
return {
|
|
8531
|
-
value: buf
|
|
8532
|
-
point1:
|
|
8533
|
-
|
|
8534
|
-
buf[2],
|
|
8535
|
-
buf[3]
|
|
8536
|
-
],
|
|
8537
|
-
point2: [
|
|
8538
|
-
buf[4],
|
|
8539
|
-
buf[5],
|
|
8540
|
-
buf[6]
|
|
8541
|
-
]
|
|
8542
|
-
};
|
|
8543
|
-
}
|
|
8544
|
-
if (h1.type === "vertex" && h2.type === "solid") {
|
|
8545
|
-
const pos = bk.getVertexPosition(h1.id);
|
|
8546
|
-
const result = bk.pointToSolidDistance(pos[0], pos[1], pos[2], h2.id);
|
|
8547
|
-
return {
|
|
8548
|
-
value: result[0],
|
|
8549
|
-
point1: [
|
|
8550
|
-
pos[0],
|
|
8551
|
-
pos[1],
|
|
8552
|
-
pos[2]
|
|
8553
|
-
],
|
|
8554
|
-
point2: [
|
|
8555
|
-
result[1],
|
|
8556
|
-
result[2],
|
|
8557
|
-
result[3]
|
|
8558
|
-
]
|
|
8559
|
-
};
|
|
8560
|
-
}
|
|
8561
|
-
if (h1.type === "vertex" && h2.type === "face") {
|
|
8562
|
-
const pos = bk.getVertexPosition(h1.id);
|
|
8563
|
-
const result = bk.pointToFaceDistance(pos[0], pos[1], pos[2], h2.id);
|
|
8564
|
-
return {
|
|
8565
|
-
value: result[0],
|
|
8566
|
-
point1: [
|
|
8567
|
-
pos[0],
|
|
8568
|
-
pos[1],
|
|
8569
|
-
pos[2]
|
|
8570
|
-
],
|
|
8571
|
-
point2: [
|
|
8572
|
-
result[1],
|
|
8573
|
-
result[2],
|
|
8574
|
-
result[3]
|
|
8575
|
-
]
|
|
8437
|
+
value: require_vec3.wasmIndex(buf, 0),
|
|
8438
|
+
point1: require_vec3.vec3At(buf, 1),
|
|
8439
|
+
point2: require_vec3.vec3At(buf, 4)
|
|
8576
8440
|
};
|
|
8577
8441
|
}
|
|
8578
|
-
if (h1.type === "vertex" && h2.type === "edge") {
|
|
8579
|
-
const
|
|
8580
|
-
const result = bk.pointToEdgeDistance(
|
|
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);
|
|
8581
8445
|
return {
|
|
8582
|
-
value: result
|
|
8583
|
-
point1
|
|
8584
|
-
|
|
8585
|
-
pos[1],
|
|
8586
|
-
pos[2]
|
|
8587
|
-
],
|
|
8588
|
-
point2: [
|
|
8589
|
-
result[1],
|
|
8590
|
-
result[2],
|
|
8591
|
-
result[3]
|
|
8592
|
-
]
|
|
8446
|
+
value: require_vec3.wasmIndex(result, 0),
|
|
8447
|
+
point1,
|
|
8448
|
+
point2: require_vec3.vec3At(result, 1)
|
|
8593
8449
|
};
|
|
8594
8450
|
}
|
|
8595
8451
|
const getPos = (s) => {
|
|
8596
|
-
if (s.type === "vertex")
|
|
8597
|
-
const p = bk.getVertexPosition(s.id);
|
|
8598
|
-
return [
|
|
8599
|
-
p[0],
|
|
8600
|
-
p[1],
|
|
8601
|
-
p[2]
|
|
8602
|
-
];
|
|
8603
|
-
}
|
|
8452
|
+
if (s.type === "vertex") return require_vec3.vec3At(bk.getVertexPosition(s.id));
|
|
8604
8453
|
if (s.type === "solid") {
|
|
8605
8454
|
const bb = bk.boundingBox(s.id);
|
|
8606
8455
|
return [
|
|
8607
|
-
(bb
|
|
8608
|
-
(bb
|
|
8609
|
-
(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
|
|
8610
8459
|
];
|
|
8611
8460
|
}
|
|
8612
8461
|
return [
|
|
@@ -8630,23 +8479,15 @@ function surfaceCurvature(bk, face, u, v) {
|
|
|
8630
8479
|
const fid = unwrap(face, "face");
|
|
8631
8480
|
const data = bk.measureCurvatureAtSurface(fid, u, v);
|
|
8632
8481
|
if (data.length < 8) throw new Error(`brepkit: measureCurvatureAtSurface returned ${data.length} values, expected 8`);
|
|
8633
|
-
const k1 = data
|
|
8634
|
-
const k2 = data
|
|
8482
|
+
const k1 = require_vec3.wasmIndex(data, 0);
|
|
8483
|
+
const k2 = require_vec3.wasmIndex(data, 1);
|
|
8635
8484
|
return {
|
|
8636
8485
|
gaussian: k1 * k2,
|
|
8637
8486
|
mean: (k1 + k2) / 2,
|
|
8638
8487
|
max: Math.max(k1, k2),
|
|
8639
8488
|
min: Math.min(k1, k2),
|
|
8640
|
-
maxDirection:
|
|
8641
|
-
|
|
8642
|
-
data[3],
|
|
8643
|
-
data[4]
|
|
8644
|
-
],
|
|
8645
|
-
minDirection: [
|
|
8646
|
-
data[5],
|
|
8647
|
-
data[6],
|
|
8648
|
-
data[7]
|
|
8649
|
-
]
|
|
8489
|
+
maxDirection: require_vec3.vec3At(data, 2),
|
|
8490
|
+
minDirection: require_vec3.vec3At(data, 5)
|
|
8650
8491
|
};
|
|
8651
8492
|
}
|
|
8652
8493
|
function surfaceCenterOfMass(bk, face) {
|
|
@@ -8655,12 +8496,23 @@ function surfaceCenterOfMass(bk, face) {
|
|
|
8655
8496
|
const idx = mesh.indices;
|
|
8656
8497
|
let cx = 0, cy = 0, cz = 0, totalArea = 0;
|
|
8657
8498
|
for (let t = 0; t < idx.length; t += 3) {
|
|
8658
|
-
const i0 = idx
|
|
8659
|
-
const
|
|
8660
|
-
const
|
|
8661
|
-
const
|
|
8662
|
-
const
|
|
8663
|
-
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;
|
|
8664
8516
|
const faceArea = .5 * Math.sqrt((uy * vz - uz * vy) ** 2 + (uz * vx - ux * vz) ** 2 + (ux * vy - uy * vx) ** 2);
|
|
8665
8517
|
cx += tcx * faceArea;
|
|
8666
8518
|
cy += tcy * faceArea;
|
|
@@ -8748,9 +8600,9 @@ function faceCentroidById(bk, faceId) {
|
|
|
8748
8600
|
let cz = 0;
|
|
8749
8601
|
const nVerts = pos.length / 3;
|
|
8750
8602
|
for (let i = 0; i < pos.length; i += 3) {
|
|
8751
|
-
cx += pos
|
|
8752
|
-
cy += pos
|
|
8753
|
-
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);
|
|
8754
8606
|
}
|
|
8755
8607
|
return [
|
|
8756
8608
|
cx / nVerts,
|
|
@@ -8776,7 +8628,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8776
8628
|
const hashCount = Math.min(inputFaceIds.length, inputFaceHashes.length);
|
|
8777
8629
|
const inputSigs = [];
|
|
8778
8630
|
for (let i = 0; i < hashCount; i++) {
|
|
8779
|
-
const fid = inputFaceIds
|
|
8631
|
+
const fid = require_vec3.wasmIndex(inputFaceIds, i);
|
|
8780
8632
|
try {
|
|
8781
8633
|
const normal = bk.getFaceNormal(fid);
|
|
8782
8634
|
const centroid = faceCentroidById(bk, fid);
|
|
@@ -8824,7 +8676,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8824
8676
|
let bestScore = -Infinity;
|
|
8825
8677
|
let bestIdx = -1;
|
|
8826
8678
|
for (let i = 0; i < inputSigs.length; i++) {
|
|
8827
|
-
const inp = inputSigs
|
|
8679
|
+
const inp = require_vec3.wasmIndex(inputSigs, i);
|
|
8828
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);
|
|
8829
8681
|
if (dot < NORMAL_THRESHOLD) continue;
|
|
8830
8682
|
const distSq = centroidDistSq(out.centroid, inp.centroid);
|
|
@@ -8836,7 +8688,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8836
8688
|
}
|
|
8837
8689
|
}
|
|
8838
8690
|
if (bestIdx >= 0) {
|
|
8839
|
-
const bestInput = inputSigs
|
|
8691
|
+
const bestInput = require_vec3.wasmIndex(inputSigs, bestIdx);
|
|
8840
8692
|
const existing = modified.get(bestInput.hash) ?? [];
|
|
8841
8693
|
existing.push(out.hash);
|
|
8842
8694
|
modified.set(bestInput.hash, existing);
|
|
@@ -8858,7 +8710,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
|
|
|
8858
8710
|
}
|
|
8859
8711
|
}
|
|
8860
8712
|
}
|
|
8861
|
-
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);
|
|
8862
8714
|
}
|
|
8863
8715
|
/**
|
|
8864
8716
|
* Build a ShapeEvolution by comparing input face hashes to output face hashes.
|
|
@@ -8875,7 +8727,7 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
|
|
|
8875
8727
|
if (h.type === "solid") {
|
|
8876
8728
|
const outputFaces = toArray(bk.getSolidFaces(h.id));
|
|
8877
8729
|
const outputHashes = outputFaces.map((fid) => fid % hashUpperBound);
|
|
8878
|
-
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)]);
|
|
8879
8731
|
else {
|
|
8880
8732
|
const inputSet = new Set(inputFaceHashes);
|
|
8881
8733
|
let hasOverlap = false;
|
|
@@ -8887,12 +8739,12 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
|
|
|
8887
8739
|
const outputSet = new Set(outputHashes);
|
|
8888
8740
|
for (const hash of outputHashes) if (inputSet.has(hash)) modified.set(hash, [hash]);
|
|
8889
8741
|
const newFaces = outputHashes.filter((fh) => !inputSet.has(fh));
|
|
8890
|
-
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);
|
|
8891
8743
|
for (const hash of inputFaceHashes) if (!outputSet.has(hash)) deleted.add(hash);
|
|
8892
8744
|
} else if (originalShape) matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaces, hashUpperBound, modified, generated, deleted);
|
|
8893
8745
|
else {
|
|
8894
|
-
for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(inputFaceHashes
|
|
8895
|
-
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));
|
|
8896
8748
|
}
|
|
8897
8749
|
}
|
|
8898
8750
|
}
|
|
@@ -9294,7 +9146,7 @@ function createAffinityGTrsf2d(ox, oy, dx, dy, ratio) {
|
|
|
9294
9146
|
0,
|
|
9295
9147
|
1
|
|
9296
9148
|
];
|
|
9297
|
-
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);
|
|
9298
9150
|
}
|
|
9299
9151
|
function createTranslationGTrsf2d(dx, dy) {
|
|
9300
9152
|
return _gtrsf([
|
|
@@ -9325,7 +9177,7 @@ function createMirrorGTrsf2d(cx, cy, mode, ox, oy, dx, dy) {
|
|
|
9325
9177
|
1
|
|
9326
9178
|
];
|
|
9327
9179
|
const px = ox ?? cx, py = oy ?? cy;
|
|
9328
|
-
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);
|
|
9329
9181
|
}
|
|
9330
9182
|
return _gtrsf([
|
|
9331
9183
|
-1,
|
|
@@ -9372,21 +9224,23 @@ function setGTrsf2dTranslationPart(gtrsf, dx, dy) {
|
|
|
9372
9224
|
}
|
|
9373
9225
|
function multiplyGTrsf2d(base, other) {
|
|
9374
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);
|
|
9375
9229
|
base.m = [
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
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)
|
|
9385
9239
|
];
|
|
9386
9240
|
const oldTx = base.tx, oldTy = base.ty;
|
|
9387
9241
|
const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
|
|
9388
|
-
base.tx =
|
|
9389
|
-
base.ty =
|
|
9242
|
+
base.tx = ai(0) * otx + ai(1) * oty + oldTx;
|
|
9243
|
+
base.ty = ai(3) * otx + ai(4) * oty + oldTy;
|
|
9390
9244
|
}
|
|
9391
9245
|
function transformCurve2dGeneral(curve, gtrsf) {
|
|
9392
9246
|
const c = c2d(curve);
|
|
@@ -9402,14 +9256,15 @@ function transformCurve2dGeneral(curve, gtrsf) {
|
|
|
9402
9256
|
1
|
|
9403
9257
|
];
|
|
9404
9258
|
const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
|
|
9405
|
-
|
|
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);
|
|
9406
9261
|
const bounds = require_occtWasmAdapter.curveBounds(c);
|
|
9407
9262
|
const N = 20;
|
|
9408
9263
|
const pts = [];
|
|
9409
9264
|
for (let i = 0; i <= N; i++) {
|
|
9410
9265
|
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
9411
9266
|
const [px, py] = require_occtWasmAdapter.evaluateCurve2d(c, t);
|
|
9412
|
-
pts.push([
|
|
9267
|
+
pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
|
|
9413
9268
|
}
|
|
9414
9269
|
return require_occtWasmAdapter.makeBezier2d(pts);
|
|
9415
9270
|
}
|
|
@@ -9543,8 +9398,8 @@ function approximateCurve2dAsBSpline(curve, tol, cont, maxSeg) {
|
|
|
9543
9398
|
for (let i = 0; i < N; i++) {
|
|
9544
9399
|
const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / N;
|
|
9545
9400
|
const [ex, ey] = require_occtWasmAdapter.evaluateCurve2d(c, tMid);
|
|
9546
|
-
const p0 = poles
|
|
9547
|
-
const p1 = poles
|
|
9401
|
+
const p0 = require_vec3.wasmIndex(poles, i);
|
|
9402
|
+
const p1 = require_vec3.wasmIndex(poles, i + 1);
|
|
9548
9403
|
const mx = (p0[0] + p1[0]) / 2;
|
|
9549
9404
|
const my = (p0[1] + p1[1]) / 2;
|
|
9550
9405
|
const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
|
|
@@ -9570,8 +9425,8 @@ function decomposeBSpline2dToBeziers(curve) {
|
|
|
9570
9425
|
];
|
|
9571
9426
|
const result = [];
|
|
9572
9427
|
for (let i = 0; i < breakpoints.length - 1; i++) {
|
|
9573
|
-
const t0 = breakpoints
|
|
9574
|
-
const t1 = breakpoints
|
|
9428
|
+
const t0 = require_vec3.wasmIndex(breakpoints, i);
|
|
9429
|
+
const t1 = require_vec3.wasmIndex(breakpoints, i + 1);
|
|
9575
9430
|
const span = t1 - t0;
|
|
9576
9431
|
if (span < 1e-15) continue;
|
|
9577
9432
|
const p0 = require_occtWasmAdapter.evaluateCurve2d(c, t0);
|
|
@@ -9722,13 +9577,13 @@ function liftCurve2dToPlane(bk, curve, origin, planeZ, planeX) {
|
|
|
9722
9577
|
const [eu, ev] = require_occtWasmAdapter.evaluateCurve2d(c, bounds.first + (seg + 1) * segmentSpan);
|
|
9723
9578
|
edgeIds.push(bk.makeCircleArc3d(...lift(su, sv), ...lift(eu, ev), ...center3d, ...axis));
|
|
9724
9579
|
}
|
|
9725
|
-
if (edgeIds.length === 1) return edgeHandle(edgeIds
|
|
9580
|
+
if (edgeIds.length === 1) return edgeHandle(require_vec3.wasmIndex(edgeIds, 0));
|
|
9726
9581
|
return wireHandle(bk.makeWire(edgeIds, false));
|
|
9727
9582
|
}
|
|
9728
9583
|
}
|
|
9729
9584
|
if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
|
|
9730
9585
|
const points3d = c.poles.map(([u, v]) => lift(u, v));
|
|
9731
|
-
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));
|
|
9732
9587
|
const degree = Math.min(3, points3d.length - 1);
|
|
9733
9588
|
const coords = points3d.flatMap(([px, py, pz]) => [
|
|
9734
9589
|
px,
|
|
@@ -9757,58 +9612,40 @@ function buildEdgeOnSurface(bk, curve, surface) {
|
|
|
9757
9612
|
for (let i = 0; i <= N; i++) {
|
|
9758
9613
|
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
9759
9614
|
const [u, v] = require_occtWasmAdapter.evaluateCurve2d(c, t);
|
|
9760
|
-
|
|
9761
|
-
points.push([
|
|
9762
|
-
p[0],
|
|
9763
|
-
p[1],
|
|
9764
|
-
p[2]
|
|
9765
|
-
]);
|
|
9615
|
+
points.push(require_vec3.vec3At(bk.evaluateSurface(fid, u, v)));
|
|
9766
9616
|
}
|
|
9767
9617
|
return interpolatePoints(bk, points);
|
|
9768
9618
|
}
|
|
9769
9619
|
function extractSurfaceFromFace(face) {
|
|
9770
9620
|
return face;
|
|
9771
9621
|
}
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
const MAX_N = 80;
|
|
9780
|
-
const REFINE_THRESHOLD = .05;
|
|
9781
|
-
const tValues = [];
|
|
9782
|
-
for (let i = 0; i <= BASE_N; i++) tValues.push(tMin + (tMax - tMin) * i / BASE_N);
|
|
9783
|
-
const evaluateUV = (t) => {
|
|
9784
|
-
const pt = bk.evaluateEdgeCurve(eid, t);
|
|
9785
|
-
const uv = bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
|
|
9786
|
-
return [uv[0], uv[1]];
|
|
9787
|
-
};
|
|
9788
|
-
const uvSamples = tValues.map((t) => ({
|
|
9789
|
-
t,
|
|
9790
|
-
uv: evaluateUV(t)
|
|
9791
|
-
}));
|
|
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) {
|
|
9792
9629
|
let refinements = 0;
|
|
9793
|
-
while (uvSamples.length <
|
|
9630
|
+
while (uvSamples.length < maxSamples) {
|
|
9794
9631
|
const insertions = [];
|
|
9795
9632
|
for (let i = 0; i < uvSamples.length - 1; i++) {
|
|
9796
|
-
const a = uvSamples
|
|
9797
|
-
const b = uvSamples
|
|
9633
|
+
const a = require_vec3.wasmIndex(uvSamples, i);
|
|
9634
|
+
const b = require_vec3.wasmIndex(uvSamples, i + 1);
|
|
9798
9635
|
const tMid = (a.t + b.t) / 2;
|
|
9799
9636
|
const uvMid = evaluateUV(tMid);
|
|
9800
9637
|
const interpU = (a.uv[0] + b.uv[0]) / 2;
|
|
9801
9638
|
const interpV = (a.uv[1] + b.uv[1]) / 2;
|
|
9802
|
-
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({
|
|
9803
9640
|
index: i + 1,
|
|
9804
9641
|
t: tMid,
|
|
9805
9642
|
uv: uvMid
|
|
9806
9643
|
});
|
|
9807
9644
|
}
|
|
9808
9645
|
if (insertions.length === 0) break;
|
|
9809
|
-
let budget =
|
|
9646
|
+
let budget = maxSamples - uvSamples.length;
|
|
9810
9647
|
for (let j = insertions.length - 1; j >= 0 && budget > 0; j--) {
|
|
9811
|
-
const ins = insertions
|
|
9648
|
+
const ins = require_vec3.wasmIndex(insertions, j);
|
|
9812
9649
|
uvSamples.splice(ins.index, 0, {
|
|
9813
9650
|
t: ins.t,
|
|
9814
9651
|
uv: ins.uv
|
|
@@ -9818,13 +9655,35 @@ function extractCurve2dFromEdge(bk, edge, face) {
|
|
|
9818
9655
|
refinements++;
|
|
9819
9656
|
if (refinements > 3) break;
|
|
9820
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);
|
|
9821
9680
|
const uvPoints = uvSamples.map((s) => s.uv);
|
|
9822
9681
|
if (uvPoints.length >= 2) return makeBSpline2d(uvPoints);
|
|
9823
9682
|
const verts = bk.getEdgeVertices(eid);
|
|
9824
9683
|
if (verts.length >= 6) {
|
|
9825
|
-
const uv1 = bk.projectPointOnSurface(fid, verts
|
|
9826
|
-
const uv2 = bk.projectPointOnSurface(fid, verts
|
|
9827
|
-
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));
|
|
9828
9687
|
}
|
|
9829
9688
|
throw new Error(`brepkit: extractCurve2dFromEdge: degenerate edge (${verts.length} coords)`);
|
|
9830
9689
|
}
|
|
@@ -9840,13 +9699,14 @@ function fillSurface(bk, wires, _options) {
|
|
|
9840
9699
|
for (const edge of wireEdges) {
|
|
9841
9700
|
const edgeId = unwrap(edge, "edge");
|
|
9842
9701
|
const params = bk.getEdgeCurveParameters(edgeId);
|
|
9843
|
-
const tMin = params
|
|
9702
|
+
const tMin = require_vec3.wasmIndex(params, 0);
|
|
9703
|
+
const tMax = require_vec3.wasmIndex(params, 1);
|
|
9844
9704
|
const N = 10;
|
|
9845
9705
|
const pts = [];
|
|
9846
9706
|
for (let i = 0; i <= N; i++) {
|
|
9847
9707
|
const t = tMin + (tMax - tMin) * i / N;
|
|
9848
9708
|
const p = bk.evaluateEdgeCurve(edgeId, t);
|
|
9849
|
-
pts.push(p
|
|
9709
|
+
pts.push(require_vec3.wasmIndex(p, 0), require_vec3.wasmIndex(p, 1), require_vec3.wasmIndex(p, 2));
|
|
9850
9710
|
}
|
|
9851
9711
|
allCoords.push(...pts);
|
|
9852
9712
|
curveLengths.push(N + 1);
|
|
@@ -10868,7 +10728,7 @@ async function init() {
|
|
|
10868
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)");
|
|
10869
10729
|
}
|
|
10870
10730
|
//#endregion
|
|
10871
|
-
//#region \0@oxc-project+runtime@0.
|
|
10731
|
+
//#region \0@oxc-project+runtime@0.128.0/helpers/usingCtx.js
|
|
10872
10732
|
function _usingCtx() {
|
|
10873
10733
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
10874
10734
|
var n = Error();
|