brepjs 18.124.0 → 18.124.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d.cjs +10 -8
- package/dist/2d.js +10 -8
- package/dist/{adjacencyFns-BJ6jcQ-N.cjs → adjacencyFns-CpKlADYt.cjs} +3 -3
- package/dist/{adjacencyFns-CnehwLNj.js → adjacencyFns-DECdcer5.js} +3 -3
- package/dist/{blueprint-BGWbpQ-w.js → blueprint-CaY00-X2.js} +16 -11
- package/dist/{blueprint-BSfG0Uik.cjs → blueprint-CpJLcUJV.cjs} +14 -10
- package/dist/{blueprintFns-C0-nGqlW.cjs → blueprintFns-B5nFaJI0.cjs} +2 -2
- package/dist/{blueprintFns-Bt1hKlL7.js → blueprintFns-vgwEIgI0.js} +2 -2
- package/dist/{blueprintSketcher-Bd5ZS9p6.cjs → blueprintSketcher-4e0yYtCY.cjs} +19 -11
- package/dist/{blueprintSketcher-BTGRoQ_G.js → blueprintSketcher-BjBjj2cK.js} +19 -11
- package/dist/{boolean2D-Cr6oLsbf.cjs → boolean2D-7heWA1co.cjs} +12 -8
- package/dist/{boolean2D-zZ9-qR5a.js → boolean2D-Bk-VrRyQ.js} +14 -9
- package/dist/brepjs.cjs +121 -81
- package/dist/brepjs.js +132 -85
- package/dist/{cameraFns-j2I9G3L_.cjs → cameraFns-CGwrxgqB.cjs} +5 -4
- package/dist/{cameraFns-CGMawqfi.js → cameraFns-DKEilV2v.js} +5 -4
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-CaXBdZz9.js → cornerFinder-C4s6pVZ-.js} +1 -1
- package/dist/{cornerFinder-CPwSLgpM.cjs → cornerFinder-zEgIFMnk.cjs} +1 -1
- package/dist/{curveFns-BBLaLG1U.cjs → curveFns-BZZYHVow.cjs} +8 -5
- package/dist/{curveFns-BoHbhtqX.js → curveFns-RczIU30U.js} +8 -5
- package/dist/{drawFns-DOkSdo8E.cjs → drawFns-BcXzWFfn.cjs} +59 -30
- package/dist/{drawFns-BrRbAeYB.js → drawFns-BjT3RaeQ.js} +59 -30
- package/dist/{faceFns-UozswcwP.cjs → faceFns-C4xNv2zn.cjs} +4 -3
- package/dist/{faceFns-Ce7Fq6j5.js → faceFns-fvp_zfuI.js} +6 -4
- package/dist/{healingFns-Dn0EFSHm.js → healingFns-AE5182Ds.js} +38 -21
- package/dist/{healingFns-mKogaVOk.cjs → healingFns-SxSiVPQa.cjs} +38 -21
- package/dist/{helpers-DuTAcGVX.cjs → helpers-CHYzwQMk.cjs} +6 -6
- package/dist/{helpers-CZsK8STz.js → helpers-CyLQ07aD.js} +6 -6
- package/dist/{importFns-Ch2YwieP.cjs → importFns-90S7P_7P.cjs} +5 -6
- package/dist/{importFns-CE4byS-8.js → importFns-DdXOAX6k.js} +5 -6
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/{loftFns-BYiUcAxk.cjs → loftFns-B3mbh5RA.cjs} +15 -9
- package/dist/{loftFns-DQVg8qxM.js → loftFns-CyY4qfvC.js} +15 -9
- package/dist/{measureFns-BbLLBg5q.js → measureFns-B1uLQugf.js} +3 -3
- package/dist/{measureFns-Cao9gY1L.cjs → measureFns-Cx2XJVVC.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CnYIUU9b.cjs → meshFns-2ZxW-X9I.cjs} +3 -3
- package/dist/{meshFns-B6NveFwc.js → meshFns-DrO3d03M.js} +3 -3
- package/dist/{occtWasmAdapter-BQKQXF63.js → occtWasmAdapter-BEe---7w.js} +3 -1
- package/dist/{occtWasmAdapter-Aubfbks6.cjs → occtWasmAdapter-DEpy64ji.cjs} +3 -1
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{originTrackingFns-uz38yuMp.cjs → originTrackingFns-D3rUK08B.cjs} +2 -2
- package/dist/{originTrackingFns-DXcggmgf.js → originTrackingFns-DIAwMSih.js} +2 -2
- package/dist/{primitiveFns-CmmTWOkO.js → primitiveFns-CDPqVTcc.js} +7 -5
- package/dist/{primitiveFns-DmEPf6av.cjs → primitiveFns-c7wqS-K2.cjs} +7 -5
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-CnPEaqHw.cjs → refResolveFns-Cm8ZHPl5.cjs} +10 -8
- package/dist/{refResolveFns-DqY7Cd00.js → refResolveFns-o3-Gdnjn.js} +10 -8
- package/dist/{rolldown-runtime-DakpK96I.cjs → rolldown-runtime-C0BPl7ul.cjs} +1 -1
- package/dist/{shapeFns-BLZ1dDSz.cjs → shapeFns-CJ6mph9b.cjs} +2 -2
- package/dist/{shapeFns-mYczuWOy.js → shapeFns-DEpbxB9Z.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-bHlssytH.js → shapeTypes-BHRboc_x.js} +235 -20
- package/dist/{shapeTypes-DZKuRt24.cjs → shapeTypes-D5Y41q7x.cjs} +219 -12
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-5tA9O1SM.cjs → solidBuilders-CsUkRC69.cjs} +14 -9
- package/dist/{solidBuilders-9s-j-ZiW.js → solidBuilders-DQQ0re9T.js} +14 -9
- package/dist/{surfaceBuilders-0x7j0ibk.cjs → surfaceBuilders-BXNZydNl.cjs} +7 -5
- package/dist/{surfaceBuilders-B7UnwkQz.js → surfaceBuilders-C8k0K7DR.js} +7 -5
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-DE3M-E9o.js → textBlueprints-BAyLXffK.js} +36 -21
- package/dist/{textBlueprints-BPbIpA4-.cjs → textBlueprints-t8MdWfki.cjs} +37 -22
- package/dist/{textMetrics-D3Bly1w4.js → textMetrics-CefI-bMN.js} +3 -2
- package/dist/{textMetrics-rRuWxQG_.cjs → textMetrics-DUEI9s5M.cjs} +3 -2
- package/dist/{threadFns-BAjFNk2_.js → threadFns-Bau5Sqad.js} +17 -12
- package/dist/{threadFns-BMT6ziG_.cjs → threadFns-OVYAleOH.cjs} +17 -12
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-DVhWxBwT.js → topologyQueryFns-QvPyCF-7.js} +1 -1
- package/dist/{topologyQueryFns-DZUpJz2p.cjs → topologyQueryFns-gah07J7-.cjs} +1 -1
- package/dist/{validityTypes-19mfqWVv.js → validityTypes-DokbYKzd.js} +1 -1
- package/dist/{validityTypes-CCnRq3A9.cjs → validityTypes-Dx-04qO0.cjs} +1 -1
- package/package.json +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as EXACT_BREP_CAPABILITIES, C as serializeCurve2d$2, D as UnsupportedKernelOperationError, E as quickHull, O as isUnsupportedKernelOperationError, S as scaleCurve2d$2, T as translateCurve2d$2, _ as makeEllipse2d$2, a as buildBinarySTL, b as mirrorAtPoint, c as curveBounds, d as evaluateCurve2d$2, f as intersectCurves2dFn, g as makeCircle2d$2, h as makeBezier2d$2, i as buildAsciiSTL, l as curveTypeName, m as makeArc2dThreePoints, n as DEFAULT_STL_ANGULAR_TOLERANCE, o as addCurveToBBox, p as makeArc2dTangent, r as DEFAULT_STL_TOLERANCE, s as createBBox2d, t as OcctWasmAdapter, u as deserializeCurve2d$2, v as makeLine2d$2, w as tangentCurve2d, x as rotateCurve2d$2, y as mirrorAcrossAxis } from "./occtWasmAdapter-
|
|
1
|
+
import { A as EXACT_BREP_CAPABILITIES, C as serializeCurve2d$2, D as UnsupportedKernelOperationError, E as quickHull, O as isUnsupportedKernelOperationError, S as scaleCurve2d$2, T as translateCurve2d$2, _ as makeEllipse2d$2, a as buildBinarySTL, b as mirrorAtPoint, c as curveBounds, d as evaluateCurve2d$2, f as intersectCurves2dFn, g as makeCircle2d$2, h as makeBezier2d$2, i as buildAsciiSTL, l as curveTypeName, m as makeArc2dThreePoints, n as DEFAULT_STL_ANGULAR_TOLERANCE, o as addCurveToBBox, p as makeArc2dTangent, r as DEFAULT_STL_TOLERANCE, s as createBBox2d, t as OcctWasmAdapter, u as deserializeCurve2d$2, v as makeLine2d$2, w as tangentCurve2d, x as rotateCurve2d$2, y as mirrorAcrossAxis } from "./occtWasmAdapter-BEe---7w.js";
|
|
2
2
|
import { i as wasmIndex, r as vec3At } from "./bug-BdOHwn_e.js";
|
|
3
3
|
//#region src/kernel/quality.ts
|
|
4
4
|
/**
|
|
@@ -2176,9 +2176,7 @@ function transformBatch$2(oc, entries) {
|
|
|
2176
2176
|
case "scale":
|
|
2177
2177
|
batch.addScale(e.shape, ...e.center, e.factor);
|
|
2178
2178
|
break;
|
|
2179
|
-
case "mirror":
|
|
2180
|
-
batch.addMirror(e.shape, ...e.origin, ...e.normal);
|
|
2181
|
-
break;
|
|
2179
|
+
case "mirror": batch.addMirror(e.shape, ...e.origin, ...e.normal);
|
|
2182
2180
|
}
|
|
2183
2181
|
const result = batch.execute();
|
|
2184
2182
|
try {
|
|
@@ -3956,7 +3954,8 @@ function makeFaceOnSurface$1(oc, surfaceOrFace, wire) {
|
|
|
3956
3954
|
function bsplineSurface$1(oc, points, rows, cols) {
|
|
3957
3955
|
const arr = new oc.TColgp_Array2OfPnt_2(1, rows, 1, cols);
|
|
3958
3956
|
for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
|
|
3959
|
-
const
|
|
3957
|
+
const idx = r * cols + c;
|
|
3958
|
+
const pt = wasmIndex(points, idx);
|
|
3960
3959
|
const pnt = new oc.gp_Pnt_3(pt[0], pt[1], pt[2]);
|
|
3961
3960
|
arr.SetValue_1(r + 1, c + 1, pnt);
|
|
3962
3961
|
pnt.delete();
|
|
@@ -4741,7 +4740,8 @@ function transformCurve2dGeneral$1(curve, gtrsf) {
|
|
|
4741
4740
|
const N = 20;
|
|
4742
4741
|
const pts = [];
|
|
4743
4742
|
for (let i = 0; i <= N; i++) {
|
|
4744
|
-
const
|
|
4743
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
4744
|
+
const [px, py] = evaluateCurve2d$2(c, t);
|
|
4745
4745
|
pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
|
|
4746
4746
|
}
|
|
4747
4747
|
return makeBezier2d$2(pts);
|
|
@@ -4874,7 +4874,8 @@ function approximateCurve2dAsBSpline$1(curve, tol, cont, maxSeg) {
|
|
|
4874
4874
|
}
|
|
4875
4875
|
maxErr = 0;
|
|
4876
4876
|
for (let i = 0; i < curN; i++) {
|
|
4877
|
-
const
|
|
4877
|
+
const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / curN;
|
|
4878
|
+
const [ex, ey] = evaluateCurve2d$2(c, tMid);
|
|
4878
4879
|
const p0 = wasmIndex(poles, i);
|
|
4879
4880
|
const p1 = wasmIndex(poles, i + 1);
|
|
4880
4881
|
const mx = (p0[0] + p1[0]) / 2;
|
|
@@ -5123,7 +5124,8 @@ function liftCurve2dToPlane$1(oc, curve, planeOrigin, planeZ, planeX) {
|
|
|
5123
5124
|
const nSamples = 60;
|
|
5124
5125
|
const pts3d = [];
|
|
5125
5126
|
for (let i = 0; i <= nSamples; i++) {
|
|
5126
|
-
const
|
|
5127
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / nSamples;
|
|
5128
|
+
const [u, v] = evaluateCurve2d$2(c, t);
|
|
5127
5129
|
pts3d.push(lift(u, v));
|
|
5128
5130
|
}
|
|
5129
5131
|
return interpolatePoints3d(oc, pts3d);
|
|
@@ -5134,7 +5136,8 @@ function buildEdgeOnSurface$1(oc, curve, surface) {
|
|
|
5134
5136
|
const N = 60;
|
|
5135
5137
|
const pts3d = [];
|
|
5136
5138
|
for (let i = 0; i <= N; i++) {
|
|
5137
|
-
const
|
|
5139
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
5140
|
+
const [u, v] = evaluateCurve2d$2(c, t);
|
|
5138
5141
|
const gpPnt = surface.get().Value(u, v);
|
|
5139
5142
|
pts3d.push([
|
|
5140
5143
|
gpPnt.X(),
|
|
@@ -6686,8 +6689,6 @@ function fuseAll(bk, shapes, options) {
|
|
|
6686
6689
|
}
|
|
6687
6690
|
function cutAll(bk, shape, tools, options) {
|
|
6688
6691
|
if (tools.length === 0) return shape;
|
|
6689
|
-
if (tools.length === 1) return cut(bk, shape, tools[0], options);
|
|
6690
|
-
const baseId = unwrapSolidOrThrow(shape, "cutAll");
|
|
6691
6692
|
const toolIds = [];
|
|
6692
6693
|
for (const tool of tools) {
|
|
6693
6694
|
const h = tool;
|
|
@@ -6695,7 +6696,24 @@ function cutAll(bk, shape, tools, options) {
|
|
|
6695
6696
|
else toolIds.push(unwrapSolidOrThrow(tool, "cutAll"));
|
|
6696
6697
|
}
|
|
6697
6698
|
if (toolIds.length === 0) return shape;
|
|
6698
|
-
|
|
6699
|
+
const baseHandle = shape;
|
|
6700
|
+
if (isBrepkitHandle(shape) && baseHandle.type === "compound") {
|
|
6701
|
+
const survivors = [];
|
|
6702
|
+
for (const childId of toArray(bk.getCompoundSolids(baseHandle.id))) try {
|
|
6703
|
+
survivors.push(bk.compoundCut(childId, toolIds));
|
|
6704
|
+
} catch (e) {
|
|
6705
|
+
if (!isEmptyBooleanError(e)) throw e;
|
|
6706
|
+
}
|
|
6707
|
+
return compoundHandle(bk.makeCompound(survivors));
|
|
6708
|
+
}
|
|
6709
|
+
if (tools.length === 1) return cut(bk, shape, tools[0], options);
|
|
6710
|
+
const baseId = unwrapSolidOrThrow(shape, "cutAll");
|
|
6711
|
+
try {
|
|
6712
|
+
return solidHandle(bk.compoundCut(baseId, new Uint32Array(toolIds)));
|
|
6713
|
+
} catch (e) {
|
|
6714
|
+
if (isEmptyBooleanError(e)) return emptyCompound(bk);
|
|
6715
|
+
throw e;
|
|
6716
|
+
}
|
|
6699
6717
|
}
|
|
6700
6718
|
function split(bk, shape, tools) {
|
|
6701
6719
|
if (tools.length === 0) throw new Error("brepkit: split requires at least one tool");
|
|
@@ -8355,7 +8373,8 @@ function exportSTEP(bk, shapes) {
|
|
|
8355
8373
|
return parts.join("\n");
|
|
8356
8374
|
}
|
|
8357
8375
|
function exportSTL$1(bk, shape, binary, tolerance = DEFAULT_STL_TOLERANCE, angularTolerance = DEFAULT_STL_ANGULAR_TOLERANCE) {
|
|
8358
|
-
const
|
|
8376
|
+
const solidIds = unwrapSolidsForExport(bk, shape, "exportSTL");
|
|
8377
|
+
const { vertices, triangles } = mesh$1(bk, solidHandle(wasmIndex(solidIds, 0)), {
|
|
8359
8378
|
tolerance,
|
|
8360
8379
|
angularTolerance,
|
|
8361
8380
|
skipNormals: true
|
|
@@ -8609,7 +8628,6 @@ function reverseCurve2d(curve) {
|
|
|
8609
8628
|
if (Array.isArray(m.weights)) m.weights = [...m.weights].reverse();
|
|
8610
8629
|
break;
|
|
8611
8630
|
}
|
|
8612
|
-
default: break;
|
|
8613
8631
|
}
|
|
8614
8632
|
}
|
|
8615
8633
|
function copyCurve2d(curve) {
|
|
@@ -8801,7 +8819,8 @@ function transformCurve2dGeneral(curve, gtrsf) {
|
|
|
8801
8819
|
const N = 20;
|
|
8802
8820
|
const pts = [];
|
|
8803
8821
|
for (let i = 0; i <= N; i++) {
|
|
8804
|
-
const
|
|
8822
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
8823
|
+
const [px, py] = evaluateCurve2d$2(c, t);
|
|
8805
8824
|
pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
|
|
8806
8825
|
}
|
|
8807
8826
|
return makeBezier2d$2(pts);
|
|
@@ -8934,7 +8953,8 @@ function approximateCurve2dAsBSpline(curve, tol, cont, maxSeg) {
|
|
|
8934
8953
|
}
|
|
8935
8954
|
maxErr = 0;
|
|
8936
8955
|
for (let i = 0; i < N; i++) {
|
|
8937
|
-
const
|
|
8956
|
+
const tMid = bounds.first + (bounds.last - bounds.first) * (i + .5) / N;
|
|
8957
|
+
const [ex, ey] = evaluateCurve2d$2(c, tMid);
|
|
8938
8958
|
const p0 = wasmIndex(poles, i);
|
|
8939
8959
|
const p1 = wasmIndex(poles, i + 1);
|
|
8940
8960
|
const mx = (p0[0] + p1[0]) / 2;
|
|
@@ -9165,7 +9185,8 @@ function liftCurve2dToPlane(bk, curve, origin, planeZ, planeX) {
|
|
|
9165
9185
|
const nSamples = 100;
|
|
9166
9186
|
const points = [];
|
|
9167
9187
|
for (let i = 0; i <= nSamples; i++) {
|
|
9168
|
-
const
|
|
9188
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / nSamples;
|
|
9189
|
+
const [u, v] = evaluateCurve2d$2(c, t);
|
|
9169
9190
|
points.push(lift(u, v));
|
|
9170
9191
|
}
|
|
9171
9192
|
return interpolatePoints(bk, points);
|
|
@@ -9178,7 +9199,8 @@ function buildEdgeOnSurface(bk, curve, surface) {
|
|
|
9178
9199
|
const N = bk.getSurfaceType(fid) === "plane" ? 50 : 100;
|
|
9179
9200
|
const points = [];
|
|
9180
9201
|
for (let i = 0; i <= N; i++) {
|
|
9181
|
-
const
|
|
9202
|
+
const t = bounds.first + (bounds.last - bounds.first) * i / N;
|
|
9203
|
+
const [u, v] = evaluateCurve2d$2(c, t);
|
|
9182
9204
|
points.push(vec3At(bk.evaluateSurface(fid, u, v)));
|
|
9183
9205
|
}
|
|
9184
9206
|
return interpolatePoints(bk, points);
|
|
@@ -9908,6 +9930,7 @@ function makeSweepOps$1(bk) {
|
|
|
9908
9930
|
}
|
|
9909
9931
|
//#endregion
|
|
9910
9932
|
//#region src/kernel/brepkit/brepkitAdapter.ts
|
|
9933
|
+
/* v8 ignore file -- brepkit WASM kernel not available in OCCT test suite */
|
|
9911
9934
|
/**
|
|
9912
9935
|
* Kernel-lifecycle ops that call directly into the brepkit WASM instance
|
|
9913
9936
|
* without delegating through a `*Ops.ts` module. These are too thin to
|
|
@@ -10466,7 +10489,181 @@ function affineMatrix(linear, translation) {
|
|
|
10466
10489
|
m[14] = translation[2];
|
|
10467
10490
|
return m;
|
|
10468
10491
|
}
|
|
10492
|
+
/**
|
|
10493
|
+
* Profile shapes — edges, wires and faces — have no Manifold counterpart, so
|
|
10494
|
+
* they carry a placeholder value and live purely as op-graph nodes holding
|
|
10495
|
+
* their points. Calling Manifold's solid transform on one throws
|
|
10496
|
+
* `solid.transform is not a function`.
|
|
10497
|
+
*
|
|
10498
|
+
* Transform them by baking the matrix into the recorded points and emitting a
|
|
10499
|
+
* node of the same kind. `ringOrPts` reads points off the node and does not
|
|
10500
|
+
* walk inputs, so a transform-shaped node would read as an empty profile;
|
|
10501
|
+
* replay rebuilds profile nodes from those same points, so a baked transform
|
|
10502
|
+
* applies exactly once.
|
|
10503
|
+
*/
|
|
10504
|
+
var PROFILE_POINT_KEYS = [
|
|
10505
|
+
"pts",
|
|
10506
|
+
"ring",
|
|
10507
|
+
"outline"
|
|
10508
|
+
];
|
|
10509
|
+
function isVec3(v) {
|
|
10510
|
+
return Array.isArray(v) && v.length === 3 && v.every((n) => typeof n === "number");
|
|
10511
|
+
}
|
|
10512
|
+
function applyMat4(m, v) {
|
|
10513
|
+
const g = (i) => m[i] ?? 0;
|
|
10514
|
+
return [
|
|
10515
|
+
g(0) * v[0] + g(4) * v[1] + g(8) * v[2] + g(12),
|
|
10516
|
+
g(1) * v[0] + g(5) * v[1] + g(9) * v[2] + g(13),
|
|
10517
|
+
g(2) * v[0] + g(6) * v[1] + g(10) * v[2] + g(14)
|
|
10518
|
+
];
|
|
10519
|
+
}
|
|
10520
|
+
function numOf(v, fallback = 0) {
|
|
10521
|
+
return typeof v === "number" ? v : fallback;
|
|
10522
|
+
}
|
|
10523
|
+
function transformDir(matrix, v) {
|
|
10524
|
+
const o = applyMat4(matrix, [
|
|
10525
|
+
0,
|
|
10526
|
+
0,
|
|
10527
|
+
0
|
|
10528
|
+
]);
|
|
10529
|
+
const p = applyMat4(matrix, v);
|
|
10530
|
+
return [
|
|
10531
|
+
p[0] - o[0],
|
|
10532
|
+
p[1] - o[1],
|
|
10533
|
+
p[2] - o[2]
|
|
10534
|
+
];
|
|
10535
|
+
}
|
|
10536
|
+
function unit3(v) {
|
|
10537
|
+
const n = Math.hypot(v[0], v[1], v[2]);
|
|
10538
|
+
return n < 1e-12 ? v : [
|
|
10539
|
+
v[0] / n,
|
|
10540
|
+
v[1] / n,
|
|
10541
|
+
v[2] / n
|
|
10542
|
+
];
|
|
10543
|
+
}
|
|
10544
|
+
function similarityScale(m) {
|
|
10545
|
+
const g = (i) => m[i] ?? 0;
|
|
10546
|
+
const cx = [
|
|
10547
|
+
g(0),
|
|
10548
|
+
g(1),
|
|
10549
|
+
g(2)
|
|
10550
|
+
];
|
|
10551
|
+
const cy = [
|
|
10552
|
+
g(4),
|
|
10553
|
+
g(5),
|
|
10554
|
+
g(6)
|
|
10555
|
+
];
|
|
10556
|
+
const cz = [
|
|
10557
|
+
g(8),
|
|
10558
|
+
g(9),
|
|
10559
|
+
g(10)
|
|
10560
|
+
];
|
|
10561
|
+
const len = (v) => Math.hypot(v[0], v[1], v[2]);
|
|
10562
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
10563
|
+
const nx = len(cx);
|
|
10564
|
+
const ny = len(cy);
|
|
10565
|
+
const nz = len(cz);
|
|
10566
|
+
if (nx < 1e-12 || ny < 1e-12 || nz < 1e-12) return void 0;
|
|
10567
|
+
const tol = 1e-9 * nx;
|
|
10568
|
+
if (Math.abs(nx - ny) > tol || Math.abs(nx - nz) > tol) return void 0;
|
|
10569
|
+
if (Math.abs(dot(cx, cy)) > tol * ny) return void 0;
|
|
10570
|
+
if (Math.abs(dot(cx, cz)) > tol * nz) return void 0;
|
|
10571
|
+
if (Math.abs(dot(cy, cz)) > tol * nz) return void 0;
|
|
10572
|
+
return nx;
|
|
10573
|
+
}
|
|
10574
|
+
function transformCurveDesc(desc, matrix) {
|
|
10575
|
+
const kind = desc["k"];
|
|
10576
|
+
if (kind === "line") {
|
|
10577
|
+
const p1 = desc["p1"];
|
|
10578
|
+
const p2 = desc["p2"];
|
|
10579
|
+
if (!isVec3(p1) || !isVec3(p2)) return void 0;
|
|
10580
|
+
return {
|
|
10581
|
+
...desc,
|
|
10582
|
+
p1: applyMat4(matrix, p1),
|
|
10583
|
+
p2: applyMat4(matrix, p2)
|
|
10584
|
+
};
|
|
10585
|
+
}
|
|
10586
|
+
if (kind === "bezier") {
|
|
10587
|
+
const pts = desc["points"];
|
|
10588
|
+
if (!Array.isArray(pts)) return void 0;
|
|
10589
|
+
return {
|
|
10590
|
+
...desc,
|
|
10591
|
+
points: pts.map((p) => isVec3(p) ? applyMat4(matrix, p) : p)
|
|
10592
|
+
};
|
|
10593
|
+
}
|
|
10594
|
+
const s = similarityScale(matrix);
|
|
10595
|
+
if (s === void 0) return void 0;
|
|
10596
|
+
if (kind === "conic") {
|
|
10597
|
+
const c = desc["center"];
|
|
10598
|
+
const x = desc["x"];
|
|
10599
|
+
const y = desc["y"];
|
|
10600
|
+
if (!isVec3(c) || !isVec3(x) || !isVec3(y)) return void 0;
|
|
10601
|
+
return {
|
|
10602
|
+
...desc,
|
|
10603
|
+
center: applyMat4(matrix, c),
|
|
10604
|
+
x: unit3(transformDir(matrix, x)),
|
|
10605
|
+
y: unit3(transformDir(matrix, y)),
|
|
10606
|
+
rx: numOf(desc["rx"]) * s,
|
|
10607
|
+
ry: numOf(desc["ry"]) * s
|
|
10608
|
+
};
|
|
10609
|
+
}
|
|
10610
|
+
if (kind === "helix") {
|
|
10611
|
+
const c = desc["center"];
|
|
10612
|
+
const ax = desc["axis"];
|
|
10613
|
+
const x = desc["x"];
|
|
10614
|
+
const y = desc["y"];
|
|
10615
|
+
if (!isVec3(c) || !isVec3(ax) || !isVec3(x) || !isVec3(y)) return void 0;
|
|
10616
|
+
return {
|
|
10617
|
+
...desc,
|
|
10618
|
+
center: applyMat4(matrix, c),
|
|
10619
|
+
axis: unit3(transformDir(matrix, ax)),
|
|
10620
|
+
x: unit3(transformDir(matrix, x)),
|
|
10621
|
+
y: unit3(transformDir(matrix, y)),
|
|
10622
|
+
radius: numOf(desc["radius"]) * s,
|
|
10623
|
+
pitch: numOf(desc["pitch"]) * s
|
|
10624
|
+
};
|
|
10625
|
+
}
|
|
10626
|
+
}
|
|
10627
|
+
function transformProfileNode(node, matrix, input) {
|
|
10628
|
+
const src = node.params ?? {};
|
|
10629
|
+
const params = { ...src };
|
|
10630
|
+
for (const k of PROFILE_POINT_KEYS) {
|
|
10631
|
+
const pts = src[k];
|
|
10632
|
+
if (!Array.isArray(pts)) continue;
|
|
10633
|
+
params[k] = pts.map((v) => isVec3(v) ? applyMat4(matrix, v) : v);
|
|
10634
|
+
}
|
|
10635
|
+
for (const k of ["origin"]) {
|
|
10636
|
+
const v = src[k];
|
|
10637
|
+
if (isVec3(v)) params[k] = applyMat4(matrix, v);
|
|
10638
|
+
}
|
|
10639
|
+
for (const k of ["xAxis", "yAxis"]) {
|
|
10640
|
+
const v = src[k];
|
|
10641
|
+
if (!isVec3(v)) continue;
|
|
10642
|
+
const a = applyMat4(matrix, [
|
|
10643
|
+
0,
|
|
10644
|
+
0,
|
|
10645
|
+
0
|
|
10646
|
+
]);
|
|
10647
|
+
const b = applyMat4(matrix, v);
|
|
10648
|
+
params[k] = [
|
|
10649
|
+
b[0] - a[0],
|
|
10650
|
+
b[1] - a[1],
|
|
10651
|
+
b[2] - a[2]
|
|
10652
|
+
];
|
|
10653
|
+
}
|
|
10654
|
+
const curve = src["curve"];
|
|
10655
|
+
if (curve !== null && typeof curve === "object") {
|
|
10656
|
+
const moved = transformCurveDesc(curve, matrix);
|
|
10657
|
+
if (moved === void 0) delete params["curve"];
|
|
10658
|
+
else params["curve"] = moved;
|
|
10659
|
+
}
|
|
10660
|
+
return wrap({
|
|
10661
|
+
delete: () => {},
|
|
10662
|
+
isEmpty: () => false
|
|
10663
|
+
}, makeNode(node.op ?? "profileWire", params, [input]));
|
|
10664
|
+
}
|
|
10469
10665
|
function applyMatrix(solid, matrix, op, params, input) {
|
|
10666
|
+
if (typeof solid.transform !== "function") return transformProfileNode(input, matrix, input);
|
|
10470
10667
|
return wrap(solid.transform(matrix), makeNode(op, params, [input]));
|
|
10471
10668
|
}
|
|
10472
10669
|
function translate(shape, x, y, z) {
|
|
@@ -12754,6 +12951,14 @@ var HANDLERS = {
|
|
|
12754
12951
|
0,
|
|
12755
12952
|
0
|
|
12756
12953
|
];
|
|
12954
|
+
if (pts.length > 2) {
|
|
12955
|
+
const through = pts.map((q) => [
|
|
12956
|
+
q[0],
|
|
12957
|
+
q[1],
|
|
12958
|
+
q[2]
|
|
12959
|
+
]);
|
|
12960
|
+
return t.interpolatePoints(through);
|
|
12961
|
+
}
|
|
12757
12962
|
const b = pts.length > 1 ? pts[pts.length - 1] ?? a : [
|
|
12758
12963
|
a[0] + .001,
|
|
12759
12964
|
a[1],
|
|
@@ -13253,6 +13458,16 @@ function makeMeasureOps(_module) {
|
|
|
13253
13458
|
if (e && e.__nativeEdge && typeof e.length === "number") return e.length;
|
|
13254
13459
|
const node = asManifoldShape(shape)?.node;
|
|
13255
13460
|
if (node?.op === "profileEdge" && node.params?.curve) return descLength(node.params.curve);
|
|
13461
|
+
const pts = node?.op === "profileEdge" ? node.params?.pts : void 0;
|
|
13462
|
+
if (pts && pts.length > 1) {
|
|
13463
|
+
let total = 0;
|
|
13464
|
+
for (let i = 1; i < pts.length; i++) {
|
|
13465
|
+
const a = pts[i - 1] ?? [];
|
|
13466
|
+
const b = pts[i] ?? [];
|
|
13467
|
+
total += Math.hypot((b[0] ?? 0) - (a[0] ?? 0), (b[1] ?? 0) - (a[1] ?? 0), (b[2] ?? 0) - (a[2] ?? 0));
|
|
13468
|
+
}
|
|
13469
|
+
return total;
|
|
13470
|
+
}
|
|
13256
13471
|
return notImplemented("length");
|
|
13257
13472
|
},
|
|
13258
13473
|
centerOfMass: (shape) => centerOfMass(shape),
|
|
@@ -14808,7 +15023,7 @@ function segSeg(p1, p2, p3, p4) {
|
|
|
14808
15023
|
if (Math.abs(den) < 1e-15) return null;
|
|
14809
15024
|
const t = ((p3[0] - p1[0]) * d2y - (p3[1] - p1[1]) * d2x) / den;
|
|
14810
15025
|
const u = ((p3[0] - p1[0]) * d1y - (p3[1] - p1[1]) * d1x) / den;
|
|
14811
|
-
if (t < -1e-9 || t > 1
|
|
15026
|
+
if (t < -1e-9 || t > 1 + 1e-9 || u < -1e-9 || u > 1 + 1e-9) return null;
|
|
14812
15027
|
return [p1[0] + d1x * t, p1[1] + d1y * t];
|
|
14813
15028
|
}
|
|
14814
15029
|
/**
|
|
@@ -15929,7 +16144,7 @@ async function init() {
|
|
|
15929
16144
|
throw new Error("brepjs: no kernel package found. Install one of:\n npm install occt-wasm (recommended, default)\n npm install brepjs-opencascade\n npm install brepkit-wasm");
|
|
15930
16145
|
}
|
|
15931
16146
|
//#endregion
|
|
15932
|
-
//#region \0@oxc-project+runtime@0.
|
|
16147
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/usingCtx.js
|
|
15933
16148
|
function _usingCtx() {
|
|
15934
16149
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
|
|
15935
16150
|
var n = Error();
|