brepjs 12.8.2 → 12.9.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/lib/svgPath.d.ts.map +1 -1
- package/dist/2d/lib/vectorOperations.d.ts +4 -1
- package/dist/2d/lib/vectorOperations.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +5 -5
- package/dist/{Blueprint-DbVaf6k7.js → Blueprint-1HGbugaC.js} +33 -63
- package/dist/{Blueprint-CQ28WJhz.cjs → Blueprint-CUyXM6CV.cjs} +15 -45
- package/dist/{boolean2D-0blbVtJ8.cjs → boolean2D-9OnbotKT.cjs} +9 -9
- package/dist/{boolean2D-y3E92F0u.js → boolean2D-CR4efa35.js} +11 -11
- package/dist/{booleanFns-gmsX3Cv2.cjs → booleanFns-BBd2oTvv.cjs} +43 -40
- package/dist/{booleanFns-BCTjYZAg.js → booleanFns-Br2KdGJq.js} +53 -50
- package/dist/brepjs.cjs +379 -284
- package/dist/brepjs.js +1437 -1341
- package/dist/core/definitionMaps.d.ts +2 -7
- package/dist/core/definitionMaps.d.ts.map +1 -1
- package/dist/core/dimensionTypes.d.ts +52 -0
- package/dist/core/dimensionTypes.d.ts.map +1 -0
- package/dist/core/disposal.d.ts +18 -0
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core/errors.d.ts +1 -8
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/kernelErrorTranslation.d.ts +15 -0
- package/dist/core/kernelErrorTranslation.d.ts.map +1 -0
- package/dist/core/planeOps.d.ts +14 -0
- package/dist/core/planeOps.d.ts.map +1 -1
- package/dist/core/result.d.ts +4 -0
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/shapeTypes.d.ts +14 -146
- package/dist/core/shapeTypes.d.ts.map +1 -1
- package/dist/core/typeDiscriminants.d.ts +14 -0
- package/dist/core/typeDiscriminants.d.ts.map +1 -0
- package/dist/core/validityTypes.d.ts +100 -0
- package/dist/core/validityTypes.d.ts.map +1 -0
- package/dist/core.cjs +52 -11
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +118 -75
- package/dist/{curveFns-mROFhiuG.js → curveFns-1u0oZ0u0.js} +14 -14
- package/dist/{curveFns-BZngcnQ1.cjs → curveFns-BwLvO_Ia.cjs} +2 -2
- package/dist/{drawFns-Bwakrq7w.js → drawFns-B0na6sbo.js} +16 -16
- package/dist/{drawFns-CjRc1NfQ.cjs → drawFns-CzlEePor.cjs} +18 -18
- package/dist/{faceFns-DB1Fc5gy.cjs → faceFns-BAKkZG6D.cjs} +2 -2
- package/dist/{faceFns-B8GnxjdY.js → faceFns-DGMp47Os.js} +3 -3
- package/dist/{helpers-C8NoT0Wu.cjs → helpers-DVdscQxW.cjs} +73 -8
- package/dist/{helpers-X0juxnwj.js → helpers-sJjnIXDA.js} +85 -20
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/brepkit/booleanOps.d.ts +23 -0
- package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/constructionOps.d.ts +51 -0
- package/dist/kernel/brepkit/constructionOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/evolutionOps.d.ts +31 -0
- package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/geometryOps.d.ts +56 -0
- package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/helpers.d.ts +84 -0
- package/dist/kernel/brepkit/helpers.d.ts.map +1 -0
- package/dist/kernel/brepkit/internalOps.d.ts +28 -0
- package/dist/kernel/brepkit/internalOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/ioOps.d.ts +43 -0
- package/dist/kernel/brepkit/ioOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/measureOps.d.ts +30 -0
- package/dist/kernel/brepkit/measureOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/meshOps.d.ts +7 -0
- package/dist/kernel/brepkit/meshOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/modifierOps.d.ts +15 -0
- package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/repairOps.d.ts +14 -0
- package/dist/kernel/brepkit/repairOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/sweepOps.d.ts +27 -0
- package/dist/kernel/brepkit/sweepOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/topologyOps.d.ts +16 -0
- package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -0
- package/dist/kernel/brepkit/transformOps.d.ts +14 -0
- package/dist/kernel/brepkit/transformOps.d.ts.map +1 -0
- package/dist/kernel/brepkitAdapter.d.ts +1 -1
- package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
- package/dist/kernel/brepkitWasmTypes.d.ts +8 -0
- package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
- package/dist/kernel/defaultAdapter.d.ts.map +1 -1
- package/dist/kernel/extendedConstructorOps.d.ts +9 -1
- package/dist/kernel/extendedConstructorOps.d.ts.map +1 -1
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.d.ts.map +1 -1
- package/dist/kernel/interfaces/boolean-ops.d.ts +25 -0
- package/dist/kernel/interfaces/boolean-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/construction-ops.d.ts +76 -0
- package/dist/kernel/interfaces/construction-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/core.d.ts +45 -0
- package/dist/kernel/interfaces/core.d.ts.map +1 -0
- package/dist/kernel/interfaces/evolution-ops.d.ts +19 -0
- package/dist/kernel/interfaces/evolution-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/geometry-ops.d.ts +77 -0
- package/dist/kernel/interfaces/geometry-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/index.d.ts +29 -0
- package/dist/kernel/interfaces/index.d.ts.map +1 -0
- package/dist/kernel/interfaces/io-ops.d.ts +66 -0
- package/dist/kernel/interfaces/io-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/measure-ops.d.ts +35 -0
- package/dist/kernel/interfaces/measure-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/mesh-ops.d.ts +21 -0
- package/dist/kernel/interfaces/mesh-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/modifier-ops.d.ts +22 -0
- package/dist/kernel/interfaces/modifier-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/repair-ops.d.ts +36 -0
- package/dist/kernel/interfaces/repair-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/sweep-ops.d.ts +49 -0
- package/dist/kernel/interfaces/sweep-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/topology-ops.d.ts +30 -0
- package/dist/kernel/interfaces/topology-ops.d.ts.map +1 -0
- package/dist/kernel/interfaces/transform-ops.d.ts +20 -0
- package/dist/kernel/interfaces/transform-ops.d.ts.map +1 -0
- package/dist/kernel/modifierOps.d.ts +2 -2
- package/dist/kernel/modifierOps.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +2 -446
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-hp3pc1M7.cjs → loft-BNvBZzqe.cjs} +5 -5
- package/dist/{loft-Bhw-FMoL.js → loft-D0aCZRaB.js} +7 -7
- package/dist/measurement/measureFns.d.ts +2 -2
- package/dist/measurement/measureFns.d.ts.map +1 -1
- package/dist/{measurement-D8EJ694A.js → measurement-C7o5jE6G.js} +2 -2
- package/dist/{measurement-BoNTUBAp.cjs → measurement-DZcaxo1A.cjs} +2 -2
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BnV0ZR8w.cjs → meshFns-7dgZgNYK.cjs} +4 -4
- package/dist/{meshFns-nQjK38EC.js → meshFns-CtUl9fGY.js} +3 -3
- package/dist/operations/compoundOpsFns.d.ts +38 -0
- package/dist/operations/compoundOpsFns.d.ts.map +1 -0
- package/dist/operations/extrude.d.ts +2 -12
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts +2 -93
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/guidedSweepFns.d.ts +3 -22
- package/dist/operations/guidedSweepFns.d.ts.map +1 -1
- package/dist/operations/loft.d.ts +2 -16
- package/dist/operations/loft.d.ts.map +1 -1
- package/dist/operations/multiSweepFns.d.ts +3 -29
- package/dist/operations/multiSweepFns.d.ts.map +1 -1
- package/dist/operations/roofFns.d.ts +2 -2
- package/dist/operations/roofFns.d.ts.map +1 -1
- package/dist/operations/sweepFns.d.ts +121 -0
- package/dist/operations/sweepFns.d.ts.map +1 -0
- package/dist/{operations-BfbkK6DU.js → operations-DisJ5F8s.js} +110 -57
- package/dist/{operations-CYpmLSC4.cjs → operations-DwZ-RBO1.cjs} +97 -44
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +14 -14
- package/dist/originTrackingFns-NJ1dWoiF.js +137 -0
- package/dist/originTrackingFns-dhaCe8Yb.cjs +136 -0
- package/dist/query/edgeFinder.d.ts +4 -14
- package/dist/query/edgeFinder.d.ts.map +1 -1
- package/dist/query/faceFinder.d.ts +4 -14
- package/dist/query/faceFinder.d.ts.map +1 -1
- package/dist/query/finderCore.d.ts +6 -0
- package/dist/query/finderCore.d.ts.map +1 -1
- package/dist/query/shapeFinders.d.ts +32 -0
- package/dist/query/shapeFinders.d.ts.map +1 -0
- package/dist/query/wireFinder.d.ts +4 -9
- package/dist/query/wireFinder.d.ts.map +1 -1
- package/dist/query.cjs +54 -32
- package/dist/query.js +56 -34
- package/dist/{result-fAX0OZzI.cjs → result-DJAAj1yb.cjs} +8 -59
- package/dist/{result-BaSD1fqR.js → result-DtuwWSUD.js} +38 -89
- package/dist/result.cjs +1 -1
- package/dist/result.js +22 -22
- package/dist/shapeFns-BJbua5kT.js +34 -0
- package/dist/shapeFns-w9tWELHX.cjs +33 -0
- package/dist/{shapeTypes-CpSaBLDv.js → shapeTypes-CAEAyk8j.js} +233 -172
- package/dist/{shapeTypes-7xEam9Ri.cjs → shapeTypes-owrg2MNK.cjs} +421 -360
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-994_MQwB.cjs → solidBuilders-BLQ4I6Ig.cjs} +3 -3
- package/dist/{solidBuilders-DmwhTCCd.js → solidBuilders-BS-1220W.js} +3 -3
- package/dist/{surfaceBuilders-nQdJ56fe.js → surfaceBuilders-Dj6AjhOv.js} +7 -7
- package/dist/{surfaceBuilders-5VA34a3_.cjs → surfaceBuilders-KU_7OD2q.cjs} +3 -3
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/compoundOpsFns.d.ts +3 -35
- package/dist/topology/compoundOpsFns.d.ts.map +1 -1
- package/dist/topology/index.d.ts +0 -1
- package/dist/topology/index.d.ts.map +1 -1
- package/dist/topology/metadataPropagation.d.ts +30 -0
- package/dist/topology/metadataPropagation.d.ts.map +1 -0
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/originTrackingFns.d.ts +23 -0
- package/dist/topology/originTrackingFns.d.ts.map +1 -0
- package/dist/topology/shapeFns.d.ts +6 -120
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/topologyQueryFns.d.ts +67 -0
- package/dist/topology/topologyQueryFns.d.ts.map +1 -0
- package/dist/topology/transformFns.d.ts +49 -0
- package/dist/topology/transformFns.d.ts.map +1 -0
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-ANwCzGL8.cjs → topology-CyPHYYjV.cjs} +205 -20
- package/dist/{topology-C7x98OVn.js → topology-D6LeuhI_.js} +235 -50
- package/dist/topology.cjs +18 -17
- package/dist/topology.js +92 -91
- package/dist/topologyQueryFns-De439iBP.js +119 -0
- package/dist/topologyQueryFns-fz5kz5e1.cjs +118 -0
- package/dist/{types-CWDdqcrq.js → types-CcKqsmd0.js} +2 -2
- package/dist/utils/precisionRound.d.ts +4 -0
- package/dist/utils/precisionRound.d.ts.map +1 -1
- package/dist/utils/vec2d.d.ts +5 -0
- package/dist/utils/vec2d.d.ts.map +1 -1
- package/dist/{vecOps-ZDdZWbwT.js → vecOps-LTN--A58.js} +15 -15
- package/dist/{vectors-D_IiZx0q.cjs → vectors-C8N_QeEX.cjs} +9 -1
- package/dist/{vectors-Bx8wkNui.js → vectors-DTREgnVp.js} +15 -7
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +23 -23
- package/package.json +3 -3
- package/dist/core/geometryHelpers.d.ts +0 -30
- package/dist/core/geometryHelpers.d.ts.map +0 -1
- package/dist/core/memory.d.ts +0 -6
- package/dist/core/memory.d.ts.map +0 -1
- package/dist/core/typeErrors.d.ts +0 -17
- package/dist/core/typeErrors.d.ts.map +0 -1
- package/dist/cornerFinder-Ckz-mPHE.js +0 -59
- package/dist/cornerFinder-ZmOyOOsh.cjs +0 -58
- package/dist/shapeFns-C2SnNvdH.cjs +0 -468
- package/dist/shapeFns-FDuKkrDR.js +0 -469
- package/dist/utils/round2.d.ts +0 -3
- package/dist/utils/round2.d.ts.map +0 -1
- package/dist/utils/round5.d.ts +0 -3
- package/dist/utils/round5.d.ts.map +0 -1
package/dist/brepjs.js
CHANGED
|
@@ -26,10 +26,10 @@ var __using = (stack, value, async) => {
|
|
|
26
26
|
return value;
|
|
27
27
|
};
|
|
28
28
|
var __callDispose = (stack, error, hasError) => {
|
|
29
|
-
var
|
|
30
|
-
return _2 = Error(
|
|
29
|
+
var E6 = typeof SuppressedError === "function" ? SuppressedError : function(e8, s5, m11, _2) {
|
|
30
|
+
return _2 = Error(m11), _2.name = "SuppressedError", _2.error = e8, _2.suppressed = s5, _2;
|
|
31
31
|
};
|
|
32
|
-
var fail = (e8) => error = hasError ? new
|
|
32
|
+
var fail = (e8) => error = hasError ? new E6(e8, error, "An error was suppressed during disposal") : (hasError = true, e8);
|
|
33
33
|
var next = (it) => {
|
|
34
34
|
while (it = stack.pop()) {
|
|
35
35
|
try {
|
|
@@ -43,136 +43,138 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
43
43
|
};
|
|
44
44
|
return next();
|
|
45
45
|
};
|
|
46
|
-
import { c as castShape, D as DisposalScope,
|
|
47
|
-
import {
|
|
48
|
-
import { o as ok,
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import { D
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import { B as B4, a as
|
|
46
|
+
import { c as castShape, D as DisposalScope, g as getKernel, o as isFace, d as isShell, k as isSolid, j as isShape3D, h as createSolid, l as createWire, i as isEdge, b as isWire } from "./shapeTypes-CAEAyk8j.js";
|
|
47
|
+
import { q, s, t, e, m, n, v, w, x, f, y, z, a, A, B, C, E, F, G, H, I, J, K, L, M, N } from "./shapeTypes-CAEAyk8j.js";
|
|
48
|
+
import { o as ok, e as err, q as queryError, v as validationError, B as BrepErrorCode, k as kernelError, i as ioError, b as isErr, t as typeCastError, u as unwrap$1 } from "./result-DtuwWSUD.js";
|
|
49
|
+
import { g, O, h, a as a2, c, j, d, l, m as m2, n as n2, f as f2, p, r, w as w2, x as x2, y as y2, z as z2, A as A2, C as C2, D, E as E2, F as F2, G as G2, H as H2, I as I2, J as J2, K as K2, L as L2, M as M2 } from "./result-DtuwWSUD.js";
|
|
50
|
+
import { h as vecDistance, v as vecLength, c as vecNormalize, H as HASH_CODE_MAX, b as vecScale, i as vecIsZero } from "./vecOps-LTN--A58.js";
|
|
51
|
+
import { D as D2, R, a as a3, j as j2, e as e2, d as d2, k, l as l2, m as m3, n as n3, o, g as g2, f as f3 } from "./vecOps-LTN--A58.js";
|
|
52
|
+
import { a as a4, c as c2, m as m4, b, r as r2, t as t2 } from "./vectors-DTREgnVp.js";
|
|
53
|
+
import { w as walkAssembly, s as sweep, c as circularPattern, l as linearPattern } from "./operations-DisJ5F8s.js";
|
|
54
|
+
import { a as a5, b as b2, d as d3, e as e3, f as f4, g as g3, h as h2, i, j as j3, k as k2, m as m5, n as n4, o as o2, p as p2, q as q2, r as r3, t as t3, u, v as v2, x as x3, y as y3, z as z3, A as A3, B as B2, C as C3, D as D3, E as E3, F as F3, G as G3 } from "./operations-DisJ5F8s.js";
|
|
55
|
+
import { B as B3, d as d4, C as C4 } from "./Blueprint-1HGbugaC.js";
|
|
56
|
+
import { B as B4, a as a6, c as c3, C as C5, F as F4, S, d as d5, j as j4, f as f5, k as k3, h as h3, l as l3, o as o3, p as p3, r as r4 } from "./boolean2D-CR4efa35.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 {
|
|
59
|
-
import { g as
|
|
58
|
+
import { k as createTypedFinder, l as edgeFinder, m as faceFinder } from "./helpers-sJjnIXDA.js";
|
|
59
|
+
import { g as g4, w as w3 } from "./helpers-sJjnIXDA.js";
|
|
60
60
|
import { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportOBJ, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD } from "./io.js";
|
|
61
|
-
import { C as
|
|
62
|
-
import {
|
|
63
|
-
import { r as
|
|
64
|
-
import { c as
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
70
|
-
import {
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
import { i as
|
|
74
|
-
import {
|
|
75
|
-
import {
|
|
76
|
-
import {
|
|
77
|
-
import {
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
82
|
-
import { c as makeCylinder } from "./solidBuilders-
|
|
83
|
-
import {
|
|
61
|
+
import { C as C6, D as D4, a as a7, S as S2, b as b3, X, Y, c as c4, d as d6, e as e4, f as f6, Z, g as g5, h as h4, i as i2, j as j5, k as k4, l as l4, m as m6, n as n5, o as o4, p as p4, q as q3, r as r5, s as s2, t as t4, u as u2, v as v3, w as w4, x as x4, y as y4, z as z4, _, $, a0, a1, A as A4, a2 as a22, B as B5, E as E4, a3 as a32, F as F5, G as G4, H as H3, I as I3, J as J3, K as K3, L as L3, M as M3, N as N2, O as O2, P, Q, R as R2, T, U, a4 as a42, V, a5 as a52, a6 as a62, W } from "./drawFns-B0na6sbo.js";
|
|
62
|
+
import { t as toVec3 } from "./types-CcKqsmd0.js";
|
|
63
|
+
import { r as r6, a as a8 } from "./types-CcKqsmd0.js";
|
|
64
|
+
import { c as clone$1, a as isEmpty$1, s as simplify$1, t as toBREP$1 } from "./shapeFns-BJbua5kT.js";
|
|
65
|
+
import { g as g6, b as b4, i as i3 } from "./shapeFns-BJbua5kT.js";
|
|
66
|
+
import { c as collectInputFaceHashes, p as propagateAllMetadata, a as cut$1, f as fuse$1, i as intersect$1, s as section$1, b as sectionToFace$1, d as slice$1, e as split$1, g as fuseAll, h as cutAll } from "./booleanFns-Br2KdGJq.js";
|
|
67
|
+
import { j as j6, k as k5, l as l5, m as m7, n as n6, o as o5, q as q4, r as r7, t as t5 } from "./booleanFns-Br2KdGJq.js";
|
|
68
|
+
import { a as applyMatrix$1, c as chamferDistAngle, h as heal$1, i as isValid$1, m as mirror$1, r as rotate$1, s as scale$1, t as transformCopy$1, b as translate$1 } from "./topology-D6LeuhI_.js";
|
|
69
|
+
import { d as d7, e as e5, f as f7, g as g7, j as j7, k as k6, l as l6, n as n7, o as o6, p as p5, q as q5, u as u3, v as v4, w as w5, x as x5, y as y5, z as z5, A as A5, B as B6, C as C7, D as D5, E as E5, F as F6, G as G5, H as H4, I as I4, J as J4, K as K4, L as L4, M as M4, N as N3, O as O3, P as P2, Q as Q2, R as R3, S as S3, T as T2, U as U2, V as V2, W as W2, X as X2, Y as Y2 } from "./topology-D6LeuhI_.js";
|
|
70
|
+
import { d as curveStartPoint, a as curveIsClosed, e as curveTangentAt, f as curvePointAt, h as curveEndPoint, c as curveLength } from "./curveFns-1u0oZ0u0.js";
|
|
71
|
+
import { i as i4, j as j8, k as k7, l as l7, g as g8, b as b5, m as m8, o as o7 } from "./curveFns-1u0oZ0u0.js";
|
|
72
|
+
import { e as faceCenter, n as normalAt, j as fromBREP$1, k as innerWires, o as outerWire, g as getSurfaceType } from "./faceFns-DGMp47Os.js";
|
|
73
|
+
import { l as l8, c as c5, m as m9, d as d8, f as f8, q as q6, r as r8, s as s3, i as i5, p as p6, t as t6, v as v5, w as w6, u as u4, h as h5 } from "./faceFns-DGMp47Os.js";
|
|
74
|
+
import { m as mesh$1, a as meshEdges$1 } from "./meshFns-CtUl9fGY.js";
|
|
75
|
+
import { c as c6, b as b6, e as e6, d as d9, f as f9 } from "./meshFns-CtUl9fGY.js";
|
|
76
|
+
import { v as vertexPosition, b as getFaces, e as getVertices, d as getEdges, f as getBounds, h as describe$1, c as getWires } from "./topologyQueryFns-De439iBP.js";
|
|
77
|
+
import { i as i6, j as j9, k as k8, l as l9, m as m10 } from "./topologyQueryFns-De439iBP.js";
|
|
78
|
+
import { m as measureArea, a as measureSurfaceProps, b as measureVolumeProps, c as measureVolume } from "./measurement-C7o5jE6G.js";
|
|
79
|
+
import { d as d10, e as e7, f as f10, g as g9, h as h6, i as i7 } from "./measurement-C7o5jE6G.js";
|
|
80
|
+
import { c as makeFace } from "./surfaceBuilders-Dj6AjhOv.js";
|
|
81
|
+
import { i as i8 } from "./surfaceBuilders-Dj6AjhOv.js";
|
|
82
|
+
import { c as makeCylinder } from "./solidBuilders-BS-1220W.js";
|
|
83
|
+
import { closedWire, isClosedWire, isManifoldShell, isOrientedFace, isValidSolid, manifoldShell, orientedFace, validSolid } from "./core.js";
|
|
84
|
+
import { cornerFinder } from "./query.js";
|
|
84
85
|
import { createOperationRegistry, createTaskQueue, createWorkerClient, createWorkerHandler, dequeueTask, enqueueTask, isDisposeRequest, isErrorResponse, isInitRequest, isOperationRequest, isQueueEmpty, isSuccessResponse, pendingCount, registerHandler, rejectAll } from "./worker.js";
|
|
86
|
+
import { g as g10, s as s4 } from "./originTrackingFns-NJ1dWoiF.js";
|
|
85
87
|
function supportsProjection(kernel) {
|
|
86
88
|
return "projectShape" in kernel;
|
|
87
89
|
}
|
|
88
90
|
function supportsConstraintSketch(kernel) {
|
|
89
91
|
return "sketchNew" in kernel && "sketchDof" in kernel;
|
|
90
92
|
}
|
|
91
|
-
function evaluateCurve2d(
|
|
92
|
-
switch (
|
|
93
|
+
function evaluateCurve2d(c7, t7) {
|
|
94
|
+
switch (c7.__bk2d) {
|
|
93
95
|
case "line":
|
|
94
|
-
return [
|
|
96
|
+
return [c7.ox + c7.dx * t7, c7.oy + c7.dy * t7];
|
|
95
97
|
case "circle": {
|
|
96
|
-
const angle =
|
|
97
|
-
return [
|
|
98
|
+
const angle = c7.sense ? t7 : -t7;
|
|
99
|
+
return [c7.cx + c7.radius * Math.cos(angle), c7.cy + c7.radius * Math.sin(angle)];
|
|
98
100
|
}
|
|
99
101
|
case "ellipse": {
|
|
100
|
-
const angle =
|
|
101
|
-
const cos = Math.cos(
|
|
102
|
-
const sin = Math.sin(
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
return [
|
|
102
|
+
const angle = c7.sense ? t7 : -t7;
|
|
103
|
+
const cos = Math.cos(c7.xDirAngle);
|
|
104
|
+
const sin = Math.sin(c7.xDirAngle);
|
|
105
|
+
const x6 = c7.majorRadius * Math.cos(angle);
|
|
106
|
+
const y6 = c7.minorRadius * Math.sin(angle);
|
|
107
|
+
return [c7.cx + x6 * cos - y6 * sin, c7.cy + x6 * sin + y6 * cos];
|
|
106
108
|
}
|
|
107
109
|
case "bezier":
|
|
108
|
-
return evaluateBezier(
|
|
110
|
+
return evaluateBezier(c7.poles, t7);
|
|
109
111
|
case "bspline":
|
|
110
|
-
return evaluateBSpline2d(
|
|
112
|
+
return evaluateBSpline2d(c7, t7);
|
|
111
113
|
case "trimmed": {
|
|
112
|
-
const mapped =
|
|
113
|
-
return evaluateCurve2d(
|
|
114
|
+
const mapped = c7.tStart + t7 * (c7.tEnd - c7.tStart);
|
|
115
|
+
return evaluateCurve2d(c7.basis, mapped);
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
|
-
function tangentCurve2d(
|
|
118
|
-
switch (
|
|
119
|
+
function tangentCurve2d(c7, t7) {
|
|
120
|
+
switch (c7.__bk2d) {
|
|
119
121
|
case "line":
|
|
120
|
-
return [
|
|
122
|
+
return [c7.dx, c7.dy];
|
|
121
123
|
case "circle": {
|
|
122
|
-
const angle =
|
|
123
|
-
const sign =
|
|
124
|
-
return [-
|
|
124
|
+
const angle = c7.sense ? t7 : -t7;
|
|
125
|
+
const sign = c7.sense ? 1 : -1;
|
|
126
|
+
return [-c7.radius * Math.sin(angle) * sign, c7.radius * Math.cos(angle) * sign];
|
|
125
127
|
}
|
|
126
128
|
case "ellipse": {
|
|
127
|
-
const angle =
|
|
128
|
-
const sign =
|
|
129
|
-
const cos = Math.cos(
|
|
130
|
-
const sin = Math.sin(
|
|
131
|
-
const dx = -
|
|
132
|
-
const dy =
|
|
129
|
+
const angle = c7.sense ? t7 : -t7;
|
|
130
|
+
const sign = c7.sense ? 1 : -1;
|
|
131
|
+
const cos = Math.cos(c7.xDirAngle);
|
|
132
|
+
const sin = Math.sin(c7.xDirAngle);
|
|
133
|
+
const dx = -c7.majorRadius * Math.sin(angle) * sign;
|
|
134
|
+
const dy = c7.minorRadius * Math.cos(angle) * sign;
|
|
133
135
|
return [dx * cos - dy * sin, dx * sin + dy * cos];
|
|
134
136
|
}
|
|
135
137
|
case "bezier": {
|
|
136
|
-
const
|
|
137
|
-
const p0 = evaluateBezier(
|
|
138
|
-
const p1 = evaluateBezier(
|
|
139
|
-
const dt = Math.min(1,
|
|
138
|
+
const h7 = 1e-8;
|
|
139
|
+
const p0 = evaluateBezier(c7.poles, Math.max(0, t7 - h7));
|
|
140
|
+
const p1 = evaluateBezier(c7.poles, Math.min(1, t7 + h7));
|
|
141
|
+
const dt = Math.min(1, t7 + h7) - Math.max(0, t7 - h7);
|
|
140
142
|
return [(p1[0] - p0[0]) / dt, (p1[1] - p0[1]) / dt];
|
|
141
143
|
}
|
|
142
144
|
case "bspline": {
|
|
143
|
-
const
|
|
144
|
-
const kFirst =
|
|
145
|
-
const kLast =
|
|
146
|
-
const p0 = evaluateBSpline2d(
|
|
147
|
-
const p1 = evaluateBSpline2d(
|
|
148
|
-
const dt = Math.min(kLast,
|
|
145
|
+
const h7 = 1e-8;
|
|
146
|
+
const kFirst = c7.knots[0];
|
|
147
|
+
const kLast = c7.knots[c7.knots.length - 1];
|
|
148
|
+
const p0 = evaluateBSpline2d(c7, Math.max(kFirst, t7 - h7));
|
|
149
|
+
const p1 = evaluateBSpline2d(c7, Math.min(kLast, t7 + h7));
|
|
150
|
+
const dt = Math.min(kLast, t7 + h7) - Math.max(kFirst, t7 - h7);
|
|
149
151
|
return [(p1[0] - p0[0]) / dt, (p1[1] - p0[1]) / dt];
|
|
150
152
|
}
|
|
151
153
|
case "trimmed": {
|
|
152
|
-
const mapped =
|
|
153
|
-
const tan = tangentCurve2d(
|
|
154
|
-
const scale2 =
|
|
154
|
+
const mapped = c7.tStart + t7 * (c7.tEnd - c7.tStart);
|
|
155
|
+
const tan = tangentCurve2d(c7.basis, mapped);
|
|
156
|
+
const scale2 = c7.tEnd - c7.tStart;
|
|
155
157
|
return [tan[0] * scale2, tan[1] * scale2];
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
|
-
function curveBounds(
|
|
160
|
-
switch (
|
|
161
|
+
function curveBounds(c7) {
|
|
162
|
+
switch (c7.__bk2d) {
|
|
161
163
|
case "line":
|
|
162
|
-
return { first: 0, last:
|
|
164
|
+
return { first: 0, last: c7.len };
|
|
163
165
|
case "circle":
|
|
164
166
|
case "ellipse":
|
|
165
167
|
return { first: 0, last: 2 * Math.PI };
|
|
166
168
|
case "bezier":
|
|
167
169
|
return { first: 0, last: 1 };
|
|
168
170
|
case "bspline":
|
|
169
|
-
return { first:
|
|
171
|
+
return { first: c7.knots[0], last: c7.knots[c7.knots.length - 1] };
|
|
170
172
|
case "trimmed":
|
|
171
173
|
return { first: 0, last: 1 };
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
|
-
function curveTypeName(
|
|
175
|
-
switch (
|
|
176
|
+
function curveTypeName(c7) {
|
|
177
|
+
switch (c7.__bk2d) {
|
|
176
178
|
case "line":
|
|
177
179
|
return "LINE";
|
|
178
180
|
case "circle":
|
|
@@ -184,7 +186,7 @@ function curveTypeName(c8) {
|
|
|
184
186
|
case "bspline":
|
|
185
187
|
return "BSPLINE_CURVE";
|
|
186
188
|
case "trimmed":
|
|
187
|
-
return "TRIMMED_" + curveTypeName(
|
|
189
|
+
return "TRIMMED_" + curveTypeName(c7.basis);
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
function makeLine2d(x1, y1, x22, y22) {
|
|
@@ -217,125 +219,125 @@ function makeEllipse2d(cx, cy, majorRadius, minorRadius, xDirX = 1, xDirY = 0, s
|
|
|
217
219
|
function makeBezier2d(poles) {
|
|
218
220
|
return { __bk2d: "bezier", poles: [...poles] };
|
|
219
221
|
}
|
|
220
|
-
function translateCurve2d(
|
|
221
|
-
switch (
|
|
222
|
+
function translateCurve2d(c7, dx, dy) {
|
|
223
|
+
switch (c7.__bk2d) {
|
|
222
224
|
case "line":
|
|
223
|
-
return { ...
|
|
225
|
+
return { ...c7, ox: c7.ox + dx, oy: c7.oy + dy };
|
|
224
226
|
case "circle":
|
|
225
|
-
return { ...
|
|
227
|
+
return { ...c7, cx: c7.cx + dx, cy: c7.cy + dy };
|
|
226
228
|
case "ellipse":
|
|
227
|
-
return { ...
|
|
229
|
+
return { ...c7, cx: c7.cx + dx, cy: c7.cy + dy };
|
|
228
230
|
case "bezier":
|
|
229
|
-
return { ...
|
|
231
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => [x6 + dx, y6 + dy]) };
|
|
230
232
|
case "bspline":
|
|
231
|
-
return { ...
|
|
233
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => [x6 + dx, y6 + dy]) };
|
|
232
234
|
case "trimmed":
|
|
233
|
-
return { ...
|
|
235
|
+
return { ...c7, basis: translateCurve2d(c7.basis, dx, dy) };
|
|
234
236
|
}
|
|
235
237
|
}
|
|
236
|
-
function rotateCurve2d(
|
|
238
|
+
function rotateCurve2d(c7, angle, cx, cy) {
|
|
237
239
|
const cos = Math.cos(angle);
|
|
238
240
|
const sin = Math.sin(angle);
|
|
239
|
-
const rotatePoint = (
|
|
240
|
-
const rx =
|
|
241
|
-
const ry =
|
|
241
|
+
const rotatePoint = (x6, y6) => {
|
|
242
|
+
const rx = x6 - cx;
|
|
243
|
+
const ry = y6 - cy;
|
|
242
244
|
return [cx + rx * cos - ry * sin, cy + rx * sin + ry * cos];
|
|
243
245
|
};
|
|
244
|
-
switch (
|
|
246
|
+
switch (c7.__bk2d) {
|
|
245
247
|
case "line": {
|
|
246
|
-
const [ox, oy] = rotatePoint(
|
|
247
|
-
const ndx =
|
|
248
|
-
const ndy =
|
|
249
|
-
return { ...
|
|
248
|
+
const [ox, oy] = rotatePoint(c7.ox, c7.oy);
|
|
249
|
+
const ndx = c7.dx * cos - c7.dy * sin;
|
|
250
|
+
const ndy = c7.dx * sin + c7.dy * cos;
|
|
251
|
+
return { ...c7, ox, oy, dx: ndx, dy: ndy };
|
|
250
252
|
}
|
|
251
253
|
case "circle": {
|
|
252
|
-
const [ncx, ncy] = rotatePoint(
|
|
253
|
-
return { ...
|
|
254
|
+
const [ncx, ncy] = rotatePoint(c7.cx, c7.cy);
|
|
255
|
+
return { ...c7, cx: ncx, cy: ncy };
|
|
254
256
|
}
|
|
255
257
|
case "ellipse": {
|
|
256
|
-
const [ncx, ncy] = rotatePoint(
|
|
257
|
-
return { ...
|
|
258
|
+
const [ncx, ncy] = rotatePoint(c7.cx, c7.cy);
|
|
259
|
+
return { ...c7, cx: ncx, cy: ncy, xDirAngle: c7.xDirAngle + angle };
|
|
258
260
|
}
|
|
259
261
|
case "bezier":
|
|
260
|
-
return { ...
|
|
262
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => rotatePoint(x6, y6)) };
|
|
261
263
|
case "bspline":
|
|
262
|
-
return { ...
|
|
264
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => rotatePoint(x6, y6)) };
|
|
263
265
|
case "trimmed":
|
|
264
|
-
return { ...
|
|
266
|
+
return { ...c7, basis: rotateCurve2d(c7.basis, angle, cx, cy) };
|
|
265
267
|
}
|
|
266
268
|
}
|
|
267
|
-
function scaleCurve2d(
|
|
268
|
-
const scalePoint = (
|
|
269
|
-
cx + (
|
|
270
|
-
cy + (
|
|
269
|
+
function scaleCurve2d(c7, factor, cx, cy) {
|
|
270
|
+
const scalePoint = (x6, y6) => [
|
|
271
|
+
cx + (x6 - cx) * factor,
|
|
272
|
+
cy + (y6 - cy) * factor
|
|
271
273
|
];
|
|
272
|
-
switch (
|
|
274
|
+
switch (c7.__bk2d) {
|
|
273
275
|
case "line": {
|
|
274
|
-
const [ox, oy] = scalePoint(
|
|
275
|
-
return { ...
|
|
276
|
+
const [ox, oy] = scalePoint(c7.ox, c7.oy);
|
|
277
|
+
return { ...c7, ox, oy };
|
|
276
278
|
}
|
|
277
279
|
case "circle": {
|
|
278
|
-
const [ncx, ncy] = scalePoint(
|
|
279
|
-
return { ...
|
|
280
|
+
const [ncx, ncy] = scalePoint(c7.cx, c7.cy);
|
|
281
|
+
return { ...c7, cx: ncx, cy: ncy, radius: c7.radius * Math.abs(factor) };
|
|
280
282
|
}
|
|
281
283
|
case "ellipse": {
|
|
282
|
-
const [ncx, ncy] = scalePoint(
|
|
284
|
+
const [ncx, ncy] = scalePoint(c7.cx, c7.cy);
|
|
283
285
|
return {
|
|
284
|
-
...
|
|
286
|
+
...c7,
|
|
285
287
|
cx: ncx,
|
|
286
288
|
cy: ncy,
|
|
287
|
-
majorRadius:
|
|
288
|
-
minorRadius:
|
|
289
|
+
majorRadius: c7.majorRadius * Math.abs(factor),
|
|
290
|
+
minorRadius: c7.minorRadius * Math.abs(factor)
|
|
289
291
|
};
|
|
290
292
|
}
|
|
291
293
|
case "bezier":
|
|
292
|
-
return { ...
|
|
294
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => scalePoint(x6, y6)) };
|
|
293
295
|
case "bspline":
|
|
294
|
-
return { ...
|
|
296
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => scalePoint(x6, y6)) };
|
|
295
297
|
case "trimmed":
|
|
296
|
-
return { ...
|
|
298
|
+
return { ...c7, basis: scaleCurve2d(c7.basis, factor, cx, cy) };
|
|
297
299
|
}
|
|
298
300
|
}
|
|
299
|
-
function mirrorAtPoint(
|
|
300
|
-
return scaleCurve2d(
|
|
301
|
+
function mirrorAtPoint(c7, cx, cy) {
|
|
302
|
+
return scaleCurve2d(c7, -1, cx, cy);
|
|
301
303
|
}
|
|
302
|
-
function mirrorAcrossAxis(
|
|
304
|
+
function mirrorAcrossAxis(c7, ox, oy, dx, dy) {
|
|
303
305
|
const len = Math.sqrt(dx * dx + dy * dy);
|
|
304
306
|
const nx = dx / len;
|
|
305
307
|
const ny = dy / len;
|
|
306
|
-
const reflectPoint = (
|
|
307
|
-
const rx =
|
|
308
|
-
const ry =
|
|
308
|
+
const reflectPoint = (x6, y6) => {
|
|
309
|
+
const rx = x6 - ox;
|
|
310
|
+
const ry = y6 - oy;
|
|
309
311
|
const dot = rx * nx + ry * ny;
|
|
310
312
|
return [ox + 2 * dot * nx - rx, oy + 2 * dot * ny - ry];
|
|
311
313
|
};
|
|
312
|
-
switch (
|
|
314
|
+
switch (c7.__bk2d) {
|
|
313
315
|
case "line": {
|
|
314
|
-
const [nox, noy] = reflectPoint(
|
|
315
|
-
const ndx = 2 * (
|
|
316
|
-
const ndy = 2 * (
|
|
317
|
-
return { ...
|
|
316
|
+
const [nox, noy] = reflectPoint(c7.ox, c7.oy);
|
|
317
|
+
const ndx = 2 * (c7.dx * nx + c7.dy * ny) * nx - c7.dx;
|
|
318
|
+
const ndy = 2 * (c7.dx * nx + c7.dy * ny) * ny - c7.dy;
|
|
319
|
+
return { ...c7, ox: nox, oy: noy, dx: ndx, dy: ndy };
|
|
318
320
|
}
|
|
319
321
|
case "circle": {
|
|
320
|
-
const [ncx, ncy] = reflectPoint(
|
|
321
|
-
return { ...
|
|
322
|
+
const [ncx, ncy] = reflectPoint(c7.cx, c7.cy);
|
|
323
|
+
return { ...c7, cx: ncx, cy: ncy, sense: !c7.sense };
|
|
322
324
|
}
|
|
323
325
|
case "ellipse": {
|
|
324
|
-
const [ncx, ncy] = reflectPoint(
|
|
326
|
+
const [ncx, ncy] = reflectPoint(c7.cx, c7.cy);
|
|
325
327
|
const cos2 = nx * nx - ny * ny;
|
|
326
328
|
const sin2 = 2 * nx * ny;
|
|
327
329
|
const newAngle = Math.atan2(
|
|
328
|
-
sin2 * Math.cos(
|
|
329
|
-
cos2 * Math.cos(
|
|
330
|
+
sin2 * Math.cos(c7.xDirAngle) - cos2 * Math.sin(c7.xDirAngle),
|
|
331
|
+
cos2 * Math.cos(c7.xDirAngle) + sin2 * Math.sin(c7.xDirAngle)
|
|
330
332
|
);
|
|
331
|
-
return { ...
|
|
333
|
+
return { ...c7, cx: ncx, cy: ncy, xDirAngle: newAngle, sense: !c7.sense };
|
|
332
334
|
}
|
|
333
335
|
case "bezier":
|
|
334
|
-
return { ...
|
|
336
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => reflectPoint(x6, y6)) };
|
|
335
337
|
case "bspline":
|
|
336
|
-
return { ...
|
|
338
|
+
return { ...c7, poles: c7.poles.map(([x6, y6]) => reflectPoint(x6, y6)) };
|
|
337
339
|
case "trimmed":
|
|
338
|
-
return { ...
|
|
340
|
+
return { ...c7, basis: mirrorAcrossAxis(c7.basis, ox, oy, dx, dy) };
|
|
339
341
|
}
|
|
340
342
|
}
|
|
341
343
|
function intersectCurves2dFn(c1, c22, tolerance) {
|
|
@@ -356,34 +358,34 @@ function intersectCurves2dFn(c1, c22, tolerance) {
|
|
|
356
358
|
const isSelf = c1 === c22;
|
|
357
359
|
return numericalIntersect(c1, c22, tolerance, isSelf);
|
|
358
360
|
}
|
|
359
|
-
function unwrapCurve(
|
|
360
|
-
let cur =
|
|
361
|
+
function unwrapCurve(c7) {
|
|
362
|
+
let cur = c7;
|
|
361
363
|
while (cur.__bk2d === "trimmed") cur = cur.basis;
|
|
362
364
|
return cur;
|
|
363
365
|
}
|
|
364
|
-
function inDomain(
|
|
365
|
-
const
|
|
366
|
-
return
|
|
366
|
+
function inDomain(c7, t7, tol) {
|
|
367
|
+
const b7 = curveBounds(c7);
|
|
368
|
+
return t7 >= b7.first - tol && t7 <= b7.last + tol;
|
|
367
369
|
}
|
|
368
|
-
function refineParam(
|
|
369
|
-
const bounds = curveBounds(
|
|
370
|
+
function refineParam(c7, px, py) {
|
|
371
|
+
const bounds = curveBounds(c7);
|
|
370
372
|
if (!isFinite(bounds.first) || !isFinite(bounds.last)) return null;
|
|
371
373
|
const N4 = 80;
|
|
372
374
|
const dt = (bounds.last - bounds.first) / N4;
|
|
373
375
|
let bestT = bounds.first;
|
|
374
376
|
let bestD = Infinity;
|
|
375
377
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
376
|
-
const
|
|
377
|
-
const [ex2, ey2] = evaluateCurve2d(
|
|
378
|
+
const t7 = bounds.first + i9 * dt;
|
|
379
|
+
const [ex2, ey2] = evaluateCurve2d(c7, t7);
|
|
378
380
|
const d11 = (ex2 - px) ** 2 + (ey2 - py) ** 2;
|
|
379
381
|
if (d11 < bestD) {
|
|
380
382
|
bestD = d11;
|
|
381
|
-
bestT =
|
|
383
|
+
bestT = t7;
|
|
382
384
|
}
|
|
383
385
|
}
|
|
384
|
-
const [sx, sy] = evaluateCurve2d(
|
|
385
|
-
const [ex, ey] = evaluateCurve2d(
|
|
386
|
-
const [mx, my] = evaluateCurve2d(
|
|
386
|
+
const [sx, sy] = evaluateCurve2d(c7, bounds.first);
|
|
387
|
+
const [ex, ey] = evaluateCurve2d(c7, bounds.last);
|
|
388
|
+
const [mx, my] = evaluateCurve2d(c7, (bounds.first + bounds.last) / 2);
|
|
387
389
|
const geomExtent = Math.max(
|
|
388
390
|
Math.sqrt((ex - sx) ** 2 + (ey - sy) ** 2),
|
|
389
391
|
Math.sqrt((mx - sx) ** 2 + (my - sy) ** 2),
|
|
@@ -426,14 +428,14 @@ function intersectLineCircle(cLine, line, cCirc, circ, tol) {
|
|
|
426
428
|
const fx = line.ox - circ.cx;
|
|
427
429
|
const fy = line.oy - circ.cy;
|
|
428
430
|
const a9 = line.dx * line.dx + line.dy * line.dy;
|
|
429
|
-
const
|
|
430
|
-
const
|
|
431
|
-
const disc =
|
|
431
|
+
const b7 = 2 * (fx * line.dx + fy * line.dy);
|
|
432
|
+
const c7 = fx * fx + fy * fy - circ.radius * circ.radius;
|
|
433
|
+
const disc = b7 * b7 - 4 * a9 * c7;
|
|
432
434
|
if (disc < -tol) return [];
|
|
433
435
|
const results = [];
|
|
434
436
|
const sqrtDisc = Math.sqrt(Math.max(0, disc));
|
|
435
|
-
const t1 = (-
|
|
436
|
-
const t22 = (-
|
|
437
|
+
const t1 = (-b7 - sqrtDisc) / (2 * a9);
|
|
438
|
+
const t22 = (-b7 + sqrtDisc) / (2 * a9);
|
|
437
439
|
for (const tLine of disc < tol * tol ? [t1] : [t1, t22]) {
|
|
438
440
|
if (!inDomain(cLine, tLine, tol)) continue;
|
|
439
441
|
const px = line.ox + tLine * line.dx;
|
|
@@ -455,12 +457,12 @@ function intersectCircleCircle(c1, circ1, c22, circ2, tol) {
|
|
|
455
457
|
if (d11 < 1e-14) return [];
|
|
456
458
|
const a9 = (circ1.radius * circ1.radius - circ2.radius * circ2.radius + d11 * d11) / (2 * d11);
|
|
457
459
|
const h22 = circ1.radius * circ1.radius - a9 * a9;
|
|
458
|
-
const
|
|
460
|
+
const h7 = Math.sqrt(Math.max(0, h22));
|
|
459
461
|
const mx = circ1.cx + a9 * dx / d11;
|
|
460
462
|
const my = circ1.cy + a9 * dy / d11;
|
|
461
|
-
const candidates =
|
|
462
|
-
[mx +
|
|
463
|
-
[mx -
|
|
463
|
+
const candidates = h7 < tol ? [[mx, my]] : [
|
|
464
|
+
[mx + h7 * dy / d11, my - h7 * dx / d11],
|
|
465
|
+
[mx - h7 * dy / d11, my + h7 * dx / d11]
|
|
464
466
|
];
|
|
465
467
|
const results = [];
|
|
466
468
|
for (const [px, py] of candidates) {
|
|
@@ -498,9 +500,9 @@ function numericalIntersect(c1, c22, tolerance, isSelf = false) {
|
|
|
498
500
|
for (let i9 = 0; i9 < N4; i9++) {
|
|
499
501
|
const p1a = pts1[i9];
|
|
500
502
|
const p1b = pts1[i9 + 1];
|
|
501
|
-
for (let
|
|
502
|
-
const p2a = pts2[
|
|
503
|
-
const p2b = pts2[
|
|
503
|
+
for (let j10 = 0; j10 < N4; j10++) {
|
|
504
|
+
const p2a = pts2[j10];
|
|
505
|
+
const p2b = pts2[j10 + 1];
|
|
504
506
|
const x1min = Math.min(p1a.x, p1b.x) - crossTol;
|
|
505
507
|
const x1max = Math.max(p1a.x, p1b.x) + crossTol;
|
|
506
508
|
const y1min = Math.min(p1a.y, p1b.y) - crossTol;
|
|
@@ -556,8 +558,8 @@ function numericalIntersect(c1, c22, tolerance, isSelf = false) {
|
|
|
556
558
|
}
|
|
557
559
|
return { points: found, segments: [] };
|
|
558
560
|
}
|
|
559
|
-
function serializeCurve2d(
|
|
560
|
-
return JSON.stringify(
|
|
561
|
+
function serializeCurve2d(c7) {
|
|
562
|
+
return JSON.stringify(c7);
|
|
561
563
|
}
|
|
562
564
|
function deserializeCurve2d(data) {
|
|
563
565
|
return JSON.parse(data);
|
|
@@ -565,73 +567,73 @@ function deserializeCurve2d(data) {
|
|
|
565
567
|
function createBBox2d() {
|
|
566
568
|
return { __bk2d_bbox: true, xMin: Infinity, yMin: Infinity, xMax: -Infinity, yMax: -Infinity };
|
|
567
569
|
}
|
|
568
|
-
function addCurveToBBox(bbox,
|
|
569
|
-
const bounds = curveBounds(
|
|
570
|
+
function addCurveToBBox(bbox, c7, _tol) {
|
|
571
|
+
const bounds = curveBounds(c7);
|
|
570
572
|
if (!isFinite(bounds.first) || !isFinite(bounds.last)) return;
|
|
571
573
|
const nSamples = 20;
|
|
572
574
|
const dt = (bounds.last - bounds.first) / nSamples;
|
|
573
575
|
for (let i9 = 0; i9 <= nSamples; i9++) {
|
|
574
|
-
const
|
|
575
|
-
const [
|
|
576
|
-
if (
|
|
577
|
-
if (
|
|
578
|
-
if (
|
|
579
|
-
if (
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
function evaluateBezier(poles,
|
|
583
|
-
const
|
|
584
|
-
const work = poles.map(([
|
|
585
|
-
for (let r9 = 1; r9 <
|
|
586
|
-
for (let i9 = 0; i9 <
|
|
576
|
+
const t7 = bounds.first + i9 * dt;
|
|
577
|
+
const [x6, y6] = evaluateCurve2d(c7, t7);
|
|
578
|
+
if (x6 < bbox.xMin) bbox.xMin = x6;
|
|
579
|
+
if (y6 < bbox.yMin) bbox.yMin = y6;
|
|
580
|
+
if (x6 > bbox.xMax) bbox.xMax = x6;
|
|
581
|
+
if (y6 > bbox.yMax) bbox.yMax = y6;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
function evaluateBezier(poles, t7) {
|
|
585
|
+
const n8 = poles.length;
|
|
586
|
+
const work = poles.map(([x6, y6]) => [x6, y6]);
|
|
587
|
+
for (let r9 = 1; r9 < n8; r9++) {
|
|
588
|
+
for (let i9 = 0; i9 < n8 - r9; i9++) {
|
|
587
589
|
const wi = work[i9];
|
|
588
590
|
const wi1 = work[i9 + 1];
|
|
589
|
-
wi[0] = (1 -
|
|
590
|
-
wi[1] = (1 -
|
|
591
|
+
wi[0] = (1 - t7) * wi[0] + t7 * wi1[0];
|
|
592
|
+
wi[1] = (1 - t7) * wi[1] + t7 * wi1[1];
|
|
591
593
|
}
|
|
592
594
|
}
|
|
593
595
|
return work[0];
|
|
594
596
|
}
|
|
595
|
-
function evaluateBSpline2d(
|
|
597
|
+
function evaluateBSpline2d(c7, t7) {
|
|
596
598
|
const fullKnots = [];
|
|
597
|
-
for (let i9 = 0; i9 <
|
|
598
|
-
const mult =
|
|
599
|
-
for (let
|
|
600
|
-
fullKnots.push(
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
const
|
|
604
|
-
const
|
|
605
|
-
const
|
|
606
|
-
const tClamped = Math.max(fullKnots[
|
|
607
|
-
let span =
|
|
608
|
-
for (let i9 =
|
|
599
|
+
for (let i9 = 0; i9 < c7.knots.length; i9++) {
|
|
600
|
+
const mult = c7.multiplicities[i9] ?? 1;
|
|
601
|
+
for (let j10 = 0; j10 < mult; j10++) {
|
|
602
|
+
fullKnots.push(c7.knots[i9]);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
const p7 = c7.degree;
|
|
606
|
+
const n8 = c7.poles.length;
|
|
607
|
+
const k9 = fullKnots.length;
|
|
608
|
+
const tClamped = Math.max(fullKnots[p7], Math.min(fullKnots[k9 - p7 - 1], t7));
|
|
609
|
+
let span = p7;
|
|
610
|
+
for (let i9 = p7; i9 < k9 - p7 - 1; i9++) {
|
|
609
611
|
if (tClamped >= fullKnots[i9] && tClamped < fullKnots[i9 + 1]) {
|
|
610
612
|
span = i9;
|
|
611
613
|
break;
|
|
612
614
|
}
|
|
613
615
|
}
|
|
614
|
-
if (tClamped >= fullKnots[
|
|
616
|
+
if (tClamped >= fullKnots[k9 - p7 - 1]) span = k9 - p7 - 2;
|
|
615
617
|
const d11 = [];
|
|
616
|
-
for (let
|
|
617
|
-
const idx = Math.min(span -
|
|
618
|
-
const pole =
|
|
618
|
+
for (let j10 = 0; j10 <= p7; j10++) {
|
|
619
|
+
const idx = Math.min(span - p7 + j10, n8 - 1);
|
|
620
|
+
const pole = c7.poles[Math.max(0, idx)];
|
|
619
621
|
d11.push([pole[0], pole[1]]);
|
|
620
622
|
}
|
|
621
|
-
for (let r9 = 1; r9 <=
|
|
622
|
-
for (let
|
|
623
|
-
const i9 = span -
|
|
623
|
+
for (let r9 = 1; r9 <= p7; r9++) {
|
|
624
|
+
for (let j10 = p7; j10 >= r9; j10--) {
|
|
625
|
+
const i9 = span - p7 + j10;
|
|
624
626
|
const left = fullKnots[i9] ?? 0;
|
|
625
|
-
const right = fullKnots[i9 +
|
|
627
|
+
const right = fullKnots[i9 + p7 - r9 + 1] ?? 1;
|
|
626
628
|
const denom = right - left;
|
|
627
629
|
const alpha = denom > 1e-15 ? (tClamped - left) / denom : 0;
|
|
628
|
-
const dj = d11[
|
|
629
|
-
const djPrev = d11[
|
|
630
|
+
const dj = d11[j10];
|
|
631
|
+
const djPrev = d11[j10 - 1];
|
|
630
632
|
dj[0] = (1 - alpha) * djPrev[0] + alpha * dj[0];
|
|
631
633
|
dj[1] = (1 - alpha) * djPrev[1] + alpha * dj[1];
|
|
632
634
|
}
|
|
633
635
|
}
|
|
634
|
-
return d11[
|
|
636
|
+
return d11[p7];
|
|
635
637
|
}
|
|
636
638
|
function isBrepkitHandle(shape2) {
|
|
637
639
|
return shape2 !== null && shape2 !== void 0 && typeof shape2 === "object" && shape2.__brepkit;
|
|
@@ -668,11 +670,11 @@ function shellHandle(id) {
|
|
|
668
670
|
return handle("shell", id);
|
|
669
671
|
}
|
|
670
672
|
function compoundHandle(id) {
|
|
671
|
-
const
|
|
673
|
+
const h7 = handle("compound", id);
|
|
672
674
|
if (syntheticCompounds.has(id)) {
|
|
673
|
-
return { ...
|
|
675
|
+
return { ...h7, delete: () => syntheticCompounds.delete(id) };
|
|
674
676
|
}
|
|
675
|
-
return
|
|
677
|
+
return h7;
|
|
676
678
|
}
|
|
677
679
|
function vertexHandle(id) {
|
|
678
680
|
return handle("vertex", id);
|
|
@@ -723,16 +725,16 @@ function dist3(x1, y1, z1, x22, y22, z22) {
|
|
|
723
725
|
function copyWasmBytes(bytes) {
|
|
724
726
|
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
725
727
|
}
|
|
726
|
-
function translationMatrix(
|
|
728
|
+
function translationMatrix(x6, y6, z6) {
|
|
727
729
|
return [
|
|
728
730
|
1,
|
|
729
731
|
0,
|
|
730
732
|
0,
|
|
731
|
-
|
|
733
|
+
x6,
|
|
732
734
|
0,
|
|
733
735
|
1,
|
|
734
736
|
0,
|
|
735
|
-
|
|
737
|
+
y6,
|
|
736
738
|
0,
|
|
737
739
|
0,
|
|
738
740
|
1,
|
|
@@ -745,20 +747,20 @@ function translationMatrix(x7, y7, z6) {
|
|
|
745
747
|
}
|
|
746
748
|
function rotationMatrix(angleDeg, axis = [0, 0, 1], center = [0, 0, 0]) {
|
|
747
749
|
const rad = angleDeg * Math.PI / 180;
|
|
748
|
-
const
|
|
749
|
-
const
|
|
750
|
-
const
|
|
750
|
+
const c7 = Math.cos(rad);
|
|
751
|
+
const s5 = Math.sin(rad);
|
|
752
|
+
const t7 = 1 - c7;
|
|
751
753
|
const len = Math.sqrt(axis[0] ** 2 + axis[1] ** 2 + axis[2] ** 2);
|
|
752
754
|
const [ux, uy, uz] = [axis[0] / len, axis[1] / len, axis[2] / len];
|
|
753
|
-
const r00 =
|
|
754
|
-
const r01 =
|
|
755
|
-
const r02 =
|
|
756
|
-
const r10 =
|
|
757
|
-
const r11 =
|
|
758
|
-
const r12 =
|
|
759
|
-
const r20 =
|
|
760
|
-
const r21 =
|
|
761
|
-
const r22 =
|
|
755
|
+
const r00 = t7 * ux * ux + c7;
|
|
756
|
+
const r01 = t7 * ux * uy - s5 * uz;
|
|
757
|
+
const r02 = t7 * ux * uz + s5 * uy;
|
|
758
|
+
const r10 = t7 * uy * ux + s5 * uz;
|
|
759
|
+
const r11 = t7 * uy * uy + c7;
|
|
760
|
+
const r12 = t7 * uy * uz - s5 * ux;
|
|
761
|
+
const r20 = t7 * uz * ux - s5 * uy;
|
|
762
|
+
const r21 = t7 * uz * uy + s5 * ux;
|
|
763
|
+
const r22 = t7 * uz * uz + c7;
|
|
762
764
|
const [cx, cy, cz] = center;
|
|
763
765
|
const tx = cx - (r00 * cx + r01 * cy + r02 * cz);
|
|
764
766
|
const ty = cy - (r10 * cx + r11 * cy + r12 * cz);
|
|
@@ -862,6 +864,30 @@ function warnOnce(key, message) {
|
|
|
862
864
|
_warned.add(key);
|
|
863
865
|
console.warn(`brepkit: ${message}`);
|
|
864
866
|
}
|
|
867
|
+
function mapNumericTransition(mode) {
|
|
868
|
+
switch (mode) {
|
|
869
|
+
case 0:
|
|
870
|
+
return "rmf";
|
|
871
|
+
case 1:
|
|
872
|
+
return "rightCorner";
|
|
873
|
+
case 2:
|
|
874
|
+
return "roundCorner";
|
|
875
|
+
default:
|
|
876
|
+
return void 0;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function mapStringTransition(mode) {
|
|
880
|
+
switch (mode) {
|
|
881
|
+
case "right":
|
|
882
|
+
return "rightCorner";
|
|
883
|
+
case "round":
|
|
884
|
+
return "roundCorner";
|
|
885
|
+
case "transformed":
|
|
886
|
+
return "rmf";
|
|
887
|
+
default:
|
|
888
|
+
return void 0;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
865
891
|
function hasBooleanOptions(opts) {
|
|
866
892
|
return opts.optimisation !== void 0 || opts.simplify !== void 0 || opts.strategy !== void 0 || opts.fuzzyValue !== void 0;
|
|
867
893
|
}
|
|
@@ -948,9 +974,9 @@ class BrepkitAdapter {
|
|
|
948
974
|
if (this.bk.compoundFuse) {
|
|
949
975
|
const solidIds = [];
|
|
950
976
|
for (const shape2 of shapes) {
|
|
951
|
-
const
|
|
952
|
-
if (
|
|
953
|
-
solidIds.push(...toArray(this.bk.getCompoundSolids(
|
|
977
|
+
const h7 = shape2;
|
|
978
|
+
if (h7.type === "compound") {
|
|
979
|
+
solidIds.push(...toArray(this.bk.getCompoundSolids(h7.id)));
|
|
954
980
|
} else {
|
|
955
981
|
solidIds.push(unwrapSolidOrThrow(shape2, "fuseAll"));
|
|
956
982
|
}
|
|
@@ -981,9 +1007,9 @@ class BrepkitAdapter {
|
|
|
981
1007
|
const baseId = unwrapSolidOrThrow(shape2, "cutAll");
|
|
982
1008
|
const toolIds = [];
|
|
983
1009
|
for (const tool of tools) {
|
|
984
|
-
const
|
|
985
|
-
if (
|
|
986
|
-
toolIds.push(...toArray(this.bk.getCompoundSolids(
|
|
1010
|
+
const h7 = tool;
|
|
1011
|
+
if (h7.type === "compound") {
|
|
1012
|
+
toolIds.push(...toArray(this.bk.getCompoundSolids(h7.id)));
|
|
987
1013
|
} else {
|
|
988
1014
|
toolIds.push(unwrapSolidOrThrow(tool, "cutAll"));
|
|
989
1015
|
}
|
|
@@ -1014,15 +1040,15 @@ class BrepkitAdapter {
|
|
|
1014
1040
|
hull(shapes, _tolerance) {
|
|
1015
1041
|
const coords = [];
|
|
1016
1042
|
for (const shape2 of shapes) {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
const vertIds = toArray(this.bk.getSolidVertices(
|
|
1043
|
+
const h7 = shape2;
|
|
1044
|
+
if (h7.type === "solid") {
|
|
1045
|
+
const vertIds = toArray(this.bk.getSolidVertices(h7.id));
|
|
1020
1046
|
for (const vid of vertIds) {
|
|
1021
1047
|
const pos = this.bk.getVertexPosition(vid);
|
|
1022
1048
|
coords.push(pos[0], pos[1], pos[2]);
|
|
1023
1049
|
}
|
|
1024
|
-
} else if (
|
|
1025
|
-
const pos = this.bk.getVertexPosition(
|
|
1050
|
+
} else if (h7.type === "vertex") {
|
|
1051
|
+
const pos = this.bk.getVertexPosition(h7.id);
|
|
1026
1052
|
coords.push(pos[0], pos[1], pos[2]);
|
|
1027
1053
|
}
|
|
1028
1054
|
}
|
|
@@ -1033,8 +1059,8 @@ class BrepkitAdapter {
|
|
|
1033
1059
|
hullFromPoints(points, _tolerance) {
|
|
1034
1060
|
if (points.length < 4) throw new Error("brepkit: hull needs at least 4 points");
|
|
1035
1061
|
const coords = [];
|
|
1036
|
-
for (const
|
|
1037
|
-
coords.push(
|
|
1062
|
+
for (const p7 of points) {
|
|
1063
|
+
coords.push(p7.x, p7.y, p7.z);
|
|
1038
1064
|
}
|
|
1039
1065
|
const id = this.bk.convexHull(coords);
|
|
1040
1066
|
return solidHandle(id);
|
|
@@ -1042,10 +1068,10 @@ class BrepkitAdapter {
|
|
|
1042
1068
|
buildSolidFromFaces(points, faces, _tolerance) {
|
|
1043
1069
|
const positions = new Float64Array(points.length * 3);
|
|
1044
1070
|
for (let i9 = 0; i9 < points.length; i9++) {
|
|
1045
|
-
const
|
|
1046
|
-
positions[i9 * 3] =
|
|
1047
|
-
positions[i9 * 3 + 1] =
|
|
1048
|
-
positions[i9 * 3 + 2] =
|
|
1071
|
+
const p7 = points[i9];
|
|
1072
|
+
positions[i9 * 3] = p7.x;
|
|
1073
|
+
positions[i9 * 3 + 1] = p7.y;
|
|
1074
|
+
positions[i9 * 3 + 2] = p7.z;
|
|
1049
1075
|
}
|
|
1050
1076
|
const indices = new Uint32Array(faces.length * 3);
|
|
1051
1077
|
for (let i9 = 0; i9 < faces.length; i9++) {
|
|
@@ -1060,8 +1086,8 @@ class BrepkitAdapter {
|
|
|
1060
1086
|
// ═══════════════════════════════════════════════════════════════════════
|
|
1061
1087
|
// Shape construction
|
|
1062
1088
|
// ═══════════════════════════════════════════════════════════════════════
|
|
1063
|
-
makeVertex(
|
|
1064
|
-
const id = this.bk.makeVertex(
|
|
1089
|
+
makeVertex(x6, y6, z6) {
|
|
1090
|
+
const id = this.bk.makeVertex(x6, y6, z6);
|
|
1065
1091
|
return vertexHandle(id);
|
|
1066
1092
|
}
|
|
1067
1093
|
makeEdge(curve, start, end) {
|
|
@@ -1090,9 +1116,9 @@ class BrepkitAdapter {
|
|
|
1090
1116
|
makeWire(edges) {
|
|
1091
1117
|
const edgeIds = [];
|
|
1092
1118
|
for (const e8 of edges) {
|
|
1093
|
-
const
|
|
1094
|
-
if (
|
|
1095
|
-
for (const childEdgeId of toArray(this.bk.getWireEdges(
|
|
1119
|
+
const h7 = e8;
|
|
1120
|
+
if (h7.type === "wire") {
|
|
1121
|
+
for (const childEdgeId of toArray(this.bk.getWireEdges(h7.id))) {
|
|
1096
1122
|
edgeIds.push(childEdgeId);
|
|
1097
1123
|
}
|
|
1098
1124
|
} else {
|
|
@@ -1103,9 +1129,9 @@ class BrepkitAdapter {
|
|
|
1103
1129
|
return wireHandle(id);
|
|
1104
1130
|
}
|
|
1105
1131
|
makeFace(wire, _planar) {
|
|
1106
|
-
const
|
|
1107
|
-
if (
|
|
1108
|
-
const wireId = this.bk.makeWire([
|
|
1132
|
+
const h7 = wire;
|
|
1133
|
+
if (h7.type === "edge") {
|
|
1134
|
+
const wireId = this.bk.makeWire([h7.id], true);
|
|
1109
1135
|
const id2 = this.bk.makeFaceFromWire(wireId);
|
|
1110
1136
|
return faceHandle(id2);
|
|
1111
1137
|
}
|
|
@@ -1196,8 +1222,8 @@ class BrepkitAdapter {
|
|
|
1196
1222
|
nz[2] * ux[0] - nz[0] * ux[2],
|
|
1197
1223
|
nz[0] * ux[1] - nz[1] * ux[0]
|
|
1198
1224
|
];
|
|
1199
|
-
const proj = (
|
|
1200
|
-
const dx =
|
|
1225
|
+
const proj = (p7) => {
|
|
1226
|
+
const dx = p7[0] - p1[0], dy = p7[1] - p1[1], dz = p7[2] - p1[2];
|
|
1201
1227
|
return [dx * ux[0] + dy * ux[1] + dz * ux[2], dx * uy[0] + dy * uy[1] + dz * uy[2]];
|
|
1202
1228
|
};
|
|
1203
1229
|
const [ax2, ay2] = proj(p1);
|
|
@@ -1247,12 +1273,12 @@ class BrepkitAdapter {
|
|
|
1247
1273
|
makeBezierEdge(points) {
|
|
1248
1274
|
if (points.length < 2) throw new Error("brepkit: bezier requires at least 2 points");
|
|
1249
1275
|
const degree = points.length - 1;
|
|
1250
|
-
const
|
|
1276
|
+
const n8 = points.length;
|
|
1251
1277
|
const knots = [...Array(degree + 1).fill(0), ...Array(degree + 1).fill(1)];
|
|
1252
|
-
const weights = Array(
|
|
1253
|
-
const flatCp = points.flatMap(([
|
|
1278
|
+
const weights = Array(n8).fill(1);
|
|
1279
|
+
const flatCp = points.flatMap(([x6, y6, z6]) => [x6, y6, z6]);
|
|
1254
1280
|
const startPt = points[0];
|
|
1255
|
-
const endPt = points[
|
|
1281
|
+
const endPt = points[n8 - 1];
|
|
1256
1282
|
const id = this.bk.makeNurbsEdge(
|
|
1257
1283
|
startPt[0],
|
|
1258
1284
|
startPt[1],
|
|
@@ -1294,9 +1320,9 @@ class BrepkitAdapter {
|
|
|
1294
1320
|
const sign = leftHanded ? -1 : 1;
|
|
1295
1321
|
const points = [];
|
|
1296
1322
|
for (let i9 = 0; i9 <= nSamples; i9++) {
|
|
1297
|
-
const
|
|
1298
|
-
const angle = sign * 2 * Math.PI * turns *
|
|
1299
|
-
points.push([cx + radius * Math.cos(angle), cy + radius * Math.sin(angle), cz + height *
|
|
1323
|
+
const t7 = i9 / nSamples;
|
|
1324
|
+
const angle = sign * 2 * Math.PI * turns * t7;
|
|
1325
|
+
points.push([cx + radius * Math.cos(angle), cy + radius * Math.sin(angle), cz + height * t7]);
|
|
1300
1326
|
}
|
|
1301
1327
|
const edge = this.interpolatePoints(points);
|
|
1302
1328
|
return this.makeWire([edge]);
|
|
@@ -1304,11 +1330,11 @@ class BrepkitAdapter {
|
|
|
1304
1330
|
makeWireFromMixed(items) {
|
|
1305
1331
|
const edgeIds = [];
|
|
1306
1332
|
for (const item of items) {
|
|
1307
|
-
const
|
|
1308
|
-
if (
|
|
1309
|
-
edgeIds.push(
|
|
1310
|
-
} else if (
|
|
1311
|
-
for (const childEdgeId of toArray(this.bk.getWireEdges(
|
|
1333
|
+
const h7 = item;
|
|
1334
|
+
if (h7.type === "edge") {
|
|
1335
|
+
edgeIds.push(h7.id);
|
|
1336
|
+
} else if (h7.type === "wire") {
|
|
1337
|
+
for (const childEdgeId of toArray(this.bk.getWireEdges(h7.id))) {
|
|
1312
1338
|
edgeIds.push(childEdgeId);
|
|
1313
1339
|
}
|
|
1314
1340
|
}
|
|
@@ -1323,9 +1349,9 @@ class BrepkitAdapter {
|
|
|
1323
1349
|
if (handles.length === 0) {
|
|
1324
1350
|
throw new Error("brepkit: makeCompound requires at least one shape");
|
|
1325
1351
|
}
|
|
1326
|
-
const allSolids = handles.every((
|
|
1352
|
+
const allSolids = handles.every((h7) => h7.type === "solid");
|
|
1327
1353
|
if (allSolids) {
|
|
1328
|
-
const id2 = this.bk.makeCompound(handles.map((
|
|
1354
|
+
const id2 = this.bk.makeCompound(handles.map((h7) => h7.id));
|
|
1329
1355
|
return compoundHandle(id2);
|
|
1330
1356
|
}
|
|
1331
1357
|
const id = syntheticCompoundCounter++;
|
|
@@ -1334,9 +1360,9 @@ class BrepkitAdapter {
|
|
|
1334
1360
|
}
|
|
1335
1361
|
makeBoxFromCorners(p1, p22) {
|
|
1336
1362
|
const w7 = Math.abs(p22[0] - p1[0]);
|
|
1337
|
-
const
|
|
1363
|
+
const h7 = Math.abs(p22[1] - p1[1]);
|
|
1338
1364
|
const d11 = Math.abs(p22[2] - p1[2]);
|
|
1339
|
-
const box = this.makeBox(w7,
|
|
1365
|
+
const box = this.makeBox(w7, h7, d11);
|
|
1340
1366
|
const minX = Math.min(p1[0], p22[0]);
|
|
1341
1367
|
const minY = Math.min(p1[1], p22[1]);
|
|
1342
1368
|
const minZ = Math.min(p1[2], p22[2]);
|
|
@@ -1346,15 +1372,15 @@ class BrepkitAdapter {
|
|
|
1346
1372
|
return box;
|
|
1347
1373
|
}
|
|
1348
1374
|
solidFromShell(shell2) {
|
|
1349
|
-
const
|
|
1350
|
-
if (
|
|
1351
|
-
if (
|
|
1375
|
+
const h7 = shell2;
|
|
1376
|
+
if (h7.type === "solid") return shell2;
|
|
1377
|
+
if (h7.type === "shell") {
|
|
1352
1378
|
try {
|
|
1353
|
-
this.bk.getSolidFaces(
|
|
1354
|
-
return solidHandle(
|
|
1379
|
+
this.bk.getSolidFaces(h7.id);
|
|
1380
|
+
return solidHandle(h7.id);
|
|
1355
1381
|
} catch {
|
|
1356
1382
|
}
|
|
1357
|
-
const id2 = this.bk.solidFromShell(
|
|
1383
|
+
const id2 = this.bk.solidFromShell(h7.id);
|
|
1358
1384
|
return solidHandle(id2);
|
|
1359
1385
|
}
|
|
1360
1386
|
const id = this.bk.solidFromShell(unwrap(shell2, "shell"));
|
|
@@ -1415,28 +1441,42 @@ class BrepkitAdapter {
|
|
|
1415
1441
|
);
|
|
1416
1442
|
}
|
|
1417
1443
|
const faceIds = wires.map((w7) => {
|
|
1418
|
-
const
|
|
1419
|
-
if (
|
|
1420
|
-
return this.bk.makeFaceFromWire(
|
|
1444
|
+
const h7 = w7;
|
|
1445
|
+
if (h7.type === "wire") {
|
|
1446
|
+
return this.bk.makeFaceFromWire(h7.id);
|
|
1421
1447
|
}
|
|
1422
1448
|
return unwrap(w7, "face");
|
|
1423
1449
|
});
|
|
1424
1450
|
const id = this.bk.loft(faceIds);
|
|
1425
1451
|
return solidHandle(id);
|
|
1426
1452
|
}
|
|
1427
|
-
sweep(wire, spine,
|
|
1428
|
-
|
|
1429
|
-
warnOnce("sweep-transition", "Sweep transition mode not supported; ignored.");
|
|
1430
|
-
}
|
|
1453
|
+
sweep(wire, spine, options) {
|
|
1454
|
+
const contactMode = options?.transitionMode !== void 0 ? mapNumericTransition(options.transitionMode) : void 0;
|
|
1431
1455
|
const profileHandle = wire;
|
|
1432
1456
|
const faceId = profileHandle.type === "wire" ? this.bk.makeFaceFromWire(profileHandle.id) : unwrap(wire, "face");
|
|
1433
1457
|
const spineHandle = spine;
|
|
1434
1458
|
if (spineHandle.type === "wire") {
|
|
1435
1459
|
const edges = this.iterShapes(spine, "edge");
|
|
1436
1460
|
const edgeIds = edges.map((e8) => unwrap(e8, "edge"));
|
|
1461
|
+
if (contactMode && edgeIds.length === 1) {
|
|
1462
|
+
const edgeId = edgeIds[0];
|
|
1463
|
+
if (edgeId !== void 0) {
|
|
1464
|
+
return solidHandle(this.bk.sweepWithOptions(faceId, edgeId, contactMode, [], 0));
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
if (contactMode && edgeIds.length > 1) {
|
|
1468
|
+
warnOnce(
|
|
1469
|
+
"sweep-transition-multi-edge",
|
|
1470
|
+
"Sweep transition mode not supported for multi-edge wires; ignored."
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1437
1473
|
const id2 = this.bk.sweepAlongEdges(faceId, edgeIds);
|
|
1438
1474
|
return solidHandle(id2);
|
|
1439
1475
|
}
|
|
1476
|
+
if (contactMode) {
|
|
1477
|
+
const edgeId = unwrap(spine, "edge");
|
|
1478
|
+
return solidHandle(this.bk.sweepWithOptions(faceId, edgeId, contactMode, [], 0));
|
|
1479
|
+
}
|
|
1440
1480
|
const nurbsData = this.extractNurbsFromEdge(spine);
|
|
1441
1481
|
if (!nurbsData) {
|
|
1442
1482
|
throw new Error("brepkit: sweep spine must be an edge or wire");
|
|
@@ -1497,25 +1537,58 @@ class BrepkitAdapter {
|
|
|
1497
1537
|
return solidHandle(this.bk.filletVariable(solidId, JSON.stringify(spec)));
|
|
1498
1538
|
}
|
|
1499
1539
|
chamfer(shape2, edges, distance) {
|
|
1500
|
-
const
|
|
1501
|
-
if (typeof distance !== "number") {
|
|
1502
|
-
warnOnce(
|
|
1503
|
-
"chamfer-asymmetric",
|
|
1504
|
-
typeof distance === "function" ? "Per-edge chamfer distance function not supported; falling back to distance=1." : "Asymmetric chamfer not supported; using first distance only."
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1540
|
+
const solidId = unwrapSolidOrThrow(shape2, "chamfer");
|
|
1507
1541
|
const edgeIds = edges.map((e8) => unwrap(e8, "edge"));
|
|
1508
|
-
|
|
1509
|
-
|
|
1542
|
+
if (typeof distance === "number") {
|
|
1543
|
+
return solidHandle(this.bk.chamfer(solidId, edgeIds, distance));
|
|
1544
|
+
}
|
|
1545
|
+
if (Array.isArray(distance)) {
|
|
1546
|
+
const [d1, d22] = distance;
|
|
1547
|
+
if (typeof this.bk.chamferAsymmetric === "function") {
|
|
1548
|
+
return solidHandle(this.bk.chamferAsymmetric(solidId, edgeIds, d1, d22));
|
|
1549
|
+
}
|
|
1550
|
+
warnOnce("chamfer-asymmetric", "chamferAsymmetric not available; using averaged distance.");
|
|
1551
|
+
return solidHandle(this.bk.chamfer(solidId, edgeIds, (d1 + d22) / 2));
|
|
1552
|
+
}
|
|
1553
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1554
|
+
for (const [i9, edge] of edges.entries()) {
|
|
1555
|
+
const r9 = distance(edge);
|
|
1556
|
+
const eid = edgeIds[i9];
|
|
1557
|
+
if (eid === void 0) continue;
|
|
1558
|
+
const [d1, d22] = Array.isArray(r9) ? r9 : [r9, r9];
|
|
1559
|
+
const key = `${d1},${d22}`;
|
|
1560
|
+
const group = groups.get(key);
|
|
1561
|
+
if (group) {
|
|
1562
|
+
group.ids.push(eid);
|
|
1563
|
+
} else {
|
|
1564
|
+
groups.set(key, { ids: [eid], d1, d2: d22 });
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
let result = solidId;
|
|
1568
|
+
for (const group of groups.values()) {
|
|
1569
|
+
if (group.d1 === group.d2) {
|
|
1570
|
+
result = this.bk.chamfer(result, group.ids, group.d1);
|
|
1571
|
+
} else if (typeof this.bk.chamferAsymmetric === "function") {
|
|
1572
|
+
result = this.bk.chamferAsymmetric(result, group.ids, group.d1, group.d2);
|
|
1573
|
+
} else {
|
|
1574
|
+
warnOnce(
|
|
1575
|
+
"chamfer-callback",
|
|
1576
|
+
"chamferAsymmetric not available; asymmetric edges use averaged distance."
|
|
1577
|
+
);
|
|
1578
|
+
result = this.bk.chamfer(result, group.ids, (group.d1 + group.d2) / 2);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
return solidHandle(result);
|
|
1510
1582
|
}
|
|
1511
1583
|
chamferDistAngle(shape2, edges, distance, angleDeg) {
|
|
1512
|
-
warnOnce(
|
|
1513
|
-
"chamfer-dist-angle",
|
|
1514
|
-
"Distance-angle chamfer approximated as averaged two-distance chamfer."
|
|
1515
|
-
);
|
|
1516
1584
|
const d22 = distance * Math.tan(angleDeg * Math.PI / 180);
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1585
|
+
const solidId = unwrapSolidOrThrow(shape2, "chamferDistAngle");
|
|
1586
|
+
const edgeIds = edges.map((e8) => unwrap(e8, "edge"));
|
|
1587
|
+
if (typeof this.bk.chamferAsymmetric === "function") {
|
|
1588
|
+
return solidHandle(this.bk.chamferAsymmetric(solidId, edgeIds, distance, d22));
|
|
1589
|
+
}
|
|
1590
|
+
warnOnce("chamfer-dist-angle", "chamferAsymmetric not available; using averaged distance.");
|
|
1591
|
+
return solidHandle(this.bk.chamfer(solidId, edgeIds, (distance + d22) / 2));
|
|
1519
1592
|
}
|
|
1520
1593
|
shell(shape2, faces, thickness, tolerance) {
|
|
1521
1594
|
if (tolerance !== void 0) {
|
|
@@ -1548,15 +1621,58 @@ class BrepkitAdapter {
|
|
|
1548
1621
|
if (bestMatch >= 0 && bestDot > 0.99) return bestMatch;
|
|
1549
1622
|
} catch {
|
|
1550
1623
|
}
|
|
1624
|
+
try {
|
|
1625
|
+
const origVerts = toArray(this.bk.getFaceVertices(fid));
|
|
1626
|
+
if (origVerts.length >= 1) {
|
|
1627
|
+
let ox = 0, oy = 0, oz = 0;
|
|
1628
|
+
for (const vid of origVerts) {
|
|
1629
|
+
const pos = this.bk.getVertexPosition(vid);
|
|
1630
|
+
ox += pos[0];
|
|
1631
|
+
oy += pos[1];
|
|
1632
|
+
oz += pos[2];
|
|
1633
|
+
}
|
|
1634
|
+
const n8 = origVerts.length;
|
|
1635
|
+
ox /= n8;
|
|
1636
|
+
oy /= n8;
|
|
1637
|
+
oz /= n8;
|
|
1638
|
+
let bestCentroidMatch = -1;
|
|
1639
|
+
let bestCentroidDist = Infinity;
|
|
1640
|
+
for (const sf of solidFaces) {
|
|
1641
|
+
try {
|
|
1642
|
+
const sv = toArray(this.bk.getFaceVertices(sf));
|
|
1643
|
+
if (sv.length < 1) continue;
|
|
1644
|
+
let sx = 0, sy = 0, sz = 0;
|
|
1645
|
+
for (const svid of sv) {
|
|
1646
|
+
const spos = this.bk.getVertexPosition(svid);
|
|
1647
|
+
sx += spos[0];
|
|
1648
|
+
sy += spos[1];
|
|
1649
|
+
sz += spos[2];
|
|
1650
|
+
}
|
|
1651
|
+
const sn = sv.length;
|
|
1652
|
+
sx /= sn;
|
|
1653
|
+
sy /= sn;
|
|
1654
|
+
sz /= sn;
|
|
1655
|
+
const dist = Math.sqrt((ox - sx) ** 2 + (oy - sy) ** 2 + (oz - sz) ** 2);
|
|
1656
|
+
if (dist < bestCentroidDist) {
|
|
1657
|
+
bestCentroidDist = dist;
|
|
1658
|
+
bestCentroidMatch = sf;
|
|
1659
|
+
}
|
|
1660
|
+
} catch {
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
if (bestCentroidMatch >= 0 && bestCentroidDist < 1e-3) return bestCentroidMatch;
|
|
1664
|
+
}
|
|
1665
|
+
} catch {
|
|
1666
|
+
}
|
|
1551
1667
|
return fid;
|
|
1552
1668
|
});
|
|
1553
1669
|
const id = this.bk.shell(solidId, thickness, resolvedFaceIds);
|
|
1554
1670
|
return solidHandle(id);
|
|
1555
1671
|
}
|
|
1556
1672
|
thicken(shape2, thickness) {
|
|
1557
|
-
const
|
|
1558
|
-
if (
|
|
1559
|
-
const id = this.bk.thicken(
|
|
1673
|
+
const h7 = shape2;
|
|
1674
|
+
if (h7.type === "face") {
|
|
1675
|
+
const id = this.bk.thicken(h7.id, thickness);
|
|
1560
1676
|
return solidHandle(id);
|
|
1561
1677
|
}
|
|
1562
1678
|
throw new Error("brepkit: thicken() requires a face");
|
|
@@ -1568,9 +1684,9 @@ class BrepkitAdapter {
|
|
|
1568
1684
|
"offset() tolerance parameter is not supported; brepkit uses its own internal tolerance."
|
|
1569
1685
|
);
|
|
1570
1686
|
}
|
|
1571
|
-
const
|
|
1572
|
-
if (
|
|
1573
|
-
const id2 = this.bk.thicken(
|
|
1687
|
+
const h7 = shape2;
|
|
1688
|
+
if (h7.type === "face") {
|
|
1689
|
+
const id2 = this.bk.thicken(h7.id, distance);
|
|
1574
1690
|
return solidHandle(id2);
|
|
1575
1691
|
}
|
|
1576
1692
|
const id = this.bk.offsetSolid(unwrapSolidOrThrow(shape2, "offset"), distance);
|
|
@@ -1585,17 +1701,17 @@ class BrepkitAdapter {
|
|
|
1585
1701
|
}
|
|
1586
1702
|
throw new Error("brepkit: transform expects a 16-element matrix array");
|
|
1587
1703
|
}
|
|
1588
|
-
translate(shape2,
|
|
1589
|
-
return this.applyMatrix(shape2, translationMatrix(
|
|
1704
|
+
translate(shape2, x6, y6, z6) {
|
|
1705
|
+
return this.applyMatrix(shape2, translationMatrix(x6, y6, z6));
|
|
1590
1706
|
}
|
|
1591
1707
|
rotate(shape2, angle, axis, center) {
|
|
1592
1708
|
return this.applyMatrix(shape2, rotationMatrix(angle, axis, center));
|
|
1593
1709
|
}
|
|
1594
1710
|
mirror(shape2, origin, normal) {
|
|
1595
|
-
const
|
|
1596
|
-
if (
|
|
1711
|
+
const h7 = shape2;
|
|
1712
|
+
if (h7.type === "solid") {
|
|
1597
1713
|
const id = this.bk.mirror(
|
|
1598
|
-
|
|
1714
|
+
h7.id,
|
|
1599
1715
|
origin[0],
|
|
1600
1716
|
origin[1],
|
|
1601
1717
|
origin[2],
|
|
@@ -1665,12 +1781,12 @@ class BrepkitAdapter {
|
|
|
1665
1781
|
* fallback when hash matching fails (brepkit always creates new face IDs).
|
|
1666
1782
|
*/
|
|
1667
1783
|
buildEvolution(resultShape, inputFaceHashes, hashUpperBound, isTransform, originalShape) {
|
|
1668
|
-
const
|
|
1784
|
+
const h7 = resultShape;
|
|
1669
1785
|
const modified = /* @__PURE__ */ new Map();
|
|
1670
1786
|
const generated = /* @__PURE__ */ new Map();
|
|
1671
1787
|
const deleted = /* @__PURE__ */ new Set();
|
|
1672
|
-
if (
|
|
1673
|
-
const outputFaces = toArray(this.bk.getSolidFaces(
|
|
1788
|
+
if (h7.type === "solid") {
|
|
1789
|
+
const outputFaces = toArray(this.bk.getSolidFaces(h7.id));
|
|
1674
1790
|
const outputHashes = outputFaces.map((fid) => fid % hashUpperBound);
|
|
1675
1791
|
if (isTransform) {
|
|
1676
1792
|
for (let i9 = 0; i9 < inputFaceHashes.length && i9 < outputHashes.length; i9++) {
|
|
@@ -1753,10 +1869,10 @@ class BrepkitAdapter {
|
|
|
1753
1869
|
}
|
|
1754
1870
|
}
|
|
1755
1871
|
/** Squared Euclidean distance between two 3-component centroids. */
|
|
1756
|
-
static centroidDistSq(a9,
|
|
1757
|
-
const dx = a9[0] -
|
|
1758
|
-
const dy = a9[1] -
|
|
1759
|
-
const dz = a9[2] -
|
|
1872
|
+
static centroidDistSq(a9, b7) {
|
|
1873
|
+
const dx = a9[0] - b7[0];
|
|
1874
|
+
const dy = a9[1] - b7[1];
|
|
1875
|
+
const dz = a9[2] - b7[2];
|
|
1760
1876
|
return dx * dx + dy * dy + dz * dz;
|
|
1761
1877
|
}
|
|
1762
1878
|
/** Compute face centroid as the average of tessellation vertices. */
|
|
@@ -1863,9 +1979,9 @@ class BrepkitAdapter {
|
|
|
1863
1979
|
}
|
|
1864
1980
|
}
|
|
1865
1981
|
}
|
|
1866
|
-
translateWithHistory(shape2,
|
|
1982
|
+
translateWithHistory(shape2, x6, y6, z6, inputFaceHashes, hashUpperBound) {
|
|
1867
1983
|
return this.buildEvolution(
|
|
1868
|
-
this.translate(shape2,
|
|
1984
|
+
this.translate(shape2, x6, y6, z6),
|
|
1869
1985
|
inputFaceHashes,
|
|
1870
1986
|
hashUpperBound,
|
|
1871
1987
|
true
|
|
@@ -1939,15 +2055,15 @@ class BrepkitAdapter {
|
|
|
1939
2055
|
result.evolution.deleted,
|
|
1940
2056
|
intermediateOutputs
|
|
1941
2057
|
);
|
|
1942
|
-
for (const [
|
|
1943
|
-
if (!combinedModified.has(
|
|
1944
|
-
combinedModified.set(
|
|
2058
|
+
for (const [k9, v6] of result.evolution.modified) {
|
|
2059
|
+
if (!combinedModified.has(k9) && !intermediateOutputs.has(k9)) {
|
|
2060
|
+
combinedModified.set(k9, [...v6]);
|
|
1945
2061
|
}
|
|
1946
2062
|
}
|
|
1947
|
-
for (const [
|
|
1948
|
-
if (!intermediateOutputs.has(
|
|
1949
|
-
const existing = combinedGenerated.get(
|
|
1950
|
-
combinedGenerated.set(
|
|
2063
|
+
for (const [k9, v6] of result.evolution.generated) {
|
|
2064
|
+
if (!intermediateOutputs.has(k9)) {
|
|
2065
|
+
const existing = combinedGenerated.get(k9) ?? [];
|
|
2066
|
+
combinedGenerated.set(k9, [...existing, ...v6]);
|
|
1951
2067
|
}
|
|
1952
2068
|
}
|
|
1953
2069
|
for (const d11 of result.evolution.deleted) {
|
|
@@ -1976,8 +2092,8 @@ class BrepkitAdapter {
|
|
|
1976
2092
|
inputFaceHashes,
|
|
1977
2093
|
hashUpperBound,
|
|
1978
2094
|
options,
|
|
1979
|
-
(a9,
|
|
1980
|
-
(
|
|
2095
|
+
(a9, b7) => this.bk.fuseWithEvolution(a9, b7),
|
|
2096
|
+
(s5, t7, o8) => this.fuse(s5, t7, o8),
|
|
1981
2097
|
"fuseWithHistory"
|
|
1982
2098
|
);
|
|
1983
2099
|
}
|
|
@@ -1988,8 +2104,8 @@ class BrepkitAdapter {
|
|
|
1988
2104
|
inputFaceHashes,
|
|
1989
2105
|
hashUpperBound,
|
|
1990
2106
|
options,
|
|
1991
|
-
(a9,
|
|
1992
|
-
(
|
|
2107
|
+
(a9, b7) => this.bk.cutWithEvolution(a9, b7),
|
|
2108
|
+
(s5, t7, o8) => this.cut(s5, t7, o8),
|
|
1993
2109
|
"cutWithHistory"
|
|
1994
2110
|
);
|
|
1995
2111
|
}
|
|
@@ -2000,8 +2116,8 @@ class BrepkitAdapter {
|
|
|
2000
2116
|
inputFaceHashes,
|
|
2001
2117
|
hashUpperBound,
|
|
2002
2118
|
options,
|
|
2003
|
-
(a9,
|
|
2004
|
-
(
|
|
2119
|
+
(a9, b7) => this.bk.intersectWithEvolution(a9, b7),
|
|
2120
|
+
(s5, t7, o8) => this.intersect(s5, t7, o8),
|
|
2005
2121
|
"intersectWithHistory"
|
|
2006
2122
|
);
|
|
2007
2123
|
}
|
|
@@ -2060,14 +2176,14 @@ class BrepkitAdapter {
|
|
|
2060
2176
|
"mesh angularTolerance is not supported; only linear deflection is used."
|
|
2061
2177
|
);
|
|
2062
2178
|
}
|
|
2063
|
-
const
|
|
2179
|
+
const h7 = unwrap(shape2);
|
|
2064
2180
|
const bkHandle = shape2;
|
|
2065
2181
|
const deflection = options.tolerance || DEFAULT_DEFLECTION;
|
|
2066
2182
|
let result;
|
|
2067
2183
|
if (bkHandle.type === "solid") {
|
|
2068
|
-
result = this.meshSolid(
|
|
2184
|
+
result = this.meshSolid(h7, deflection, !!options.includeUVs);
|
|
2069
2185
|
} else if (bkHandle.type === "face") {
|
|
2070
|
-
result = this.meshSingleFace(
|
|
2186
|
+
result = this.meshSingleFace(h7, deflection, 0);
|
|
2071
2187
|
} else {
|
|
2072
2188
|
throw new Error(`brepkit: cannot mesh shape of type '${bkHandle.type}'`);
|
|
2073
2189
|
}
|
|
@@ -2157,36 +2273,36 @@ class BrepkitAdapter {
|
|
|
2157
2273
|
}
|
|
2158
2274
|
exportSTEPAssembly(parts, _options) {
|
|
2159
2275
|
if (parts.length === 0) return "";
|
|
2160
|
-
const shapes = parts.map((
|
|
2276
|
+
const shapes = parts.map((p7) => p7.shape);
|
|
2161
2277
|
return this.exportSTEP(shapes);
|
|
2162
2278
|
}
|
|
2163
2279
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2164
2280
|
// Measurement
|
|
2165
2281
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2166
2282
|
volume(shape2) {
|
|
2167
|
-
const
|
|
2168
|
-
if (
|
|
2283
|
+
const h7 = shape2;
|
|
2284
|
+
if (h7.type === "solid") {
|
|
2169
2285
|
return this.bk.volume(unwrap(shape2), DEFAULT_DEFLECTION);
|
|
2170
2286
|
}
|
|
2171
|
-
if (
|
|
2287
|
+
if (h7.type === "compound") {
|
|
2172
2288
|
const solids = this.iterShapes(shape2, "solid");
|
|
2173
2289
|
let total = 0;
|
|
2174
|
-
for (const
|
|
2175
|
-
total += this.bk.volume(unwrap(
|
|
2290
|
+
for (const s5 of solids) {
|
|
2291
|
+
total += this.bk.volume(unwrap(s5), DEFAULT_DEFLECTION);
|
|
2176
2292
|
}
|
|
2177
2293
|
return total;
|
|
2178
2294
|
}
|
|
2179
2295
|
return 0;
|
|
2180
2296
|
}
|
|
2181
2297
|
area(shape2) {
|
|
2182
|
-
const
|
|
2183
|
-
if (
|
|
2298
|
+
const h7 = shape2;
|
|
2299
|
+
if (h7.type === "face") {
|
|
2184
2300
|
return this.bk.faceArea(unwrap(shape2), DEFAULT_DEFLECTION);
|
|
2185
2301
|
}
|
|
2186
|
-
if (
|
|
2302
|
+
if (h7.type === "solid") {
|
|
2187
2303
|
return this.bk.surfaceArea(unwrap(shape2), DEFAULT_DEFLECTION);
|
|
2188
2304
|
}
|
|
2189
|
-
if (
|
|
2305
|
+
if (h7.type === "compound") {
|
|
2190
2306
|
const faces = this.iterShapes(shape2, "face");
|
|
2191
2307
|
let total = 0;
|
|
2192
2308
|
for (const face of faces) {
|
|
@@ -2197,58 +2313,58 @@ class BrepkitAdapter {
|
|
|
2197
2313
|
return 0;
|
|
2198
2314
|
}
|
|
2199
2315
|
length(shape2) {
|
|
2200
|
-
const
|
|
2201
|
-
if (
|
|
2316
|
+
const h7 = shape2;
|
|
2317
|
+
if (h7.type === "edge") {
|
|
2202
2318
|
return this.bk.edgeLength(unwrap(shape2));
|
|
2203
2319
|
}
|
|
2204
|
-
if (
|
|
2320
|
+
if (h7.type === "face") {
|
|
2205
2321
|
return this.bk.facePerimeter(unwrap(shape2));
|
|
2206
2322
|
}
|
|
2207
|
-
if (
|
|
2208
|
-
return this.bk.wireLength(
|
|
2323
|
+
if (h7.type === "wire") {
|
|
2324
|
+
return this.bk.wireLength(h7.id);
|
|
2209
2325
|
}
|
|
2210
2326
|
throw new Error("brepkit: length() requires an edge, wire, or face");
|
|
2211
2327
|
}
|
|
2212
2328
|
centerOfMass(shape2) {
|
|
2213
|
-
const
|
|
2214
|
-
if (
|
|
2329
|
+
const h7 = shape2;
|
|
2330
|
+
if (h7.type === "solid") {
|
|
2215
2331
|
const result = this.bk.centerOfMass(unwrap(shape2), DEFAULT_DEFLECTION);
|
|
2216
2332
|
return [result[0], result[1], result[2]];
|
|
2217
2333
|
}
|
|
2218
|
-
if (
|
|
2334
|
+
if (h7.type === "face") {
|
|
2219
2335
|
const domain = this.uvBounds(shape2);
|
|
2220
2336
|
const uMid = (domain.uMin + domain.uMax) / 2;
|
|
2221
2337
|
const vMid = (domain.vMin + domain.vMax) / 2;
|
|
2222
2338
|
return this.pointOnSurface(shape2, uMid, vMid);
|
|
2223
2339
|
}
|
|
2224
|
-
if (
|
|
2225
|
-
const verts = this.bk.getEdgeVertices(
|
|
2340
|
+
if (h7.type === "edge") {
|
|
2341
|
+
const verts = this.bk.getEdgeVertices(h7.id);
|
|
2226
2342
|
return [
|
|
2227
2343
|
(verts[0] + verts[3]) / 2,
|
|
2228
2344
|
(verts[1] + verts[4]) / 2,
|
|
2229
2345
|
(verts[2] + verts[5]) / 2
|
|
2230
2346
|
];
|
|
2231
2347
|
}
|
|
2232
|
-
if (
|
|
2348
|
+
if (h7.type === "vertex") {
|
|
2233
2349
|
return this.vertexPosition(shape2);
|
|
2234
2350
|
}
|
|
2235
2351
|
const vertices = this.iterShapes(shape2, "vertex");
|
|
2236
2352
|
if (vertices.length > 0) {
|
|
2237
2353
|
let sx = 0, sy = 0, sz = 0;
|
|
2238
|
-
for (const
|
|
2239
|
-
const
|
|
2240
|
-
sx +=
|
|
2241
|
-
sy +=
|
|
2242
|
-
sz +=
|
|
2354
|
+
for (const v6 of vertices) {
|
|
2355
|
+
const p7 = this.vertexPosition(v6);
|
|
2356
|
+
sx += p7[0];
|
|
2357
|
+
sy += p7[1];
|
|
2358
|
+
sz += p7[2];
|
|
2243
2359
|
}
|
|
2244
2360
|
return [sx / vertices.length, sy / vertices.length, sz / vertices.length];
|
|
2245
2361
|
}
|
|
2246
2362
|
return [0, 0, 0];
|
|
2247
2363
|
}
|
|
2248
2364
|
linearCenterOfMass(shape2) {
|
|
2249
|
-
const
|
|
2250
|
-
if (
|
|
2251
|
-
const verts = this.bk.getEdgeVertices(
|
|
2365
|
+
const h7 = shape2;
|
|
2366
|
+
if (h7.type === "edge") {
|
|
2367
|
+
const verts = this.bk.getEdgeVertices(h7.id);
|
|
2252
2368
|
return [
|
|
2253
2369
|
(verts[0] + verts[3]) / 2,
|
|
2254
2370
|
(verts[1] + verts[4]) / 2,
|
|
@@ -2258,15 +2374,15 @@ class BrepkitAdapter {
|
|
|
2258
2374
|
return this.centerOfMass(shape2);
|
|
2259
2375
|
}
|
|
2260
2376
|
boundingBox(shape2) {
|
|
2261
|
-
const
|
|
2262
|
-
if (
|
|
2377
|
+
const h7 = shape2;
|
|
2378
|
+
if (h7.type === "solid") {
|
|
2263
2379
|
const bb = this.bk.boundingBox(unwrap(shape2));
|
|
2264
2380
|
return {
|
|
2265
2381
|
min: [bb[0], bb[1], bb[2]],
|
|
2266
2382
|
max: [bb[3], bb[4], bb[5]]
|
|
2267
2383
|
};
|
|
2268
2384
|
}
|
|
2269
|
-
if (
|
|
2385
|
+
if (h7.type === "vertex") {
|
|
2270
2386
|
const pos = this.vertexPosition(shape2);
|
|
2271
2387
|
return { min: [...pos], max: [...pos] };
|
|
2272
2388
|
}
|
|
@@ -2278,13 +2394,13 @@ class BrepkitAdapter {
|
|
|
2278
2394
|
let minX = first[0], minY = first[1], minZ = first[2];
|
|
2279
2395
|
let maxX = first[0], maxY = first[1], maxZ = first[2];
|
|
2280
2396
|
for (let i9 = 1; i9 < vertices.length; i9++) {
|
|
2281
|
-
const
|
|
2282
|
-
if (
|
|
2283
|
-
if (
|
|
2284
|
-
if (
|
|
2285
|
-
if (
|
|
2286
|
-
if (
|
|
2287
|
-
if (
|
|
2397
|
+
const p7 = this.vertexPosition(vertices[i9]);
|
|
2398
|
+
if (p7[0] < minX) minX = p7[0];
|
|
2399
|
+
if (p7[0] > maxX) maxX = p7[0];
|
|
2400
|
+
if (p7[1] < minY) minY = p7[1];
|
|
2401
|
+
if (p7[1] > maxY) maxY = p7[1];
|
|
2402
|
+
if (p7[2] < minZ) minZ = p7[2];
|
|
2403
|
+
if (p7[2] > maxZ) maxZ = p7[2];
|
|
2288
2404
|
}
|
|
2289
2405
|
return { min: [minX, minY, minZ], max: [maxX, maxY, maxZ] };
|
|
2290
2406
|
}
|
|
@@ -2292,11 +2408,11 @@ class BrepkitAdapter {
|
|
|
2292
2408
|
// Topology introspection
|
|
2293
2409
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2294
2410
|
iterShapes(shape2, type) {
|
|
2295
|
-
const
|
|
2411
|
+
const h7 = unwrap(shape2);
|
|
2296
2412
|
const bkHandle = shape2;
|
|
2297
2413
|
switch (bkHandle.type) {
|
|
2298
2414
|
case "compound": {
|
|
2299
|
-
const children = syntheticCompounds.get(
|
|
2415
|
+
const children = syntheticCompounds.get(h7);
|
|
2300
2416
|
if (children) {
|
|
2301
2417
|
const results = [];
|
|
2302
2418
|
for (const child of children) {
|
|
@@ -2309,24 +2425,24 @@ class BrepkitAdapter {
|
|
|
2309
2425
|
return results;
|
|
2310
2426
|
}
|
|
2311
2427
|
if (type === "solid") {
|
|
2312
|
-
return toArray(this.bk.getCompoundSolids(
|
|
2428
|
+
return toArray(this.bk.getCompoundSolids(h7)).map(solidHandle);
|
|
2313
2429
|
}
|
|
2314
2430
|
if (type === "face" || type === "edge" || type === "vertex" || type === "wire") {
|
|
2315
|
-
const solids = toArray(this.bk.getCompoundSolids(
|
|
2316
|
-
return solids.flatMap((
|
|
2431
|
+
const solids = toArray(this.bk.getCompoundSolids(h7)).map(solidHandle);
|
|
2432
|
+
return solids.flatMap((s5) => this.iterShapes(s5, type));
|
|
2317
2433
|
}
|
|
2318
2434
|
return [];
|
|
2319
2435
|
}
|
|
2320
2436
|
case "solid": {
|
|
2321
2437
|
switch (type) {
|
|
2322
2438
|
case "face":
|
|
2323
|
-
return toArray(this.bk.getSolidFaces(
|
|
2439
|
+
return toArray(this.bk.getSolidFaces(h7)).map(faceHandle);
|
|
2324
2440
|
case "edge":
|
|
2325
|
-
return toArray(this.bk.getSolidEdges(
|
|
2441
|
+
return toArray(this.bk.getSolidEdges(h7)).map(edgeHandle);
|
|
2326
2442
|
case "vertex":
|
|
2327
|
-
return toArray(this.bk.getSolidVertices(
|
|
2443
|
+
return toArray(this.bk.getSolidVertices(h7)).map(vertexHandle);
|
|
2328
2444
|
case "wire":
|
|
2329
|
-
return toArray(this.bk.getSolidFaces(
|
|
2445
|
+
return toArray(this.bk.getSolidFaces(h7)).flatMap(
|
|
2330
2446
|
(faceId) => toArray(this.bk.getFaceWires(faceId)).map(wireHandle)
|
|
2331
2447
|
);
|
|
2332
2448
|
default:
|
|
@@ -2335,10 +2451,10 @@ class BrepkitAdapter {
|
|
|
2335
2451
|
}
|
|
2336
2452
|
case "shell": {
|
|
2337
2453
|
if (type === "face") {
|
|
2338
|
-
return toArray(this.bk.getShellFaces(
|
|
2454
|
+
return toArray(this.bk.getShellFaces(h7)).map(faceHandle);
|
|
2339
2455
|
}
|
|
2340
2456
|
if (type === "edge" || type === "vertex") {
|
|
2341
|
-
const faces = toArray(this.bk.getShellFaces(
|
|
2457
|
+
const faces = toArray(this.bk.getShellFaces(h7)).map(faceHandle);
|
|
2342
2458
|
const seen = /* @__PURE__ */ new Set();
|
|
2343
2459
|
const results = [];
|
|
2344
2460
|
for (const face of faces) {
|
|
@@ -2359,13 +2475,13 @@ class BrepkitAdapter {
|
|
|
2359
2475
|
return [shape2];
|
|
2360
2476
|
}
|
|
2361
2477
|
if (type === "edge") {
|
|
2362
|
-
return toArray(this.bk.getFaceEdges(
|
|
2478
|
+
return toArray(this.bk.getFaceEdges(h7)).map(edgeHandle);
|
|
2363
2479
|
}
|
|
2364
2480
|
if (type === "vertex") {
|
|
2365
|
-
return toArray(this.bk.getFaceVertices(
|
|
2481
|
+
return toArray(this.bk.getFaceVertices(h7)).map(vertexHandle);
|
|
2366
2482
|
}
|
|
2367
2483
|
if (type === "wire") {
|
|
2368
|
-
return toArray(this.bk.getFaceWires(
|
|
2484
|
+
return toArray(this.bk.getFaceWires(h7)).map(wireHandle);
|
|
2369
2485
|
}
|
|
2370
2486
|
return [];
|
|
2371
2487
|
}
|
|
@@ -2374,10 +2490,10 @@ class BrepkitAdapter {
|
|
|
2374
2490
|
return [shape2];
|
|
2375
2491
|
}
|
|
2376
2492
|
if (type === "edge") {
|
|
2377
|
-
return toArray(this.bk.getWireEdges(
|
|
2493
|
+
return toArray(this.bk.getWireEdges(h7)).map(edgeHandle);
|
|
2378
2494
|
}
|
|
2379
2495
|
if (type === "vertex") {
|
|
2380
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2496
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7));
|
|
2381
2497
|
const seen = /* @__PURE__ */ new Set();
|
|
2382
2498
|
const results = [];
|
|
2383
2499
|
for (const eid of edgeIds) {
|
|
@@ -2386,11 +2502,11 @@ class BrepkitAdapter {
|
|
|
2386
2502
|
[verts[0], verts[1], verts[2]],
|
|
2387
2503
|
[verts[3], verts[4], verts[5]]
|
|
2388
2504
|
];
|
|
2389
|
-
for (const [
|
|
2390
|
-
const key = `${
|
|
2505
|
+
for (const [x6, y6, z6] of coords) {
|
|
2506
|
+
const key = `${x6},${y6},${z6}`;
|
|
2391
2507
|
if (!seen.has(key)) {
|
|
2392
2508
|
seen.add(key);
|
|
2393
|
-
results.push(vertexHandle(this.bk.makeVertex(
|
|
2509
|
+
results.push(vertexHandle(this.bk.makeVertex(x6, y6, z6)));
|
|
2394
2510
|
}
|
|
2395
2511
|
}
|
|
2396
2512
|
}
|
|
@@ -2403,7 +2519,7 @@ class BrepkitAdapter {
|
|
|
2403
2519
|
return [shape2];
|
|
2404
2520
|
}
|
|
2405
2521
|
if (type === "vertex") {
|
|
2406
|
-
const verts = this.bk.getEdgeVertices(
|
|
2522
|
+
const verts = this.bk.getEdgeVertices(h7);
|
|
2407
2523
|
const v1 = this.bk.makeVertex(verts[0], verts[1], verts[2]);
|
|
2408
2524
|
const v22 = this.bk.makeVertex(verts[3], verts[4], verts[5]);
|
|
2409
2525
|
return [vertexHandle(v1), vertexHandle(v22)];
|
|
@@ -2423,11 +2539,11 @@ class BrepkitAdapter {
|
|
|
2423
2539
|
if (isBrepkitHandle(shape2)) return shape2.type;
|
|
2424
2540
|
throw new Error("brepkit: cannot determine shape type of non-brepkit handle");
|
|
2425
2541
|
}
|
|
2426
|
-
isSame(a9,
|
|
2427
|
-
return isBrepkitHandle(a9) && isBrepkitHandle(
|
|
2542
|
+
isSame(a9, b7) {
|
|
2543
|
+
return isBrepkitHandle(a9) && isBrepkitHandle(b7) && a9.id === b7.id && a9.type === b7.type;
|
|
2428
2544
|
}
|
|
2429
|
-
isEqual(a9,
|
|
2430
|
-
return this.isSame(a9,
|
|
2545
|
+
isEqual(a9, b7) {
|
|
2546
|
+
return this.isSame(a9, b7);
|
|
2431
2547
|
}
|
|
2432
2548
|
downcast(shape2, _type) {
|
|
2433
2549
|
return shape2;
|
|
@@ -2440,8 +2556,8 @@ class BrepkitAdapter {
|
|
|
2440
2556
|
return !shape2 || !isBrepkitHandle(shape2);
|
|
2441
2557
|
}
|
|
2442
2558
|
shapeOrientation(shape2) {
|
|
2443
|
-
const
|
|
2444
|
-
const orient = this.bk.getShapeOrientation(
|
|
2559
|
+
const h7 = unwrap(shape2);
|
|
2560
|
+
const orient = this.bk.getShapeOrientation(h7);
|
|
2445
2561
|
return orient;
|
|
2446
2562
|
}
|
|
2447
2563
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -2466,13 +2582,13 @@ class BrepkitAdapter {
|
|
|
2466
2582
|
const id = this.bk.getFaceOuterWire(unwrap(face, "face"));
|
|
2467
2583
|
return wireHandle(id);
|
|
2468
2584
|
}
|
|
2469
|
-
surfaceNormal(face,
|
|
2470
|
-
const
|
|
2471
|
-
return [
|
|
2585
|
+
surfaceNormal(face, u5, v6) {
|
|
2586
|
+
const n8 = this.bk.evaluateSurfaceNormal(unwrap(face, "face"), u5, v6);
|
|
2587
|
+
return [n8[0], n8[1], n8[2]];
|
|
2472
2588
|
}
|
|
2473
|
-
pointOnSurface(face,
|
|
2474
|
-
const
|
|
2475
|
-
return [
|
|
2589
|
+
pointOnSurface(face, u5, v6) {
|
|
2590
|
+
const p7 = this.bk.evaluateSurface(unwrap(face, "face"), u5, v6);
|
|
2591
|
+
return [p7[0], p7[1], p7[2]];
|
|
2476
2592
|
}
|
|
2477
2593
|
uvFromPoint(face, point) {
|
|
2478
2594
|
try {
|
|
@@ -2501,19 +2617,19 @@ class BrepkitAdapter {
|
|
|
2501
2617
|
// Geometry queries: edge / curve
|
|
2502
2618
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2503
2619
|
curveTangent(shape2, param) {
|
|
2504
|
-
const
|
|
2620
|
+
const h7 = shape2;
|
|
2505
2621
|
let edgeId;
|
|
2506
2622
|
let evalParam = param;
|
|
2507
|
-
if (
|
|
2508
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2623
|
+
if (h7.type === "wire") {
|
|
2624
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7.id));
|
|
2509
2625
|
edgeId = edgeIds[edgeIds.length - 1];
|
|
2510
2626
|
let cumulative = 0;
|
|
2511
2627
|
for (const eid of edgeIds) {
|
|
2512
|
-
const
|
|
2513
|
-
const span =
|
|
2628
|
+
const p7 = this.bk.getEdgeCurveParameters(eid);
|
|
2629
|
+
const span = p7[1] - p7[0];
|
|
2514
2630
|
if (param <= cumulative + span || eid === edgeId) {
|
|
2515
2631
|
edgeId = eid;
|
|
2516
|
-
evalParam = Math.min(
|
|
2632
|
+
evalParam = Math.min(p7[0] + (param - cumulative), p7[1]);
|
|
2517
2633
|
break;
|
|
2518
2634
|
}
|
|
2519
2635
|
cumulative += span;
|
|
@@ -2528,14 +2644,14 @@ class BrepkitAdapter {
|
|
|
2528
2644
|
};
|
|
2529
2645
|
}
|
|
2530
2646
|
curveParameters(shape2) {
|
|
2531
|
-
const
|
|
2532
|
-
if (
|
|
2533
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2647
|
+
const h7 = shape2;
|
|
2648
|
+
if (h7.type === "wire") {
|
|
2649
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7.id));
|
|
2534
2650
|
if (edgeIds.length === 0) return [0, 0];
|
|
2535
2651
|
let total = 0;
|
|
2536
2652
|
for (const eid of edgeIds) {
|
|
2537
|
-
const
|
|
2538
|
-
total +=
|
|
2653
|
+
const p7 = this.bk.getEdgeCurveParameters(eid);
|
|
2654
|
+
total += p7[1] - p7[0];
|
|
2539
2655
|
}
|
|
2540
2656
|
return [0, total];
|
|
2541
2657
|
}
|
|
@@ -2544,9 +2660,9 @@ class BrepkitAdapter {
|
|
|
2544
2660
|
return [params[0], params[1]];
|
|
2545
2661
|
}
|
|
2546
2662
|
curvePointAtParam(shape2, param) {
|
|
2547
|
-
const
|
|
2548
|
-
if (
|
|
2549
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2663
|
+
const h7 = shape2;
|
|
2664
|
+
if (h7.type === "wire") {
|
|
2665
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7.id));
|
|
2550
2666
|
let cumulative = 0;
|
|
2551
2667
|
for (const eid of edgeIds) {
|
|
2552
2668
|
const p22 = this.bk.getEdgeCurveParameters(eid);
|
|
@@ -2562,13 +2678,13 @@ class BrepkitAdapter {
|
|
|
2562
2678
|
return [pt[0], pt[1], pt[2]];
|
|
2563
2679
|
}
|
|
2564
2680
|
const edgeId = unwrap(shape2, "edge");
|
|
2565
|
-
const
|
|
2566
|
-
return [
|
|
2681
|
+
const p7 = this.bk.evaluateEdgeCurve(edgeId, param);
|
|
2682
|
+
return [p7[0], p7[1], p7[2]];
|
|
2567
2683
|
}
|
|
2568
2684
|
curveIsClosed(shape2) {
|
|
2569
|
-
const
|
|
2570
|
-
if (
|
|
2571
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2685
|
+
const h7 = shape2;
|
|
2686
|
+
if (h7.type === "wire") {
|
|
2687
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7.id));
|
|
2572
2688
|
if (edgeIds.length === 0) return false;
|
|
2573
2689
|
if (edgeIds.length === 1) {
|
|
2574
2690
|
const verts2 = this.bk.getEdgeVertices(edgeIds[0]);
|
|
@@ -2583,7 +2699,7 @@ class BrepkitAdapter {
|
|
|
2583
2699
|
const unmatched = [];
|
|
2584
2700
|
for (const pt of endpoints) {
|
|
2585
2701
|
const matchIdx = unmatched.findIndex(
|
|
2586
|
-
(
|
|
2702
|
+
(u5) => dist3(u5[0], u5[1], u5[2], pt[0], pt[1], pt[2]) < 1e-7
|
|
2587
2703
|
);
|
|
2588
2704
|
if (matchIdx >= 0) {
|
|
2589
2705
|
unmatched.splice(matchIdx, 1);
|
|
@@ -2597,11 +2713,11 @@ class BrepkitAdapter {
|
|
|
2597
2713
|
return dist3(verts[0], verts[1], verts[2], verts[3], verts[4], verts[5]) < 1e-7;
|
|
2598
2714
|
}
|
|
2599
2715
|
curveIsPeriodic(shape2) {
|
|
2600
|
-
const
|
|
2716
|
+
const h7 = shape2;
|
|
2601
2717
|
try {
|
|
2602
|
-
if (
|
|
2603
|
-
if (
|
|
2604
|
-
const edgeIds = toArray(this.bk.getWireEdges(
|
|
2718
|
+
if (h7.type === "edge") return this.curveIsClosed(shape2);
|
|
2719
|
+
if (h7.type === "wire") {
|
|
2720
|
+
const edgeIds = toArray(this.bk.getWireEdges(h7.id));
|
|
2605
2721
|
if (edgeIds.length === 1) return this.curveIsClosed(shape2);
|
|
2606
2722
|
}
|
|
2607
2723
|
} catch {
|
|
@@ -2619,8 +2735,8 @@ class BrepkitAdapter {
|
|
|
2619
2735
|
return 0;
|
|
2620
2736
|
}
|
|
2621
2737
|
curveType(shape2) {
|
|
2622
|
-
const
|
|
2623
|
-
if (
|
|
2738
|
+
const h7 = shape2;
|
|
2739
|
+
if (h7.type === "wire") {
|
|
2624
2740
|
const edges = this.iterShapes(shape2, "edge");
|
|
2625
2741
|
const first = edges[0];
|
|
2626
2742
|
if (first) return this.bk.getEdgeCurveType(unwrap(first, "edge"));
|
|
@@ -2665,16 +2781,16 @@ class BrepkitAdapter {
|
|
|
2665
2781
|
}
|
|
2666
2782
|
sew(shapes, tolerance) {
|
|
2667
2783
|
const faceIds = [];
|
|
2668
|
-
for (const
|
|
2669
|
-
const
|
|
2670
|
-
if (
|
|
2671
|
-
faceIds.push(
|
|
2672
|
-
} else if (
|
|
2673
|
-
for (const fid of toArray(this.bk.getSolidFaces(
|
|
2784
|
+
for (const s5 of shapes) {
|
|
2785
|
+
const h7 = s5;
|
|
2786
|
+
if (h7.type === "face") {
|
|
2787
|
+
faceIds.push(h7.id);
|
|
2788
|
+
} else if (h7.type === "solid") {
|
|
2789
|
+
for (const fid of toArray(this.bk.getSolidFaces(h7.id))) {
|
|
2674
2790
|
faceIds.push(fid);
|
|
2675
2791
|
}
|
|
2676
|
-
} else if (
|
|
2677
|
-
for (const fid of toArray(this.bk.getShellFaces(
|
|
2792
|
+
} else if (h7.type === "shell") {
|
|
2793
|
+
for (const fid of toArray(this.bk.getShellFaces(h7.id))) {
|
|
2678
2794
|
faceIds.push(fid);
|
|
2679
2795
|
}
|
|
2680
2796
|
}
|
|
@@ -2690,10 +2806,10 @@ class BrepkitAdapter {
|
|
|
2690
2806
|
return shellHandle(id);
|
|
2691
2807
|
}
|
|
2692
2808
|
healSolid(shape2) {
|
|
2693
|
-
const
|
|
2694
|
-
if (
|
|
2809
|
+
const h7 = shape2;
|
|
2810
|
+
if (h7.type !== "solid") {
|
|
2695
2811
|
throw new Error(
|
|
2696
|
-
`brepkit: healSolid requires a solid, got ${
|
|
2812
|
+
`brepkit: healSolid requires a solid, got ${h7.type}. Consider using makeCompound() to combine shapes first.`
|
|
2697
2813
|
);
|
|
2698
2814
|
}
|
|
2699
2815
|
try {
|
|
@@ -2781,13 +2897,13 @@ class BrepkitAdapter {
|
|
|
2781
2897
|
point2: [result[1], result[2], result[3]]
|
|
2782
2898
|
};
|
|
2783
2899
|
}
|
|
2784
|
-
const getPos = (
|
|
2785
|
-
if (
|
|
2786
|
-
const
|
|
2787
|
-
return [
|
|
2900
|
+
const getPos = (s5) => {
|
|
2901
|
+
if (s5.type === "vertex") {
|
|
2902
|
+
const p7 = this.bk.getVertexPosition(s5.id);
|
|
2903
|
+
return [p7[0], p7[1], p7[2]];
|
|
2788
2904
|
}
|
|
2789
|
-
if (
|
|
2790
|
-
const bb = this.bk.boundingBox(
|
|
2905
|
+
if (s5.type === "solid") {
|
|
2906
|
+
const bb = this.bk.boundingBox(s5.id);
|
|
2791
2907
|
return [(bb[0] + bb[3]) / 2, (bb[1] + bb[4]) / 2, (bb[2] + bb[5]) / 2];
|
|
2792
2908
|
}
|
|
2793
2909
|
return [0, 0, 0];
|
|
@@ -2802,7 +2918,7 @@ class BrepkitAdapter {
|
|
|
2802
2918
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2803
2919
|
// Classification
|
|
2804
2920
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2805
|
-
classifyPointOnFace(face,
|
|
2921
|
+
classifyPointOnFace(face, u5, v6, tolerance) {
|
|
2806
2922
|
if (tolerance !== void 0) {
|
|
2807
2923
|
warnOnce(
|
|
2808
2924
|
"classify-tolerance",
|
|
@@ -2811,7 +2927,7 @@ class BrepkitAdapter {
|
|
|
2811
2927
|
}
|
|
2812
2928
|
const faceId = unwrap(face, "face");
|
|
2813
2929
|
const domain = this.bk.getSurfaceDomain(faceId);
|
|
2814
|
-
if (
|
|
2930
|
+
if (u5 < domain[0] || u5 > domain[1] || v6 < domain[2] || v6 > domain[3]) {
|
|
2815
2931
|
return "out";
|
|
2816
2932
|
}
|
|
2817
2933
|
return "in";
|
|
@@ -2831,7 +2947,7 @@ class BrepkitAdapter {
|
|
|
2831
2947
|
return this.makeLineEdge(points[0], points[1]);
|
|
2832
2948
|
}
|
|
2833
2949
|
const degree = Math.min(3, points.length - 1);
|
|
2834
|
-
const coords = points.flatMap(([
|
|
2950
|
+
const coords = points.flatMap(([x6, y6, z6]) => [x6, y6, z6]);
|
|
2835
2951
|
const id = this.bk.interpolatePoints(coords, degree);
|
|
2836
2952
|
return edgeHandle(id);
|
|
2837
2953
|
}
|
|
@@ -2839,7 +2955,7 @@ class BrepkitAdapter {
|
|
|
2839
2955
|
const degree = options?.degMax ?? 3;
|
|
2840
2956
|
const tol = options?.tolerance ?? 1e-6;
|
|
2841
2957
|
const coords = [];
|
|
2842
|
-
for (const
|
|
2958
|
+
for (const p7 of points) coords.push(p7[0], p7[1], p7[2]);
|
|
2843
2959
|
const numCps = Math.max(degree + 1, Math.min(points.length, Math.ceil(points.length * 0.7)));
|
|
2844
2960
|
const id = this.bk.approximateCurveLspia(coords, degree, numCps, tol, 100);
|
|
2845
2961
|
return edgeHandle(id);
|
|
@@ -2848,20 +2964,22 @@ class BrepkitAdapter {
|
|
|
2848
2964
|
// Serialization
|
|
2849
2965
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2850
2966
|
toBREP(shape2) {
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2967
|
+
const h7 = shape2;
|
|
2968
|
+
if (h7.type === "solid") {
|
|
2969
|
+
return this.bk.toBREP(h7.id);
|
|
2970
|
+
}
|
|
2971
|
+
warnOnce("brep-non-solid", "toBREP for non-solid shapes uses STEP format.");
|
|
2855
2972
|
return this.exportSTEP([shape2]);
|
|
2856
2973
|
}
|
|
2857
2974
|
fromBREP(data) {
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2975
|
+
if (typeof this.bk.fromBREP === "function" && data.trimStart().startsWith("{")) {
|
|
2976
|
+
const id = this.bk.fromBREP(data);
|
|
2977
|
+
return solidHandle(id);
|
|
2978
|
+
}
|
|
2862
2979
|
const shapes = this.importSTEP(data);
|
|
2863
|
-
|
|
2864
|
-
|
|
2980
|
+
const first = shapes[0];
|
|
2981
|
+
if (!first) throw new Error("brepkit: fromBREP produced no shapes");
|
|
2982
|
+
return first;
|
|
2865
2983
|
}
|
|
2866
2984
|
// ═══════════════════════════════════════════════════════════════════════
|
|
2867
2985
|
// Mesh preparation
|
|
@@ -2877,8 +2995,8 @@ class BrepkitAdapter {
|
|
|
2877
2995
|
composeTransform(ops) {
|
|
2878
2996
|
let matrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
2879
2997
|
for (const op of ops) {
|
|
2880
|
-
const
|
|
2881
|
-
matrix = multiplyMatrices(
|
|
2998
|
+
const m11 = op.type === "translate" ? translationMatrix(op.x, op.y, op.z) : rotationMatrix(op.angle, op.axis, op.center);
|
|
2999
|
+
matrix = multiplyMatrices(m11, matrix);
|
|
2882
3000
|
}
|
|
2883
3001
|
return { handle: matrix, dispose: () => {
|
|
2884
3002
|
} };
|
|
@@ -2894,6 +3012,49 @@ class BrepkitAdapter {
|
|
|
2894
3012
|
const profileHandle = profile;
|
|
2895
3013
|
const faceId = profileHandle.type === "wire" ? this.bk.makeFaceFromWire(profileHandle.id) : unwrap(profile, "face");
|
|
2896
3014
|
const shellMode = !!(options && options["shellMode"]);
|
|
3015
|
+
const transitionMode = options?.["transitionMode"];
|
|
3016
|
+
const contactMode = transitionMode ? mapStringTransition(transitionMode) : void 0;
|
|
3017
|
+
if (contactMode) {
|
|
3018
|
+
const spineHandle = spine;
|
|
3019
|
+
if (spineHandle.type !== "wire") {
|
|
3020
|
+
try {
|
|
3021
|
+
const edgeId = unwrap(spine, "edge");
|
|
3022
|
+
const shape22 = solidHandle(this.bk.sweepWithOptions(faceId, edgeId, contactMode, [], 0));
|
|
3023
|
+
if (shellMode) return { shape: shape22, firstShape: profile, lastShape: profile };
|
|
3024
|
+
return shape22;
|
|
3025
|
+
} catch (e8) {
|
|
3026
|
+
console.warn(
|
|
3027
|
+
"brepkit: sweepWithOptions failed, falling back to sweepSmooth/simplePipe:",
|
|
3028
|
+
e8
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
3031
|
+
} else {
|
|
3032
|
+
const edges = this.iterShapes(spine, "edge");
|
|
3033
|
+
if (edges.length === 1) {
|
|
3034
|
+
const first = edges[0];
|
|
3035
|
+
if (first) {
|
|
3036
|
+
try {
|
|
3037
|
+
const edgeId = unwrap(first, "edge");
|
|
3038
|
+
const shape22 = solidHandle(
|
|
3039
|
+
this.bk.sweepWithOptions(faceId, edgeId, contactMode, [], 0)
|
|
3040
|
+
);
|
|
3041
|
+
if (shellMode) return { shape: shape22, firstShape: profile, lastShape: profile };
|
|
3042
|
+
return shape22;
|
|
3043
|
+
} catch (e8) {
|
|
3044
|
+
console.warn(
|
|
3045
|
+
"brepkit: sweepWithOptions failed, falling back to sweepSmooth/simplePipe:",
|
|
3046
|
+
e8
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
} else {
|
|
3051
|
+
warnOnce(
|
|
3052
|
+
"sweepPipeShell-transition-multi-edge",
|
|
3053
|
+
"sweepPipeShell transition mode not supported for multi-edge wires; ignored."
|
|
3054
|
+
);
|
|
3055
|
+
}
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
2897
3058
|
const nurbsData = this.extractNurbsFromEdge(spine);
|
|
2898
3059
|
if (nurbsData && nurbsData.degree > 1) {
|
|
2899
3060
|
try {
|
|
@@ -2917,8 +3078,8 @@ class BrepkitAdapter {
|
|
|
2917
3078
|
}
|
|
2918
3079
|
loftAdvanced(wires, options) {
|
|
2919
3080
|
const faceIds = wires.map((w7) => {
|
|
2920
|
-
const
|
|
2921
|
-
if (
|
|
3081
|
+
const h7 = w7;
|
|
3082
|
+
if (h7.type === "wire") return this.bk.makeFaceFromWire(h7.id);
|
|
2922
3083
|
return unwrap(w7, "face");
|
|
2923
3084
|
});
|
|
2924
3085
|
try {
|
|
@@ -3035,8 +3196,8 @@ class BrepkitAdapter {
|
|
|
3035
3196
|
}
|
|
3036
3197
|
bsplineSurface(points, rows, cols) {
|
|
3037
3198
|
const coords = [];
|
|
3038
|
-
for (const [
|
|
3039
|
-
coords.push(
|
|
3199
|
+
for (const [x6, y6, z6] of points) {
|
|
3200
|
+
coords.push(x6, y6, z6);
|
|
3040
3201
|
}
|
|
3041
3202
|
const degreeU = Math.min(3, rows - 1);
|
|
3042
3203
|
const degreeV = Math.min(3, cols - 1);
|
|
@@ -3050,11 +3211,11 @@ class BrepkitAdapter {
|
|
|
3050
3211
|
triangulatedSurface(points, rows, cols) {
|
|
3051
3212
|
const faces = [];
|
|
3052
3213
|
for (let r9 = 0; r9 < rows - 1; r9++) {
|
|
3053
|
-
for (let
|
|
3054
|
-
const i00 = r9 * cols +
|
|
3055
|
-
const i10 = (r9 + 1) * cols +
|
|
3056
|
-
const i01 = r9 * cols + (
|
|
3057
|
-
const i11 = (r9 + 1) * cols + (
|
|
3214
|
+
for (let c7 = 0; c7 < cols - 1; c7++) {
|
|
3215
|
+
const i00 = r9 * cols + c7;
|
|
3216
|
+
const i10 = (r9 + 1) * cols + c7;
|
|
3217
|
+
const i01 = r9 * cols + (c7 + 1);
|
|
3218
|
+
const i11 = (r9 + 1) * cols + (c7 + 1);
|
|
3058
3219
|
const f1 = this.buildTriFace(points[i00], points[i10], points[i01]);
|
|
3059
3220
|
if (f1) faces.push(f1);
|
|
3060
3221
|
const f22 = this.buildTriFace(points[i10], points[i11], points[i01]);
|
|
@@ -3067,9 +3228,9 @@ class BrepkitAdapter {
|
|
|
3067
3228
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3068
3229
|
// Mesh sewing -> solid
|
|
3069
3230
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3070
|
-
buildTriFace(a9,
|
|
3071
|
-
const ab = [
|
|
3072
|
-
const ac = [
|
|
3231
|
+
buildTriFace(a9, b7, c7) {
|
|
3232
|
+
const ab = [b7[0] - a9[0], b7[1] - a9[1], b7[2] - a9[2]];
|
|
3233
|
+
const ac = [c7[0] - a9[0], c7[1] - a9[1], c7[2] - a9[2]];
|
|
3073
3234
|
const cross = [
|
|
3074
3235
|
ab[1] * ac[2] - ab[2] * ac[1],
|
|
3075
3236
|
ab[2] * ac[0] - ab[0] * ac[2],
|
|
@@ -3078,9 +3239,9 @@ class BrepkitAdapter {
|
|
|
3078
3239
|
const area = Math.sqrt(cross[0] ** 2 + cross[1] ** 2 + cross[2] ** 2);
|
|
3079
3240
|
if (area < 1e-12) return null;
|
|
3080
3241
|
try {
|
|
3081
|
-
const e1 = this.makeLineEdge(a9,
|
|
3082
|
-
const e22 = this.makeLineEdge(
|
|
3083
|
-
const e32 = this.makeLineEdge(
|
|
3242
|
+
const e1 = this.makeLineEdge(a9, b7);
|
|
3243
|
+
const e22 = this.makeLineEdge(b7, c7);
|
|
3244
|
+
const e32 = this.makeLineEdge(c7, a9);
|
|
3084
3245
|
const wire = this.makeWire([e1, e22, e32]);
|
|
3085
3246
|
return this.makeFace(wire);
|
|
3086
3247
|
} catch (e8) {
|
|
@@ -3089,7 +3250,7 @@ class BrepkitAdapter {
|
|
|
3089
3250
|
}
|
|
3090
3251
|
}
|
|
3091
3252
|
sewAndSolidify(faces, tolerance) {
|
|
3092
|
-
const faceIds = faces.map((
|
|
3253
|
+
const faceIds = faces.map((s5) => unwrap(s5, "face"));
|
|
3093
3254
|
const solidId = this.bk.sewFaces(faceIds, tolerance);
|
|
3094
3255
|
return solidHandle(solidId);
|
|
3095
3256
|
}
|
|
@@ -3097,9 +3258,9 @@ class BrepkitAdapter {
|
|
|
3097
3258
|
// Repair
|
|
3098
3259
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3099
3260
|
fixShape(shape2) {
|
|
3100
|
-
const
|
|
3101
|
-
if (
|
|
3102
|
-
this.bk.healSolid(
|
|
3261
|
+
const h7 = shape2;
|
|
3262
|
+
if (h7.type === "solid") {
|
|
3263
|
+
this.bk.healSolid(h7.id);
|
|
3103
3264
|
}
|
|
3104
3265
|
return shape2;
|
|
3105
3266
|
}
|
|
@@ -3109,9 +3270,9 @@ class BrepkitAdapter {
|
|
|
3109
3270
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3110
3271
|
// Measurement (advanced)
|
|
3111
3272
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3112
|
-
surfaceCurvature(face,
|
|
3273
|
+
surfaceCurvature(face, u5, v6) {
|
|
3113
3274
|
const fid = unwrap(face, "face");
|
|
3114
|
-
const data = this.bk.measureCurvatureAtSurface(fid,
|
|
3275
|
+
const data = this.bk.measureCurvatureAtSurface(fid, u5, v6);
|
|
3115
3276
|
if (data.length < 8) {
|
|
3116
3277
|
throw new Error(
|
|
3117
3278
|
`brepkit: measureCurvatureAtSurface returned ${data.length} values, expected 8`
|
|
@@ -3135,8 +3296,8 @@ class BrepkitAdapter {
|
|
|
3135
3296
|
const pos = mesh2.positions;
|
|
3136
3297
|
const idx = mesh2.indices;
|
|
3137
3298
|
let cx = 0, cy = 0, cz = 0, totalArea = 0;
|
|
3138
|
-
for (let
|
|
3139
|
-
const i0 = idx[
|
|
3299
|
+
for (let t7 = 0; t7 < idx.length; t7 += 3) {
|
|
3300
|
+
const i0 = idx[t7] * 3, i1 = idx[t7 + 1] * 3, i22 = idx[t7 + 2] * 3;
|
|
3140
3301
|
const tcx = (pos[i0] + pos[i1] + pos[i22]) / 3;
|
|
3141
3302
|
const tcy = (pos[i0 + 1] + pos[i1 + 1] + pos[i22 + 1]) / 3;
|
|
3142
3303
|
const tcz = (pos[i0 + 2] + pos[i1 + 2] + pos[i22 + 2]) / 3;
|
|
@@ -3194,12 +3355,12 @@ class BrepkitAdapter {
|
|
|
3194
3355
|
}
|
|
3195
3356
|
writeXCAFToSTEP(doc, _options) {
|
|
3196
3357
|
if (doc && doc.__brepkit_xcaf && Array.isArray(doc.shapes)) {
|
|
3197
|
-
return this.exportSTEP(doc.shapes.map((
|
|
3358
|
+
return this.exportSTEP(doc.shapes.map((s5) => s5.shape));
|
|
3198
3359
|
}
|
|
3199
3360
|
return "";
|
|
3200
3361
|
}
|
|
3201
3362
|
exportSTEPConfigured(shapes, _options) {
|
|
3202
|
-
return this.exportSTEP(shapes.map((
|
|
3363
|
+
return this.exportSTEP(shapes.map((s5) => s5.shape));
|
|
3203
3364
|
}
|
|
3204
3365
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3205
3366
|
// Export helpers
|
|
@@ -3226,11 +3387,11 @@ class BrepkitAdapter {
|
|
|
3226
3387
|
getBezierPenultimatePole(edge) {
|
|
3227
3388
|
const nurbsData = this.extractNurbsFromEdge(edge);
|
|
3228
3389
|
if (!nurbsData || nurbsData.controlPoints.length < 6) return null;
|
|
3229
|
-
const
|
|
3390
|
+
const n8 = nurbsData.controlPoints.length;
|
|
3230
3391
|
return [
|
|
3231
|
-
nurbsData.controlPoints[
|
|
3232
|
-
nurbsData.controlPoints[
|
|
3233
|
-
nurbsData.controlPoints[
|
|
3392
|
+
nurbsData.controlPoints[n8 - 6],
|
|
3393
|
+
nurbsData.controlPoints[n8 - 5],
|
|
3394
|
+
nurbsData.controlPoints[n8 - 4]
|
|
3234
3395
|
];
|
|
3235
3396
|
}
|
|
3236
3397
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -3252,15 +3413,15 @@ class BrepkitAdapter {
|
|
|
3252
3413
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3253
3414
|
// 3D geometry primitive factories
|
|
3254
3415
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3255
|
-
createPoint3d(
|
|
3256
|
-
return { x:
|
|
3416
|
+
createPoint3d(x6, y6, z6) {
|
|
3417
|
+
return { x: x6, y: y6, z: z6 };
|
|
3257
3418
|
}
|
|
3258
|
-
createDirection3d(
|
|
3259
|
-
const len = Math.sqrt(
|
|
3260
|
-
return { x:
|
|
3419
|
+
createDirection3d(x6, y6, z6) {
|
|
3420
|
+
const len = Math.sqrt(x6 * x6 + y6 * y6 + z6 * z6);
|
|
3421
|
+
return { x: x6 / len, y: y6 / len, z: z6 / len };
|
|
3261
3422
|
}
|
|
3262
|
-
createVector3d(
|
|
3263
|
-
return { x:
|
|
3423
|
+
createVector3d(x6, y6, z6) {
|
|
3424
|
+
return { x: x6, y: y6, z: z6 };
|
|
3264
3425
|
}
|
|
3265
3426
|
createAxis1(cx, cy, cz, dx, dy, dz) {
|
|
3266
3427
|
return { origin: [cx, cy, cz], direction: [dx, dy, dz] };
|
|
@@ -3283,9 +3444,9 @@ class BrepkitAdapter {
|
|
|
3283
3444
|
// Shape reversal
|
|
3284
3445
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3285
3446
|
reverseShape(shape2) {
|
|
3286
|
-
const
|
|
3287
|
-
const newId = this.bk.reverseShape(
|
|
3288
|
-
return handle(
|
|
3447
|
+
const h7 = shape2;
|
|
3448
|
+
const newId = this.bk.reverseShape(h7.id);
|
|
3449
|
+
return handle(h7.type, newId);
|
|
3289
3450
|
}
|
|
3290
3451
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3291
3452
|
// Dispose
|
|
@@ -3317,27 +3478,27 @@ class BrepkitAdapter {
|
|
|
3317
3478
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3318
3479
|
// Kernel2DCapability — pure TypeScript implementation
|
|
3319
3480
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3320
|
-
c2d(
|
|
3321
|
-
return
|
|
3481
|
+
c2d(h7) {
|
|
3482
|
+
return h7;
|
|
3322
3483
|
}
|
|
3323
3484
|
/** Unwrap any trimmed wrappers to get the underlying geometry. */
|
|
3324
|
-
c2dBasis(
|
|
3325
|
-
let
|
|
3326
|
-
while (
|
|
3327
|
-
return
|
|
3485
|
+
c2dBasis(h7) {
|
|
3486
|
+
let c7 = this.c2d(h7);
|
|
3487
|
+
while (c7.__bk2d === "trimmed") c7 = c7.basis;
|
|
3488
|
+
return c7;
|
|
3328
3489
|
}
|
|
3329
|
-
bb2d(
|
|
3330
|
-
return
|
|
3490
|
+
bb2d(h7) {
|
|
3491
|
+
return h7;
|
|
3331
3492
|
}
|
|
3332
|
-
createPoint2d(
|
|
3333
|
-
return { x:
|
|
3493
|
+
createPoint2d(x6, y6) {
|
|
3494
|
+
return { x: x6, y: y6 };
|
|
3334
3495
|
}
|
|
3335
|
-
createDirection2d(
|
|
3336
|
-
const l10 = Math.sqrt(
|
|
3337
|
-
return { x:
|
|
3496
|
+
createDirection2d(x6, y6) {
|
|
3497
|
+
const l10 = Math.sqrt(x6 * x6 + y6 * y6);
|
|
3498
|
+
return { x: x6 / l10, y: y6 / l10 };
|
|
3338
3499
|
}
|
|
3339
|
-
createVector2d(
|
|
3340
|
-
return { x:
|
|
3500
|
+
createVector2d(x6, y6) {
|
|
3501
|
+
return { x: x6, y: y6 };
|
|
3341
3502
|
}
|
|
3342
3503
|
createAxis2d(px, py, dx, dy) {
|
|
3343
3504
|
return { px, py, dx, dy, delete: noop };
|
|
@@ -3392,10 +3553,10 @@ class BrepkitAdapter {
|
|
|
3392
3553
|
return makeLine2d(sx, sy, ex, ey);
|
|
3393
3554
|
}
|
|
3394
3555
|
const chord2 = dx * dx + dy * dy;
|
|
3395
|
-
const
|
|
3396
|
-
const cx = sx -
|
|
3397
|
-
const cy = sy +
|
|
3398
|
-
const radius = Math.abs(
|
|
3556
|
+
const t7 = -chord2 / denom;
|
|
3557
|
+
const cx = sx - t7 * nty;
|
|
3558
|
+
const cy = sy + t7 * ntx;
|
|
3559
|
+
const radius = Math.abs(t7);
|
|
3399
3560
|
const a12 = Math.atan2(sy - cy, sx - cx);
|
|
3400
3561
|
const a23 = Math.atan2(ey - cy, ex - cx);
|
|
3401
3562
|
const ccwTanX = -(sy - cy) / radius;
|
|
@@ -3426,13 +3587,13 @@ class BrepkitAdapter {
|
|
|
3426
3587
|
return makeBezier2d(points);
|
|
3427
3588
|
}
|
|
3428
3589
|
makeBSpline2d(points, _options) {
|
|
3429
|
-
const
|
|
3430
|
-
const degree = Math.min(3,
|
|
3590
|
+
const n8 = points.length;
|
|
3591
|
+
const degree = Math.min(3, n8 - 1);
|
|
3431
3592
|
const knots = [];
|
|
3432
3593
|
const mults = [];
|
|
3433
3594
|
knots.push(0);
|
|
3434
3595
|
mults.push(degree + 1);
|
|
3435
|
-
const nInternal =
|
|
3596
|
+
const nInternal = n8 - degree - 1;
|
|
3436
3597
|
for (let i9 = 1; i9 <= nInternal; i9++) {
|
|
3437
3598
|
knots.push(i9 / (nInternal + 1));
|
|
3438
3599
|
mults.push(1);
|
|
@@ -3472,14 +3633,14 @@ class BrepkitAdapter {
|
|
|
3472
3633
|
return JSON.parse(JSON.stringify(curve));
|
|
3473
3634
|
}
|
|
3474
3635
|
offsetCurve2d(curve, offset2) {
|
|
3475
|
-
const
|
|
3476
|
-
const bounds = curveBounds(
|
|
3636
|
+
const c7 = this.c2d(curve);
|
|
3637
|
+
const bounds = curveBounds(c7);
|
|
3477
3638
|
const N4 = 30;
|
|
3478
3639
|
const poles = [];
|
|
3479
3640
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3480
|
-
const
|
|
3481
|
-
const [px, py] = evaluateCurve2d(
|
|
3482
|
-
const [tx, ty] = tangentCurve2d(
|
|
3641
|
+
const t7 = bounds.first + (bounds.last - bounds.first) * i9 / N4;
|
|
3642
|
+
const [px, py] = evaluateCurve2d(c7, t7);
|
|
3643
|
+
const [tx, ty] = tangentCurve2d(c7, t7);
|
|
3483
3644
|
const tLen = Math.sqrt(tx * tx + ty * ty);
|
|
3484
3645
|
if (tLen > 1e-12) {
|
|
3485
3646
|
poles.push([px - ty / tLen * offset2, py + tx / tLen * offset2]);
|
|
@@ -3509,19 +3670,19 @@ class BrepkitAdapter {
|
|
|
3509
3670
|
if (len < 1e-15) return this.c2d(curve);
|
|
3510
3671
|
const ax = dx / len, ay = dy / len;
|
|
3511
3672
|
const px = -ay, py = ax;
|
|
3512
|
-
const
|
|
3513
|
-
const m00 = 1 +
|
|
3514
|
-
const
|
|
3673
|
+
const k9 = ratio - 1;
|
|
3674
|
+
const m00 = 1 + k9 * px * px, m01 = k9 * px * py;
|
|
3675
|
+
const m102 = k9 * py * px, m11 = 1 + k9 * py * py;
|
|
3515
3676
|
const txOff = ox - m00 * ox - m01 * oy;
|
|
3516
|
-
const tyOff = oy -
|
|
3517
|
-
const gtrsf = { m: [m00, m01, 0,
|
|
3677
|
+
const tyOff = oy - m102 * ox - m11 * oy;
|
|
3678
|
+
const gtrsf = { m: [m00, m01, 0, m102, m11, 0, 0, 0, 1], tx: txOff, ty: tyOff };
|
|
3518
3679
|
return this.transformCurve2dGeneral(curve, gtrsf);
|
|
3519
3680
|
}
|
|
3520
3681
|
// --- General 2D transforms (stored as 3×3 matrices) ---
|
|
3521
3682
|
// All GTrsf2d methods return objects with a no-op .delete() to match OCCT's
|
|
3522
3683
|
// Emscripten WASM objects, which callers (e.g. curves.ts) rely on for cleanup.
|
|
3523
|
-
_gtrsf(
|
|
3524
|
-
return { m:
|
|
3684
|
+
_gtrsf(m11, tx, ty) {
|
|
3685
|
+
return { m: m11, tx, ty, delete: noop };
|
|
3525
3686
|
}
|
|
3526
3687
|
createIdentityGTrsf2d() {
|
|
3527
3688
|
return this._gtrsf([1, 0, 0, 0, 1, 0, 0, 0, 1], 0, 0);
|
|
@@ -3530,11 +3691,11 @@ class BrepkitAdapter {
|
|
|
3530
3691
|
const len = Math.sqrt(dx * dx + dy * dy);
|
|
3531
3692
|
if (len < 1e-15) return this.createIdentityGTrsf2d();
|
|
3532
3693
|
const px = -dy / len, py = dx / len;
|
|
3533
|
-
const
|
|
3534
|
-
const
|
|
3535
|
-
const txv = ox -
|
|
3536
|
-
const tyv = oy -
|
|
3537
|
-
return this._gtrsf(
|
|
3694
|
+
const k9 = ratio - 1;
|
|
3695
|
+
const m11 = [1 + k9 * px * px, k9 * px * py, 0, k9 * py * px, 1 + k9 * py * py, 0, 0, 0, 1];
|
|
3696
|
+
const txv = ox - m11[0] * ox - m11[1] * oy;
|
|
3697
|
+
const tyv = oy - m11[3] * ox - m11[4] * oy;
|
|
3698
|
+
return this._gtrsf(m11, txv, tyv);
|
|
3538
3699
|
}
|
|
3539
3700
|
createTranslationGTrsf2d(dx, dy) {
|
|
3540
3701
|
return this._gtrsf([1, 0, 0, 0, 1, 0, 0, 0, 1], dx, dy);
|
|
@@ -3543,17 +3704,17 @@ class BrepkitAdapter {
|
|
|
3543
3704
|
if (mode === "axis" && dx !== void 0 && dy !== void 0) {
|
|
3544
3705
|
const len = Math.sqrt(dx * dx + dy * dy);
|
|
3545
3706
|
const nx = dx / len, ny = dy / len;
|
|
3546
|
-
const
|
|
3707
|
+
const m11 = [2 * nx * nx - 1, 2 * nx * ny, 0, 2 * nx * ny, 2 * ny * ny - 1, 0, 0, 0, 1];
|
|
3547
3708
|
const px = ox ?? cx, py = oy ?? cy;
|
|
3548
|
-
const txv = px -
|
|
3549
|
-
const tyv = py -
|
|
3550
|
-
return this._gtrsf(
|
|
3709
|
+
const txv = px - m11[0] * px - m11[1] * py;
|
|
3710
|
+
const tyv = py - m11[3] * px - m11[4] * py;
|
|
3711
|
+
return this._gtrsf(m11, txv, tyv);
|
|
3551
3712
|
}
|
|
3552
3713
|
return this._gtrsf([-1, 0, 0, 0, -1, 0, 0, 0, 1], 2 * cx, 2 * cy);
|
|
3553
3714
|
}
|
|
3554
3715
|
createRotationGTrsf2d(angle, cx, cy) {
|
|
3555
|
-
const
|
|
3556
|
-
return this._gtrsf([
|
|
3716
|
+
const c7 = Math.cos(angle), s5 = Math.sin(angle);
|
|
3717
|
+
return this._gtrsf([c7, -s5, 0, s5, c7, 0, 0, 0, 1], cx - c7 * cx + s5 * cy, cy - s5 * cx - c7 * cy);
|
|
3557
3718
|
}
|
|
3558
3719
|
createScaleGTrsf2d(factor, cx, cy) {
|
|
3559
3720
|
return this._gtrsf([factor, 0, 0, 0, factor, 0, 0, 0, 1], cx * (1 - factor), cy * (1 - factor));
|
|
@@ -3563,17 +3724,17 @@ class BrepkitAdapter {
|
|
|
3563
3724
|
gtrsf.ty = dy;
|
|
3564
3725
|
}
|
|
3565
3726
|
multiplyGTrsf2d(base, other) {
|
|
3566
|
-
const a9 = base.m,
|
|
3727
|
+
const a9 = base.m, b7 = other.m;
|
|
3567
3728
|
const r9 = [
|
|
3568
|
-
a9[0] *
|
|
3569
|
-
a9[0] *
|
|
3570
|
-
a9[0] *
|
|
3571
|
-
a9[3] *
|
|
3572
|
-
a9[3] *
|
|
3573
|
-
a9[3] *
|
|
3574
|
-
a9[6] *
|
|
3575
|
-
a9[6] *
|
|
3576
|
-
a9[6] *
|
|
3729
|
+
a9[0] * b7[0] + a9[1] * b7[3] + a9[2] * b7[6],
|
|
3730
|
+
a9[0] * b7[1] + a9[1] * b7[4] + a9[2] * b7[7],
|
|
3731
|
+
a9[0] * b7[2] + a9[1] * b7[5] + a9[2] * b7[8],
|
|
3732
|
+
a9[3] * b7[0] + a9[4] * b7[3] + a9[5] * b7[6],
|
|
3733
|
+
a9[3] * b7[1] + a9[4] * b7[4] + a9[5] * b7[7],
|
|
3734
|
+
a9[3] * b7[2] + a9[4] * b7[5] + a9[5] * b7[8],
|
|
3735
|
+
a9[6] * b7[0] + a9[7] * b7[3] + a9[8] * b7[6],
|
|
3736
|
+
a9[6] * b7[1] + a9[7] * b7[4] + a9[8] * b7[7],
|
|
3737
|
+
a9[6] * b7[2] + a9[7] * b7[5] + a9[8] * b7[8]
|
|
3577
3738
|
];
|
|
3578
3739
|
base.m = r9;
|
|
3579
3740
|
const oldTx = base.tx, oldTy = base.ty;
|
|
@@ -3582,20 +3743,20 @@ class BrepkitAdapter {
|
|
|
3582
3743
|
base.ty = a9[3] * otx + a9[4] * oty + oldTy;
|
|
3583
3744
|
}
|
|
3584
3745
|
transformCurve2dGeneral(curve, gtrsf) {
|
|
3585
|
-
const
|
|
3586
|
-
const
|
|
3746
|
+
const c7 = this.c2d(curve);
|
|
3747
|
+
const m11 = gtrsf.m ?? [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
3587
3748
|
const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
|
|
3588
|
-
const isIdentityMatrix = Math.abs(
|
|
3749
|
+
const isIdentityMatrix = Math.abs(m11[0] - 1) < 1e-12 && Math.abs(m11[4] - 1) < 1e-12 && Math.abs(m11[1]) < 1e-12 && Math.abs(m11[3]) < 1e-12;
|
|
3589
3750
|
if (isIdentityMatrix) {
|
|
3590
|
-
return translateCurve2d(
|
|
3751
|
+
return translateCurve2d(c7, tx, ty);
|
|
3591
3752
|
}
|
|
3592
|
-
const bounds = curveBounds(
|
|
3753
|
+
const bounds = curveBounds(c7);
|
|
3593
3754
|
const N4 = 20;
|
|
3594
3755
|
const pts = [];
|
|
3595
3756
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3596
|
-
const
|
|
3597
|
-
const [px, py] = evaluateCurve2d(
|
|
3598
|
-
pts.push([
|
|
3757
|
+
const t7 = bounds.first + (bounds.last - bounds.first) * i9 / N4;
|
|
3758
|
+
const [px, py] = evaluateCurve2d(c7, t7);
|
|
3759
|
+
pts.push([m11[0] * px + m11[1] * py + tx, m11[3] * px + m11[4] * py + ty]);
|
|
3599
3760
|
}
|
|
3600
3761
|
return makeBezier2d(pts);
|
|
3601
3762
|
}
|
|
@@ -3603,30 +3764,30 @@ class BrepkitAdapter {
|
|
|
3603
3764
|
intersectCurves2d(c1, c22, tolerance) {
|
|
3604
3765
|
const result = intersectCurves2dFn(this.c2d(c1), this.c2d(c22), tolerance);
|
|
3605
3766
|
const segments = result.segments.map(
|
|
3606
|
-
(
|
|
3767
|
+
(s5) => Object.assign(s5, {
|
|
3607
3768
|
delete() {
|
|
3608
3769
|
}
|
|
3609
3770
|
})
|
|
3610
3771
|
);
|
|
3611
3772
|
return { points: result.points, segments };
|
|
3612
3773
|
}
|
|
3613
|
-
projectPointOnCurve2d(curve,
|
|
3614
|
-
const
|
|
3615
|
-
const bounds = curveBounds(
|
|
3616
|
-
if (
|
|
3617
|
-
const dx =
|
|
3618
|
-
const dy =
|
|
3619
|
-
const
|
|
3620
|
-
const [px, py] = evaluateCurve2d(
|
|
3621
|
-
return { param:
|
|
3622
|
-
}
|
|
3623
|
-
if (
|
|
3624
|
-
const angle = Math.atan2(
|
|
3625
|
-
let
|
|
3626
|
-
while (
|
|
3627
|
-
while (
|
|
3628
|
-
const [px, py] = evaluateCurve2d(
|
|
3629
|
-
return { param:
|
|
3774
|
+
projectPointOnCurve2d(curve, x6, y6) {
|
|
3775
|
+
const c7 = this.c2d(curve);
|
|
3776
|
+
const bounds = curveBounds(c7);
|
|
3777
|
+
if (c7.__bk2d === "line") {
|
|
3778
|
+
const dx = x6 - c7.ox;
|
|
3779
|
+
const dy = y6 - c7.oy;
|
|
3780
|
+
const t7 = Math.max(bounds.first, Math.min(bounds.last, dx * c7.dx + dy * c7.dy));
|
|
3781
|
+
const [px, py] = evaluateCurve2d(c7, t7);
|
|
3782
|
+
return { param: t7, distance: Math.sqrt((px - x6) ** 2 + (py - y6) ** 2) };
|
|
3783
|
+
}
|
|
3784
|
+
if (c7.__bk2d === "circle") {
|
|
3785
|
+
const angle = Math.atan2(y6 - c7.cy, x6 - c7.cx);
|
|
3786
|
+
let t7 = c7.sense ? angle : -angle;
|
|
3787
|
+
while (t7 < 0) t7 += 2 * Math.PI;
|
|
3788
|
+
while (t7 > 2 * Math.PI) t7 -= 2 * Math.PI;
|
|
3789
|
+
const [px, py] = evaluateCurve2d(c7, t7);
|
|
3790
|
+
return { param: t7, distance: Math.sqrt((px - x6) ** 2 + (py - y6) ** 2) };
|
|
3630
3791
|
}
|
|
3631
3792
|
if (!isFinite(bounds.first) || !isFinite(bounds.last)) return null;
|
|
3632
3793
|
let bestT = bounds.first;
|
|
@@ -3634,18 +3795,18 @@ class BrepkitAdapter {
|
|
|
3634
3795
|
const N4 = 200;
|
|
3635
3796
|
const dt = (bounds.last - bounds.first) / N4;
|
|
3636
3797
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3637
|
-
const
|
|
3638
|
-
const [px, py] = evaluateCurve2d(
|
|
3639
|
-
const d11 = (px -
|
|
3798
|
+
const t7 = bounds.first + i9 * dt;
|
|
3799
|
+
const [px, py] = evaluateCurve2d(c7, t7);
|
|
3800
|
+
const d11 = (px - x6) ** 2 + (py - y6) ** 2;
|
|
3640
3801
|
if (d11 < bestDist) {
|
|
3641
3802
|
bestDist = d11;
|
|
3642
|
-
bestT =
|
|
3803
|
+
bestT = t7;
|
|
3643
3804
|
}
|
|
3644
3805
|
}
|
|
3645
3806
|
for (let iter = 0; iter < 10; iter++) {
|
|
3646
|
-
const [px, py] = evaluateCurve2d(
|
|
3647
|
-
const [tx, ty] = tangentCurve2d(
|
|
3648
|
-
const dot = (px -
|
|
3807
|
+
const [px, py] = evaluateCurve2d(c7, bestT);
|
|
3808
|
+
const [tx, ty] = tangentCurve2d(c7, bestT);
|
|
3809
|
+
const dot = (px - x6) * tx + (py - y6) * ty;
|
|
3649
3810
|
const denom = tx * tx + ty * ty;
|
|
3650
3811
|
if (denom < 1e-20) break;
|
|
3651
3812
|
const step = dot / denom;
|
|
@@ -3653,8 +3814,8 @@ class BrepkitAdapter {
|
|
|
3653
3814
|
if (Math.abs(newT - bestT) < 1e-14) break;
|
|
3654
3815
|
bestT = newT;
|
|
3655
3816
|
}
|
|
3656
|
-
const [fx, fy] = evaluateCurve2d(
|
|
3657
|
-
return { param: bestT, distance: Math.sqrt((fx -
|
|
3817
|
+
const [fx, fy] = evaluateCurve2d(c7, bestT);
|
|
3818
|
+
return { param: bestT, distance: Math.sqrt((fx - x6) ** 2 + (fy - y6) ** 2) };
|
|
3658
3819
|
}
|
|
3659
3820
|
distanceBetweenCurves2d(c1, c22, p1s, p1e, p2s, p2e) {
|
|
3660
3821
|
const curve1 = this.c2d(c1);
|
|
@@ -3666,8 +3827,8 @@ class BrepkitAdapter {
|
|
|
3666
3827
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3667
3828
|
const t12 = p1s + (p1e - p1s) * i9 / N4;
|
|
3668
3829
|
const [x1, y1] = evaluateCurve2d(curve1, t12);
|
|
3669
|
-
for (let
|
|
3670
|
-
const t222 = p2s + (p2e - p2s) *
|
|
3830
|
+
for (let j10 = 0; j10 <= N4; j10++) {
|
|
3831
|
+
const t222 = p2s + (p2e - p2s) * j10 / N4;
|
|
3671
3832
|
const [x22, y22] = evaluateCurve2d(curve2, t222);
|
|
3672
3833
|
const d11 = (x22 - x1) ** 2 + (y22 - y1) ** 2;
|
|
3673
3834
|
if (d11 < minDistSq) {
|
|
@@ -3702,8 +3863,8 @@ class BrepkitAdapter {
|
|
|
3702
3863
|
return Math.sqrt((fx2 - fx1) ** 2 + (fy2 - fy1) ** 2);
|
|
3703
3864
|
}
|
|
3704
3865
|
approximateCurve2dAsBSpline(curve, tol, cont, maxSeg) {
|
|
3705
|
-
const
|
|
3706
|
-
const bounds = curveBounds(
|
|
3866
|
+
const c7 = this.c2d(curve);
|
|
3867
|
+
const bounds = curveBounds(c7);
|
|
3707
3868
|
const contDeg = cont === "C0" ? 1 : cont === "C1" ? 2 : cont === "C2" ? 3 : 4;
|
|
3708
3869
|
const degree = Math.max(3, contDeg);
|
|
3709
3870
|
let N4 = Math.max(100, maxSeg * 10);
|
|
@@ -3712,13 +3873,13 @@ class BrepkitAdapter {
|
|
|
3712
3873
|
for (let attempt = 0; attempt < 3 && maxErr > tol; attempt++) {
|
|
3713
3874
|
poles = [];
|
|
3714
3875
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3715
|
-
const
|
|
3716
|
-
poles.push(evaluateCurve2d(
|
|
3876
|
+
const t7 = bounds.first + (bounds.last - bounds.first) * i9 / N4;
|
|
3877
|
+
poles.push(evaluateCurve2d(c7, t7));
|
|
3717
3878
|
}
|
|
3718
3879
|
maxErr = 0;
|
|
3719
3880
|
for (let i9 = 0; i9 < N4; i9++) {
|
|
3720
3881
|
const tMid = bounds.first + (bounds.last - bounds.first) * (i9 + 0.5) / N4;
|
|
3721
|
-
const [ex, ey] = evaluateCurve2d(
|
|
3882
|
+
const [ex, ey] = evaluateCurve2d(c7, tMid);
|
|
3722
3883
|
const p0 = poles[i9];
|
|
3723
3884
|
const p1 = poles[i9 + 1];
|
|
3724
3885
|
const mx = (p0[0] + p1[0]) / 2;
|
|
@@ -3731,9 +3892,9 @@ class BrepkitAdapter {
|
|
|
3731
3892
|
return this.makeBSpline2d(poles, { degMax: degree });
|
|
3732
3893
|
}
|
|
3733
3894
|
decomposeBSpline2dToBeziers(curve) {
|
|
3734
|
-
const
|
|
3735
|
-
if (
|
|
3736
|
-
if (
|
|
3895
|
+
const c7 = this.c2dBasis(curve);
|
|
3896
|
+
if (c7.__bk2d === "bezier") return [curve];
|
|
3897
|
+
if (c7.__bk2d !== "bspline") {
|
|
3737
3898
|
const approx = this.approximateCurve2dAsBSpline(curve, 1e-6, "C2", 10);
|
|
3738
3899
|
return this.decomposeBSpline2dToBeziers(approx);
|
|
3739
3900
|
}
|
|
@@ -3741,8 +3902,8 @@ class BrepkitAdapter {
|
|
|
3741
3902
|
const first = trimBounds.first;
|
|
3742
3903
|
const last = trimBounds.last;
|
|
3743
3904
|
const internalKnots = [];
|
|
3744
|
-
for (const
|
|
3745
|
-
if (
|
|
3905
|
+
for (const k9 of c7.knots) {
|
|
3906
|
+
if (k9 > first + 1e-12 && k9 < last - 1e-12) internalKnots.push(k9);
|
|
3746
3907
|
}
|
|
3747
3908
|
const breakpoints = [first, ...internalKnots, last];
|
|
3748
3909
|
const result = [];
|
|
@@ -3751,17 +3912,17 @@ class BrepkitAdapter {
|
|
|
3751
3912
|
const t1 = breakpoints[i9 + 1];
|
|
3752
3913
|
const span = t1 - t0;
|
|
3753
3914
|
if (span < 1e-15) continue;
|
|
3754
|
-
const p0 = evaluateCurve2d(
|
|
3755
|
-
const p32 = evaluateCurve2d(
|
|
3756
|
-
const tan0 = tangentCurve2d(
|
|
3757
|
-
const tan3 = tangentCurve2d(
|
|
3758
|
-
const
|
|
3915
|
+
const p0 = evaluateCurve2d(c7, t0);
|
|
3916
|
+
const p32 = evaluateCurve2d(c7, t1);
|
|
3917
|
+
const tan0 = tangentCurve2d(c7, t0);
|
|
3918
|
+
const tan3 = tangentCurve2d(c7, t1);
|
|
3919
|
+
const s5 = span / 3;
|
|
3759
3920
|
const bezier = {
|
|
3760
3921
|
__bk2d: "bezier",
|
|
3761
3922
|
poles: [
|
|
3762
3923
|
p0,
|
|
3763
|
-
[p0[0] + tan0[0] *
|
|
3764
|
-
[p32[0] - tan3[0] *
|
|
3924
|
+
[p0[0] + tan0[0] * s5, p0[1] + tan0[1] * s5],
|
|
3925
|
+
[p32[0] - tan3[0] * s5, p32[1] - tan3[1] * s5],
|
|
3765
3926
|
p32
|
|
3766
3927
|
]
|
|
3767
3928
|
};
|
|
@@ -3777,60 +3938,60 @@ class BrepkitAdapter {
|
|
|
3777
3938
|
addCurveToBBox(this.bb2d(bbox), this.c2d(curve));
|
|
3778
3939
|
}
|
|
3779
3940
|
getBBox2dBounds(bbox) {
|
|
3780
|
-
const
|
|
3781
|
-
return { xMin:
|
|
3941
|
+
const b7 = this.bb2d(bbox);
|
|
3942
|
+
return { xMin: b7.xMin, yMin: b7.yMin, xMax: b7.xMax, yMax: b7.yMax };
|
|
3782
3943
|
}
|
|
3783
3944
|
mergeBBox2d(target, other) {
|
|
3784
|
-
const
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
}
|
|
3790
|
-
isBBox2dOut(a9,
|
|
3791
|
-
const ba = this.bb2d(a9), bb = this.bb2d(
|
|
3945
|
+
const t7 = this.bb2d(target), o8 = this.bb2d(other);
|
|
3946
|
+
t7.xMin = Math.min(t7.xMin, o8.xMin);
|
|
3947
|
+
t7.yMin = Math.min(t7.yMin, o8.yMin);
|
|
3948
|
+
t7.xMax = Math.max(t7.xMax, o8.xMax);
|
|
3949
|
+
t7.yMax = Math.max(t7.yMax, o8.yMax);
|
|
3950
|
+
}
|
|
3951
|
+
isBBox2dOut(a9, b7) {
|
|
3952
|
+
const ba = this.bb2d(a9), bb = this.bb2d(b7);
|
|
3792
3953
|
return ba.xMax < bb.xMin || bb.xMax < ba.xMin || ba.yMax < bb.yMin || bb.yMax < ba.yMin;
|
|
3793
3954
|
}
|
|
3794
|
-
isBBox2dOutPoint(bbox,
|
|
3795
|
-
const
|
|
3796
|
-
return
|
|
3955
|
+
isBBox2dOutPoint(bbox, x6, y6) {
|
|
3956
|
+
const b7 = this.bb2d(bbox);
|
|
3957
|
+
return x6 < b7.xMin || x6 > b7.xMax || y6 < b7.yMin || y6 > b7.yMax;
|
|
3797
3958
|
}
|
|
3798
3959
|
// --- 2D type extraction ---
|
|
3799
3960
|
getCurve2dCircleData(curve) {
|
|
3800
|
-
const
|
|
3801
|
-
if (
|
|
3961
|
+
const c7 = this.c2dBasis(curve);
|
|
3962
|
+
if (c7.__bk2d === "circle") return { cx: c7.cx, cy: c7.cy, radius: c7.radius, isDirect: c7.sense };
|
|
3802
3963
|
return null;
|
|
3803
3964
|
}
|
|
3804
3965
|
getCurve2dEllipseData(curve) {
|
|
3805
|
-
const
|
|
3806
|
-
if (
|
|
3966
|
+
const c7 = this.c2dBasis(curve);
|
|
3967
|
+
if (c7.__bk2d === "ellipse")
|
|
3807
3968
|
return {
|
|
3808
|
-
majorRadius:
|
|
3809
|
-
minorRadius:
|
|
3810
|
-
xAxisAngle:
|
|
3811
|
-
isDirect:
|
|
3969
|
+
majorRadius: c7.majorRadius,
|
|
3970
|
+
minorRadius: c7.minorRadius,
|
|
3971
|
+
xAxisAngle: c7.xDirAngle,
|
|
3972
|
+
isDirect: c7.sense
|
|
3812
3973
|
};
|
|
3813
3974
|
return null;
|
|
3814
3975
|
}
|
|
3815
3976
|
getCurve2dBezierPoles(curve) {
|
|
3816
|
-
const
|
|
3817
|
-
if (
|
|
3977
|
+
const c7 = this.c2dBasis(curve);
|
|
3978
|
+
if (c7.__bk2d === "bezier") return [...c7.poles];
|
|
3818
3979
|
return null;
|
|
3819
3980
|
}
|
|
3820
3981
|
getCurve2dBezierDegree(curve) {
|
|
3821
|
-
const
|
|
3822
|
-
if (
|
|
3982
|
+
const c7 = this.c2dBasis(curve);
|
|
3983
|
+
if (c7.__bk2d === "bezier") return c7.poles.length - 1;
|
|
3823
3984
|
return null;
|
|
3824
3985
|
}
|
|
3825
3986
|
getCurve2dBSplineData(curve) {
|
|
3826
|
-
const
|
|
3827
|
-
if (
|
|
3987
|
+
const c7 = this.c2dBasis(curve);
|
|
3988
|
+
if (c7.__bk2d === "bspline")
|
|
3828
3989
|
return {
|
|
3829
|
-
poles: [...
|
|
3830
|
-
knots: [...
|
|
3831
|
-
multiplicities: [...
|
|
3832
|
-
degree:
|
|
3833
|
-
isPeriodic:
|
|
3990
|
+
poles: [...c7.poles],
|
|
3991
|
+
knots: [...c7.knots],
|
|
3992
|
+
multiplicities: [...c7.multiplicities],
|
|
3993
|
+
degree: c7.degree,
|
|
3994
|
+
isPeriodic: c7.isPeriodic
|
|
3834
3995
|
};
|
|
3835
3996
|
return null;
|
|
3836
3997
|
}
|
|
@@ -3843,14 +4004,14 @@ class BrepkitAdapter {
|
|
|
3843
4004
|
}
|
|
3844
4005
|
// --- 2D curve splitting ---
|
|
3845
4006
|
splitCurve2d(curve, params) {
|
|
3846
|
-
const
|
|
3847
|
-
const bounds = curveBounds(
|
|
3848
|
-
const sortedParams = [bounds.first, ...params.sort((a9,
|
|
4007
|
+
const c7 = this.c2d(curve);
|
|
4008
|
+
const bounds = curveBounds(c7);
|
|
4009
|
+
const sortedParams = [bounds.first, ...params.sort((a9, b7) => a9 - b7), bounds.last];
|
|
3849
4010
|
const result = [];
|
|
3850
4011
|
for (let i9 = 0; i9 < sortedParams.length - 1; i9++) {
|
|
3851
4012
|
result.push({
|
|
3852
4013
|
__bk2d: "trimmed",
|
|
3853
|
-
basis:
|
|
4014
|
+
basis: c7,
|
|
3854
4015
|
tStart: sortedParams[i9],
|
|
3855
4016
|
tEnd: sortedParams[i9 + 1]
|
|
3856
4017
|
});
|
|
@@ -3859,33 +4020,33 @@ class BrepkitAdapter {
|
|
|
3859
4020
|
}
|
|
3860
4021
|
// --- 2D → 3D projection ---
|
|
3861
4022
|
liftCurve2dToPlane(curve, origin, planeZ, planeX) {
|
|
3862
|
-
const
|
|
3863
|
-
const
|
|
4023
|
+
const c7 = this.c2d(curve);
|
|
4024
|
+
const y6 = [
|
|
3864
4025
|
planeZ[1] * planeX[2] - planeZ[2] * planeX[1],
|
|
3865
4026
|
planeZ[2] * planeX[0] - planeZ[0] * planeX[2],
|
|
3866
4027
|
planeZ[0] * planeX[1] - planeZ[1] * planeX[0]
|
|
3867
4028
|
];
|
|
3868
|
-
const lift = (
|
|
3869
|
-
origin[0] +
|
|
3870
|
-
origin[1] +
|
|
3871
|
-
origin[2] +
|
|
4029
|
+
const lift = (u5, v6) => [
|
|
4030
|
+
origin[0] + u5 * planeX[0] + v6 * y6[0],
|
|
4031
|
+
origin[1] + u5 * planeX[1] + v6 * y6[1],
|
|
4032
|
+
origin[2] + u5 * planeX[2] + v6 * y6[2]
|
|
3872
4033
|
];
|
|
3873
|
-
if (
|
|
3874
|
-
const p1 = lift(
|
|
3875
|
-
const p22 = lift(
|
|
4034
|
+
if (c7.__bk2d === "line") {
|
|
4035
|
+
const p1 = lift(c7.ox, c7.oy);
|
|
4036
|
+
const p22 = lift(c7.ox + c7.dx * c7.len, c7.oy + c7.dy * c7.len);
|
|
3876
4037
|
return this.makeLineEdge(p1, p22);
|
|
3877
4038
|
}
|
|
3878
|
-
if (
|
|
3879
|
-
let basis =
|
|
4039
|
+
if (c7.__bk2d === "circle" || c7.__bk2d === "trimmed") {
|
|
4040
|
+
let basis = c7;
|
|
3880
4041
|
while (basis.__bk2d === "trimmed") basis = basis.basis;
|
|
3881
4042
|
if (basis.__bk2d === "circle") {
|
|
3882
4043
|
const circ = basis;
|
|
3883
4044
|
const center3d = lift(circ.cx, circ.cy);
|
|
3884
4045
|
const axis = circ.sense ? planeZ : [-planeZ[0], -planeZ[1], -planeZ[2]];
|
|
3885
|
-
const bounds2 = curveBounds(
|
|
4046
|
+
const bounds2 = curveBounds(c7);
|
|
3886
4047
|
let angularSpan;
|
|
3887
|
-
if (
|
|
3888
|
-
angularSpan = Math.abs(
|
|
4048
|
+
if (c7.__bk2d === "trimmed") {
|
|
4049
|
+
angularSpan = Math.abs(c7.tEnd - c7.tStart);
|
|
3889
4050
|
} else {
|
|
3890
4051
|
angularSpan = 2 * Math.PI;
|
|
3891
4052
|
}
|
|
@@ -3893,8 +4054,8 @@ class BrepkitAdapter {
|
|
|
3893
4054
|
const segmentSpan = (bounds2.last - bounds2.first) / nSegments;
|
|
3894
4055
|
const edgeIds = [];
|
|
3895
4056
|
for (let seg = 0; seg < nSegments; seg++) {
|
|
3896
|
-
const [su, sv] = evaluateCurve2d(
|
|
3897
|
-
const [eu, ev] = evaluateCurve2d(
|
|
4057
|
+
const [su, sv] = evaluateCurve2d(c7, bounds2.first + seg * segmentSpan);
|
|
4058
|
+
const [eu, ev] = evaluateCurve2d(c7, bounds2.first + (seg + 1) * segmentSpan);
|
|
3898
4059
|
edgeIds.push(
|
|
3899
4060
|
this.bk.makeCircleArc3d(...lift(su, sv), ...lift(eu, ev), ...center3d, ...axis)
|
|
3900
4061
|
);
|
|
@@ -3903,21 +4064,21 @@ class BrepkitAdapter {
|
|
|
3903
4064
|
return wireHandle(this.bk.makeWire(edgeIds, false));
|
|
3904
4065
|
}
|
|
3905
4066
|
}
|
|
3906
|
-
if (
|
|
3907
|
-
const points3d =
|
|
4067
|
+
if (c7.__bk2d === "bezier" || c7.__bk2d === "bspline") {
|
|
4068
|
+
const points3d = c7.poles.map(([u5, v6]) => lift(u5, v6));
|
|
3908
4069
|
if (points3d.length === 2) return this.makeLineEdge(points3d[0], points3d[1]);
|
|
3909
4070
|
const degree = Math.min(3, points3d.length - 1);
|
|
3910
4071
|
const coords = points3d.flatMap(([px, py, pz]) => [px, py, pz]);
|
|
3911
4072
|
const id = this.bk.interpolatePoints(coords, degree);
|
|
3912
4073
|
return edgeHandle(id);
|
|
3913
4074
|
}
|
|
3914
|
-
const bounds = curveBounds(
|
|
4075
|
+
const bounds = curveBounds(c7);
|
|
3915
4076
|
const nSamples = 100;
|
|
3916
4077
|
const points = [];
|
|
3917
4078
|
for (let i9 = 0; i9 <= nSamples; i9++) {
|
|
3918
|
-
const
|
|
3919
|
-
const [
|
|
3920
|
-
points.push(lift(
|
|
4079
|
+
const t7 = bounds.first + (bounds.last - bounds.first) * i9 / nSamples;
|
|
4080
|
+
const [u5, v6] = evaluateCurve2d(c7, t7);
|
|
4081
|
+
points.push(lift(u5, v6));
|
|
3921
4082
|
}
|
|
3922
4083
|
return this.interpolatePoints(points);
|
|
3923
4084
|
}
|
|
@@ -3925,16 +4086,16 @@ class BrepkitAdapter {
|
|
|
3925
4086
|
if (!isBrepkitHandle(surface))
|
|
3926
4087
|
throw new Error("brepkit: buildEdgeOnSurface requires a face handle as surface");
|
|
3927
4088
|
const fid = unwrap(surface, "face");
|
|
3928
|
-
const
|
|
3929
|
-
const bounds = curveBounds(
|
|
4089
|
+
const c7 = this.c2d(curve);
|
|
4090
|
+
const bounds = curveBounds(c7);
|
|
3930
4091
|
const surfType = this.bk.getSurfaceType(fid);
|
|
3931
4092
|
const N4 = surfType === "plane" ? 50 : 100;
|
|
3932
4093
|
const points = [];
|
|
3933
4094
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
3934
|
-
const
|
|
3935
|
-
const [
|
|
3936
|
-
const
|
|
3937
|
-
points.push([
|
|
4095
|
+
const t7 = bounds.first + (bounds.last - bounds.first) * i9 / N4;
|
|
4096
|
+
const [u5, v6] = evaluateCurve2d(c7, t7);
|
|
4097
|
+
const p7 = this.bk.evaluateSurface(fid, u5, v6);
|
|
4098
|
+
points.push([p7[0], p7[1], p7[2]]);
|
|
3938
4099
|
}
|
|
3939
4100
|
return this.interpolatePoints(points);
|
|
3940
4101
|
}
|
|
@@ -3954,25 +4115,25 @@ class BrepkitAdapter {
|
|
|
3954
4115
|
for (let i9 = 0; i9 <= BASE_N; i9++) {
|
|
3955
4116
|
tValues.push(tMin + (tMax - tMin) * i9 / BASE_N);
|
|
3956
4117
|
}
|
|
3957
|
-
const evaluateUV = (
|
|
3958
|
-
const pt = this.bk.evaluateEdgeCurve(eid,
|
|
4118
|
+
const evaluateUV = (t7) => {
|
|
4119
|
+
const pt = this.bk.evaluateEdgeCurve(eid, t7);
|
|
3959
4120
|
const uv = this.bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
|
|
3960
4121
|
return [uv[0], uv[1]];
|
|
3961
4122
|
};
|
|
3962
|
-
const uvSamples = tValues.map((
|
|
3963
|
-
t:
|
|
3964
|
-
uv: evaluateUV(
|
|
4123
|
+
const uvSamples = tValues.map((t7) => ({
|
|
4124
|
+
t: t7,
|
|
4125
|
+
uv: evaluateUV(t7)
|
|
3965
4126
|
}));
|
|
3966
4127
|
let refinements = 0;
|
|
3967
4128
|
while (uvSamples.length < MAX_N) {
|
|
3968
4129
|
const insertions = [];
|
|
3969
4130
|
for (let i9 = 0; i9 < uvSamples.length - 1; i9++) {
|
|
3970
4131
|
const a9 = uvSamples[i9];
|
|
3971
|
-
const
|
|
3972
|
-
const tMid = (a9.t +
|
|
4132
|
+
const b7 = uvSamples[i9 + 1];
|
|
4133
|
+
const tMid = (a9.t + b7.t) / 2;
|
|
3973
4134
|
const uvMid = evaluateUV(tMid);
|
|
3974
|
-
const interpU = (a9.uv[0] +
|
|
3975
|
-
const interpV = (a9.uv[1] +
|
|
4135
|
+
const interpU = (a9.uv[0] + b7.uv[0]) / 2;
|
|
4136
|
+
const interpV = (a9.uv[1] + b7.uv[1]) / 2;
|
|
3976
4137
|
const deviation = Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2);
|
|
3977
4138
|
if (deviation > REFINE_THRESHOLD) {
|
|
3978
4139
|
insertions.push({ index: i9 + 1, t: tMid, uv: uvMid });
|
|
@@ -3980,15 +4141,15 @@ class BrepkitAdapter {
|
|
|
3980
4141
|
}
|
|
3981
4142
|
if (insertions.length === 0) break;
|
|
3982
4143
|
let budget = MAX_N - uvSamples.length;
|
|
3983
|
-
for (let
|
|
3984
|
-
const ins = insertions[
|
|
4144
|
+
for (let j10 = insertions.length - 1; j10 >= 0 && budget > 0; j10--) {
|
|
4145
|
+
const ins = insertions[j10];
|
|
3985
4146
|
uvSamples.splice(ins.index, 0, { t: ins.t, uv: ins.uv });
|
|
3986
4147
|
budget--;
|
|
3987
4148
|
}
|
|
3988
4149
|
refinements++;
|
|
3989
4150
|
if (refinements > 3) break;
|
|
3990
4151
|
}
|
|
3991
|
-
const uvPoints = uvSamples.map((
|
|
4152
|
+
const uvPoints = uvSamples.map((s5) => s5.uv);
|
|
3992
4153
|
if (uvPoints.length >= 2) {
|
|
3993
4154
|
return this.makeBSpline2d(uvPoints);
|
|
3994
4155
|
}
|
|
@@ -4018,9 +4179,9 @@ class BrepkitAdapter {
|
|
|
4018
4179
|
const N4 = 10;
|
|
4019
4180
|
const pts = [];
|
|
4020
4181
|
for (let i9 = 0; i9 <= N4; i9++) {
|
|
4021
|
-
const
|
|
4022
|
-
const
|
|
4023
|
-
pts.push(
|
|
4182
|
+
const t7 = tMin + (tMax - tMin) * i9 / N4;
|
|
4183
|
+
const p7 = this.bk.evaluateEdgeCurve(edgeId, t7);
|
|
4184
|
+
pts.push(p7[0], p7[1], p7[2]);
|
|
4024
4185
|
}
|
|
4025
4186
|
allCoords.push(...pts);
|
|
4026
4187
|
curveLengths.push(N4 + 1);
|
|
@@ -4041,13 +4202,13 @@ class BrepkitAdapter {
|
|
|
4041
4202
|
// Private helpers
|
|
4042
4203
|
// ═══════════════════════════════════════════════════════════════════════
|
|
4043
4204
|
applyMatrix(shape2, matrix) {
|
|
4044
|
-
const
|
|
4205
|
+
const h7 = shape2;
|
|
4045
4206
|
if (!isBrepkitHandle(shape2)) {
|
|
4046
4207
|
throw new Error("brepkit: applyMatrix requires a BrepkitHandle");
|
|
4047
4208
|
}
|
|
4048
|
-
switch (
|
|
4209
|
+
switch (h7.type) {
|
|
4049
4210
|
case "solid": {
|
|
4050
|
-
const copy = this.bk.copySolid(
|
|
4211
|
+
const copy = this.bk.copySolid(h7.id);
|
|
4051
4212
|
this.bk.transformSolid(copy, matrix);
|
|
4052
4213
|
return solidHandle(copy);
|
|
4053
4214
|
}
|
|
@@ -4057,7 +4218,7 @@ class BrepkitAdapter {
|
|
|
4057
4218
|
"brepkit: applyMatrix for faces requires copyFace/transformFace WASM exports"
|
|
4058
4219
|
);
|
|
4059
4220
|
}
|
|
4060
|
-
const copy = this.bk.copyFace(
|
|
4221
|
+
const copy = this.bk.copyFace(h7.id);
|
|
4061
4222
|
this.bk.transformFace(copy, matrix);
|
|
4062
4223
|
return faceHandle(copy);
|
|
4063
4224
|
}
|
|
@@ -4067,7 +4228,7 @@ class BrepkitAdapter {
|
|
|
4067
4228
|
"brepkit: applyMatrix for wires requires copyWire/transformWire WASM exports"
|
|
4068
4229
|
);
|
|
4069
4230
|
}
|
|
4070
|
-
const copy = this.bk.copyWire(
|
|
4231
|
+
const copy = this.bk.copyWire(h7.id);
|
|
4071
4232
|
this.bk.transformWire(copy, matrix);
|
|
4072
4233
|
return wireHandle(copy);
|
|
4073
4234
|
}
|
|
@@ -4077,12 +4238,12 @@ class BrepkitAdapter {
|
|
|
4077
4238
|
"brepkit: applyMatrix for edges requires copyEdge/transformEdge WASM exports"
|
|
4078
4239
|
);
|
|
4079
4240
|
}
|
|
4080
|
-
const copy = this.bk.copyEdge(
|
|
4241
|
+
const copy = this.bk.copyEdge(h7.id);
|
|
4081
4242
|
this.bk.transformEdge(copy, matrix);
|
|
4082
4243
|
return edgeHandle(copy);
|
|
4083
4244
|
}
|
|
4084
4245
|
default:
|
|
4085
|
-
throw new Error(`brepkit: applyMatrix does not support '${
|
|
4246
|
+
throw new Error(`brepkit: applyMatrix does not support '${h7.type}' shapes`);
|
|
4086
4247
|
}
|
|
4087
4248
|
}
|
|
4088
4249
|
/** Check if we need to transform from default placement (origin, +Z). */
|
|
@@ -4195,8 +4356,8 @@ class BrepkitAdapter {
|
|
|
4195
4356
|
const vertCount = positions.length / 3;
|
|
4196
4357
|
if (vertCount === 0) continue;
|
|
4197
4358
|
const triStart = allTriangles.length;
|
|
4198
|
-
for (const
|
|
4199
|
-
for (const
|
|
4359
|
+
for (const v6 of positions) allVertices.push(v6);
|
|
4360
|
+
for (const n8 of normals) allNormals.push(n8);
|
|
4200
4361
|
for (const idx of indices) {
|
|
4201
4362
|
allTriangles.push(idx + vertexOffset);
|
|
4202
4363
|
}
|
|
@@ -4321,9 +4482,9 @@ class BrepkitAdapter {
|
|
|
4321
4482
|
* Returns {degree, knots, controlPoints, weights} for NURBS edges.
|
|
4322
4483
|
*/
|
|
4323
4484
|
extractNurbsFromEdge(shape2) {
|
|
4324
|
-
const
|
|
4325
|
-
if (
|
|
4326
|
-
const nurbsJson = this.bk.getEdgeNurbsData(
|
|
4485
|
+
const h7 = shape2;
|
|
4486
|
+
if (h7.type !== "edge") return null;
|
|
4487
|
+
const nurbsJson = this.bk.getEdgeNurbsData(h7.id);
|
|
4327
4488
|
if (nurbsJson) {
|
|
4328
4489
|
const data = JSON.parse(nurbsJson);
|
|
4329
4490
|
return {
|
|
@@ -4333,7 +4494,7 @@ class BrepkitAdapter {
|
|
|
4333
4494
|
weights: data.weights
|
|
4334
4495
|
};
|
|
4335
4496
|
}
|
|
4336
|
-
const verts = this.bk.getEdgeVertices(
|
|
4497
|
+
const verts = this.bk.getEdgeVertices(h7.id);
|
|
4337
4498
|
return {
|
|
4338
4499
|
degree: 1,
|
|
4339
4500
|
knots: [0, 0, 1, 1],
|
|
@@ -4425,8 +4586,8 @@ class BrepkitAdapter {
|
|
|
4425
4586
|
*/
|
|
4426
4587
|
extractPlaneFromFace(faceShape) {
|
|
4427
4588
|
let faceId;
|
|
4428
|
-
const
|
|
4429
|
-
if (
|
|
4589
|
+
const h7 = faceShape;
|
|
4590
|
+
if (h7.type === "solid" || h7.type === "compound") {
|
|
4430
4591
|
const faces = this.iterShapes(faceShape, "face");
|
|
4431
4592
|
if (faces.length === 0) throw new Error("brepkit: extractPlaneFromFace: no faces found");
|
|
4432
4593
|
const firstFace = faces[0];
|
|
@@ -4448,8 +4609,8 @@ class BrepkitAdapter {
|
|
|
4448
4609
|
} else {
|
|
4449
4610
|
faceId = unwrap(faceShape, "face");
|
|
4450
4611
|
}
|
|
4451
|
-
const
|
|
4452
|
-
const normal = [
|
|
4612
|
+
const n8 = this.bk.getFaceNormal(faceId);
|
|
4613
|
+
const normal = [n8[0], n8[1], n8[2]];
|
|
4453
4614
|
const mesh2 = this.bk.tessellateFace(faceId, 1);
|
|
4454
4615
|
const positions = mesh2.positions;
|
|
4455
4616
|
if (positions.length >= 3) {
|
|
@@ -4465,8 +4626,8 @@ class BrepkitAdapter {
|
|
|
4465
4626
|
return this.bk.sketchNew();
|
|
4466
4627
|
}
|
|
4467
4628
|
/** Add a point to a constraint sketch. Returns the point index. */
|
|
4468
|
-
sketchAddPoint(sketch,
|
|
4469
|
-
return this.bk.sketchAddPoint(sketch,
|
|
4629
|
+
sketchAddPoint(sketch, x6, y6, fixed) {
|
|
4630
|
+
return this.bk.sketchAddPoint(sketch, x6, y6, fixed);
|
|
4470
4631
|
}
|
|
4471
4632
|
/** Add a constraint to a sketch (JSON-encoded constraint descriptor). */
|
|
4472
4633
|
sketchAddConstraint(sketch, constraintJson) {
|
|
@@ -4683,17 +4844,75 @@ class BrepkitAdapter {
|
|
|
4683
4844
|
return this.bk.executeBatch(json);
|
|
4684
4845
|
}
|
|
4685
4846
|
}
|
|
4686
|
-
function multiplyMatrices(a9,
|
|
4847
|
+
function multiplyMatrices(a9, b7) {
|
|
4687
4848
|
const result = new Array(16).fill(0);
|
|
4688
4849
|
for (let i9 = 0; i9 < 4; i9++) {
|
|
4689
|
-
for (let
|
|
4690
|
-
for (let
|
|
4691
|
-
result[i9 * 4 +
|
|
4850
|
+
for (let j10 = 0; j10 < 4; j10++) {
|
|
4851
|
+
for (let k9 = 0; k9 < 4; k9++) {
|
|
4852
|
+
result[i9 * 4 + j10] = result[i9 * 4 + j10] + a9[i9 * 4 + k9] * b7[k9 * 4 + j10];
|
|
4692
4853
|
}
|
|
4693
4854
|
}
|
|
4694
4855
|
}
|
|
4695
4856
|
return result;
|
|
4696
4857
|
}
|
|
4858
|
+
const kernel_ERROR_PATTERNS = [
|
|
4859
|
+
{
|
|
4860
|
+
pattern: /invalid edge configuration|edges?.*(not|fail|invalid)/i,
|
|
4861
|
+
translation: "The edges may not form a continuous loop. Check that edges connect end-to-end without gaps."
|
|
4862
|
+
},
|
|
4863
|
+
{
|
|
4864
|
+
pattern: /BRepAlgoAPI.*failed|boolean.*operation.*failed/i,
|
|
4865
|
+
translation: "Boolean operation failed. Common causes: overlapping faces, zero-thickness geometry, or degenerate shapes. Try healing input shapes first."
|
|
4866
|
+
},
|
|
4867
|
+
{
|
|
4868
|
+
pattern: /fillet.*radius.*too.*large|fillet.*failed/i,
|
|
4869
|
+
translation: "Fillet operation failed. The radius may be too large for the selected edges. Try reducing the radius or check that edges have enough room."
|
|
4870
|
+
},
|
|
4871
|
+
{
|
|
4872
|
+
pattern: /chamfer.*failed|chamfer.*distance.*too.*large/i,
|
|
4873
|
+
translation: "Chamfer operation failed. The distance may be too large for the selected edges. Try reducing the distance or check edge geometry."
|
|
4874
|
+
},
|
|
4875
|
+
{
|
|
4876
|
+
pattern: /shell.*failed|offset.*failed/i,
|
|
4877
|
+
translation: "Shell/offset operation failed. The thickness may be too large, or the shape may have complex geometry. Try reducing thickness."
|
|
4878
|
+
},
|
|
4879
|
+
{
|
|
4880
|
+
pattern: /sweep.*failed|pipe.*failed/i,
|
|
4881
|
+
translation: "Sweep operation failed. Check that the profile and spine are compatible, and that the spine has no sharp twists or self-intersections."
|
|
4882
|
+
},
|
|
4883
|
+
{
|
|
4884
|
+
pattern: /loft.*failed/i,
|
|
4885
|
+
translation: "Loft operation failed. Profiles may be incompatible or have different orientations. Ensure profiles are ordered consistently."
|
|
4886
|
+
},
|
|
4887
|
+
{
|
|
4888
|
+
pattern: /extrude.*failed|prism.*failed/i,
|
|
4889
|
+
translation: "Extrusion failed. The profile may be invalid or self-intersecting. Check that the profile forms a valid closed wire."
|
|
4890
|
+
},
|
|
4891
|
+
{
|
|
4892
|
+
pattern: /revolve.*failed|revolution.*failed/i,
|
|
4893
|
+
translation: "Revolution operation failed. The profile may intersect the axis of revolution, or the angle may be invalid."
|
|
4894
|
+
},
|
|
4895
|
+
{
|
|
4896
|
+
pattern: /self.*intersect|self-intersect/i,
|
|
4897
|
+
translation: "Shape has self-intersections. The operation resulted in overlapping geometry. Simplify the input or adjust parameters."
|
|
4898
|
+
},
|
|
4899
|
+
{
|
|
4900
|
+
pattern: /degener|degenerat/i,
|
|
4901
|
+
translation: "Degenerate geometry detected. The shape has edges or faces with zero length/area. Check input geometry for collapsed elements."
|
|
4902
|
+
},
|
|
4903
|
+
{
|
|
4904
|
+
pattern: /BRepCheck.*fail|shape.*invalid|shape.*not.*valid/i,
|
|
4905
|
+
translation: "Shape validation failed. The resulting shape has invalid topology. Try healing the shape or checking input geometry."
|
|
4906
|
+
}
|
|
4907
|
+
];
|
|
4908
|
+
function translateKernelError(kernelMessage) {
|
|
4909
|
+
for (const { pattern, translation } of kernel_ERROR_PATTERNS) {
|
|
4910
|
+
if (pattern.test(kernelMessage)) {
|
|
4911
|
+
return `${translation} (kernel: ${kernelMessage})`;
|
|
4912
|
+
}
|
|
4913
|
+
}
|
|
4914
|
+
return kernelMessage;
|
|
4915
|
+
}
|
|
4697
4916
|
const errorFactories = {
|
|
4698
4917
|
KERNEL_OPERATION: (code, message, cause) => ({ kind: "KERNEL_OPERATION", code, message, cause }),
|
|
4699
4918
|
VALIDATION: (code, message, cause) => ({ kind: "VALIDATION", code, message, cause }),
|
|
@@ -4736,32 +4955,6 @@ function kernelCallScoped(fn, code, message, kind = "KERNEL_OPERATION") {
|
|
|
4736
4955
|
__callDispose(_stack, _error, _hasError);
|
|
4737
4956
|
}
|
|
4738
4957
|
}
|
|
4739
|
-
const CURVE_TYPE_BY_INT = [
|
|
4740
|
-
"LINE",
|
|
4741
|
-
// 0
|
|
4742
|
-
"CIRCLE",
|
|
4743
|
-
// 1
|
|
4744
|
-
"ELLIPSE",
|
|
4745
|
-
// 2
|
|
4746
|
-
"HYPERBOLA",
|
|
4747
|
-
// 3
|
|
4748
|
-
"PARABOLA",
|
|
4749
|
-
// 4
|
|
4750
|
-
"BEZIER_CURVE",
|
|
4751
|
-
// 5
|
|
4752
|
-
"BSPLINE_CURVE",
|
|
4753
|
-
// 6
|
|
4754
|
-
"OFFSET_CURVE",
|
|
4755
|
-
// 7
|
|
4756
|
-
"OTHER_CURVE"
|
|
4757
|
-
// 8
|
|
4758
|
-
];
|
|
4759
|
-
const findCurveType = (type) => {
|
|
4760
|
-
const idx = typeof type === "number" ? type : Number(type?.value ?? type);
|
|
4761
|
-
const curveType = CURVE_TYPE_BY_INT[idx];
|
|
4762
|
-
if (!curveType) return err(typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
4763
|
-
return ok(curveType);
|
|
4764
|
-
};
|
|
4765
4958
|
const BOPAlgo_GlueShift = 1;
|
|
4766
4959
|
const BOPAlgo_GlueFull = 2;
|
|
4767
4960
|
function applyGlue(op, optimisation) {
|
|
@@ -4790,27 +4983,6 @@ function isFilletRadius(r9) {
|
|
|
4790
4983
|
}
|
|
4791
4984
|
return false;
|
|
4792
4985
|
}
|
|
4793
|
-
function buildWireFinder(filters) {
|
|
4794
|
-
return createTypedFinder(
|
|
4795
|
-
"wire",
|
|
4796
|
-
filters,
|
|
4797
|
-
buildWireFinder,
|
|
4798
|
-
(_base, withFilter) => ({
|
|
4799
|
-
isClosed: () => withFilter((wire) => curveIsClosed(wire)),
|
|
4800
|
-
isOpen: () => withFilter((wire) => !curveIsClosed(wire)),
|
|
4801
|
-
ofEdgeCount: (count) => withFilter((wire) => {
|
|
4802
|
-
let edgeCount = 0;
|
|
4803
|
-
for (const _raw of iterTopo(wire.wrapped, "edge")) {
|
|
4804
|
-
edgeCount++;
|
|
4805
|
-
}
|
|
4806
|
-
return edgeCount === count;
|
|
4807
|
-
})
|
|
4808
|
-
})
|
|
4809
|
-
);
|
|
4810
|
-
}
|
|
4811
|
-
function wireFinder() {
|
|
4812
|
-
return buildWireFinder([]);
|
|
4813
|
-
}
|
|
4814
4986
|
function withNearestPostFilter(baseFinder, nearestPoint) {
|
|
4815
4987
|
const findAllNearest = (shape2) => {
|
|
4816
4988
|
const candidates = baseFinder.findAll(shape2);
|
|
@@ -4863,14 +5035,14 @@ function buildVertexFinder(filters) {
|
|
|
4863
5035
|
function vertexFinder() {
|
|
4864
5036
|
return buildVertexFinder([]);
|
|
4865
5037
|
}
|
|
4866
|
-
function toKernelVec(
|
|
4867
|
-
return getKernel().createVector3d(
|
|
5038
|
+
function toKernelVec(v6) {
|
|
5039
|
+
return getKernel().createVector3d(v6[0], v6[1], v6[2]);
|
|
4868
5040
|
}
|
|
4869
|
-
function toKernelPnt(
|
|
4870
|
-
return getKernel().createPoint3d(
|
|
5041
|
+
function toKernelPnt(v6) {
|
|
5042
|
+
return getKernel().createPoint3d(v6[0], v6[1], v6[2]);
|
|
4871
5043
|
}
|
|
4872
|
-
function toKernelDir(
|
|
4873
|
-
return getKernel().createDirection3d(
|
|
5044
|
+
function toKernelDir(v6) {
|
|
5045
|
+
return getKernel().createDirection3d(v6[0], v6[1], v6[2]);
|
|
4874
5046
|
}
|
|
4875
5047
|
function fromKernelVec(ocVec) {
|
|
4876
5048
|
return [ocVec.X(), ocVec.Y(), ocVec.Z()];
|
|
@@ -4881,24 +5053,24 @@ function fromKernelPnt(ocPnt) {
|
|
|
4881
5053
|
function fromKernelDir(ocDir) {
|
|
4882
5054
|
return [ocDir.X(), ocDir.Y(), ocDir.Z()];
|
|
4883
5055
|
}
|
|
4884
|
-
function withKernelVec(
|
|
4885
|
-
const ocVec = toKernelVec(
|
|
5056
|
+
function withKernelVec(v6, fn) {
|
|
5057
|
+
const ocVec = toKernelVec(v6);
|
|
4886
5058
|
try {
|
|
4887
5059
|
return fn(ocVec);
|
|
4888
5060
|
} finally {
|
|
4889
5061
|
ocVec.delete();
|
|
4890
5062
|
}
|
|
4891
5063
|
}
|
|
4892
|
-
function withKernelPnt(
|
|
4893
|
-
const ocPnt = toKernelPnt(
|
|
5064
|
+
function withKernelPnt(v6, fn) {
|
|
5065
|
+
const ocPnt = toKernelPnt(v6);
|
|
4894
5066
|
try {
|
|
4895
5067
|
return fn(ocPnt);
|
|
4896
5068
|
} finally {
|
|
4897
5069
|
ocPnt.delete();
|
|
4898
5070
|
}
|
|
4899
5071
|
}
|
|
4900
|
-
function withKernelDir(
|
|
4901
|
-
const ocDir = toKernelDir(
|
|
5072
|
+
function withKernelDir(v6, fn) {
|
|
5073
|
+
const ocDir = toKernelDir(v6);
|
|
4902
5074
|
try {
|
|
4903
5075
|
return fn(ocDir);
|
|
4904
5076
|
} finally {
|
|
@@ -4955,10 +5127,10 @@ function surfaceFromGrid(heights, options = {}) {
|
|
|
4955
5127
|
function buildBSplineSurface(heights, rows, cols, dx, dy, scaleZ) {
|
|
4956
5128
|
const points = [];
|
|
4957
5129
|
for (let r9 = 0; r9 < rows; r9++) {
|
|
4958
|
-
for (let
|
|
5130
|
+
for (let c7 = 0; c7 < cols; c7++) {
|
|
4959
5131
|
const row = heights[r9];
|
|
4960
|
-
const z6 = (row ? row[
|
|
4961
|
-
points.push([
|
|
5132
|
+
const z6 = (row ? row[c7] ?? 0 : 0) * scaleZ;
|
|
5133
|
+
points.push([c7 * dx, r9 * dy, z6]);
|
|
4962
5134
|
}
|
|
4963
5135
|
}
|
|
4964
5136
|
const faceShape = getKernel().bsplineSurface(points, rows, cols);
|
|
@@ -4972,10 +5144,10 @@ function buildBSplineSurface(heights, rows, cols, dx, dy, scaleZ) {
|
|
|
4972
5144
|
function buildTriangulatedSurface(heights, rows, cols, dx, dy, scaleZ) {
|
|
4973
5145
|
const points = [];
|
|
4974
5146
|
for (let r9 = 0; r9 < rows; r9++) {
|
|
4975
|
-
for (let
|
|
5147
|
+
for (let c7 = 0; c7 < cols; c7++) {
|
|
4976
5148
|
const row = heights[r9];
|
|
4977
|
-
const z6 = (row ? row[
|
|
4978
|
-
points.push([
|
|
5149
|
+
const z6 = (row ? row[c7] ?? 0 : 0) * scaleZ;
|
|
5150
|
+
points.push([c7 * dx, r9 * dy, z6]);
|
|
4979
5151
|
}
|
|
4980
5152
|
}
|
|
4981
5153
|
const resultShape = getKernel().triangulatedSurface(points, rows, cols);
|
|
@@ -5014,13 +5186,13 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
5014
5186
|
);
|
|
5015
5187
|
}
|
|
5016
5188
|
const w7 = bitmap.width;
|
|
5017
|
-
const
|
|
5018
|
-
if (w7 < 2 ||
|
|
5189
|
+
const h7 = bitmap.height;
|
|
5190
|
+
if (w7 < 2 || h7 < 2) {
|
|
5019
5191
|
bitmap.close();
|
|
5020
5192
|
return err(
|
|
5021
5193
|
validationError(
|
|
5022
5194
|
BrepErrorCode.SURFACE_GRID_TOO_SMALL,
|
|
5023
|
-
`surfaceFromImage: image too small (${w7}x${
|
|
5195
|
+
`surfaceFromImage: image too small (${w7}x${h7}), need at least 2x2`
|
|
5024
5196
|
)
|
|
5025
5197
|
);
|
|
5026
5198
|
}
|
|
@@ -5033,7 +5205,7 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
5033
5205
|
)
|
|
5034
5206
|
);
|
|
5035
5207
|
}
|
|
5036
|
-
const canvas = new OffscreenCanvas(w7,
|
|
5208
|
+
const canvas = new OffscreenCanvas(w7, h7);
|
|
5037
5209
|
const ctx = canvas.getContext("2d");
|
|
5038
5210
|
if (!ctx) {
|
|
5039
5211
|
bitmap.close();
|
|
@@ -5043,29 +5215,29 @@ async function surfaceFromImage(blob, options = {}) {
|
|
|
5043
5215
|
}
|
|
5044
5216
|
ctx.drawImage(bitmap, 0, 0);
|
|
5045
5217
|
bitmap.close();
|
|
5046
|
-
const imageData = ctx.getImageData(0, 0, w7,
|
|
5218
|
+
const imageData = ctx.getImageData(0, 0, w7, h7);
|
|
5047
5219
|
const data = imageData.data;
|
|
5048
5220
|
const rows = [];
|
|
5049
|
-
for (let
|
|
5221
|
+
for (let y6 = 0; y6 < h7; y6 += downsample) {
|
|
5050
5222
|
const row = [];
|
|
5051
|
-
for (let
|
|
5052
|
-
const idx = (
|
|
5223
|
+
for (let x6 = 0; x6 < w7; x6 += downsample) {
|
|
5224
|
+
const idx = (y6 * w7 + x6) * 4;
|
|
5053
5225
|
const r9 = data[idx] ?? 0;
|
|
5054
|
-
const
|
|
5055
|
-
const
|
|
5226
|
+
const g11 = data[idx + 1] ?? 0;
|
|
5227
|
+
const b7 = data[idx + 2] ?? 0;
|
|
5056
5228
|
let value;
|
|
5057
5229
|
switch (channel) {
|
|
5058
5230
|
case "r":
|
|
5059
5231
|
value = r9 / 255;
|
|
5060
5232
|
break;
|
|
5061
5233
|
case "g":
|
|
5062
|
-
value =
|
|
5234
|
+
value = g11 / 255;
|
|
5063
5235
|
break;
|
|
5064
5236
|
case "b":
|
|
5065
|
-
value =
|
|
5237
|
+
value = b7 / 255;
|
|
5066
5238
|
break;
|
|
5067
5239
|
default:
|
|
5068
|
-
value = (REC601_R * r9 + REC601_G *
|
|
5240
|
+
value = (REC601_R * r9 + REC601_G * g11 + REC601_B * b7) / 255;
|
|
5069
5241
|
break;
|
|
5070
5242
|
}
|
|
5071
5243
|
row.push(value);
|
|
@@ -5103,7 +5275,7 @@ function hull(shapes, options = {}) {
|
|
|
5103
5275
|
const tolerance = options.tolerance ?? 0.1;
|
|
5104
5276
|
try {
|
|
5105
5277
|
const kernel = getKernel();
|
|
5106
|
-
const ocShapes = shapes.map((
|
|
5278
|
+
const ocShapes = shapes.map((s5) => s5.wrapped);
|
|
5107
5279
|
const resultOc = kernel.hull(ocShapes, tolerance);
|
|
5108
5280
|
const cast = castShape(resultOc);
|
|
5109
5281
|
if (!isSolid(cast)) {
|
|
@@ -5259,7 +5431,7 @@ function polyhedron(points, faces, options = {}) {
|
|
|
5259
5431
|
}
|
|
5260
5432
|
try {
|
|
5261
5433
|
const kernel = getKernel();
|
|
5262
|
-
const ptObjs = points.map(([
|
|
5434
|
+
const ptObjs = points.map(([x6, y6, z6]) => ({ x: x6, y: y6, z: z6 }));
|
|
5263
5435
|
const resultOc = kernel.buildSolidFromFaces(ptObjs, triangles, tolerance);
|
|
5264
5436
|
const cast = castShape(resultOc);
|
|
5265
5437
|
if (!isSolid(cast)) {
|
|
@@ -5274,94 +5446,41 @@ function polyhedron(points, faces, options = {}) {
|
|
|
5274
5446
|
return err(kernelError(BrepErrorCode.POLYHEDRON_FAILED, `Polyhedron failed: ${raw}`, e8));
|
|
5275
5447
|
}
|
|
5276
5448
|
}
|
|
5277
|
-
function
|
|
5278
|
-
if (
|
|
5279
|
-
return err(
|
|
5280
|
-
validationError(
|
|
5281
|
-
BrepErrorCode.MULTI_SWEEP_INSUFFICIENT_SECTIONS,
|
|
5282
|
-
`Multi-section sweep requires at least 2 sections, got ${sections.length}`
|
|
5283
|
-
)
|
|
5284
|
-
);
|
|
5449
|
+
function extrude$1(face, extrusionVec) {
|
|
5450
|
+
if (getKernel().isNull(face.wrapped)) {
|
|
5451
|
+
return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "extrude: face is a null shape"));
|
|
5285
5452
|
}
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
for (let i9 = 0; i9 < explicitLocations.length; i9++) {
|
|
5289
|
-
const loc = explicitLocations[i9];
|
|
5290
|
-
if (loc !== void 0 && (loc < 0 || loc > 1)) {
|
|
5291
|
-
return err(
|
|
5292
|
-
validationError(
|
|
5293
|
-
BrepErrorCode.MULTI_SWEEP_FAILED,
|
|
5294
|
-
`Section ${i9} location ${loc} is out of range [0, 1]`
|
|
5295
|
-
)
|
|
5296
|
-
);
|
|
5297
|
-
}
|
|
5298
|
-
}
|
|
5299
|
-
const definedLocs = explicitLocations.filter((l10) => l10 !== void 0);
|
|
5300
|
-
for (let i9 = 1; i9 < definedLocs.length; i9++) {
|
|
5301
|
-
if ((definedLocs[i9] ?? 0) <= (definedLocs[i9 - 1] ?? 0)) {
|
|
5302
|
-
return err(
|
|
5303
|
-
validationError(
|
|
5304
|
-
BrepErrorCode.MULTI_SWEEP_FAILED,
|
|
5305
|
-
"Section locations must be strictly increasing"
|
|
5306
|
-
)
|
|
5307
|
-
);
|
|
5308
|
-
}
|
|
5453
|
+
if (vecLength(extrusionVec) === 0) {
|
|
5454
|
+
return err(validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
|
|
5309
5455
|
}
|
|
5310
5456
|
try {
|
|
5311
5457
|
const kernel = getKernel();
|
|
5312
|
-
const
|
|
5313
|
-
const
|
|
5314
|
-
const
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
return uFirst + i9 / (sections.length - 1) * uRange;
|
|
5319
|
-
});
|
|
5320
|
-
const positionedWires = [];
|
|
5321
|
-
for (let i9 = 0; i9 < sections.length; i9++) {
|
|
5322
|
-
const param = params[i9];
|
|
5323
|
-
const section2 = sections[i9];
|
|
5324
|
-
if (param === void 0 || section2 === void 0) continue;
|
|
5325
|
-
const positioned = kernel.positionOnCurve(section2.wire.wrapped, spine.wrapped, param);
|
|
5326
|
-
positionedWires.push(kernel.downcast(positioned, "wire"));
|
|
5327
|
-
}
|
|
5328
|
-
const loftResult = kernel.loftAdvanced(positionedWires, { solid, ruled, tolerance });
|
|
5329
|
-
const result = castShape(loftResult);
|
|
5330
|
-
if (!isShape3D(result)) {
|
|
5331
|
-
return err(
|
|
5332
|
-
typeCastError("MULTI_SWEEP_NOT_3D", "Multi-section sweep did not produce a 3D shape")
|
|
5333
|
-
);
|
|
5334
|
-
}
|
|
5335
|
-
return ok(result);
|
|
5458
|
+
const len = vecLength(extrusionVec);
|
|
5459
|
+
const dir = vecNormalize(extrusionVec);
|
|
5460
|
+
const shape2 = kernel.extrude(face.wrapped, [...dir], len);
|
|
5461
|
+
const downcastShape = kernel.downcast(shape2, "solid");
|
|
5462
|
+
const solid = createSolid(downcastShape);
|
|
5463
|
+
return ok(solid);
|
|
5336
5464
|
} catch (e8) {
|
|
5337
|
-
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
5338
5465
|
return err(
|
|
5339
|
-
kernelError(
|
|
5466
|
+
kernelError("EXTRUDE_FAILED", "Extrusion operation failed", e8, {
|
|
5467
|
+
operation: "extrude",
|
|
5468
|
+
vectorLength: vecLength(extrusionVec)
|
|
5469
|
+
})
|
|
5340
5470
|
);
|
|
5341
5471
|
}
|
|
5342
5472
|
}
|
|
5343
|
-
function
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
const kernel = getKernel();
|
|
5347
|
-
const shellMode = !solid;
|
|
5348
|
-
const auxiliary = guides.length > 0 ? guides[0]?.wrapped : void 0;
|
|
5349
|
-
const sweepResult = kernel.sweepPipeShell(profile.wrapped, spine.wrapped, {
|
|
5350
|
-
transitionMode: transition,
|
|
5351
|
-
...auxiliary ? { auxiliary } : {},
|
|
5352
|
-
shellMode,
|
|
5353
|
-
...tolerance !== void 0 ? { tolerance, boundTolerance: tolerance } : {}
|
|
5354
|
-
});
|
|
5355
|
-
const ocShape = typeof sweepResult === "object" && "shape" in sweepResult ? sweepResult.shape : sweepResult;
|
|
5356
|
-
const result = castShape(ocShape);
|
|
5357
|
-
if (!isShape3D(result)) {
|
|
5358
|
-
return err(typeCastError("GUIDED_SWEEP_NOT_3D", "Guided sweep did not produce a 3D shape"));
|
|
5359
|
-
}
|
|
5360
|
-
return ok(result);
|
|
5361
|
-
} catch (e8) {
|
|
5362
|
-
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
5363
|
-
return err(kernelError(BrepErrorCode.GUIDED_SWEEP_FAILED, `Guided sweep failed: ${raw}`, e8));
|
|
5473
|
+
function revolve$1(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
|
|
5474
|
+
if (getKernel().isNull(face.wrapped)) {
|
|
5475
|
+
return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
|
|
5364
5476
|
}
|
|
5477
|
+
const kernel = getKernel();
|
|
5478
|
+
const shape2 = kernel.revolveVec(face.wrapped, [...center], [...direction], angle);
|
|
5479
|
+
const result = castShape(shape2);
|
|
5480
|
+
if (!isShape3D(result)) {
|
|
5481
|
+
return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
5482
|
+
}
|
|
5483
|
+
return ok(result);
|
|
5365
5484
|
}
|
|
5366
5485
|
const EPS = 1e-10;
|
|
5367
5486
|
function cross2(ax, ay, bx, by) {
|
|
@@ -5370,13 +5489,13 @@ function cross2(ax, ay, bx, by) {
|
|
|
5370
5489
|
function dot2(ax, ay, bx, by) {
|
|
5371
5490
|
return ax * bx + ay * by;
|
|
5372
5491
|
}
|
|
5373
|
-
function len2(
|
|
5374
|
-
return Math.sqrt(
|
|
5492
|
+
function len2(x6, y6) {
|
|
5493
|
+
return Math.sqrt(x6 * x6 + y6 * y6);
|
|
5375
5494
|
}
|
|
5376
5495
|
function polyAt(poly, i9) {
|
|
5377
|
-
const
|
|
5378
|
-
if (!
|
|
5379
|
-
return
|
|
5496
|
+
const p7 = poly[(i9 % poly.length + poly.length) % poly.length];
|
|
5497
|
+
if (!p7) throw new Error(`Invalid polygon index ${i9} for length ${poly.length}`);
|
|
5498
|
+
return p7;
|
|
5380
5499
|
}
|
|
5381
5500
|
function ensureCCW(poly) {
|
|
5382
5501
|
let area = 0;
|
|
@@ -5421,13 +5540,13 @@ function isLavNodeReflex(node) {
|
|
|
5421
5540
|
return cross2(node.x - prev.x, node.y - prev.y, next.x - node.x, next.y - node.y) < -EPS;
|
|
5422
5541
|
}
|
|
5423
5542
|
function createLav(poly) {
|
|
5424
|
-
const nodes = poly.map((
|
|
5425
|
-
const
|
|
5543
|
+
const nodes = poly.map((p7, i9) => {
|
|
5544
|
+
const b7 = bisector(poly, i9);
|
|
5426
5545
|
return {
|
|
5427
|
-
x:
|
|
5428
|
-
y:
|
|
5429
|
-
bx:
|
|
5430
|
-
by:
|
|
5546
|
+
x: p7.x,
|
|
5547
|
+
y: p7.y,
|
|
5548
|
+
bx: b7.dx,
|
|
5549
|
+
by: b7.dy,
|
|
5431
5550
|
origIdx: i9,
|
|
5432
5551
|
prev: null,
|
|
5433
5552
|
next: null,
|
|
@@ -5455,26 +5574,26 @@ function lavSize(start) {
|
|
|
5455
5574
|
}
|
|
5456
5575
|
return count;
|
|
5457
5576
|
}
|
|
5458
|
-
function bisectorIntersectTime(a9,
|
|
5459
|
-
const ddx = a9.bx -
|
|
5460
|
-
const ddy = a9.by -
|
|
5461
|
-
const dxp =
|
|
5462
|
-
const dyp =
|
|
5577
|
+
function bisectorIntersectTime(a9, b7) {
|
|
5578
|
+
const ddx = a9.bx - b7.bx;
|
|
5579
|
+
const ddy = a9.by - b7.by;
|
|
5580
|
+
const dxp = b7.x - a9.x;
|
|
5581
|
+
const dyp = b7.y - a9.y;
|
|
5463
5582
|
if (Math.abs(ddx) < EPS && Math.abs(ddy) < EPS) return null;
|
|
5464
|
-
let
|
|
5583
|
+
let t7;
|
|
5465
5584
|
if (Math.abs(ddx) > Math.abs(ddy)) {
|
|
5466
|
-
|
|
5585
|
+
t7 = dxp / ddx;
|
|
5467
5586
|
} else {
|
|
5468
|
-
|
|
5587
|
+
t7 = dyp / ddy;
|
|
5469
5588
|
}
|
|
5470
|
-
if (
|
|
5589
|
+
if (t7 < EPS) return null;
|
|
5471
5590
|
const otherDd = Math.abs(ddx) > Math.abs(ddy) ? ddy : ddx;
|
|
5472
5591
|
const otherDp = Math.abs(ddx) > Math.abs(ddy) ? dyp : dxp;
|
|
5473
5592
|
if (Math.abs(otherDd) > EPS) {
|
|
5474
5593
|
const t22 = otherDp / otherDd;
|
|
5475
|
-
if (Math.abs(
|
|
5594
|
+
if (Math.abs(t7 - t22) > 1e-4 * Math.max(1, Math.abs(t7))) return null;
|
|
5476
5595
|
}
|
|
5477
|
-
return
|
|
5596
|
+
return t7;
|
|
5478
5597
|
}
|
|
5479
5598
|
function raySplitTime(node, eA, eB) {
|
|
5480
5599
|
const edx = eB.x - eA.x;
|
|
@@ -5488,31 +5607,31 @@ function raySplitTime(node, eA, eB) {
|
|
|
5488
5607
|
const relBy = node.by - (eA.by + eB.by) / 2;
|
|
5489
5608
|
const dRate = relBx * enx + relBy * eny;
|
|
5490
5609
|
if (Math.abs(dRate) < EPS) return null;
|
|
5491
|
-
const
|
|
5492
|
-
if (
|
|
5493
|
-
const px = node.x +
|
|
5494
|
-
const py = node.y +
|
|
5495
|
-
const ax = eA.x +
|
|
5496
|
-
const ay = eA.y +
|
|
5497
|
-
const bxx = eB.x +
|
|
5498
|
-
const byy = eB.y +
|
|
5610
|
+
const t7 = -d0 / dRate;
|
|
5611
|
+
if (t7 < EPS) return null;
|
|
5612
|
+
const px = node.x + t7 * node.bx;
|
|
5613
|
+
const py = node.y + t7 * node.by;
|
|
5614
|
+
const ax = eA.x + t7 * eA.bx;
|
|
5615
|
+
const ay = eA.y + t7 * eA.by;
|
|
5616
|
+
const bxx = eB.x + t7 * eB.bx;
|
|
5617
|
+
const byy = eB.y + t7 * eB.by;
|
|
5499
5618
|
const segDx = bxx - ax;
|
|
5500
5619
|
const segDy = byy - ay;
|
|
5501
5620
|
const segL = len2(segDx, segDy);
|
|
5502
|
-
if (segL < EPS) return
|
|
5503
|
-
const
|
|
5504
|
-
if (
|
|
5505
|
-
return
|
|
5621
|
+
if (segL < EPS) return t7;
|
|
5622
|
+
const s5 = dot2(px - ax, py - ay, segDx, segDy) / (segL * segL);
|
|
5623
|
+
if (s5 < -0.01 || s5 > 1.01) return null;
|
|
5624
|
+
return t7;
|
|
5506
5625
|
}
|
|
5507
5626
|
function computeEvents(lavNodes) {
|
|
5508
5627
|
const events = [];
|
|
5509
5628
|
for (const node of lavNodes) {
|
|
5510
5629
|
if (!node.active) continue;
|
|
5511
|
-
const
|
|
5512
|
-
if (
|
|
5513
|
-
const
|
|
5514
|
-
const
|
|
5515
|
-
events.push({ time:
|
|
5630
|
+
const t7 = bisectorIntersectTime(node, node.next);
|
|
5631
|
+
if (t7 !== null && t7 > EPS) {
|
|
5632
|
+
const x6 = node.x + t7 * node.bx;
|
|
5633
|
+
const y6 = node.y + t7 * node.by;
|
|
5634
|
+
events.push({ time: t7, x: x6, y: y6, nodeA: node, nodeB: node.next, type: "edge" });
|
|
5516
5635
|
}
|
|
5517
5636
|
if (isLavNodeReflex(node)) {
|
|
5518
5637
|
let cur = node.next.next;
|
|
@@ -5520,16 +5639,16 @@ function computeEvents(lavNodes) {
|
|
|
5520
5639
|
while (cur !== node.prev && cur !== node && count < 1e3) {
|
|
5521
5640
|
const st = raySplitTime(node, cur, cur.next);
|
|
5522
5641
|
if (st !== null && st > EPS) {
|
|
5523
|
-
const
|
|
5524
|
-
const
|
|
5525
|
-
events.push({ time: st, x:
|
|
5642
|
+
const x6 = node.x + st * node.bx;
|
|
5643
|
+
const y6 = node.y + st * node.by;
|
|
5644
|
+
events.push({ time: st, x: x6, y: y6, nodeA: node, nodeB: cur, type: "split" });
|
|
5526
5645
|
}
|
|
5527
5646
|
cur = cur.next;
|
|
5528
5647
|
count++;
|
|
5529
5648
|
}
|
|
5530
5649
|
}
|
|
5531
5650
|
}
|
|
5532
|
-
events.sort((a9,
|
|
5651
|
+
events.sort((a9, b7) => a9.time - b7.time);
|
|
5533
5652
|
return events;
|
|
5534
5653
|
}
|
|
5535
5654
|
function computeStraightSkeleton(polygon) {
|
|
@@ -5537,12 +5656,12 @@ function computeStraightSkeleton(polygon) {
|
|
|
5537
5656
|
return { nodes: [], faces: [] };
|
|
5538
5657
|
}
|
|
5539
5658
|
const poly = ensureCCW(polygon);
|
|
5540
|
-
const
|
|
5659
|
+
const n8 = poly.length;
|
|
5541
5660
|
const skeletonNodes = [];
|
|
5542
|
-
const vertexToSkelNodes = Array.from({ length:
|
|
5661
|
+
const vertexToSkelNodes = Array.from({ length: n8 }, () => []);
|
|
5543
5662
|
const lavNodes = createLav(poly);
|
|
5544
5663
|
let iterations = 0;
|
|
5545
|
-
const maxIter =
|
|
5664
|
+
const maxIter = n8 * n8 * 2;
|
|
5546
5665
|
while (iterations < maxIter) {
|
|
5547
5666
|
iterations++;
|
|
5548
5667
|
const activeStart = lavNodes.find((nd) => nd.active);
|
|
@@ -5551,23 +5670,23 @@ function computeStraightSkeleton(polygon) {
|
|
|
5551
5670
|
if (sz <= 3) {
|
|
5552
5671
|
if (sz === 3) {
|
|
5553
5672
|
const a9 = activeStart;
|
|
5554
|
-
const
|
|
5555
|
-
const
|
|
5556
|
-
const
|
|
5557
|
-
const time =
|
|
5558
|
-
const mx = (a9.x +
|
|
5559
|
-
const my = (a9.y +
|
|
5673
|
+
const b7 = a9.next;
|
|
5674
|
+
const c7 = b7.next;
|
|
5675
|
+
const t7 = bisectorIntersectTime(a9, b7);
|
|
5676
|
+
const time = t7 !== null && t7 > EPS ? t7 : 0;
|
|
5677
|
+
const mx = (a9.x + b7.x + c7.x) / 3 + time * (a9.bx + b7.bx + c7.bx) / 3;
|
|
5678
|
+
const my = (a9.y + b7.y + c7.y) / 3 + time * (a9.by + b7.by + c7.by) / 3;
|
|
5560
5679
|
const nodeIdx = skeletonNodes.length;
|
|
5561
5680
|
skeletonNodes.push({ x: mx, y: my, height: time });
|
|
5562
5681
|
const aNodes = vertexToSkelNodes[a9.origIdx];
|
|
5563
|
-
const bNodes = vertexToSkelNodes[
|
|
5564
|
-
const cNodes = vertexToSkelNodes[
|
|
5682
|
+
const bNodes = vertexToSkelNodes[b7.origIdx];
|
|
5683
|
+
const cNodes = vertexToSkelNodes[c7.origIdx];
|
|
5565
5684
|
if (aNodes) aNodes.push(nodeIdx);
|
|
5566
5685
|
if (bNodes) bNodes.push(nodeIdx);
|
|
5567
5686
|
if (cNodes) cNodes.push(nodeIdx);
|
|
5568
5687
|
a9.active = false;
|
|
5569
|
-
|
|
5570
|
-
|
|
5688
|
+
b7.active = false;
|
|
5689
|
+
c7.active = false;
|
|
5571
5690
|
} else {
|
|
5572
5691
|
let cur = activeStart;
|
|
5573
5692
|
for (let i9 = 0; i9 < sz; i9++) {
|
|
@@ -5589,19 +5708,19 @@ function computeStraightSkeleton(polygon) {
|
|
|
5589
5708
|
if (!ev) break;
|
|
5590
5709
|
if (ev.type === "edge") {
|
|
5591
5710
|
const a9 = ev.nodeA;
|
|
5592
|
-
const
|
|
5593
|
-
if (!a9.active || !
|
|
5711
|
+
const b7 = ev.nodeB;
|
|
5712
|
+
if (!a9.active || !b7.active) continue;
|
|
5594
5713
|
const nodeIdx = skeletonNodes.length;
|
|
5595
5714
|
skeletonNodes.push({ x: ev.x, y: ev.y, height: ev.time });
|
|
5596
5715
|
const aNodes = vertexToSkelNodes[a9.origIdx];
|
|
5597
|
-
const bNodes = vertexToSkelNodes[
|
|
5716
|
+
const bNodes = vertexToSkelNodes[b7.origIdx];
|
|
5598
5717
|
if (aNodes) aNodes.push(nodeIdx);
|
|
5599
5718
|
if (bNodes) bNodes.push(nodeIdx);
|
|
5600
5719
|
a9.x = ev.x;
|
|
5601
5720
|
a9.y = ev.y;
|
|
5602
|
-
a9.next =
|
|
5603
|
-
|
|
5604
|
-
|
|
5721
|
+
a9.next = b7.next;
|
|
5722
|
+
b7.next.prev = a9;
|
|
5723
|
+
b7.active = false;
|
|
5605
5724
|
const lavPoly = [];
|
|
5606
5725
|
let cur = a9;
|
|
5607
5726
|
do {
|
|
@@ -5613,13 +5732,13 @@ function computeStraightSkeleton(polygon) {
|
|
|
5613
5732
|
a9.by = bDir.dy;
|
|
5614
5733
|
} else {
|
|
5615
5734
|
const a9 = ev.nodeA;
|
|
5616
|
-
const
|
|
5617
|
-
if (!a9.active || !
|
|
5735
|
+
const b7 = ev.nodeB;
|
|
5736
|
+
if (!a9.active || !b7.active) continue;
|
|
5618
5737
|
const nodeIdx = skeletonNodes.length;
|
|
5619
5738
|
skeletonNodes.push({ x: ev.x, y: ev.y, height: ev.time });
|
|
5620
5739
|
const aNodes = vertexToSkelNodes[a9.origIdx];
|
|
5621
5740
|
if (aNodes) aNodes.push(nodeIdx);
|
|
5622
|
-
const bNodes = vertexToSkelNodes[
|
|
5741
|
+
const bNodes = vertexToSkelNodes[b7.origIdx];
|
|
5623
5742
|
if (bNodes) bNodes.push(nodeIdx);
|
|
5624
5743
|
const aCopy = {
|
|
5625
5744
|
x: ev.x,
|
|
@@ -5635,20 +5754,20 @@ function computeStraightSkeleton(polygon) {
|
|
|
5635
5754
|
a9.x = ev.x;
|
|
5636
5755
|
a9.y = ev.y;
|
|
5637
5756
|
const aNext = a9.next;
|
|
5638
|
-
const bNext =
|
|
5757
|
+
const bNext = b7.next;
|
|
5639
5758
|
a9.next = bNext;
|
|
5640
5759
|
bNext.prev = a9;
|
|
5641
5760
|
aCopy.next = aNext;
|
|
5642
5761
|
aNext.prev = aCopy;
|
|
5643
|
-
aCopy.prev =
|
|
5644
|
-
|
|
5762
|
+
aCopy.prev = b7;
|
|
5763
|
+
b7.next = aCopy;
|
|
5645
5764
|
const buildLavPoly = (start) => {
|
|
5646
5765
|
const poly2 = [];
|
|
5647
|
-
let
|
|
5766
|
+
let c7 = start;
|
|
5648
5767
|
do {
|
|
5649
|
-
poly2.push({ x:
|
|
5650
|
-
|
|
5651
|
-
} while (
|
|
5768
|
+
poly2.push({ x: c7.x, y: c7.y });
|
|
5769
|
+
c7 = c7.next;
|
|
5770
|
+
} while (c7 !== start);
|
|
5652
5771
|
return poly2;
|
|
5653
5772
|
};
|
|
5654
5773
|
const lav1Poly = buildLavPoly(a9);
|
|
@@ -5662,13 +5781,13 @@ function computeStraightSkeleton(polygon) {
|
|
|
5662
5781
|
}
|
|
5663
5782
|
}
|
|
5664
5783
|
const faces = [];
|
|
5665
|
-
for (let i9 = 0; i9 <
|
|
5666
|
-
const
|
|
5784
|
+
for (let i9 = 0; i9 < n8; i9++) {
|
|
5785
|
+
const j10 = (i9 + 1) % n8;
|
|
5667
5786
|
const pi = polyAt(poly, i9);
|
|
5668
|
-
const pj = polyAt(poly,
|
|
5787
|
+
const pj = polyAt(poly, j10);
|
|
5669
5788
|
const faceVerts = [pi, pj];
|
|
5670
5789
|
const faceHeights = [0, 0];
|
|
5671
|
-
const jNodes = vertexToSkelNodes[
|
|
5790
|
+
const jNodes = vertexToSkelNodes[j10];
|
|
5672
5791
|
const iNodes = vertexToSkelNodes[i9];
|
|
5673
5792
|
if (jNodes) {
|
|
5674
5793
|
for (const ni of jNodes) {
|
|
@@ -5680,8 +5799,8 @@ function computeStraightSkeleton(polygon) {
|
|
|
5680
5799
|
}
|
|
5681
5800
|
}
|
|
5682
5801
|
if (iNodes) {
|
|
5683
|
-
for (let
|
|
5684
|
-
const idx = iNodes[
|
|
5802
|
+
for (let k9 = iNodes.length - 1; k9 >= 0; k9--) {
|
|
5803
|
+
const idx = iNodes[k9];
|
|
5685
5804
|
if (idx === void 0) continue;
|
|
5686
5805
|
const sn = skeletonNodes[idx];
|
|
5687
5806
|
if (!sn) continue;
|
|
@@ -5741,29 +5860,29 @@ function pointInTriangle(px, py, ax, ay, bx, by, cx, cy) {
|
|
|
5741
5860
|
return !(hasNeg && hasPos);
|
|
5742
5861
|
}
|
|
5743
5862
|
function earClipTriangulate(poly) {
|
|
5744
|
-
const
|
|
5745
|
-
if (
|
|
5746
|
-
if (
|
|
5863
|
+
const n8 = poly.length;
|
|
5864
|
+
if (n8 < 3) return [];
|
|
5865
|
+
if (n8 === 3) return [[0, 1, 2]];
|
|
5747
5866
|
let area2 = 0;
|
|
5748
|
-
for (let i9 = 0; i9 <
|
|
5867
|
+
for (let i9 = 0; i9 < n8; i9++) {
|
|
5749
5868
|
const a9 = poly[i9];
|
|
5750
|
-
const
|
|
5751
|
-
if (a9 &&
|
|
5869
|
+
const b7 = poly[(i9 + 1) % n8];
|
|
5870
|
+
if (a9 && b7) area2 += a9.x * b7.y - b7.x * a9.y;
|
|
5752
5871
|
}
|
|
5753
5872
|
const tris = [];
|
|
5754
|
-
const idx = Array.from({ length:
|
|
5873
|
+
const idx = Array.from({ length: n8 }, (_2, i9) => i9);
|
|
5755
5874
|
if (area2 < 0) idx.reverse();
|
|
5756
5875
|
const isEar = (prev, curr, next) => {
|
|
5757
5876
|
const a9 = poly[prev];
|
|
5758
|
-
const
|
|
5759
|
-
const
|
|
5760
|
-
if (!a9 || !
|
|
5761
|
-
if (cross2d(a9.x, a9.y,
|
|
5877
|
+
const b7 = poly[curr];
|
|
5878
|
+
const c7 = poly[next];
|
|
5879
|
+
if (!a9 || !b7 || !c7) return false;
|
|
5880
|
+
if (cross2d(a9.x, a9.y, b7.x, b7.y, c7.x, c7.y) <= 0) return false;
|
|
5762
5881
|
for (const vi of idx) {
|
|
5763
5882
|
if (vi === prev || vi === curr || vi === next) continue;
|
|
5764
|
-
const
|
|
5765
|
-
if (!
|
|
5766
|
-
if (pointInTriangle(
|
|
5883
|
+
const p7 = poly[vi];
|
|
5884
|
+
if (!p7) continue;
|
|
5885
|
+
if (pointInTriangle(p7.x, p7.y, a9.x, a9.y, b7.x, b7.y, c7.x, c7.y)) return false;
|
|
5767
5886
|
}
|
|
5768
5887
|
return true;
|
|
5769
5888
|
};
|
|
@@ -5784,8 +5903,8 @@ function earClipTriangulate(poly) {
|
|
|
5784
5903
|
if (!clipped) break;
|
|
5785
5904
|
}
|
|
5786
5905
|
if (idx.length === 3) {
|
|
5787
|
-
const [a9,
|
|
5788
|
-
if (a9 !== void 0 &&
|
|
5906
|
+
const [a9, b7, c7] = idx;
|
|
5907
|
+
if (a9 !== void 0 && b7 !== void 0 && c7 !== void 0) tris.push([a9, b7, c7]);
|
|
5789
5908
|
}
|
|
5790
5909
|
return tris;
|
|
5791
5910
|
}
|
|
@@ -5812,9 +5931,9 @@ function roof(w7, options) {
|
|
|
5812
5931
|
const triFaces = [];
|
|
5813
5932
|
for (const skFace of skeleton.faces) {
|
|
5814
5933
|
const verts3d = skFace.vertices.map(
|
|
5815
|
-
(
|
|
5816
|
-
|
|
5817
|
-
|
|
5934
|
+
(v6, i9) => [
|
|
5935
|
+
v6.x,
|
|
5936
|
+
v6.y,
|
|
5818
5937
|
(skFace.heights[i9] ?? 0) * tanAngle
|
|
5819
5938
|
]
|
|
5820
5939
|
);
|
|
@@ -5890,36 +6009,36 @@ function solveConstraints(nodes, constraints) {
|
|
|
5890
6009
|
});
|
|
5891
6010
|
}
|
|
5892
6011
|
const unsupported = [];
|
|
5893
|
-
for (const
|
|
5894
|
-
if (
|
|
5895
|
-
const a9 =
|
|
5896
|
-
const
|
|
5897
|
-
if (a9.entity.type === "plane" &&
|
|
6012
|
+
for (const c7 of constraints) {
|
|
6013
|
+
if (c7.type === "coincident" && c7.entityA && c7.entityB) {
|
|
6014
|
+
const a9 = c7.entityA;
|
|
6015
|
+
const b7 = c7.entityB;
|
|
6016
|
+
if (a9.entity.type === "plane" && b7.entity.type === "plane") {
|
|
5898
6017
|
const aNormal = a9.entity.normal ?? [0, 0, 1];
|
|
5899
6018
|
const aOrigin = a9.entity.origin;
|
|
5900
|
-
const bOrigin =
|
|
6019
|
+
const bOrigin = b7.entity.origin;
|
|
5901
6020
|
const dot = aNormal[0] * (aOrigin[0] - bOrigin[0]) + aNormal[1] * (aOrigin[1] - bOrigin[1]) + aNormal[2] * (aOrigin[2] - bOrigin[2]);
|
|
5902
6021
|
const pos = [dot * aNormal[0], dot * aNormal[1], dot * aNormal[2]];
|
|
5903
|
-
transforms.set(
|
|
6022
|
+
transforms.set(b7.node, { position: pos, rotation: [1, 0, 0, 0] });
|
|
5904
6023
|
} else {
|
|
5905
|
-
unsupported.push(`coincident(${a9.entity.type}-${
|
|
6024
|
+
unsupported.push(`coincident(${a9.entity.type}-${b7.entity.type})`);
|
|
5906
6025
|
}
|
|
5907
|
-
} else if (
|
|
5908
|
-
const a9 =
|
|
5909
|
-
const
|
|
5910
|
-
if (a9.entity.type === "plane" &&
|
|
6026
|
+
} else if (c7.type === "distance" && c7.entityA && c7.entityB && c7.value !== void 0) {
|
|
6027
|
+
const a9 = c7.entityA;
|
|
6028
|
+
const b7 = c7.entityB;
|
|
6029
|
+
if (a9.entity.type === "plane" && b7.entity.type === "plane") {
|
|
5911
6030
|
const aNormal = a9.entity.normal ?? [0, 0, 1];
|
|
5912
6031
|
const aOrigin = a9.entity.origin;
|
|
5913
|
-
const bOrigin =
|
|
6032
|
+
const bOrigin = b7.entity.origin;
|
|
5914
6033
|
const currentDist = aNormal[0] * (aOrigin[0] - bOrigin[0]) + aNormal[1] * (aOrigin[1] - bOrigin[1]) + aNormal[2] * (aOrigin[2] - bOrigin[2]);
|
|
5915
|
-
const offset2 = currentDist +
|
|
6034
|
+
const offset2 = currentDist + c7.value;
|
|
5916
6035
|
const pos = [offset2 * aNormal[0], offset2 * aNormal[1], offset2 * aNormal[2]];
|
|
5917
|
-
transforms.set(
|
|
6036
|
+
transforms.set(b7.node, { position: pos, rotation: [1, 0, 0, 0] });
|
|
5918
6037
|
} else {
|
|
5919
|
-
unsupported.push(`distance(${a9.entity.type}-${
|
|
6038
|
+
unsupported.push(`distance(${a9.entity.type}-${b7.entity.type})`);
|
|
5920
6039
|
}
|
|
5921
|
-
} else if (
|
|
5922
|
-
unsupported.push(
|
|
6040
|
+
} else if (c7.type === "concentric" || c7.type === "angle") {
|
|
6041
|
+
unsupported.push(c7.type);
|
|
5923
6042
|
}
|
|
5924
6043
|
}
|
|
5925
6044
|
const dof = unsupported.reduce((sum, type) => {
|
|
@@ -5939,9 +6058,9 @@ function extractEntity(mate) {
|
|
|
5939
6058
|
}
|
|
5940
6059
|
return null;
|
|
5941
6060
|
}
|
|
5942
|
-
function extractPair(a9,
|
|
6061
|
+
function extractPair(a9, b7) {
|
|
5943
6062
|
const entA = extractEntity(a9);
|
|
5944
|
-
const entB = extractEntity(
|
|
6063
|
+
const entB = extractEntity(b7);
|
|
5945
6064
|
if (!entA || !entB) {
|
|
5946
6065
|
return err(
|
|
5947
6066
|
validationError(
|
|
@@ -5952,7 +6071,7 @@ function extractPair(a9, b9) {
|
|
|
5952
6071
|
}
|
|
5953
6072
|
return ok({
|
|
5954
6073
|
entityA: { node: a9.node, entity: entA },
|
|
5955
|
-
entityB: { node:
|
|
6074
|
+
entityB: { node: b7.node, entity: entB }
|
|
5956
6075
|
});
|
|
5957
6076
|
}
|
|
5958
6077
|
function addMate(assembly, constraint) {
|
|
@@ -6042,20 +6161,20 @@ function checkInterference(shape1, shape2, tolerance = 1e-6) {
|
|
|
6042
6161
|
}
|
|
6043
6162
|
function checkAllInterferences(shapes, tolerance = 1e-6) {
|
|
6044
6163
|
const pairs = [];
|
|
6045
|
-
const boxes = shapes.map((
|
|
6164
|
+
const boxes = shapes.map((s5) => getBounds(s5));
|
|
6046
6165
|
shapes.forEach((si, i9) => {
|
|
6047
|
-
for (let
|
|
6048
|
-
if (aabbDisjoint(boxes[i9], boxes[
|
|
6049
|
-
const result = unwrap$1(checkInterference(si, shapes[
|
|
6166
|
+
for (let j10 = i9 + 1; j10 < shapes.length; j10++) {
|
|
6167
|
+
if (aabbDisjoint(boxes[i9], boxes[j10], tolerance)) continue;
|
|
6168
|
+
const result = unwrap$1(checkInterference(si, shapes[j10], tolerance));
|
|
6050
6169
|
if (result.hasInterference) {
|
|
6051
|
-
pairs.push({ i: i9, j:
|
|
6170
|
+
pairs.push({ i: i9, j: j10, result });
|
|
6052
6171
|
}
|
|
6053
6172
|
}
|
|
6054
6173
|
});
|
|
6055
6174
|
return pairs;
|
|
6056
6175
|
}
|
|
6057
|
-
function aabbDisjoint(a9,
|
|
6058
|
-
return a9.xMax + tolerance <
|
|
6176
|
+
function aabbDisjoint(a9, b7, tolerance) {
|
|
6177
|
+
return a9.xMax + tolerance < b7.xMin || b7.xMax + tolerance < a9.xMin || a9.yMax + tolerance < b7.yMin || b7.yMax + tolerance < a9.yMin || a9.zMax + tolerance < b7.zMin || b7.zMax + tolerance < a9.zMin;
|
|
6059
6178
|
}
|
|
6060
6179
|
function parseEntities(text) {
|
|
6061
6180
|
const lines = text.split(/\r?\n/);
|
|
@@ -6094,10 +6213,10 @@ function parseEntities(text) {
|
|
|
6094
6213
|
return entities;
|
|
6095
6214
|
}
|
|
6096
6215
|
function getNum(data, code, fallback = 0) {
|
|
6097
|
-
const
|
|
6098
|
-
if (
|
|
6099
|
-
const
|
|
6100
|
-
return isNaN(
|
|
6216
|
+
const v6 = data.get(code);
|
|
6217
|
+
if (v6 === void 0) return fallback;
|
|
6218
|
+
const n8 = parseFloat(v6);
|
|
6219
|
+
return isNaN(n8) ? fallback : n8;
|
|
6101
6220
|
}
|
|
6102
6221
|
function entityToEdge(entity) {
|
|
6103
6222
|
const { type, data } = entity;
|
|
@@ -6172,16 +6291,16 @@ async function importOBJ(blob) {
|
|
|
6172
6291
|
const line = raw.trim();
|
|
6173
6292
|
if (line.startsWith("v ")) {
|
|
6174
6293
|
const parts = line.split(/\s+/);
|
|
6175
|
-
const
|
|
6176
|
-
const
|
|
6294
|
+
const x6 = parseFloat(parts[1] ?? "");
|
|
6295
|
+
const y6 = parseFloat(parts[2] ?? "");
|
|
6177
6296
|
const z6 = parseFloat(parts[3] ?? "");
|
|
6178
|
-
if (isNaN(
|
|
6179
|
-
vertices.push([
|
|
6297
|
+
if (isNaN(x6) || isNaN(y6) || isNaN(z6)) continue;
|
|
6298
|
+
vertices.push([x6, y6, z6]);
|
|
6180
6299
|
} else if (line.startsWith("f ")) {
|
|
6181
6300
|
const parts = line.split(/\s+/).slice(1);
|
|
6182
6301
|
const indices = [];
|
|
6183
|
-
for (const
|
|
6184
|
-
const idx = parseInt(
|
|
6302
|
+
for (const p7 of parts) {
|
|
6303
|
+
const idx = parseInt(p7.split("/")[0] ?? "", 10);
|
|
6185
6304
|
if (!isNaN(idx)) indices.push(idx);
|
|
6186
6305
|
}
|
|
6187
6306
|
if (indices.length >= 3) faces.push(indices);
|
|
@@ -6331,7 +6450,7 @@ function parseModelXml(xml) {
|
|
|
6331
6450
|
}
|
|
6332
6451
|
function buildSolidFromMesh(mesh2) {
|
|
6333
6452
|
const kernel = getKernel();
|
|
6334
|
-
const points = mesh2.vertices.map(([
|
|
6453
|
+
const points = mesh2.vertices.map(([x6, y6, z6]) => ({ x: x6, y: y6, z: z6 }));
|
|
6335
6454
|
const faces = mesh2.triangles;
|
|
6336
6455
|
try {
|
|
6337
6456
|
const solid = kernel.buildSolidFromFaces(points, faces, 1e-6);
|
|
@@ -6390,14 +6509,14 @@ async function importThreeMF(blob) {
|
|
|
6390
6509
|
return err(ioError(BrepErrorCode.THREEMF_IMPORT_FAILED, `3MF import failed: ${msg}`, e8));
|
|
6391
6510
|
}
|
|
6392
6511
|
}
|
|
6393
|
-
function resolve(
|
|
6394
|
-
if ("__wrapped" in
|
|
6395
|
-
return
|
|
6512
|
+
function resolve(s5) {
|
|
6513
|
+
if ("__wrapped" in s5) {
|
|
6514
|
+
return s5.val;
|
|
6396
6515
|
}
|
|
6397
|
-
return
|
|
6516
|
+
return s5;
|
|
6398
6517
|
}
|
|
6399
|
-
function resolve3D(
|
|
6400
|
-
return resolve(
|
|
6518
|
+
function resolve3D(s5) {
|
|
6519
|
+
return resolve(s5);
|
|
6401
6520
|
}
|
|
6402
6521
|
function validateNotNull(shape2, label) {
|
|
6403
6522
|
if (getKernel().isNull(shape2.wrapped)) {
|
|
@@ -6405,20 +6524,6 @@ function validateNotNull(shape2, label) {
|
|
|
6405
6524
|
}
|
|
6406
6525
|
return ok(void 0);
|
|
6407
6526
|
}
|
|
6408
|
-
function collectInputFaceHashes(inputs) {
|
|
6409
|
-
const hasMetadata = inputs.some((s6) => {
|
|
6410
|
-
return getFaceOrigins(s6) !== void 0 || hasFaceTags(s6) || hasColorMetadata(s6);
|
|
6411
|
-
});
|
|
6412
|
-
if (!hasMetadata) return [];
|
|
6413
|
-
const hashes = [];
|
|
6414
|
-
for (const input of inputs) {
|
|
6415
|
-
const faces = getKernel().iterShapes(input.wrapped, "face");
|
|
6416
|
-
for (const face of faces) {
|
|
6417
|
-
hashes.push(face.HashCode(HASH_CODE_MAX));
|
|
6418
|
-
}
|
|
6419
|
-
}
|
|
6420
|
-
return hashes;
|
|
6421
|
-
}
|
|
6422
6527
|
function thicken$1(shape2, thickness) {
|
|
6423
6528
|
const check = validateNotNull(shape2, "thicken: shape");
|
|
6424
6529
|
if (isErr(check)) return check;
|
|
@@ -6431,9 +6536,7 @@ function thicken$1(shape2, thickness) {
|
|
|
6431
6536
|
HASH_CODE_MAX
|
|
6432
6537
|
);
|
|
6433
6538
|
const cast = castShape(resultShape);
|
|
6434
|
-
|
|
6435
|
-
propagateFaceTagsFromEvolution(evolution, [shape2], cast);
|
|
6436
|
-
propagateColorsFromEvolution(evolution, [shape2], cast);
|
|
6539
|
+
propagateAllMetadata(evolution, [shape2], cast);
|
|
6437
6540
|
return ok(cast);
|
|
6438
6541
|
} catch (e8) {
|
|
6439
6542
|
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
@@ -6525,9 +6628,7 @@ function fillet$1(shape2, edges, radius) {
|
|
|
6525
6628
|
if (!isShape3D(cast)) {
|
|
6526
6629
|
return err(kernelError(BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape"));
|
|
6527
6630
|
}
|
|
6528
|
-
|
|
6529
|
-
propagateFaceTagsFromEvolution(evolution, [shape2], cast);
|
|
6530
|
-
propagateColorsFromEvolution(evolution, [shape2], cast);
|
|
6631
|
+
propagateAllMetadata(evolution, [shape2], cast);
|
|
6531
6632
|
return ok(cast);
|
|
6532
6633
|
} catch (e8) {
|
|
6533
6634
|
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
@@ -6614,9 +6715,7 @@ function chamfer$1(shape2, edges, distance) {
|
|
|
6614
6715
|
if (!isShape3D(cast)) {
|
|
6615
6716
|
return err(kernelError(BrepErrorCode.CHAMFER_NOT_3D, "Chamfer result is not a 3D shape"));
|
|
6616
6717
|
}
|
|
6617
|
-
|
|
6618
|
-
propagateFaceTagsFromEvolution(evolution, [shape2], cast);
|
|
6619
|
-
propagateColorsFromEvolution(evolution, [shape2], cast);
|
|
6718
|
+
propagateAllMetadata(evolution, [shape2], cast);
|
|
6620
6719
|
return ok(cast);
|
|
6621
6720
|
} catch (e8) {
|
|
6622
6721
|
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
@@ -6652,9 +6751,7 @@ function shell$1(shape2, faces, thickness, tolerance = 1e-3) {
|
|
|
6652
6751
|
if (!isShape3D(cast)) {
|
|
6653
6752
|
return err(kernelError("SHELL_RESULT_NOT_3D", "Shell result is not a 3D shape"));
|
|
6654
6753
|
}
|
|
6655
|
-
|
|
6656
|
-
propagateFaceTagsFromEvolution(evolution, [shape2], cast);
|
|
6657
|
-
propagateColorsFromEvolution(evolution, [shape2], cast);
|
|
6754
|
+
propagateAllMetadata(evolution, [shape2], cast);
|
|
6658
6755
|
return ok(cast);
|
|
6659
6756
|
} catch (e8) {
|
|
6660
6757
|
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
@@ -6686,17 +6783,15 @@ function offset$1(shape2, distance, tolerance = 1e-6) {
|
|
|
6686
6783
|
if (!isShape3D(cast)) {
|
|
6687
6784
|
return err(kernelError("OFFSET_RESULT_NOT_3D", "Offset result is not a 3D shape"));
|
|
6688
6785
|
}
|
|
6689
|
-
|
|
6690
|
-
propagateFaceTagsFromEvolution(evolution, [shape2], cast);
|
|
6691
|
-
propagateColorsFromEvolution(evolution, [shape2], cast);
|
|
6786
|
+
propagateAllMetadata(evolution, [shape2], cast);
|
|
6692
6787
|
return ok(cast);
|
|
6693
6788
|
} catch (e8) {
|
|
6694
6789
|
const raw = e8 instanceof Error ? e8.message : String(e8);
|
|
6695
6790
|
return err(kernelError("OFFSET_FAILED", `Offset operation failed: ${raw}`, e8));
|
|
6696
6791
|
}
|
|
6697
6792
|
}
|
|
6698
|
-
function translate(shape2,
|
|
6699
|
-
return translate$1(resolve(shape2),
|
|
6793
|
+
function translate(shape2, v6) {
|
|
6794
|
+
return translate$1(resolve(shape2), v6);
|
|
6700
6795
|
}
|
|
6701
6796
|
function rotate(shape2, angle, options) {
|
|
6702
6797
|
const pivotPoint = options?.at;
|
|
@@ -6718,14 +6813,14 @@ function applyMatrix(shape2, matrix) {
|
|
|
6718
6813
|
function transformCopy(shape2, composed) {
|
|
6719
6814
|
return transformCopy$1(resolve(shape2), composed);
|
|
6720
6815
|
}
|
|
6721
|
-
function fuse(a9,
|
|
6722
|
-
return fuse$1(resolve(a9), resolve(
|
|
6816
|
+
function fuse(a9, b7, options) {
|
|
6817
|
+
return fuse$1(resolve(a9), resolve(b7), options);
|
|
6723
6818
|
}
|
|
6724
6819
|
function cut(base, tool, options) {
|
|
6725
6820
|
return cut$1(resolve(base), resolve(tool), options);
|
|
6726
6821
|
}
|
|
6727
|
-
function intersect(a9,
|
|
6728
|
-
return intersect$1(resolve(a9), resolve(
|
|
6822
|
+
function intersect(a9, b7, options) {
|
|
6823
|
+
return intersect$1(resolve(a9), resolve(b7), options);
|
|
6729
6824
|
}
|
|
6730
6825
|
function section(shape2, plane, options) {
|
|
6731
6826
|
return section$1(resolve(shape2), plane, options);
|
|
@@ -6774,24 +6869,24 @@ function normalizeChamferDistance(distance) {
|
|
|
6774
6869
|
return { mode: "standard", distance };
|
|
6775
6870
|
}
|
|
6776
6871
|
function fillet(shape2, edgesOrRadius, maybeRadius) {
|
|
6777
|
-
const
|
|
6872
|
+
const s5 = resolve(shape2);
|
|
6778
6873
|
let edges;
|
|
6779
6874
|
let radius;
|
|
6780
6875
|
if (maybeRadius !== void 0) {
|
|
6781
|
-
edges = resolveEdges(edgesOrRadius,
|
|
6876
|
+
edges = resolveEdges(edgesOrRadius, s5);
|
|
6782
6877
|
radius = maybeRadius;
|
|
6783
6878
|
} else {
|
|
6784
6879
|
edges = void 0;
|
|
6785
6880
|
radius = edgesOrRadius;
|
|
6786
6881
|
}
|
|
6787
|
-
return fillet$1(
|
|
6882
|
+
return fillet$1(s5, edges, radius);
|
|
6788
6883
|
}
|
|
6789
6884
|
function chamfer(shape2, edgesOrDistance, maybeDistance) {
|
|
6790
|
-
const
|
|
6885
|
+
const s5 = resolve(shape2);
|
|
6791
6886
|
let edges;
|
|
6792
6887
|
let distance;
|
|
6793
6888
|
if (maybeDistance !== void 0) {
|
|
6794
|
-
edges = resolveEdges(edgesOrDistance,
|
|
6889
|
+
edges = resolveEdges(edgesOrDistance, s5);
|
|
6795
6890
|
distance = maybeDistance;
|
|
6796
6891
|
} else {
|
|
6797
6892
|
edges = void 0;
|
|
@@ -6799,20 +6894,20 @@ function chamfer(shape2, edgesOrDistance, maybeDistance) {
|
|
|
6799
6894
|
}
|
|
6800
6895
|
const normalized = normalizeChamferDistance(distance);
|
|
6801
6896
|
if (normalized.mode === "distAngle") {
|
|
6802
|
-
const selectedEdges = edges ?? getEdges(
|
|
6897
|
+
const selectedEdges = edges ?? getEdges(s5);
|
|
6803
6898
|
return chamferDistAngle(
|
|
6804
|
-
|
|
6899
|
+
s5,
|
|
6805
6900
|
[...selectedEdges],
|
|
6806
6901
|
normalized.distance,
|
|
6807
6902
|
normalized.angle
|
|
6808
6903
|
);
|
|
6809
6904
|
}
|
|
6810
|
-
return chamfer$1(
|
|
6905
|
+
return chamfer$1(s5, edges, normalized.distance);
|
|
6811
6906
|
}
|
|
6812
6907
|
function shell(shape2, faces, thickness, options) {
|
|
6813
|
-
const
|
|
6814
|
-
const resolvedFaces = resolveFaces(faces,
|
|
6815
|
-
return shell$1(
|
|
6908
|
+
const s5 = resolve(shape2);
|
|
6909
|
+
const resolvedFaces = resolveFaces(faces, s5);
|
|
6910
|
+
return shell$1(s5, resolvedFaces, thickness, options?.tolerance);
|
|
6816
6911
|
}
|
|
6817
6912
|
function offset(shape2, distance, options) {
|
|
6818
6913
|
return offset$1(resolve(shape2), distance, options?.tolerance);
|
|
@@ -6934,7 +7029,7 @@ function toWire(profile) {
|
|
|
6934
7029
|
return profile;
|
|
6935
7030
|
}
|
|
6936
7031
|
function drill(shape2, options) {
|
|
6937
|
-
const
|
|
7032
|
+
const s5 = resolve(shape2);
|
|
6938
7033
|
const { at, radius, axis: rawAxis } = options;
|
|
6939
7034
|
const axis = rawAxis ?? [0, 0, 1];
|
|
6940
7035
|
if (radius <= 0) {
|
|
@@ -6949,23 +7044,23 @@ function drill(shape2, options) {
|
|
|
6949
7044
|
if (options.depth !== void 0) {
|
|
6950
7045
|
tool = makeCylinder(radius, options.depth, pos, dir);
|
|
6951
7046
|
} else {
|
|
6952
|
-
const
|
|
7047
|
+
const b7 = getBounds(s5);
|
|
6953
7048
|
const corners = [
|
|
6954
|
-
[
|
|
6955
|
-
[
|
|
6956
|
-
[
|
|
6957
|
-
[
|
|
6958
|
-
[
|
|
6959
|
-
[
|
|
6960
|
-
[
|
|
6961
|
-
[
|
|
7049
|
+
[b7.xMin, b7.yMin, b7.zMin],
|
|
7050
|
+
[b7.xMax, b7.yMin, b7.zMin],
|
|
7051
|
+
[b7.xMin, b7.yMax, b7.zMin],
|
|
7052
|
+
[b7.xMax, b7.yMax, b7.zMin],
|
|
7053
|
+
[b7.xMin, b7.yMin, b7.zMax],
|
|
7054
|
+
[b7.xMax, b7.yMin, b7.zMax],
|
|
7055
|
+
[b7.xMin, b7.yMax, b7.zMax],
|
|
7056
|
+
[b7.xMax, b7.yMax, b7.zMax]
|
|
6962
7057
|
];
|
|
6963
7058
|
let tMin = Infinity;
|
|
6964
7059
|
let tMax = -Infinity;
|
|
6965
|
-
for (const
|
|
6966
|
-
const
|
|
6967
|
-
if (
|
|
6968
|
-
if (
|
|
7060
|
+
for (const c7 of corners) {
|
|
7061
|
+
const t7 = (c7[0] - pos[0]) * dir[0] + (c7[1] - pos[1]) * dir[1] + (c7[2] - pos[2]) * dir[2];
|
|
7062
|
+
if (t7 < tMin) tMin = t7;
|
|
7063
|
+
if (t7 > tMax) tMax = t7;
|
|
6969
7064
|
}
|
|
6970
7065
|
const overshoot = 1;
|
|
6971
7066
|
tMin -= overshoot;
|
|
@@ -6974,15 +7069,15 @@ function drill(shape2, options) {
|
|
|
6974
7069
|
const startPos = [pos[0] + dir[0] * tMin, pos[1] + dir[1] * tMin, pos[2] + dir[2] * tMin];
|
|
6975
7070
|
tool = makeCylinder(radius, depth, startPos, dir);
|
|
6976
7071
|
}
|
|
6977
|
-
return cut$1(
|
|
7072
|
+
return cut$1(s5, tool);
|
|
6978
7073
|
}
|
|
6979
7074
|
function pocket(shape2, options) {
|
|
6980
|
-
const
|
|
7075
|
+
const s5 = resolve(shape2);
|
|
6981
7076
|
const { profile, depth } = options;
|
|
6982
7077
|
if (depth <= 0) {
|
|
6983
7078
|
return err(validationError("POCKET_INVALID_DEPTH", "Pocket depth must be positive"));
|
|
6984
7079
|
}
|
|
6985
|
-
const targetResult = resolveTargetFace(
|
|
7080
|
+
const targetResult = resolveTargetFace(s5, options.face);
|
|
6986
7081
|
if (isErr(targetResult)) return targetResult;
|
|
6987
7082
|
const targetFace = targetResult.value;
|
|
6988
7083
|
const normal = normalAt(targetFace);
|
|
@@ -6992,15 +7087,15 @@ function pocket(shape2, options) {
|
|
|
6992
7087
|
const extDir = vecScale(vecNormalize(normal), -depth);
|
|
6993
7088
|
const toolResult = extrude$1(faceResult.value, extDir);
|
|
6994
7089
|
if (isErr(toolResult)) return toolResult;
|
|
6995
|
-
return cut$1(
|
|
7090
|
+
return cut$1(s5, toolResult.value);
|
|
6996
7091
|
}
|
|
6997
7092
|
function boss(shape2, options) {
|
|
6998
|
-
const
|
|
7093
|
+
const s5 = resolve(shape2);
|
|
6999
7094
|
const { profile, height } = options;
|
|
7000
7095
|
if (height <= 0) {
|
|
7001
7096
|
return err(validationError("BOSS_INVALID_HEIGHT", "Boss height must be positive"));
|
|
7002
7097
|
}
|
|
7003
|
-
const targetResult = resolveTargetFace(
|
|
7098
|
+
const targetResult = resolveTargetFace(s5, options.face);
|
|
7004
7099
|
if (isErr(targetResult)) return targetResult;
|
|
7005
7100
|
const targetFace = targetResult.value;
|
|
7006
7101
|
const normal = normalAt(targetFace);
|
|
@@ -7010,17 +7105,17 @@ function boss(shape2, options) {
|
|
|
7010
7105
|
const extDir = vecScale(vecNormalize(normal), height);
|
|
7011
7106
|
const toolResult = extrude$1(faceResult.value, extDir);
|
|
7012
7107
|
if (isErr(toolResult)) return toolResult;
|
|
7013
|
-
return fuse$1(
|
|
7108
|
+
return fuse$1(s5, toolResult.value);
|
|
7014
7109
|
}
|
|
7015
7110
|
function mirrorJoin(shape2, options) {
|
|
7016
|
-
const
|
|
7111
|
+
const s5 = resolve(shape2);
|
|
7017
7112
|
const normal = options?.normal ?? [1, 0, 0];
|
|
7018
7113
|
const planeOrigin = options?.at;
|
|
7019
|
-
const mirrored = mirror$1(
|
|
7020
|
-
return fuse$1(
|
|
7114
|
+
const mirrored = mirror$1(s5, normal, planeOrigin);
|
|
7115
|
+
return fuse$1(s5, mirrored);
|
|
7021
7116
|
}
|
|
7022
7117
|
function rectangularPattern(shape2, options) {
|
|
7023
|
-
const
|
|
7118
|
+
const s5 = resolve(shape2);
|
|
7024
7119
|
const { xDir, xCount, xSpacing, yDir, yCount, ySpacing } = options;
|
|
7025
7120
|
if (xCount < 1 || yCount < 1) {
|
|
7026
7121
|
return err(validationError("PATTERN_INVALID_COUNT", "Pattern counts must be at least 1"));
|
|
@@ -7031,10 +7126,10 @@ function rectangularPattern(shape2, options) {
|
|
|
7031
7126
|
if (vecIsZero(yDir)) {
|
|
7032
7127
|
return err(validationError("PATTERN_ZERO_DIRECTION", "Y direction cannot be zero"));
|
|
7033
7128
|
}
|
|
7034
|
-
if (xCount === 1 && yCount === 1) return ok(
|
|
7129
|
+
if (xCount === 1 && yCount === 1) return ok(s5);
|
|
7035
7130
|
const xNorm = vecNormalize(xDir);
|
|
7036
7131
|
const yNorm = vecNormalize(yDir);
|
|
7037
|
-
const copies = [
|
|
7132
|
+
const copies = [s5];
|
|
7038
7133
|
for (let xi = 0; xi < xCount; xi++) {
|
|
7039
7134
|
for (let yi = 0; yi < yCount; yi++) {
|
|
7040
7135
|
if (xi === 0 && yi === 0) continue;
|
|
@@ -7043,7 +7138,7 @@ function rectangularPattern(shape2, options) {
|
|
|
7043
7138
|
xNorm[1] * xSpacing * xi + yNorm[1] * ySpacing * yi,
|
|
7044
7139
|
xNorm[2] * xSpacing * xi + yNorm[2] * ySpacing * yi
|
|
7045
7140
|
];
|
|
7046
|
-
copies.push(translate$1(
|
|
7141
|
+
copies.push(translate$1(s5, offset2));
|
|
7047
7142
|
}
|
|
7048
7143
|
}
|
|
7049
7144
|
return fuseAll(copies);
|
|
@@ -7079,7 +7174,7 @@ function createWrappedBase(val) {
|
|
|
7079
7174
|
const self = {
|
|
7080
7175
|
val,
|
|
7081
7176
|
__wrapped: true,
|
|
7082
|
-
translate: (
|
|
7177
|
+
translate: (v6) => wrapAny(translate(val, v6)),
|
|
7083
7178
|
rotate: (angle, opts) => wrapAny(rotate(val, angle, opts)),
|
|
7084
7179
|
mirror: (opts) => wrapAny(mirror(val, opts)),
|
|
7085
7180
|
scale: (factor, opts) => wrapAny(scale(val, factor, opts)),
|
|
@@ -7168,8 +7263,8 @@ function createWrappedCurve(val) {
|
|
|
7168
7263
|
length: () => curveLength(val),
|
|
7169
7264
|
startPoint: () => curveStartPoint(val),
|
|
7170
7265
|
endPoint: () => curveEndPoint(val),
|
|
7171
|
-
pointAt: (
|
|
7172
|
-
tangentAt: (
|
|
7266
|
+
pointAt: (t7) => curvePointAt(val, t7),
|
|
7267
|
+
tangentAt: (t7) => curveTangentAt(val, t7),
|
|
7173
7268
|
isClosed: () => curveIsClosed(val),
|
|
7174
7269
|
sweep(spine, opts) {
|
|
7175
7270
|
if (!isWire(val)) throw new Error("sweep requires a Wire");
|
|
@@ -7204,114 +7299,113 @@ function wrapAny(val) {
|
|
|
7204
7299
|
function wrap3D(val) {
|
|
7205
7300
|
return createWrapped3D(val);
|
|
7206
7301
|
}
|
|
7207
|
-
function shape(
|
|
7208
|
-
if (
|
|
7209
|
-
return createWrappedFace(
|
|
7302
|
+
function shape(s5) {
|
|
7303
|
+
if (s5 && typeof s5 === "object" && "face" in s5 && typeof s5.face === "function" && "_defaultOrigin" in s5) {
|
|
7304
|
+
return createWrappedFace(s5.face());
|
|
7210
7305
|
}
|
|
7211
|
-
if (
|
|
7212
|
-
if (isFace(
|
|
7213
|
-
if (isShape3D(
|
|
7214
|
-
if (isEdge(
|
|
7215
|
-
return createWrappedBase(
|
|
7306
|
+
if (s5 && typeof s5 === "object" && "wrapped" in s5) {
|
|
7307
|
+
if (isFace(s5)) return createWrappedFace(s5);
|
|
7308
|
+
if (isShape3D(s5)) return createWrapped3D(s5);
|
|
7309
|
+
if (isEdge(s5) || isWire(s5)) return createWrappedCurve(s5);
|
|
7310
|
+
return createWrappedBase(s5);
|
|
7216
7311
|
}
|
|
7217
7312
|
throw new Error("shape() requires a Sketch or branded shape type");
|
|
7218
7313
|
}
|
|
7219
7314
|
export {
|
|
7220
7315
|
B4 as BaseSketcher2d,
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7316
|
+
B3 as Blueprint,
|
|
7317
|
+
a6 as BlueprintSketcher,
|
|
7318
|
+
c3 as Blueprints,
|
|
7319
|
+
d4 as BoundingBox2d,
|
|
7320
|
+
g as BrepBugError,
|
|
7226
7321
|
BrepErrorCode,
|
|
7227
7322
|
BrepWrapperError,
|
|
7228
7323
|
BrepkitAdapter,
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7324
|
+
C5 as CompoundBlueprint,
|
|
7325
|
+
C6 as CompoundSketch,
|
|
7326
|
+
C4 as Curve2D,
|
|
7327
|
+
D2 as DEG2RAD,
|
|
7233
7328
|
DisposalScope,
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
|
|
7329
|
+
D4 as Drawing,
|
|
7330
|
+
a7 as DrawingPen,
|
|
7331
|
+
F4 as FaceSketcher,
|
|
7237
7332
|
HASH_CODE_MAX,
|
|
7238
|
-
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7333
|
+
O as OK,
|
|
7334
|
+
R as RAD2DEG,
|
|
7335
|
+
S as Sketch,
|
|
7336
|
+
S2 as Sketcher,
|
|
7337
|
+
b3 as Sketches,
|
|
7338
|
+
a5 as addChild,
|
|
7339
|
+
d7 as addHoles,
|
|
7245
7340
|
addMate,
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7341
|
+
b2 as addStep,
|
|
7342
|
+
e5 as adjacentFaces,
|
|
7343
|
+
h as all,
|
|
7249
7344
|
a2 as andThen,
|
|
7250
7345
|
applyGlue,
|
|
7251
7346
|
applyMatrix,
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
e5 as bezier,
|
|
7347
|
+
i4 as approximateCurve,
|
|
7348
|
+
q as as2D,
|
|
7349
|
+
s as as3D,
|
|
7350
|
+
l8 as asTopo,
|
|
7351
|
+
f7 as autoHeal,
|
|
7352
|
+
g7 as bezier,
|
|
7259
7353
|
blueprintToDXF,
|
|
7260
7354
|
boss,
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7355
|
+
j7 as box,
|
|
7356
|
+
k6 as bsplineApprox,
|
|
7357
|
+
c as bug,
|
|
7264
7358
|
X as cameraFromPlane,
|
|
7265
7359
|
Y as cameraLookAt,
|
|
7266
7360
|
c5 as cast,
|
|
7267
7361
|
castShape,
|
|
7268
|
-
|
|
7362
|
+
t as castShape3D,
|
|
7269
7363
|
chamfer,
|
|
7270
7364
|
chamferDistAngle as chamferDistAngleShape,
|
|
7271
7365
|
checkAllInterferences,
|
|
7272
7366
|
checkInterference,
|
|
7273
|
-
|
|
7367
|
+
l6 as circle,
|
|
7274
7368
|
circularPattern,
|
|
7275
7369
|
m9 as classifyPointOnFace,
|
|
7276
7370
|
c6 as clearMeshCache,
|
|
7277
7371
|
clone,
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7372
|
+
closedWire,
|
|
7373
|
+
j as collect,
|
|
7374
|
+
d3 as collectShapes,
|
|
7375
|
+
j6 as colorFaces,
|
|
7376
|
+
k5 as colorShape,
|
|
7377
|
+
e3 as complexExtrude,
|
|
7378
|
+
n7 as composeTransforms,
|
|
7379
|
+
o6 as compound,
|
|
7380
|
+
c4 as compoundSketchExtrude,
|
|
7287
7381
|
d6 as compoundSketchFace,
|
|
7288
7382
|
e4 as compoundSketchLoft,
|
|
7289
|
-
|
|
7290
|
-
|
|
7383
|
+
f6 as compoundSketchRevolve,
|
|
7384
|
+
d as computationError,
|
|
7291
7385
|
computeStraightSkeleton,
|
|
7292
|
-
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7386
|
+
p5 as cone,
|
|
7387
|
+
cornerFinder,
|
|
7388
|
+
f4 as countNodes,
|
|
7389
|
+
g3 as createAssembly,
|
|
7390
|
+
h2 as createAssemblyNode,
|
|
7297
7391
|
createBlueprint,
|
|
7298
7392
|
Z as createCamera,
|
|
7299
|
-
|
|
7393
|
+
e as createCompound,
|
|
7300
7394
|
d10 as createDistanceQuery,
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7395
|
+
m as createEdge,
|
|
7396
|
+
n as createFace,
|
|
7397
|
+
v as createHandle,
|
|
7398
|
+
i as createHistory,
|
|
7399
|
+
w as createKernelHandle,
|
|
7400
|
+
b6 as createMeshCache,
|
|
7401
|
+
a4 as createNamedPlane,
|
|
7308
7402
|
createOperationRegistry,
|
|
7309
|
-
|
|
7310
|
-
|
|
7311
|
-
|
|
7403
|
+
c2 as createPlane,
|
|
7404
|
+
j3 as createRegistry,
|
|
7405
|
+
x as createShell,
|
|
7312
7406
|
createSolid,
|
|
7313
7407
|
createTaskQueue,
|
|
7314
|
-
|
|
7408
|
+
f as createVertex,
|
|
7315
7409
|
createWire,
|
|
7316
7410
|
createWorkerClient,
|
|
7317
7411
|
createWorkerHandler,
|
|
@@ -7325,51 +7419,51 @@ export {
|
|
|
7325
7419
|
curve2dTangentAt,
|
|
7326
7420
|
curveEndPoint,
|
|
7327
7421
|
curveIsClosed,
|
|
7328
|
-
|
|
7422
|
+
j8 as curveIsPeriodic,
|
|
7329
7423
|
curveLength,
|
|
7330
|
-
|
|
7424
|
+
k7 as curvePeriod,
|
|
7331
7425
|
curvePointAt,
|
|
7332
7426
|
curveStartPoint,
|
|
7333
7427
|
curveTangentAt,
|
|
7334
7428
|
cut,
|
|
7335
7429
|
d5 as cut2D,
|
|
7336
7430
|
cutAll,
|
|
7337
|
-
|
|
7338
|
-
|
|
7431
|
+
j4 as cutBlueprints,
|
|
7432
|
+
q5 as cylinder,
|
|
7339
7433
|
dequeueTask,
|
|
7340
7434
|
describe,
|
|
7341
|
-
|
|
7342
|
-
|
|
7435
|
+
g5 as deserializeDrawing,
|
|
7436
|
+
k2 as deserializeHistory,
|
|
7343
7437
|
fromBREP$1 as deserializeShape,
|
|
7344
7438
|
d8 as downcast,
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7439
|
+
h4 as draw,
|
|
7440
|
+
i2 as drawCircle,
|
|
7441
|
+
j5 as drawEllipse,
|
|
7348
7442
|
k4 as drawFaceOutline,
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7443
|
+
l4 as drawParametricFunction,
|
|
7444
|
+
m6 as drawPointsInterpolation,
|
|
7445
|
+
n5 as drawPolysides,
|
|
7446
|
+
o4 as drawProjection,
|
|
7353
7447
|
p4 as drawRectangle,
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7448
|
+
q3 as drawRoundedRectangle,
|
|
7449
|
+
r5 as drawSingleCircle,
|
|
7450
|
+
s2 as drawSingleEllipse,
|
|
7357
7451
|
t4 as drawText,
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7452
|
+
u2 as drawingChamfer,
|
|
7453
|
+
v3 as drawingCut,
|
|
7454
|
+
w4 as drawingFillet,
|
|
7361
7455
|
x4 as drawingFuse,
|
|
7362
7456
|
y4 as drawingIntersect,
|
|
7363
|
-
|
|
7457
|
+
z4 as drawingToSketchOnPlane,
|
|
7364
7458
|
drill,
|
|
7365
7459
|
edgeFinder,
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7460
|
+
u3 as edgesOfFace,
|
|
7461
|
+
v4 as ellipse,
|
|
7462
|
+
w5 as ellipseArc,
|
|
7463
|
+
x5 as ellipsoid,
|
|
7370
7464
|
enqueueTask,
|
|
7371
7465
|
err,
|
|
7372
|
-
|
|
7466
|
+
m5 as exportAssemblySTEP,
|
|
7373
7467
|
exportDXF,
|
|
7374
7468
|
exportGlb,
|
|
7375
7469
|
exportGltf,
|
|
@@ -7379,60 +7473,61 @@ export {
|
|
|
7379
7473
|
f9 as exportSTL,
|
|
7380
7474
|
exportThreeMF,
|
|
7381
7475
|
extrude,
|
|
7382
|
-
|
|
7476
|
+
y5 as face,
|
|
7383
7477
|
faceCenter,
|
|
7384
7478
|
faceFinder,
|
|
7385
7479
|
f8 as faceGeomType,
|
|
7386
|
-
|
|
7387
|
-
|
|
7480
|
+
q6 as faceOrientation,
|
|
7481
|
+
z5 as facesOfEdge,
|
|
7388
7482
|
i8 as fill,
|
|
7389
|
-
|
|
7483
|
+
A5 as filledFace,
|
|
7390
7484
|
fillet,
|
|
7391
|
-
findCurveType,
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7485
|
+
y as findCurveType,
|
|
7486
|
+
l5 as findFacesByTag,
|
|
7487
|
+
n4 as findNode,
|
|
7488
|
+
o2 as findStep,
|
|
7489
|
+
l as flatMap,
|
|
7490
|
+
m2 as flatten,
|
|
7396
7491
|
r8 as flipFaceOrientation,
|
|
7397
|
-
|
|
7492
|
+
l7 as flipOrientation,
|
|
7398
7493
|
_ as fontMetrics,
|
|
7399
7494
|
fromBREP,
|
|
7400
7495
|
fromKernelDir,
|
|
7401
7496
|
fromKernelPnt,
|
|
7402
7497
|
fromKernelVec,
|
|
7403
|
-
|
|
7498
|
+
n2 as fromNullable,
|
|
7404
7499
|
fuse,
|
|
7405
|
-
|
|
7500
|
+
f5 as fuse2D,
|
|
7406
7501
|
fuseAll,
|
|
7407
7502
|
k3 as fuseBlueprints,
|
|
7408
|
-
g3 as genericSweep,
|
|
7409
7503
|
getBounds,
|
|
7410
7504
|
getBounds2D,
|
|
7411
|
-
|
|
7505
|
+
g8 as getCurveType,
|
|
7506
|
+
z as getDisposalStats,
|
|
7412
7507
|
getEdges,
|
|
7413
|
-
|
|
7414
|
-
getFaceOrigins,
|
|
7415
|
-
|
|
7508
|
+
m7 as getFaceColor,
|
|
7509
|
+
g10 as getFaceOrigins,
|
|
7510
|
+
n6 as getFaceTags,
|
|
7416
7511
|
getFaces,
|
|
7417
7512
|
$ as getFont,
|
|
7418
|
-
|
|
7419
|
-
|
|
7513
|
+
g6 as getHashCode,
|
|
7514
|
+
p2 as getHistoryShape,
|
|
7420
7515
|
getKernel,
|
|
7421
|
-
|
|
7516
|
+
b5 as getOrientation,
|
|
7422
7517
|
getOrientation2D,
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7518
|
+
o5 as getShapeColor,
|
|
7519
|
+
a as getShapeKind,
|
|
7520
|
+
g4 as getSingleFace,
|
|
7426
7521
|
getSurfaceType,
|
|
7427
|
-
|
|
7522
|
+
q4 as getTagMetadata,
|
|
7428
7523
|
getVertices,
|
|
7429
7524
|
getWires,
|
|
7430
|
-
guidedSweep,
|
|
7525
|
+
q2 as guidedSweep,
|
|
7431
7526
|
heal,
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
|
|
7527
|
+
B6 as healFace,
|
|
7528
|
+
C7 as healSolid,
|
|
7529
|
+
D5 as healWire,
|
|
7530
|
+
E5 as helix,
|
|
7436
7531
|
hull,
|
|
7437
7532
|
importDXF,
|
|
7438
7533
|
importIGES,
|
|
@@ -7442,73 +7537,74 @@ export {
|
|
|
7442
7537
|
importSVG,
|
|
7443
7538
|
importSVGPathD,
|
|
7444
7539
|
importThreeMF,
|
|
7445
|
-
|
|
7540
|
+
A as initFromOC,
|
|
7446
7541
|
innerWires,
|
|
7447
7542
|
m8 as interpolateCurve,
|
|
7448
7543
|
intersect,
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7544
|
+
h3 as intersect2D,
|
|
7545
|
+
l3 as intersectBlueprints,
|
|
7546
|
+
i6 as invalidateShapeCache,
|
|
7452
7547
|
ioError,
|
|
7453
|
-
|
|
7454
|
-
|
|
7548
|
+
B as is2D,
|
|
7549
|
+
C as is3D,
|
|
7455
7550
|
isChamferRadius,
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7551
|
+
isClosedWire,
|
|
7552
|
+
s3 as isCompSolid,
|
|
7553
|
+
E as isCompound,
|
|
7459
7554
|
isDisposeRequest,
|
|
7460
7555
|
isEdge,
|
|
7461
7556
|
isEmpty,
|
|
7462
|
-
|
|
7557
|
+
b4 as isEqualShape,
|
|
7463
7558
|
isErr,
|
|
7464
7559
|
isErrorResponse,
|
|
7465
7560
|
isFace,
|
|
7466
7561
|
isFilletRadius,
|
|
7467
7562
|
isInitRequest,
|
|
7468
7563
|
isInside2D,
|
|
7469
|
-
|
|
7470
|
-
|
|
7564
|
+
F as isLive,
|
|
7565
|
+
isManifoldShell,
|
|
7471
7566
|
isNumber,
|
|
7472
|
-
|
|
7567
|
+
f2 as isOk,
|
|
7473
7568
|
isOperationRequest,
|
|
7474
|
-
|
|
7569
|
+
isOrientedFace,
|
|
7475
7570
|
a0 as isProjectionPlane,
|
|
7476
7571
|
isQueueEmpty,
|
|
7477
|
-
|
|
7478
|
-
|
|
7572
|
+
i3 as isSameShape,
|
|
7573
|
+
G as isShape1D,
|
|
7479
7574
|
isShape3D,
|
|
7480
7575
|
isShell,
|
|
7481
7576
|
isSolid,
|
|
7482
7577
|
isSuccessResponse,
|
|
7483
7578
|
isValid,
|
|
7484
|
-
|
|
7485
|
-
|
|
7579
|
+
isValidSolid,
|
|
7580
|
+
H as isVertex,
|
|
7486
7581
|
isWire,
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
iterTopo,
|
|
7490
|
-
|
|
7491
|
-
|
|
7582
|
+
j9 as iterEdges,
|
|
7583
|
+
k8 as iterFaces,
|
|
7584
|
+
i5 as iterTopo,
|
|
7585
|
+
l9 as iterVertices,
|
|
7586
|
+
m10 as iterWires,
|
|
7492
7587
|
kernelCall,
|
|
7493
7588
|
kernelCallRaw,
|
|
7494
7589
|
kernelCallScoped,
|
|
7495
7590
|
kernelError,
|
|
7496
|
-
|
|
7591
|
+
F6 as line,
|
|
7497
7592
|
linearPattern,
|
|
7498
7593
|
a1 as loadFont,
|
|
7499
7594
|
loft,
|
|
7500
|
-
|
|
7501
|
-
|
|
7595
|
+
A4 as makeBaseBox,
|
|
7596
|
+
m4 as makePlane,
|
|
7502
7597
|
a22 as makeProjectedEdges,
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7598
|
+
manifoldShell,
|
|
7599
|
+
p as map,
|
|
7600
|
+
r as mapBoth,
|
|
7601
|
+
w2 as mapErr,
|
|
7602
|
+
x2 as match,
|
|
7507
7603
|
measureArea,
|
|
7508
7604
|
e7 as measureCurvatureAt,
|
|
7509
7605
|
f10 as measureCurvatureAtMid,
|
|
7510
7606
|
g9 as measureDistance,
|
|
7511
|
-
|
|
7607
|
+
h6 as measureLength,
|
|
7512
7608
|
i7 as measureLinearProps,
|
|
7513
7609
|
measureSurfaceProps,
|
|
7514
7610
|
measureVolume,
|
|
@@ -7520,169 +7616,169 @@ export {
|
|
|
7520
7616
|
mirror2D,
|
|
7521
7617
|
B5 as mirrorDrawing,
|
|
7522
7618
|
mirrorJoin,
|
|
7523
|
-
|
|
7524
|
-
|
|
7525
|
-
multiSectionSweep,
|
|
7619
|
+
r3 as modifyStep,
|
|
7620
|
+
y2 as moduleInitError,
|
|
7621
|
+
t3 as multiSectionSweep,
|
|
7526
7622
|
normalAt,
|
|
7527
7623
|
offset,
|
|
7528
|
-
|
|
7529
|
-
|
|
7624
|
+
G5 as offsetFace,
|
|
7625
|
+
o7 as offsetWire2D,
|
|
7530
7626
|
ok,
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7627
|
+
z2 as or,
|
|
7628
|
+
A2 as orElse,
|
|
7629
|
+
o3 as organiseBlueprints,
|
|
7630
|
+
orientedFace,
|
|
7535
7631
|
outerWire,
|
|
7536
7632
|
pendingCount,
|
|
7537
|
-
|
|
7538
|
-
|
|
7633
|
+
C2 as pipeline,
|
|
7634
|
+
b as pivotPlane,
|
|
7539
7635
|
pocket,
|
|
7540
|
-
|
|
7541
|
-
|
|
7636
|
+
p6 as pointOnSurface,
|
|
7637
|
+
H4 as polygon,
|
|
7542
7638
|
polyhedron,
|
|
7543
7639
|
E4 as polysideInnerRadius,
|
|
7544
7640
|
p3 as polysidesBlueprint,
|
|
7545
7641
|
a32 as projectEdges,
|
|
7546
|
-
|
|
7642
|
+
t6 as projectPointOnFace,
|
|
7547
7643
|
queryError,
|
|
7548
7644
|
rectangularPattern,
|
|
7549
7645
|
registerHandler,
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7646
|
+
I as registerKernel,
|
|
7647
|
+
u as registerOperation,
|
|
7648
|
+
v2 as registerShape,
|
|
7553
7649
|
rejectAll,
|
|
7554
7650
|
x3 as removeChild,
|
|
7555
|
-
|
|
7651
|
+
v5 as removeHolesFromFace,
|
|
7556
7652
|
y3 as replayFrom,
|
|
7557
|
-
|
|
7558
|
-
|
|
7653
|
+
z3 as replayHistory,
|
|
7654
|
+
J as resetDisposalStats,
|
|
7655
|
+
I4 as resize,
|
|
7559
7656
|
resolve,
|
|
7560
7657
|
resolve3D,
|
|
7561
|
-
|
|
7562
|
-
|
|
7658
|
+
r6 as resolveDirection,
|
|
7659
|
+
r2 as resolvePlane,
|
|
7563
7660
|
reverseCurve,
|
|
7564
|
-
r as revolution,
|
|
7565
7661
|
revolve,
|
|
7566
7662
|
roof,
|
|
7567
7663
|
rotate,
|
|
7568
7664
|
rotate2D,
|
|
7569
|
-
|
|
7570
|
-
|
|
7665
|
+
F5 as rotateDrawing,
|
|
7666
|
+
r4 as roundedRectangleBlueprint,
|
|
7571
7667
|
scale,
|
|
7572
7668
|
scale2D,
|
|
7573
|
-
|
|
7669
|
+
G4 as scaleDrawing,
|
|
7574
7670
|
section,
|
|
7575
7671
|
sectionToFace,
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7672
|
+
A3 as serializeHistory,
|
|
7673
|
+
s4 as setShapeOrigin,
|
|
7674
|
+
r7 as setTagMetadata,
|
|
7675
|
+
J4 as sewShells,
|
|
7580
7676
|
shape,
|
|
7581
7677
|
w6 as shapeType,
|
|
7582
|
-
|
|
7678
|
+
K4 as sharedEdges,
|
|
7583
7679
|
shell,
|
|
7584
7680
|
simplify,
|
|
7585
7681
|
sketch2DOnFace,
|
|
7586
7682
|
sketch2DOnPlane,
|
|
7587
7683
|
H3 as sketchCircle,
|
|
7588
7684
|
I3 as sketchEllipse,
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7685
|
+
J3 as sketchExtrude,
|
|
7686
|
+
K3 as sketchFace,
|
|
7687
|
+
L3 as sketchFaceOffset,
|
|
7688
|
+
M3 as sketchHelix,
|
|
7593
7689
|
N2 as sketchLoft,
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7690
|
+
O2 as sketchParametricFunction,
|
|
7691
|
+
P as sketchPolysides,
|
|
7692
|
+
Q as sketchRectangle,
|
|
7693
|
+
R2 as sketchRevolve,
|
|
7598
7694
|
T as sketchRoundedRectangle,
|
|
7599
7695
|
U as sketchSweep,
|
|
7600
7696
|
a42 as sketchText,
|
|
7601
7697
|
V as sketchWires,
|
|
7602
|
-
|
|
7698
|
+
D as sketcherStateError,
|
|
7603
7699
|
slice,
|
|
7604
|
-
|
|
7700
|
+
L4 as solid,
|
|
7605
7701
|
solveAssembly,
|
|
7606
|
-
|
|
7702
|
+
M4 as sphere,
|
|
7607
7703
|
split,
|
|
7608
|
-
|
|
7704
|
+
B2 as stepCount,
|
|
7609
7705
|
C3 as stepsFrom,
|
|
7610
7706
|
stretch2D,
|
|
7611
|
-
|
|
7612
|
-
|
|
7707
|
+
N3 as subFace,
|
|
7708
|
+
D3 as supportExtrude,
|
|
7613
7709
|
supportsConstraintSketch,
|
|
7614
7710
|
supportsProjection,
|
|
7615
7711
|
surfaceFromGrid,
|
|
7616
7712
|
surfaceFromImage,
|
|
7617
7713
|
sweep,
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
|
|
7621
|
-
|
|
7714
|
+
t5 as tagFaces,
|
|
7715
|
+
O3 as tangentArc,
|
|
7716
|
+
E2 as tap,
|
|
7717
|
+
F2 as tapErr,
|
|
7622
7718
|
a52 as textBlueprints,
|
|
7623
7719
|
a62 as textMetrics,
|
|
7624
7720
|
thicken,
|
|
7625
|
-
|
|
7721
|
+
P2 as threePointArc,
|
|
7626
7722
|
toBREP,
|
|
7627
|
-
|
|
7628
|
-
|
|
7723
|
+
Q2 as toBufferGeometryData,
|
|
7724
|
+
R3 as toGroupedBufferGeometryData,
|
|
7629
7725
|
toKernelVec,
|
|
7630
|
-
|
|
7726
|
+
S3 as toLineGeometryData,
|
|
7631
7727
|
toSVGPathD,
|
|
7632
|
-
|
|
7728
|
+
a8 as toVec2,
|
|
7633
7729
|
toVec3,
|
|
7634
|
-
|
|
7730
|
+
T2 as torus,
|
|
7635
7731
|
transformCopy,
|
|
7636
7732
|
translate,
|
|
7637
7733
|
translate2D,
|
|
7638
7734
|
W as translateDrawing,
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7735
|
+
t2 as translatePlane,
|
|
7736
|
+
G2 as tryCatch,
|
|
7737
|
+
H2 as tryCatchAsync,
|
|
7642
7738
|
E3 as twistExtrude,
|
|
7643
7739
|
typeCastError,
|
|
7644
|
-
|
|
7645
|
-
|
|
7740
|
+
F3 as undoLast,
|
|
7741
|
+
I2 as unsupportedError,
|
|
7646
7742
|
unwrap$1 as unwrap,
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
|
|
7743
|
+
J2 as unwrapErr,
|
|
7744
|
+
K2 as unwrapOr,
|
|
7745
|
+
L2 as unwrapOrElse,
|
|
7746
|
+
G3 as updateNode,
|
|
7747
|
+
u4 as uvBounds,
|
|
7748
|
+
h5 as uvCoordinates,
|
|
7749
|
+
validSolid,
|
|
7654
7750
|
validationError,
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7751
|
+
a3 as vecAdd,
|
|
7752
|
+
j2 as vecAngle,
|
|
7753
|
+
e2 as vecCross,
|
|
7658
7754
|
vecDistance,
|
|
7659
|
-
|
|
7660
|
-
|
|
7755
|
+
d2 as vecDot,
|
|
7756
|
+
k as vecEquals,
|
|
7661
7757
|
vecIsZero,
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7758
|
+
vecLength,
|
|
7759
|
+
l2 as vecLengthSq,
|
|
7760
|
+
m3 as vecNegate,
|
|
7665
7761
|
vecNormalize,
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7762
|
+
n3 as vecProjectToPlane,
|
|
7763
|
+
o as vecRepr,
|
|
7764
|
+
g2 as vecRotate,
|
|
7669
7765
|
vecScale,
|
|
7670
|
-
|
|
7671
|
-
|
|
7766
|
+
f3 as vecSub,
|
|
7767
|
+
U2 as vertex,
|
|
7672
7768
|
vertexFinder,
|
|
7673
7769
|
vertexPosition,
|
|
7674
|
-
|
|
7770
|
+
V2 as verticesOfEdge,
|
|
7675
7771
|
walkAssembly,
|
|
7676
|
-
|
|
7677
|
-
wireFinder,
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7772
|
+
W2 as wire,
|
|
7773
|
+
w3 as wireFinder,
|
|
7774
|
+
X2 as wireLoop,
|
|
7775
|
+
Y2 as wiresOfFace,
|
|
7776
|
+
K as withKernel,
|
|
7681
7777
|
withKernelDir,
|
|
7682
7778
|
withKernelPnt,
|
|
7683
7779
|
withKernelVec,
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7780
|
+
L as withScope,
|
|
7781
|
+
M as withScopeResult,
|
|
7782
|
+
N as withScopeResultAsync,
|
|
7783
|
+
M2 as zipResults
|
|
7688
7784
|
};
|