brepjs 12.2.12 → 12.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/2d/blueprints/Blueprint.d.ts +1 -1
- package/dist/2d/blueprints/Blueprint.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/{Blueprint-CX2oh-NE.cjs → Blueprint-CoFJDAQd.cjs} +6 -6
- package/dist/{Blueprint-BWAzjtvF.js → Blueprint-CtuUvzex.js} +6 -6
- package/dist/{boolean2D-G9edb4Pw.cjs → boolean2D-Dk-vLBdl.cjs} +8 -8
- package/dist/{boolean2D-B17ZPZ63.js → boolean2D-x2irapGj.js} +8 -8
- package/dist/{booleanFns-DQj7i7qb.cjs → booleanFns-BJjYqwJ5.cjs} +3 -3
- package/dist/{booleanFns-EsNGs4Zu.js → booleanFns-DtOkwLHI.js} +3 -3
- package/dist/brepjs.cjs +343 -35
- package/dist/brepjs.js +383 -75
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-NbeO5KWC.cjs → cornerFinder-BESZIitp.cjs} +2 -2
- package/dist/{cornerFinder-57qxNypG.js → cornerFinder-FY38t0zq.js} +2 -2
- package/dist/{curveFns-BN9bWCIl.cjs → curveFns-Ch87sD5O.cjs} +1 -1
- package/dist/{curveFns-DRb_8jyd.js → curveFns-LRNGcHXh.js} +1 -1
- package/dist/{drawFns-Br57GZWI.cjs → drawFns-BEeoD1yO.cjs} +16 -16
- package/dist/{drawFns-DWTCgzlb.js → drawFns-D8QyY7cg.js} +16 -16
- package/dist/{faceFns-Dka8xvYk.js → faceFns-B6ebRh5I.js} +6 -2
- package/dist/{faceFns-Cfvj4nxx.cjs → faceFns-BLTEPBKq.cjs} +5 -1
- package/dist/{helpers-Cu_7Qo9J.cjs → helpers-DNzVfe-Z.cjs} +4 -4
- package/dist/{helpers-10HaneKK.js → helpers-DeFPsrcI.js} +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +3 -3
- package/dist/io.js +3 -3
- package/dist/kernel/advancedOps.d.ts +2 -0
- package/dist/kernel/advancedOps.d.ts.map +1 -1
- package/dist/kernel/brepkitAdapter.d.ts +59 -0
- package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
- package/dist/kernel/brepkitWasmTypes.d.ts +2 -2
- package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
- package/dist/kernel/defaultAdapter.d.ts +35 -0
- package/dist/kernel/defaultAdapter.d.ts.map +1 -1
- package/dist/kernel/index.d.ts +2 -2
- package/dist/kernel/index.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +85 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-BDnb8toT.cjs → loft-DR1UN5uN.cjs} +4 -4
- package/dist/{loft-DTFP5fVL.js → loft-DsVv4yxU.js} +4 -4
- package/dist/{measurement-ypLLNq5y.cjs → measurement-DoYXRaKI.cjs} +2 -2
- package/dist/{measurement-9v764TRE.js → measurement-oWvhSVZG.js} +2 -2
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-xWim4bEU.cjs → meshFns-BU2l_yOm.cjs} +2 -2
- package/dist/{meshFns-B1FRGCo4.js → meshFns-HNwWuM4v.js} +2 -2
- package/dist/{operations-CLaaoj2N.cjs → operations-D-gTZNtM.cjs} +6 -6
- package/dist/{operations-C0597E2p.js → operations-D_3rrfrE.js} +6 -6
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query.cjs +4 -4
- package/dist/query.js +5 -5
- package/dist/{shapeFns-Dim8UTHh.js → shapeFns-CbXxLvV_.js} +2 -2
- package/dist/{shapeFns-ZbzAD8yC.cjs → shapeFns-DHlLNHTn.cjs} +2 -2
- package/dist/{shapeTypes-BQGbhdgi.cjs → shapeTypes-7xEam9Ri.cjs} +124 -0
- package/dist/{shapeTypes-ByN4-0Hp.js → shapeTypes-CpSaBLDv.js} +124 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-Bc6kgqJ9.js → solidBuilders-BXhh5hP2.js} +2 -2
- package/dist/{solidBuilders-CYEEZgiP.cjs → solidBuilders-BzfRBizW.cjs} +2 -2
- package/dist/{surfaceBuilders-CXarnCh8.cjs → surfaceBuilders-Be_ENWSA.cjs} +2 -2
- package/dist/{surfaceBuilders-Bdn7iqv5.js → surfaceBuilders-D7ZH2QNS.js} +2 -2
- package/dist/topology/adjacencyFns.d.ts.map +1 -1
- package/dist/topology/faceFns.d.ts +5 -0
- package/dist/topology/faceFns.d.ts.map +1 -1
- package/dist/{topology-CPYjaISY.cjs → topology-BHnY7Szr.cjs} +8 -8
- package/dist/{topology-Cq1j_bp1.js → topology-C1eZ86dI.js} +8 -8
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +7 -7
- package/package.json +4 -4
package/dist/brepjs.js
CHANGED
|
@@ -43,49 +43,52 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
43
43
|
};
|
|
44
44
|
return next();
|
|
45
45
|
};
|
|
46
|
-
import { c as castShape, D as DisposalScope, B as getKernel, k as isFace, q as isShell, r as isSolid, p as isShape3D, F as createSolid, G as createWire, j as isEdge, u as isWire } from "./shapeTypes-
|
|
47
|
-
import { M, N, O, a, C, H, I, b, d, P, E, g, Q, i, e, f, h, l, m, n, o, s, t, v, w, R, x, S, y, z, A } from "./shapeTypes-
|
|
46
|
+
import { c as castShape, D as DisposalScope, B as getKernel, k as isFace, q as isShell, r as isSolid, p as isShape3D, F as createSolid, G as createWire, j as isEdge, u as isWire } from "./shapeTypes-CpSaBLDv.js";
|
|
47
|
+
import { M, N, O, a, C, H, I, b, d, P, E, g, Q, i, e, f, h, l, m, n, o, s, t, v, w, R, x, S, y, z, A } from "./shapeTypes-CpSaBLDv.js";
|
|
48
48
|
import { o as ok, z as translateKernelError, e as err, p as typeCastError, q as queryError, y as validationError, B as BrepErrorCode, k as kernelError, i as ioError, d as isErr, r as unwrap$1 } from "./errors-B7kgv0cd.js";
|
|
49
49
|
import { O as O2, A as A2, a as a2, c, b as b2, f as f2, C as C2, g as g2, m as m2, h as h2, j, l as l2, D, E as E2, F, s as s2, G, H as H2, t as t2, n as n2, u, v as v2, w as w2, x as x2, I as I2 } from "./errors-B7kgv0cd.js";
|
|
50
50
|
import { c as vecDistance, H as HASH_CODE_MAX, n as vecScale, j as vecNormalize, f as vecIsZero } from "./vecOps-ZDdZWbwT.js";
|
|
51
51
|
import { D as D2, R as R2, v as v3, a as a3, b as b3, d as d2, e as e2, g as g3, h as h3, i as i2, k, l as l3, m as m3, o as o2 } from "./vecOps-ZDdZWbwT.js";
|
|
52
|
-
import { B, d as d3, C as C3, t as t3 } from "./Blueprint-
|
|
53
|
-
import { b as b4, g as g4, r } from "./loft-
|
|
54
|
-
import { w as walkAssembly, e as extrude$1, r as revolve$1, s as sweep, c as circularPattern, l as linearPattern } from "./operations-
|
|
55
|
-
import { a as a4, b as b5, d as d4, f as f3, g as g5, h as h4, i as i3, j as j2, k as k2, m as m4, n as n3, o as o3, p, q, t as t4, u as u2, v as v4, x as x3, y as y2, z as z2, A as A3, B as B2, C as C4, D as D3, E as E3, F as F2, G as G2 } from "./operations-
|
|
56
|
-
import { B as B3, a as a5, e as e3, C as C5, F as F3, S as S2, f as f4, l as l4, g as g6, n as n4, k as k3, q as q2, o as o4, p as p2, r as r2 } from "./boolean2D-
|
|
52
|
+
import { B, d as d3, C as C3, t as t3 } from "./Blueprint-CtuUvzex.js";
|
|
53
|
+
import { b as b4, g as g4, r } from "./loft-DsVv4yxU.js";
|
|
54
|
+
import { w as walkAssembly, e as extrude$1, r as revolve$1, s as sweep, c as circularPattern, l as linearPattern } from "./operations-D_3rrfrE.js";
|
|
55
|
+
import { a as a4, b as b5, d as d4, f as f3, g as g5, h as h4, i as i3, j as j2, k as k2, m as m4, n as n3, o as o3, p, q, t as t4, u as u2, v as v4, x as x3, y as y2, z as z2, A as A3, B as B2, C as C4, D as D3, E as E3, F as F2, G as G2 } from "./operations-D_3rrfrE.js";
|
|
56
|
+
import { B as B3, a as a5, e as e3, C as C5, F as F3, S as S2, f as f4, l as l4, g as g6, n as n4, k as k3, q as q2, o as o4, p as p2, r as r2 } from "./boolean2D-x2irapGj.js";
|
|
57
57
|
import { createBlueprint, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, getBounds2D, getOrientation2D, isInside2D, mirror2D, reverseCurve, rotate2D, scale2D, sketch2DOnFace, sketch2DOnPlane, stretch2D, toSVGPathD, translate2D } from "./2d.js";
|
|
58
|
-
import { l as createTypedFinder, m as faceFinder } from "./helpers-
|
|
59
|
-
import { g as g7 } from "./helpers-
|
|
58
|
+
import { l as createTypedFinder, m as faceFinder } from "./helpers-DeFPsrcI.js";
|
|
59
|
+
import { g as g7 } from "./helpers-DeFPsrcI.js";
|
|
60
60
|
import { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportOBJ, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD } from "./io.js";
|
|
61
|
-
import { C as C6, D as D4, a as a6, S as S3, b as b6, X, Y, c as c2, d as d5, e as e4, f as f5, Z, g as g8, h as h5, i as i4, j as j3, k as k4, l as l5, m as m5, n as n5, o as o5, p as p3, q as q3, r as r3, s as s3, t as t5, u as u3, v as v5, w as w3, x as x4, y as y3, z as z3, _, $, a0, a1, A as A4, a2 as a22, B as B4, E as E4, a3 as a32, F as F4, G as G3, H as H3, I as I3, J, K, L, M as M2, N as N2, O as O3, P as P2, Q as Q2, R as R3, T, U, a4 as a42, V, a5 as a52, a6 as a62, W } from "./drawFns-
|
|
61
|
+
import { C as C6, D as D4, a as a6, S as S3, b as b6, X, Y, c as c2, d as d5, e as e4, f as f5, Z, g as g8, h as h5, i as i4, j as j3, k as k4, l as l5, m as m5, n as n5, o as o5, p as p3, q as q3, r as r3, s as s3, t as t5, u as u3, v as v5, w as w3, x as x4, y as y3, z as z3, _, $, a0, a1, A as A4, a2 as a22, B as B4, E as E4, a3 as a32, F as F4, G as G3, H as H3, I as I3, J, K, L, M as M2, N as N2, O as O3, P as P2, Q as Q2, R as R3, T, U, a4 as a42, V, a5 as a52, a6 as a62, W } from "./drawFns-D8QyY7cg.js";
|
|
62
62
|
import { a as toVec3 } from "./types-CWDdqcrq.js";
|
|
63
63
|
import { r as r4, t as t6 } from "./types-CWDdqcrq.js";
|
|
64
64
|
import { c as c3, a as a7, p as p4, r as r5, t as t7 } from "./vectors-cec8p8NQ.js";
|
|
65
|
-
import { v as vertexPosition, a as getFaces, e as getVertices, d as getEdges, h as getBounds, b as propagateOriginsFromEvolution, g as getFaceOrigins, j as applyMatrix$1, k as clone$1, l as describe$1, m as isEmpty$1, n as mirror$1, r as rotate$1, s as scale$1, o as simplify$1, t as toBREP$1, q as transformCopy$1, u as translate$1, c as getWires } from "./shapeFns-
|
|
66
|
-
import { w as w4, f as f6, x as x5, i as i5, y as y4, z as z4, A as A5, B as B5, C as C7, D as D5 } from "./shapeFns-
|
|
67
|
-
import { p as propagateFaceTagsFromEvolution, a as propagateColorsFromEvolution, h as hasFaceTags, b as hasColorMetadata, c as cut$1, f as fuse$1, i as intersect$1, s as section$1, d as sectionToFace$1, e as slice$1, g as split$1, j as fuseAll, k as cutAll } from "./booleanFns-
|
|
68
|
-
import { l as l6, m as m6, n as n6, o as o6, q as q4, r as r6, t as t8, u as u4, v as v6 } from "./booleanFns-
|
|
69
|
-
import { c as chamferDistAngle, h as heal$1, i as isValid$1 } from "./topology-
|
|
70
|
-
import { a as a8, b as b7, d as d6, e as e5, f as f7, g as g9, j as j4, k as k5, l as l7, m as m7, n as n7, o as o7, p as p5, q as q5, r as r7, s as s4, t as t9, u as u5, v as v7, w as w5, x as x6, y as y5, z as z5, A as A6, B as B6, C as C8, D as D6, E as E5, F as F5, G as G4, H as H4, I as I4, J as J2, K as K2, L as L2, M as M3, N as N3, O as O4, P as P3, Q as Q3 } from "./topology-
|
|
71
|
-
import { e as curveIsClosed, d as curveStartPoint, c as curveTangentAt, h as curvePointAt, a as curveEndPoint, i as curveLength } from "./curveFns-
|
|
72
|
-
import { j as j5, k as k6, l as l8, f as f8, b as b8, g as g10, m as m8, o as o8 } from "./curveFns-
|
|
73
|
-
import { i as iterTopo, e as faceCenter, n as normalAt, j as fromBREP$1, k as innerWires, o as outerWire, g as getSurfaceType } from "./faceFns-
|
|
74
|
-
import { l as l9, c as c4, m as m9, d as d7, f as f9, q as q6, r as r8, s as s5, p as p6, t as t10, v as v8, u as u6, h as h6 } from "./faceFns-
|
|
75
|
-
import { m as mesh$1, a as meshEdges$1 } from "./meshFns-
|
|
76
|
-
import { c as c5, b as b9, e as e6, d as d8, f as f10 } from "./meshFns-
|
|
77
|
-
import { m as measureArea, a as measureSurfaceProps, b as measureVolumeProps, c as measureVolume } from "./measurement-
|
|
78
|
-
import { d as d9, e as e7, f as f11, g as g11, h as h7, i as i6 } from "./measurement-
|
|
79
|
-
import { m as makeFace } from "./surfaceBuilders-
|
|
80
|
-
import { n as n8 } from "./surfaceBuilders-
|
|
65
|
+
import { v as vertexPosition, a as getFaces, e as getVertices, d as getEdges, h as getBounds, b as propagateOriginsFromEvolution, g as getFaceOrigins, j as applyMatrix$1, k as clone$1, l as describe$1, m as isEmpty$1, n as mirror$1, r as rotate$1, s as scale$1, o as simplify$1, t as toBREP$1, q as transformCopy$1, u as translate$1, c as getWires } from "./shapeFns-CbXxLvV_.js";
|
|
66
|
+
import { w as w4, f as f6, x as x5, i as i5, y as y4, z as z4, A as A5, B as B5, C as C7, D as D5 } from "./shapeFns-CbXxLvV_.js";
|
|
67
|
+
import { p as propagateFaceTagsFromEvolution, a as propagateColorsFromEvolution, h as hasFaceTags, b as hasColorMetadata, c as cut$1, f as fuse$1, i as intersect$1, s as section$1, d as sectionToFace$1, e as slice$1, g as split$1, j as fuseAll, k as cutAll } from "./booleanFns-DtOkwLHI.js";
|
|
68
|
+
import { l as l6, m as m6, n as n6, o as o6, q as q4, r as r6, t as t8, u as u4, v as v6 } from "./booleanFns-DtOkwLHI.js";
|
|
69
|
+
import { c as chamferDistAngle, h as heal$1, i as isValid$1 } from "./topology-C1eZ86dI.js";
|
|
70
|
+
import { a as a8, b as b7, d as d6, e as e5, f as f7, g as g9, j as j4, k as k5, l as l7, m as m7, n as n7, o as o7, p as p5, q as q5, r as r7, s as s4, t as t9, u as u5, v as v7, w as w5, x as x6, y as y5, z as z5, A as A6, B as B6, C as C8, D as D6, E as E5, F as F5, G as G4, H as H4, I as I4, J as J2, K as K2, L as L2, M as M3, N as N3, O as O4, P as P3, Q as Q3 } from "./topology-C1eZ86dI.js";
|
|
71
|
+
import { e as curveIsClosed, d as curveStartPoint, c as curveTangentAt, h as curvePointAt, a as curveEndPoint, i as curveLength } from "./curveFns-LRNGcHXh.js";
|
|
72
|
+
import { j as j5, k as k6, l as l8, f as f8, b as b8, g as g10, m as m8, o as o8 } from "./curveFns-LRNGcHXh.js";
|
|
73
|
+
import { i as iterTopo, e as faceCenter, n as normalAt, j as fromBREP$1, k as innerWires, o as outerWire, g as getSurfaceType } from "./faceFns-B6ebRh5I.js";
|
|
74
|
+
import { l as l9, c as c4, m as m9, d as d7, f as f9, q as q6, r as r8, s as s5, p as p6, t as t10, v as v8, w as w6, u as u6, h as h6 } from "./faceFns-B6ebRh5I.js";
|
|
75
|
+
import { m as mesh$1, a as meshEdges$1 } from "./meshFns-HNwWuM4v.js";
|
|
76
|
+
import { c as c5, b as b9, e as e6, d as d8, f as f10 } from "./meshFns-HNwWuM4v.js";
|
|
77
|
+
import { m as measureArea, a as measureSurfaceProps, b as measureVolumeProps, c as measureVolume } from "./measurement-oWvhSVZG.js";
|
|
78
|
+
import { d as d9, e as e7, f as f11, g as g11, h as h7, i as i6 } from "./measurement-oWvhSVZG.js";
|
|
79
|
+
import { m as makeFace } from "./surfaceBuilders-D7ZH2QNS.js";
|
|
80
|
+
import { n as n8 } from "./surfaceBuilders-D7ZH2QNS.js";
|
|
81
81
|
import { edgeFinder } from "./query.js";
|
|
82
|
-
import { c as makeCylinder } from "./solidBuilders-
|
|
82
|
+
import { c as makeCylinder } from "./solidBuilders-BXhh5hP2.js";
|
|
83
83
|
import { BrepBugError, bug } from "./result.js";
|
|
84
|
-
import { c as c6 } from "./cornerFinder-
|
|
84
|
+
import { c as c6 } from "./cornerFinder-FY38t0zq.js";
|
|
85
85
|
import { createOperationRegistry, createTaskQueue, createWorkerClient, createWorkerHandler, dequeueTask, enqueueTask, isDisposeRequest, isErrorResponse, isInitRequest, isOperationRequest, isQueueEmpty, isSuccessResponse, pendingCount, registerHandler, rejectAll } from "./worker.js";
|
|
86
86
|
function supportsProjection(kernel) {
|
|
87
87
|
return "projectShape" in kernel;
|
|
88
88
|
}
|
|
89
|
+
function supportsConstraintSketch(kernel) {
|
|
90
|
+
return "sketchNew" in kernel && "sketchDof" in kernel;
|
|
91
|
+
}
|
|
89
92
|
function evaluateCurve2d(c7, t11) {
|
|
90
93
|
switch (c7.__bk2d) {
|
|
91
94
|
case "line":
|
|
@@ -718,6 +721,9 @@ function dist3(x1, y1, z1, x22, y22, z22) {
|
|
|
718
721
|
const dx = x1 - x22, dy = y1 - y22, dz = z1 - z22;
|
|
719
722
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
720
723
|
}
|
|
724
|
+
function copyWasmBytes(bytes) {
|
|
725
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
726
|
+
}
|
|
721
727
|
function translationMatrix(x7, y6, z6) {
|
|
722
728
|
return [
|
|
723
729
|
1,
|
|
@@ -1330,10 +1336,10 @@ class BrepkitAdapter {
|
|
|
1330
1336
|
return compoundHandle(id);
|
|
1331
1337
|
}
|
|
1332
1338
|
makeBoxFromCorners(p1, p22) {
|
|
1333
|
-
const
|
|
1339
|
+
const w7 = Math.abs(p22[0] - p1[0]);
|
|
1334
1340
|
const h8 = Math.abs(p22[1] - p1[1]);
|
|
1335
1341
|
const d10 = Math.abs(p22[2] - p1[2]);
|
|
1336
|
-
const box = this.makeBox(
|
|
1342
|
+
const box = this.makeBox(w7, h8, d10);
|
|
1337
1343
|
const minX = Math.min(p1[0], p22[0]);
|
|
1338
1344
|
const minY = Math.min(p1[1], p22[1]);
|
|
1339
1345
|
const minZ = Math.min(p1[2], p22[2]);
|
|
@@ -1411,12 +1417,12 @@ class BrepkitAdapter {
|
|
|
1411
1417
|
"Loft options (ruled, startShape, endShape) not supported; ignored."
|
|
1412
1418
|
);
|
|
1413
1419
|
}
|
|
1414
|
-
const faceIds = wires.map((
|
|
1415
|
-
const h8 =
|
|
1420
|
+
const faceIds = wires.map((w7) => {
|
|
1421
|
+
const h8 = w7;
|
|
1416
1422
|
if (h8.type === "wire") {
|
|
1417
1423
|
return this.bk.makeFaceFromWire(h8.id);
|
|
1418
1424
|
}
|
|
1419
|
-
return unwrap(
|
|
1425
|
+
return unwrap(w7, "face");
|
|
1420
1426
|
});
|
|
1421
1427
|
const id = this.bk.loft(faceIds);
|
|
1422
1428
|
return solidHandle(id);
|
|
@@ -2049,7 +2055,7 @@ class BrepkitAdapter {
|
|
|
2049
2055
|
const deflection = options.tolerance || DEFAULT_DEFLECTION;
|
|
2050
2056
|
let result;
|
|
2051
2057
|
if (bkHandle.type === "solid") {
|
|
2052
|
-
result = this.meshSolid(h8, deflection);
|
|
2058
|
+
result = this.meshSolid(h8, deflection, !!options.includeUVs);
|
|
2053
2059
|
} else if (bkHandle.type === "face") {
|
|
2054
2060
|
result = this.meshSingleFace(h8, deflection, 0);
|
|
2055
2061
|
} else {
|
|
@@ -2890,10 +2896,10 @@ class BrepkitAdapter {
|
|
|
2890
2896
|
return shape2;
|
|
2891
2897
|
}
|
|
2892
2898
|
loftAdvanced(wires, options) {
|
|
2893
|
-
const faceIds = wires.map((
|
|
2894
|
-
const h8 =
|
|
2899
|
+
const faceIds = wires.map((w7) => {
|
|
2900
|
+
const h8 = w7;
|
|
2895
2901
|
if (h8.type === "wire") return this.bk.makeFaceFromWire(h8.id);
|
|
2896
|
-
return unwrap(
|
|
2902
|
+
return unwrap(w7, "face");
|
|
2897
2903
|
});
|
|
2898
2904
|
try {
|
|
2899
2905
|
const opts = {};
|
|
@@ -2996,12 +3002,14 @@ class BrepkitAdapter {
|
|
|
2996
3002
|
return this.makeFace(wire, true);
|
|
2997
3003
|
}
|
|
2998
3004
|
addHolesInFace(face, holeWires) {
|
|
2999
|
-
const wireIds = holeWires.map((
|
|
3005
|
+
const wireIds = holeWires.map((w7) => unwrap(w7, "wire"));
|
|
3000
3006
|
const id = this.bk.addHolesToFace(unwrap(face, "face"), wireIds);
|
|
3001
3007
|
return faceHandle(id);
|
|
3002
3008
|
}
|
|
3003
|
-
|
|
3004
|
-
|
|
3009
|
+
removeHolesFromFace(face) {
|
|
3010
|
+
const id = this.bk.removeHolesFromFace(unwrap(face, "face"));
|
|
3011
|
+
return faceHandle(id);
|
|
3012
|
+
}
|
|
3005
3013
|
makeFaceOnSurface(_surface, wire) {
|
|
3006
3014
|
return this.makeFace(wire, true);
|
|
3007
3015
|
}
|
|
@@ -3262,9 +3270,25 @@ class BrepkitAdapter {
|
|
|
3262
3270
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3263
3271
|
// Dispose
|
|
3264
3272
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3273
|
+
/**
|
|
3274
|
+
* Create an arena checkpoint. Returns checkpoint index.
|
|
3275
|
+
* Use {@link restoreCheckpoint} to roll back or {@link discardCheckpoint} to keep.
|
|
3276
|
+
*/
|
|
3277
|
+
checkpoint() {
|
|
3278
|
+
return this.bk.checkpoint();
|
|
3279
|
+
}
|
|
3280
|
+
/** Get the current number of active checkpoints. */
|
|
3281
|
+
checkpointCount() {
|
|
3282
|
+
return this.bk.checkpointCount();
|
|
3283
|
+
}
|
|
3284
|
+
/** Restore arena to a checkpoint, freeing all handles created after it. */
|
|
3285
|
+
restoreCheckpoint(cp) {
|
|
3286
|
+
this.bk.restore(cp);
|
|
3287
|
+
}
|
|
3288
|
+
/** Discard a checkpoint without restoring (keep all handles). */
|
|
3289
|
+
discardCheckpoint(cp) {
|
|
3290
|
+
this.bk.discardCheckpoint(cp);
|
|
3291
|
+
}
|
|
3268
3292
|
dispose(_handle) {
|
|
3269
3293
|
}
|
|
3270
3294
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -3891,22 +3915,62 @@ class BrepkitAdapter {
|
|
|
3891
3915
|
}
|
|
3892
3916
|
extractCurve2dFromEdge(edge, face) {
|
|
3893
3917
|
const eid = unwrap(edge, "edge");
|
|
3894
|
-
unwrap(face, "face");
|
|
3918
|
+
const fid = unwrap(face, "face");
|
|
3895
3919
|
const params = this.bk.getEdgeCurveParameters(eid);
|
|
3896
3920
|
const tMin = params[0] ?? 0;
|
|
3897
3921
|
const tMax = params[1] ?? 1;
|
|
3898
|
-
const
|
|
3899
|
-
const
|
|
3900
|
-
|
|
3901
|
-
|
|
3922
|
+
const BASE_N = 20;
|
|
3923
|
+
const MAX_N = 80;
|
|
3924
|
+
const REFINE_THRESHOLD = 0.05;
|
|
3925
|
+
const tValues = [];
|
|
3926
|
+
for (let i7 = 0; i7 <= BASE_N; i7++) {
|
|
3927
|
+
tValues.push(tMin + (tMax - tMin) * i7 / BASE_N);
|
|
3928
|
+
}
|
|
3929
|
+
const evaluateUV = (t11) => {
|
|
3902
3930
|
const pt = this.bk.evaluateEdgeCurve(eid, t11);
|
|
3903
|
-
|
|
3931
|
+
const uv = this.bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
|
|
3932
|
+
return [uv[0], uv[1]];
|
|
3933
|
+
};
|
|
3934
|
+
const uvSamples = tValues.map((t11) => ({
|
|
3935
|
+
t: t11,
|
|
3936
|
+
uv: evaluateUV(t11)
|
|
3937
|
+
}));
|
|
3938
|
+
let refinements = 0;
|
|
3939
|
+
while (uvSamples.length < MAX_N) {
|
|
3940
|
+
const insertions = [];
|
|
3941
|
+
for (let i7 = 0; i7 < uvSamples.length - 1; i7++) {
|
|
3942
|
+
const a9 = uvSamples[i7];
|
|
3943
|
+
const b10 = uvSamples[i7 + 1];
|
|
3944
|
+
const tMid = (a9.t + b10.t) / 2;
|
|
3945
|
+
const uvMid = evaluateUV(tMid);
|
|
3946
|
+
const interpU = (a9.uv[0] + b10.uv[0]) / 2;
|
|
3947
|
+
const interpV = (a9.uv[1] + b10.uv[1]) / 2;
|
|
3948
|
+
const deviation = Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2);
|
|
3949
|
+
if (deviation > REFINE_THRESHOLD) {
|
|
3950
|
+
insertions.push({ index: i7 + 1, t: tMid, uv: uvMid });
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
if (insertions.length === 0) break;
|
|
3954
|
+
let budget = MAX_N - uvSamples.length;
|
|
3955
|
+
for (let j6 = insertions.length - 1; j6 >= 0 && budget > 0; j6--) {
|
|
3956
|
+
const ins = insertions[j6];
|
|
3957
|
+
uvSamples.splice(ins.index, 0, { t: ins.t, uv: ins.uv });
|
|
3958
|
+
budget--;
|
|
3959
|
+
}
|
|
3960
|
+
refinements++;
|
|
3961
|
+
if (refinements > 3) break;
|
|
3904
3962
|
}
|
|
3963
|
+
const uvPoints = uvSamples.map((s6) => s6.uv);
|
|
3905
3964
|
if (uvPoints.length >= 2) {
|
|
3906
3965
|
return this.makeBSpline2d(uvPoints);
|
|
3907
3966
|
}
|
|
3908
3967
|
const verts = this.bk.getEdgeVertices(eid);
|
|
3909
|
-
|
|
3968
|
+
if (verts.length >= 6) {
|
|
3969
|
+
const uv1 = this.bk.projectPointOnSurface(fid, verts[0], verts[1], verts[2]);
|
|
3970
|
+
const uv2 = this.bk.projectPointOnSurface(fid, verts[3], verts[4], verts[5]);
|
|
3971
|
+
return makeLine2d(uv1[0], uv1[1], uv2[0], uv2[1]);
|
|
3972
|
+
}
|
|
3973
|
+
throw new Error(`brepkit: extractCurve2dFromEdge: degenerate edge (${verts.length} coords)`);
|
|
3910
3974
|
}
|
|
3911
3975
|
buildCurves3d(_wire) {
|
|
3912
3976
|
}
|
|
@@ -4023,9 +4087,9 @@ class BrepkitAdapter {
|
|
|
4023
4087
|
return result;
|
|
4024
4088
|
}
|
|
4025
4089
|
/** Tessellate a solid with per-face groups for brepjs mesh format. */
|
|
4026
|
-
meshSolid(solidId, deflection) {
|
|
4090
|
+
meshSolid(solidId, deflection, includeUVs) {
|
|
4027
4091
|
try {
|
|
4028
|
-
return this.meshSolidGrouped(solidId, deflection);
|
|
4092
|
+
return this.meshSolidGrouped(solidId, deflection, includeUVs);
|
|
4029
4093
|
} catch (e8) {
|
|
4030
4094
|
console.warn(
|
|
4031
4095
|
`brepkit: tessellateSolidGrouped failed (solidId=${solidId}), falling back to per-face:`,
|
|
@@ -4037,8 +4101,11 @@ class BrepkitAdapter {
|
|
|
4037
4101
|
/**
|
|
4038
4102
|
* Batch tessellation via `tessellateSolidGrouped` — single WASM call for
|
|
4039
4103
|
* all faces. Falls back to `meshSolidPerFace` on error.
|
|
4104
|
+
*
|
|
4105
|
+
* When `includeUVs` is true, makes an additional `tessellateSolidUV` call
|
|
4106
|
+
* to populate real surface parametrization coordinates.
|
|
4040
4107
|
*/
|
|
4041
|
-
meshSolidGrouped(solidId, deflection) {
|
|
4108
|
+
meshSolidGrouped(solidId, deflection, includeUVs) {
|
|
4042
4109
|
const json = this.bk.tessellateSolidGrouped(solidId, deflection);
|
|
4043
4110
|
const data = JSON.parse(json);
|
|
4044
4111
|
const faceIds = toArray(this.bk.getSolidFaces(solidId));
|
|
@@ -4059,12 +4126,26 @@ class BrepkitAdapter {
|
|
|
4059
4126
|
faceHash: faceIds[i7] ?? 0
|
|
4060
4127
|
});
|
|
4061
4128
|
}
|
|
4129
|
+
let uvs = new Float32Array(0);
|
|
4130
|
+
if (includeUVs) {
|
|
4131
|
+
const expectedUvLen = data.positions.length / 3 * 2;
|
|
4132
|
+
try {
|
|
4133
|
+
const uvJson = this.bk.tessellateSolidUV(solidId, deflection);
|
|
4134
|
+
const uvData = JSON.parse(uvJson);
|
|
4135
|
+
if (uvData.uvs.length === expectedUvLen) {
|
|
4136
|
+
uvs = new Float32Array(uvData.uvs);
|
|
4137
|
+
} else {
|
|
4138
|
+
uvs = new Float32Array(expectedUvLen);
|
|
4139
|
+
}
|
|
4140
|
+
} catch {
|
|
4141
|
+
uvs = new Float32Array(expectedUvLen);
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4062
4144
|
return {
|
|
4063
4145
|
vertices: new Float32Array(data.positions),
|
|
4064
4146
|
normals: new Float32Array(data.normals),
|
|
4065
4147
|
triangles: new Uint32Array(data.indices),
|
|
4066
|
-
|
|
4067
|
-
uvs: new Float32Array(0),
|
|
4148
|
+
uvs,
|
|
4068
4149
|
faceGroups
|
|
4069
4150
|
};
|
|
4070
4151
|
}
|
|
@@ -4348,6 +4429,231 @@ class BrepkitAdapter {
|
|
|
4348
4429
|
}
|
|
4349
4430
|
return { point: [0, 0, 0], normal };
|
|
4350
4431
|
}
|
|
4432
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4433
|
+
// Constraint sketch solver (brepkit-only capability)
|
|
4434
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4435
|
+
/** Create a new constraint sketch. Returns an opaque sketch handle. */
|
|
4436
|
+
sketchNew() {
|
|
4437
|
+
return this.bk.sketchNew();
|
|
4438
|
+
}
|
|
4439
|
+
/** Add a point to a constraint sketch. Returns the point index. */
|
|
4440
|
+
sketchAddPoint(sketch, x7, y6, fixed) {
|
|
4441
|
+
return this.bk.sketchAddPoint(sketch, x7, y6, fixed);
|
|
4442
|
+
}
|
|
4443
|
+
/** Add a constraint to a sketch (JSON-encoded constraint descriptor). */
|
|
4444
|
+
sketchAddConstraint(sketch, constraintJson) {
|
|
4445
|
+
this.bk.sketchAddConstraint(sketch, constraintJson);
|
|
4446
|
+
}
|
|
4447
|
+
/**
|
|
4448
|
+
* Solve sketch constraints. Returns a JSON result with solved point positions.
|
|
4449
|
+
* @param maxIterations — solver iteration limit (e.g. 100)
|
|
4450
|
+
* @param tolerance — convergence tolerance (e.g. 1e-10)
|
|
4451
|
+
*/
|
|
4452
|
+
sketchSolve(sketch, maxIterations, tolerance) {
|
|
4453
|
+
return this.bk.sketchSolve(sketch, maxIterations, tolerance);
|
|
4454
|
+
}
|
|
4455
|
+
/** Get degrees of freedom remaining in a solved or partially-constrained sketch. */
|
|
4456
|
+
sketchDof(sketch) {
|
|
4457
|
+
return this.bk.sketchDof(sketch);
|
|
4458
|
+
}
|
|
4459
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4460
|
+
// Extended I/O formats
|
|
4461
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4462
|
+
export3MF(shape2, tolerance) {
|
|
4463
|
+
const solidId = unwrapSolidOrThrow(shape2, "export3MF");
|
|
4464
|
+
return copyWasmBytes(this.bk.export3mf(solidId, tolerance));
|
|
4465
|
+
}
|
|
4466
|
+
exportGLB(shape2, tolerance) {
|
|
4467
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportGLB");
|
|
4468
|
+
return copyWasmBytes(this.bk.exportGlb(solidId, tolerance));
|
|
4469
|
+
}
|
|
4470
|
+
exportOBJ(shape2, tolerance) {
|
|
4471
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportOBJ");
|
|
4472
|
+
return copyWasmBytes(this.bk.exportObj(solidId, tolerance));
|
|
4473
|
+
}
|
|
4474
|
+
exportPLY(shape2, tolerance) {
|
|
4475
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportPLY");
|
|
4476
|
+
return copyWasmBytes(this.bk.exportPly(solidId, tolerance));
|
|
4477
|
+
}
|
|
4478
|
+
import3MF(data) {
|
|
4479
|
+
const result = toArray(this.bk.import3mf(new Uint8Array(data)));
|
|
4480
|
+
return result.map((id) => solidHandle(id));
|
|
4481
|
+
}
|
|
4482
|
+
importOBJ(data) {
|
|
4483
|
+
const result = this.bk.importObj(new Uint8Array(data));
|
|
4484
|
+
return solidHandle(result);
|
|
4485
|
+
}
|
|
4486
|
+
importGLB(data) {
|
|
4487
|
+
const result = this.bk.importGlb(new Uint8Array(data));
|
|
4488
|
+
return solidHandle(result);
|
|
4489
|
+
}
|
|
4490
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4491
|
+
// Advanced modeling
|
|
4492
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4493
|
+
filletVariable(shape2, spec) {
|
|
4494
|
+
const solidId = unwrapSolidOrThrow(shape2, "filletVariable");
|
|
4495
|
+
return solidHandle(this.bk.filletVariable(solidId, spec));
|
|
4496
|
+
}
|
|
4497
|
+
helicalSweep(profile, axisOrigin, axisDirection, radius, pitch, turns) {
|
|
4498
|
+
const profileId = unwrap(profile, "face");
|
|
4499
|
+
return solidHandle(
|
|
4500
|
+
this.bk.helicalSweep(
|
|
4501
|
+
profileId,
|
|
4502
|
+
axisOrigin[0],
|
|
4503
|
+
axisOrigin[1],
|
|
4504
|
+
axisOrigin[2],
|
|
4505
|
+
axisDirection[0],
|
|
4506
|
+
axisDirection[1],
|
|
4507
|
+
axisDirection[2],
|
|
4508
|
+
radius,
|
|
4509
|
+
pitch,
|
|
4510
|
+
turns
|
|
4511
|
+
)
|
|
4512
|
+
);
|
|
4513
|
+
}
|
|
4514
|
+
sweepWithOptions(profile, pathEdge, contactMode, scaleValues, segments) {
|
|
4515
|
+
const profileId = unwrap(profile, "face");
|
|
4516
|
+
const pathId = unwrap(pathEdge, "edge");
|
|
4517
|
+
return solidHandle(
|
|
4518
|
+
this.bk.sweepWithOptions(profileId, pathId, contactMode, scaleValues, segments)
|
|
4519
|
+
);
|
|
4520
|
+
}
|
|
4521
|
+
draft(shape2, faces, pullDirection, neutralPlane, angleDeg) {
|
|
4522
|
+
const solidId = unwrapSolidOrThrow(shape2, "draft");
|
|
4523
|
+
const faceIds = faces.map((f12) => unwrap(f12, "face"));
|
|
4524
|
+
return solidHandle(
|
|
4525
|
+
this.bk.draft(
|
|
4526
|
+
solidId,
|
|
4527
|
+
faceIds,
|
|
4528
|
+
pullDirection[0],
|
|
4529
|
+
pullDirection[1],
|
|
4530
|
+
pullDirection[2],
|
|
4531
|
+
neutralPlane[0],
|
|
4532
|
+
neutralPlane[1],
|
|
4533
|
+
neutralPlane[2],
|
|
4534
|
+
angleDeg
|
|
4535
|
+
)
|
|
4536
|
+
);
|
|
4537
|
+
}
|
|
4538
|
+
defeature(shape2, faces) {
|
|
4539
|
+
const solidId = unwrapSolidOrThrow(shape2, "defeature");
|
|
4540
|
+
const faceIds = faces.map((f12) => unwrap(f12, "face"));
|
|
4541
|
+
return solidHandle(this.bk.defeature(solidId, faceIds));
|
|
4542
|
+
}
|
|
4543
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4544
|
+
// Feature detection
|
|
4545
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4546
|
+
detectSmallFeatures(shape2, areaThreshold, tolerance) {
|
|
4547
|
+
const solidId = unwrapSolidOrThrow(shape2, "detectSmallFeatures");
|
|
4548
|
+
return Array.from(this.bk.detectSmallFeatures(solidId, areaThreshold, tolerance)).map(
|
|
4549
|
+
(id) => faceHandle(id)
|
|
4550
|
+
);
|
|
4551
|
+
}
|
|
4552
|
+
recognizeFeatures(shape2, tolerance) {
|
|
4553
|
+
const solidId = unwrapSolidOrThrow(shape2, "recognizeFeatures");
|
|
4554
|
+
return this.bk.recognizeFeatures(solidId, tolerance);
|
|
4555
|
+
}
|
|
4556
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4557
|
+
// Mesh boolean
|
|
4558
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4559
|
+
meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance) {
|
|
4560
|
+
const mesh2 = this.bk.meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance);
|
|
4561
|
+
return {
|
|
4562
|
+
vertices: new Float32Array(mesh2.positions),
|
|
4563
|
+
normals: new Float32Array(mesh2.normals),
|
|
4564
|
+
triangles: new Uint32Array(mesh2.indices),
|
|
4565
|
+
uvs: new Float32Array(0),
|
|
4566
|
+
faceGroups: [{ start: 0, count: mesh2.indices.length, faceHash: 0 }]
|
|
4567
|
+
};
|
|
4568
|
+
}
|
|
4569
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4570
|
+
// Topology queries
|
|
4571
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4572
|
+
edgeToFaceMap(shape2) {
|
|
4573
|
+
const solidId = unwrapSolidOrThrow(shape2, "edgeToFaceMap");
|
|
4574
|
+
return this.bk.edgeToFaceMap(solidId);
|
|
4575
|
+
}
|
|
4576
|
+
sharedEdges(faceA, faceB) {
|
|
4577
|
+
const aId = unwrap(faceA, "face");
|
|
4578
|
+
const bId = unwrap(faceB, "face");
|
|
4579
|
+
return Array.from(this.bk.sharedEdges(aId, bId)).map((id) => edgeHandle(id));
|
|
4580
|
+
}
|
|
4581
|
+
adjacentFaces(shape2, face) {
|
|
4582
|
+
const solidId = unwrapSolidOrThrow(shape2, "adjacentFaces");
|
|
4583
|
+
const faceId = unwrap(face, "face");
|
|
4584
|
+
return Array.from(this.bk.adjacentFaces(solidId, faceId)).map((id) => faceHandle(id));
|
|
4585
|
+
}
|
|
4586
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4587
|
+
// NURBS curve operations
|
|
4588
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4589
|
+
curveDegreeElevate(edge, elevateBy) {
|
|
4590
|
+
const edgeId = unwrap(edge, "edge");
|
|
4591
|
+
return edgeHandle(this.bk.curveDegreeElevate(edgeId, elevateBy));
|
|
4592
|
+
}
|
|
4593
|
+
curveKnotInsert(edge, knot, times) {
|
|
4594
|
+
const edgeId = unwrap(edge, "edge");
|
|
4595
|
+
return edgeHandle(this.bk.curveKnotInsert(edgeId, knot, times));
|
|
4596
|
+
}
|
|
4597
|
+
curveKnotRemove(edge, knot, tolerance) {
|
|
4598
|
+
const edgeId = unwrap(edge, "edge");
|
|
4599
|
+
return edgeHandle(this.bk.curveKnotRemove(edgeId, knot, tolerance));
|
|
4600
|
+
}
|
|
4601
|
+
curveSplit(edge, param) {
|
|
4602
|
+
const edgeId = unwrap(edge, "edge");
|
|
4603
|
+
const result = this.bk.curveSplit(edgeId, param);
|
|
4604
|
+
return [edgeHandle(result[0]), edgeHandle(result[1])];
|
|
4605
|
+
}
|
|
4606
|
+
approximateSurfaceLspia(coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations) {
|
|
4607
|
+
return faceHandle(
|
|
4608
|
+
this.bk.approximateSurfaceLspia(
|
|
4609
|
+
coords,
|
|
4610
|
+
rows,
|
|
4611
|
+
cols,
|
|
4612
|
+
degreeU,
|
|
4613
|
+
degreeV,
|
|
4614
|
+
numCpsU,
|
|
4615
|
+
numCpsV,
|
|
4616
|
+
tolerance,
|
|
4617
|
+
maxIterations
|
|
4618
|
+
)
|
|
4619
|
+
);
|
|
4620
|
+
}
|
|
4621
|
+
untrimFace(face, samplesPerCurve, interiorSamples) {
|
|
4622
|
+
const faceId = unwrap(face, "face");
|
|
4623
|
+
return faceHandle(this.bk.untrimFace(faceId, samplesPerCurve, interiorSamples));
|
|
4624
|
+
}
|
|
4625
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4626
|
+
// Validation / Repair
|
|
4627
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4628
|
+
mergeCoincidentVertices(shape2, tolerance) {
|
|
4629
|
+
const solidId = unwrapSolidOrThrow(shape2, "mergeCoincidentVertices");
|
|
4630
|
+
return this.bk.mergeCoincidentVertices(solidId, tolerance);
|
|
4631
|
+
}
|
|
4632
|
+
removeDegenerateEdges(shape2, tolerance) {
|
|
4633
|
+
const solidId = unwrapSolidOrThrow(shape2, "removeDegenerateEdges");
|
|
4634
|
+
return this.bk.removeDegenerateEdges(solidId, tolerance);
|
|
4635
|
+
}
|
|
4636
|
+
fixFaceOrientations(shape2) {
|
|
4637
|
+
const solidId = unwrapSolidOrThrow(shape2, "fixFaceOrientations");
|
|
4638
|
+
return this.bk.fixFaceOrientations(solidId);
|
|
4639
|
+
}
|
|
4640
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4641
|
+
// Classification
|
|
4642
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4643
|
+
classifyPointRobust(shape2, point, tolerance) {
|
|
4644
|
+
const solidId = unwrapSolidOrThrow(shape2, "classifyPointRobust");
|
|
4645
|
+
return this.bk.classifyPointRobust(solidId, point[0], point[1], point[2], tolerance);
|
|
4646
|
+
}
|
|
4647
|
+
classifyPointWinding(shape2, point, tolerance) {
|
|
4648
|
+
const solidId = unwrapSolidOrThrow(shape2, "classifyPointWinding");
|
|
4649
|
+
return this.bk.classifyPointWinding(solidId, point[0], point[1], point[2], tolerance);
|
|
4650
|
+
}
|
|
4651
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4652
|
+
// Batch execution
|
|
4653
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4654
|
+
executeBatch(json) {
|
|
4655
|
+
return this.bk.executeBatch(json);
|
|
4656
|
+
}
|
|
4351
4657
|
}
|
|
4352
4658
|
function multiplyMatrices(a9, b10) {
|
|
4353
4659
|
const result = new Array(16).fill(0);
|
|
@@ -4679,14 +4985,14 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
4679
4985
|
)
|
|
4680
4986
|
);
|
|
4681
4987
|
}
|
|
4682
|
-
const
|
|
4988
|
+
const w7 = bitmap.width;
|
|
4683
4989
|
const h8 = bitmap.height;
|
|
4684
|
-
if (
|
|
4990
|
+
if (w7 < 2 || h8 < 2) {
|
|
4685
4991
|
bitmap.close();
|
|
4686
4992
|
return err(
|
|
4687
4993
|
validationError(
|
|
4688
4994
|
BrepErrorCode.SURFACE_GRID_TOO_SMALL,
|
|
4689
|
-
`surfaceFromImage: image too small (${
|
|
4995
|
+
`surfaceFromImage: image too small (${w7}x${h8}), need at least 2x2`
|
|
4690
4996
|
)
|
|
4691
4997
|
);
|
|
4692
4998
|
}
|
|
@@ -4699,7 +5005,7 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
4699
5005
|
)
|
|
4700
5006
|
);
|
|
4701
5007
|
}
|
|
4702
|
-
const canvas = new OffscreenCanvas(
|
|
5008
|
+
const canvas = new OffscreenCanvas(w7, h8);
|
|
4703
5009
|
const ctx = canvas.getContext("2d");
|
|
4704
5010
|
if (!ctx) {
|
|
4705
5011
|
bitmap.close();
|
|
@@ -4709,13 +5015,13 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
4709
5015
|
}
|
|
4710
5016
|
ctx.drawImage(bitmap, 0, 0);
|
|
4711
5017
|
bitmap.close();
|
|
4712
|
-
const imageData = ctx.getImageData(0, 0,
|
|
5018
|
+
const imageData = ctx.getImageData(0, 0, w7, h8);
|
|
4713
5019
|
const data = imageData.data;
|
|
4714
5020
|
const rows = [];
|
|
4715
5021
|
for (let y6 = 0; y6 < h8; y6 += downsample) {
|
|
4716
5022
|
const row = [];
|
|
4717
|
-
for (let x7 = 0; x7 <
|
|
4718
|
-
const idx = (y6 *
|
|
5023
|
+
for (let x7 = 0; x7 < w7; x7 += downsample) {
|
|
5024
|
+
const idx = (y6 * w7 + x7) * 4;
|
|
4719
5025
|
const r9 = data[idx] ?? 0;
|
|
4720
5026
|
const g12 = data[idx + 1] ?? 0;
|
|
4721
5027
|
const b10 = data[idx + 2] ?? 0;
|
|
@@ -5375,8 +5681,8 @@ function computeStraightSkeleton(polygon) {
|
|
|
5375
5681
|
}
|
|
5376
5682
|
return { nodes: uniqueNodes, faces };
|
|
5377
5683
|
}
|
|
5378
|
-
function extractPolygon(
|
|
5379
|
-
const edges = getEdges(
|
|
5684
|
+
function extractPolygon(w7) {
|
|
5685
|
+
const edges = getEdges(w7);
|
|
5380
5686
|
const pts = edges.map((e8) => {
|
|
5381
5687
|
const pt = curveStartPoint(e8);
|
|
5382
5688
|
return { x: pt[0], y: pt[1] };
|
|
@@ -5455,11 +5761,11 @@ function earClipTriangulate(poly) {
|
|
|
5455
5761
|
}
|
|
5456
5762
|
return tris;
|
|
5457
5763
|
}
|
|
5458
|
-
function roof(
|
|
5764
|
+
function roof(w7, options) {
|
|
5459
5765
|
const angle = (options?.angle ?? 45) * (Math.PI / 180);
|
|
5460
5766
|
const tanAngle = Math.tan(angle);
|
|
5461
5767
|
try {
|
|
5462
|
-
const polygon = extractPolygon(
|
|
5768
|
+
const polygon = extractPolygon(w7);
|
|
5463
5769
|
if (polygon.length < 3) {
|
|
5464
5770
|
return err(
|
|
5465
5771
|
kernelError(
|
|
@@ -6522,7 +6828,7 @@ function loft$1(wires, { ruled = true, startPoint, endPoint, tolerance = 1e-6 }
|
|
|
6522
6828
|
const endVertex = endPoint ? kernel.makeVertex(...toVec3(endPoint)) : void 0;
|
|
6523
6829
|
try {
|
|
6524
6830
|
const shape2 = kernel.loftAdvanced(
|
|
6525
|
-
wires.map((
|
|
6831
|
+
wires.map((w7) => w7.wrapped),
|
|
6526
6832
|
{
|
|
6527
6833
|
solid: !returnShell,
|
|
6528
6834
|
ruled,
|
|
@@ -6555,7 +6861,7 @@ function revolve(face, options) {
|
|
|
6555
6861
|
);
|
|
6556
6862
|
}
|
|
6557
6863
|
function loft(wires, options) {
|
|
6558
|
-
const resolvedWires = wires.map((
|
|
6864
|
+
const resolvedWires = wires.map((w7) => resolve(w7));
|
|
6559
6865
|
return loft$1(resolvedWires, options);
|
|
6560
6866
|
}
|
|
6561
6867
|
function resolveTargetFace(shape2, faceSpec) {
|
|
@@ -6652,8 +6958,8 @@ function pocket(shape2, options) {
|
|
|
6652
6958
|
if (isErr(targetResult)) return targetResult;
|
|
6653
6959
|
const targetFace = targetResult.value;
|
|
6654
6960
|
const normal = normalAt(targetFace);
|
|
6655
|
-
const
|
|
6656
|
-
const faceResult = makeFace(
|
|
6961
|
+
const w7 = toWire(profile);
|
|
6962
|
+
const faceResult = makeFace(w7);
|
|
6657
6963
|
if (isErr(faceResult)) return faceResult;
|
|
6658
6964
|
const extDir = vecScale(vecNormalize(normal), -depth);
|
|
6659
6965
|
const toolResult = extrude$1(faceResult.value, extDir);
|
|
@@ -6670,8 +6976,8 @@ function boss(shape2, options) {
|
|
|
6670
6976
|
if (isErr(targetResult)) return targetResult;
|
|
6671
6977
|
const targetFace = targetResult.value;
|
|
6672
6978
|
const normal = normalAt(targetFace);
|
|
6673
|
-
const
|
|
6674
|
-
const faceResult = makeFace(
|
|
6979
|
+
const w7 = toWire(profile);
|
|
6980
|
+
const faceResult = makeFace(w7);
|
|
6675
6981
|
if (isErr(faceResult)) return faceResult;
|
|
6676
6982
|
const extDir = vecScale(vecNormalize(normal), height);
|
|
6677
6983
|
const toolResult = extrude$1(faceResult.value, extDir);
|
|
@@ -6839,8 +7145,8 @@ function createWrappedCurve(val) {
|
|
|
6839
7145
|
isClosed: () => curveIsClosed(val),
|
|
6840
7146
|
sweep(spine, opts) {
|
|
6841
7147
|
if (!isWire(val)) throw new Error("sweep requires a Wire");
|
|
6842
|
-
const
|
|
6843
|
-
const result = unwrapOrThrow(sweep(
|
|
7148
|
+
const w7 = val;
|
|
7149
|
+
const result = unwrapOrThrow(sweep(w7, resolve(spine), opts));
|
|
6844
7150
|
const shape3D = Array.isArray(result) ? result[0] : result;
|
|
6845
7151
|
return wrap3D(shape3D);
|
|
6846
7152
|
}
|
|
@@ -7217,6 +7523,7 @@ export {
|
|
|
7217
7523
|
v4 as registerShape,
|
|
7218
7524
|
rejectAll,
|
|
7219
7525
|
x3 as removeChild,
|
|
7526
|
+
v8 as removeHolesFromFace,
|
|
7220
7527
|
y2 as replayFrom,
|
|
7221
7528
|
z2 as replayHistory,
|
|
7222
7529
|
C7 as resize,
|
|
@@ -7242,7 +7549,7 @@ export {
|
|
|
7242
7549
|
u4 as setTagMetadata,
|
|
7243
7550
|
B6 as sewShells,
|
|
7244
7551
|
shape,
|
|
7245
|
-
|
|
7552
|
+
w6 as shapeType,
|
|
7246
7553
|
C8 as sharedEdges,
|
|
7247
7554
|
shell,
|
|
7248
7555
|
simplify,
|
|
@@ -7274,6 +7581,7 @@ export {
|
|
|
7274
7581
|
stretch2D,
|
|
7275
7582
|
F5 as subFace,
|
|
7276
7583
|
D3 as supportExtrude,
|
|
7584
|
+
supportsConstraintSketch,
|
|
7277
7585
|
supportsProjection,
|
|
7278
7586
|
surfaceFromGrid,
|
|
7279
7587
|
surfaceFromImage,
|