@faicad/sheetmetal 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/allowanceFns.d.ts +1 -1
- package/dist/allowanceFns.d.ts.map +1 -1
- package/dist/allowanceFns.js +1 -1
- package/dist/allowanceFns.js.map +1 -1
- package/dist/api.d.ts +21 -20
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +20 -20
- package/dist/api.js.map +1 -1
- package/dist/authorFns.d.ts +2 -2
- package/dist/authorFns.d.ts.map +1 -1
- package/dist/authorFns.js +61 -51
- package/dist/authorFns.js.map +1 -1
- package/dist/bendTableFns.d.ts +1 -1
- package/dist/bendTableFns.d.ts.map +1 -1
- package/dist/bendTableFns.js +1 -1
- package/dist/bendTableFns.js.map +1 -1
- package/dist/contourFlangeFns.d.ts +5 -4
- package/dist/contourFlangeFns.d.ts.map +1 -1
- package/dist/contourFlangeFns.js +59 -44
- package/dist/contourFlangeFns.js.map +1 -1
- package/dist/cutoutFns.d.ts +5 -5
- package/dist/cutoutFns.d.ts.map +1 -1
- package/dist/cutoutFns.js +22 -14
- package/dist/cutoutFns.js.map +1 -1
- package/dist/dxfFns.d.ts +1 -1
- package/dist/dxfFns.d.ts.map +1 -1
- package/dist/dxfFns.js +1 -1
- package/dist/dxfFns.js.map +1 -1
- package/dist/facade.d.ts +43 -42
- package/dist/facade.d.ts.map +1 -1
- package/dist/facade.js +83 -83
- package/dist/facade.js.map +1 -1
- package/dist/featureTreeFns.d.ts +1 -1
- package/dist/featureTreeFns.d.ts.map +1 -1
- package/dist/featureTreeFns.js +1 -1
- package/dist/featureTreeFns.js.map +1 -1
- package/dist/foldFns.d.ts +3 -3
- package/dist/foldFns.d.ts.map +1 -1
- package/dist/foldFns.js +12 -12
- package/dist/foldFns.js.map +1 -1
- package/dist/foreignUnfoldFns.d.ts +2 -1
- package/dist/foreignUnfoldFns.d.ts.map +1 -1
- package/dist/foreignUnfoldFns.js +21 -10
- package/dist/foreignUnfoldFns.js.map +1 -1
- package/dist/formFns.d.ts +4 -4
- package/dist/formFns.d.ts.map +1 -1
- package/dist/formFns.js +91 -76
- package/dist/formFns.js.map +1 -1
- package/dist/geometryOps.d.ts +32 -0
- package/dist/geometryOps.d.ts.map +1 -0
- package/dist/geometryOps.js +83 -0
- package/dist/geometryOps.js.map +1 -0
- package/dist/hemFns.d.ts +2 -2
- package/dist/hemFns.d.ts.map +1 -1
- package/dist/hemFns.js +4 -4
- package/dist/hemFns.js.map +1 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/jogFns.d.ts +2 -2
- package/dist/jogFns.d.ts.map +1 -1
- package/dist/jogFns.js +6 -6
- package/dist/jogFns.js.map +1 -1
- package/dist/loftedFlangeFns.d.ts +2 -2
- package/dist/loftedFlangeFns.d.ts.map +1 -1
- package/dist/loftedFlangeFns.js +35 -25
- package/dist/loftedFlangeFns.js.map +1 -1
- package/dist/miterFns.d.ts +3 -3
- package/dist/miterFns.d.ts.map +1 -1
- package/dist/miterFns.js +30 -19
- package/dist/miterFns.js.map +1 -1
- package/dist/nestFns.d.ts +1 -1
- package/dist/nestFns.d.ts.map +1 -1
- package/dist/nestFns.js +1 -1
- package/dist/nestFns.js.map +1 -1
- package/dist/polygonFns.d.ts +2 -2
- package/dist/polygonFns.d.ts.map +1 -1
- package/dist/polygonFns.js +1 -1
- package/dist/polygonFns.js.map +1 -1
- package/dist/reliefFns.d.ts +4 -4
- package/dist/reliefFns.d.ts.map +1 -1
- package/dist/reliefFns.js +39 -31
- package/dist/reliefFns.js.map +1 -1
- package/dist/reportFns.d.ts +1 -1
- package/dist/reportFns.d.ts.map +1 -1
- package/dist/reportFns.js +1 -1
- package/dist/reportFns.js.map +1 -1
- package/dist/tabFns.d.ts +3 -3
- package/dist/tabFns.d.ts.map +1 -1
- package/dist/tabFns.js +21 -13
- package/dist/tabFns.js.map +1 -1
- package/dist/types.d.ts +21 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/unfoldFns.d.ts +1 -1
- package/dist/unfoldFns.d.ts.map +1 -1
- package/dist/unfoldFns.js +2 -2
- package/dist/unfoldFns.js.map +1 -1
- package/dist/validateFns.d.ts.map +1 -1
- package/dist/validateFns.js +4 -6
- package/dist/validateFns.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foreignUnfoldFns.js","sourceRoot":"","sources":["../src/foreignUnfoldFns.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,EAAE,EACF,GAAG,EACH,eAAe,EACf,QAAQ,EACR,cAAc,EACd,cAAc,EACd,QAAQ,EACR,UAAU,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,IAAI,EACJ,QAAQ,GACT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC;AAqBtB;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAU,EAAE,CAAS;IACvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG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EAAE,CAAC,CAAC,CAAC;QACvB,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,IAAkB,EAAE,MAAoB;IAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import {\n type Result,\n type Vec3,\n type Solid,\n type Face,\n ok,\n err,\n validationError,\n getFaces,\n getSurfaceType,\n pointOnSurface,\n normalAt,\n faceCenter,\n sharedEdges,\n measureArea,\n getBounds,\n isValid,\n vecAdd,\n vecSub,\n vecScale,\n vecDot,\n vecCross,\n vecLength,\n vecNormalize,\n line,\n wireLoop,\n} from '@faicad/faijs/brepjs-compat';\nimport type {\n UnfoldResult,\n FlatPattern,\n BendReport,\n SheetMetalWarning,\n} from './types.js';\nimport { developedLength } from './allowanceFns.js';\n\n/** Default neutral-axis K-factor for a purely geometric unfold (mid-surface). */\nconst DEFAULT_FOREIGN_K = 0.5;\n/** Relative tolerance for the cylinder-fit residual (fraction of the radius). */\nconst FIT_RESIDUAL_TOL = 1e-2;\n/** Absolute tolerance for matching parallel planes / coincident geometry. */\nconst GEOM_TOL = 1e-4;\n\n/** A fitted cylinder recovered numerically from a face's sampled points + normals. */\nexport interface FittedCylinder {\n /** A point on the axis line. */\n axisOrigin: Vec3;\n /** Unit axis direction. */\n axisDir: Vec3;\n /** Fitted radius (mean distance from the axis line to the sampled points). */\n radius: number;\n /** Angular extent swept by the face about the axis, in radians. */\n angleSpan: number;\n /** Max relative residual of the fit (fraction of radius); small for a true cylinder. */\n residual: number;\n}\n\ninterface Sample {\n point: Vec3;\n normal: Vec3;\n}\n\n/**\n * Sample a regular grid of surface points and their normals across the face's UV\n * bounds. `pointOnSurface` takes normalized (0-1) UV; `normalAt` re-projects the\n * sampled point to UV internally, so the pair holds for true cylinders/planes but\n * is not an exact-UV guarantee for degenerate parameterizations.\n */\nfunction sampleFace(face: Face, n: number): Sample[] {\n const samples: Sample[] = [];\n for (let i = 0; i < n; i += 1) {\n const u = n === 1 ? 0.5 : i / (n - 1);\n for (let j = 0; j < n; j += 1) {\n const v = n === 1 ? 0.5 : j / (n - 1);\n const point = pointOnSurface(face, u, v);\n const normal = normalAt(face, point);\n const len = vecLength(normal);\n if (len < GEOM_TOL) continue;\n samples.push({ point, normal: vecScale(normal, 1 / len) });\n }\n }\n return samples;\n}\n\n/**\n * Numerically fit a cylinder to a face.\n *\n * Every normal of a cylinder is perpendicular to the axis, so the axis direction\n * is the common perpendicular of the sampled normals: it is recovered as the\n * sign-aligned average of the cross products of pairs of non-parallel sampled\n * normals (each such cross product lies along ±axis). The axis LINE and RADIUS\n * are then found by projecting the sample points onto the plane ⟂ axis and\n * fitting a circle (algebraic least squares); the radius is the mean distance\n * from the axis line to the points. The angular span is the extent of the\n * projected points about the fitted centre. Returns `null` when the surface\n * does not fit a cylinder within {@link FIT_RESIDUAL_TOL}.\n *\n * @param face - the B-rep face to fit.\n * @returns the fitted cylinder, or null if the face is not cylindrical.\n */\nexport function fitCylinder(face: Face): FittedCylinder | null {\n const surf = getSurfaceType(face);\n if (!surf.ok || surf.value !== 'CYLINDRE') return null;\n\n const samples = sampleFace(face, 6);\n if (samples.length < 4) return null;\n\n const axisDir = axisFromNormals(samples.map((s) => s.normal));\n if (axisDir === null) return null;\n\n // Project points onto the plane ⟂ axis (in a local 2D basis) and fit a circle.\n const basis = perpBasis(axisDir);\n const pts2: [number, number][] = samples.map((s) => [\n vecDot(s.point, basis.e1),\n vecDot(s.point, basis.e2),\n ]);\n const circle = fitCircle2(pts2);\n if (circle === null) return null;\n\n // Lift the 2D centre back to a 3D point on the axis: use the axial component of\n // an arbitrary sample so the origin sits at a real location on the face.\n const axial = vecDot(samples[0]?.point ?? [0, 0, 0], axisDir);\n const axisOrigin = vecAdd(\n vecAdd(vecScale(basis.e1, circle.cx), vecScale(basis.e2, circle.cy)),\n vecScale(axisDir, axial)\n );\n\n // Radius = mean distance from the axis line to the sampled points; residual is\n // the max relative deviation from that radius (a true cylinder is near zero).\n let sumR = 0;\n for (const s of samples) sumR += distanceToAxis(s.point, axisOrigin, axisDir);\n const radius = sumR / samples.length;\n if (radius < GEOM_TOL) return null;\n let maxDev = 0;\n for (const s of samples) {\n const d = distanceToAxis(s.point, axisOrigin, axisDir);\n maxDev = Math.max(maxDev, Math.abs(d - radius));\n }\n const residual = maxDev / radius;\n if (residual > FIT_RESIDUAL_TOL) return null;\n\n const angleSpan = angularExtent(pts2, circle.cx, circle.cy);\n return { axisOrigin, axisDir, radius, angleSpan, residual };\n}\n\n/**\n * Axis direction as the common perpendicular of the cylinder normals: average the\n * cross products of pairs of sufficiently non-parallel normals, aligning each to a\n * consistent hemisphere before summing so they don't cancel. Returns `null` if no\n * pair is non-parallel (a degenerate/near-planar sample).\n */\nfunction axisFromNormals(normals: Vec3[]): Vec3 | null {\n let acc: Vec3 = [0, 0, 0];\n let ref: Vec3 | null = null;\n for (let i = 0; i < normals.length; i += 1) {\n for (let j = i + 1; j < normals.length; j += 1) {\n const a = normals[i];\n const b = normals[j];\n if (a === undefined || b === undefined) continue;\n const c = vecCross(a, b);\n const len = vecLength(c);\n if (len < 1e-3) continue;\n let unit = vecScale(c, 1 / len);\n if (ref === null) ref = unit;\n else if (vecDot(unit, ref) < 0) unit = vecScale(unit, -1);\n acc = vecAdd(acc, unit);\n }\n }\n if (vecLength(acc) < GEOM_TOL) return null;\n return vecNormalize(acc);\n}\n\n/** An orthonormal pair spanning the plane perpendicular to `axis`. */\nfunction perpBasis(axis: Vec3): { e1: Vec3; e2: Vec3 } {\n const seed: Vec3 = Math.abs(axis[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0];\n const e1 = vecNormalize(vecCross(axis, seed));\n const e2 = vecNormalize(vecCross(axis, e1));\n return { e1, e2 };\n}\n\n/** Perpendicular distance from `p` to the line through `o` with unit direction `d`. */\nfunction distanceToAxis(p: Vec3, o: Vec3, d: Vec3): number {\n const w = vecSub(p, o);\n const along = vecDot(w, d);\n const perp = vecSub(w, vecScale(d, along));\n return vecLength(perp);\n}\n\n/** Algebraic (Kåsa) least-squares circle fit to 2D points. */\nfunction fitCircle2(pts: [number, number][]): { cx: number; cy: number; r: number } | null {\n const n = pts.length;\n if (n < 3) return null;\n let sx = 0;\n let sy = 0;\n let sxx = 0;\n let syy = 0;\n let sxy = 0;\n let sxz = 0;\n let syz = 0;\n let sz = 0;\n for (const [x, y] of pts) {\n const z = x * x + y * y;\n sx += x;\n sy += y;\n sxx += x * x;\n syy += y * y;\n sxy += x * y;\n sxz += x * z;\n syz += y * z;\n sz += z;\n }\n // Solve the normal equations for [A, B, C] in A·x + B·y + C = z (= x²+y²).\n const m = [\n [sxx, sxy, sx],\n [sxy, syy, sy],\n [sx, sy, n],\n ];\n const rhs = [sxz, syz, sz];\n const sol = solve3(m, rhs);\n if (sol === null) return null;\n const [a, b, c] = sol;\n const cx = a / 2;\n const cy = b / 2;\n const r2 = c + cx * cx + cy * cy;\n if (r2 <= 0) return null;\n return { cx, cy, r: Math.sqrt(r2) };\n}\n\n/** Solve a 3×3 linear system by Cramer's rule; `null` if (near-)singular. */\nfunction solve3(m: number[][], rhs: number[]): [number, number, number] | null {\n const det = det3(m);\n if (Math.abs(det) < 1e-12) return null;\n const mx = [\n [rhs[0] ?? 0, m[0]?.[1] ?? 0, m[0]?.[2] ?? 0],\n [rhs[1] ?? 0, m[1]?.[1] ?? 0, m[1]?.[2] ?? 0],\n [rhs[2] ?? 0, m[2]?.[1] ?? 0, m[2]?.[2] ?? 0],\n ];\n const my = [\n [m[0]?.[0] ?? 0, rhs[0] ?? 0, m[0]?.[2] ?? 0],\n [m[1]?.[0] ?? 0, rhs[1] ?? 0, m[1]?.[2] ?? 0],\n [m[2]?.[0] ?? 0, rhs[2] ?? 0, m[2]?.[2] ?? 0],\n ];\n const mz = [\n [m[0]?.[0] ?? 0, m[0]?.[1] ?? 0, rhs[0] ?? 0],\n [m[1]?.[0] ?? 0, m[1]?.[1] ?? 0, rhs[1] ?? 0],\n [m[2]?.[0] ?? 0, m[2]?.[1] ?? 0, rhs[2] ?? 0],\n ];\n return [det3(mx) / det, det3(my) / det, det3(mz) / det];\n}\n\nfunction det3(m: number[][]): number {\n const a = m[0] ?? [];\n const b = m[1] ?? [];\n const c = m[2] ?? [];\n return (\n (a[0] ?? 0) * ((b[1] ?? 0) * (c[2] ?? 0) - (b[2] ?? 0) * (c[1] ?? 0)) -\n (a[1] ?? 0) * ((b[0] ?? 0) * (c[2] ?? 0) - (b[2] ?? 0) * (c[0] ?? 0)) +\n (a[2] ?? 0) * ((b[0] ?? 0) * (c[1] ?? 0) - (b[1] ?? 0) * (c[0] ?? 0))\n );\n}\n\n/** Angular extent (radians) spanned by 2D points about a centre. */\nfunction angularExtent(pts: [number, number][], cx: number, cy: number): number {\n const angles = pts.map(([x, y]) => Math.atan2(y - cy, x - cx)).sort((a, b) => a - b);\n if (angles.length < 2) return 0;\n // Largest gap between consecutive sorted angles (wrapping); the span is 2π minus it.\n let maxGap = (angles[0] ?? 0) + 2 * Math.PI - (angles[angles.length - 1] ?? 0);\n for (let i = 1; i < angles.length; i += 1) {\n maxGap = Math.max(maxGap, (angles[i] ?? 0) - (angles[i - 1] ?? 0));\n }\n return 2 * Math.PI - maxGap;\n}\n\n// ---------------------------------------------------------------------------\n// Foreign-solid unfold\n// ---------------------------------------------------------------------------\n\n/** A detected flat panel: a pair of large parallel planar faces a thickness apart. */\ninterface DetectedFlat {\n id: string;\n /** The two parallel planar faces (outer + inner) of the panel. */\n faces: [Face, Face];\n /** Mid-surface plane normal (unit). */\n normal: Vec3;\n /** Centroid of the mid-surface. */\n center: Vec3;\n /** Mid-surface area (mean of the two face areas). */\n area: number;\n}\n\n/** A detected bend: a pair of coaxial inner/outer cylindrical faces. */\ninterface DetectedBend {\n id: string;\n faces: Face[];\n fit: FittedCylinder;\n /** Inner radius (smaller of the fitted pair). */\n innerRadius: number;\n /** Swept angle in degrees. */\n angleDeg: number;\n}\n\n/**\n * Unfold an ARBITRARY imported sheet-metal solid with no feature tree, by\n * detecting its geometry numerically. The supported class is roughly-uniform-\n * thickness solids whose panels are planar and whose bends are cylindrical:\n *\n * 1. Classify faces by surface type — planar faces are panel faces, cylindrical\n * faces are bend faces. Any other surface type is reported `UNSUPPORTED_FACE`.\n * 2. Pair the two large parallel planar faces of each flat panel (a thickness\n * apart); pair the inner/outer cylindrical faces of each bend and fit its\n * axis + inner radius + swept angle via {@link fitCylinder}.\n * 3. Build a bend graph (flats = nodes; a bend connects the two flats it shares\n * edges with), take a spanning tree from a root flat, and turn any non-tree\n * bend into a seam cut (warned).\n * 4. Walk the tree replacing each cylindrical bend region with a developed strip\n * of length `developedLength(angle, thickness, { innerRadius, kFactor })`\n * (`kFactor` defaults to the {@link DEFAULT_FOREIGN_K} mid-surface), laying\n * each flat out into the plane. Bend direction (up/down) is read from the\n * cylinder centre relative to the parent flat.\n *\n * Non-fatal warnings ride inside the Ok payload; the function fails only when the\n * input is not a recognizable sheet-metal solid at all.\n *\n * @param solid - the foreign solid to unfold.\n * @param opts - optional k-factor override.\n * @returns the unfold result, or an error.\n */\nexport function unfoldForeignSolid(\n solid: Solid,\n opts?: { kFactor?: number | undefined }\n): Result<UnfoldResult> {\n if (!isValid(solid)) {\n return err(validationError('INVALID_SOLID', 'foreign solid is not a valid B-rep'));\n }\n const kFactor = opts?.kFactor ?? DEFAULT_FOREIGN_K;\n if (!Number.isFinite(kFactor) || kFactor < 0 || kFactor > 1) {\n return err(validationError('INVALID_K_FACTOR', `kFactor must be in [0, 1], got ${kFactor}`));\n }\n\n const warnings: SheetMetalWarning[] = [];\n const faces = getFaces<'3D'>(solid);\n if (faces.length === 0) {\n return err(validationError('EMPTY_SOLID', 'foreign solid has no faces'));\n }\n\n const planarFaces: Face[] = [];\n const cylFaces: Face[] = [];\n for (const face of faces) {\n const t = getSurfaceType(face);\n if (!t.ok) {\n warnings.push({ code: 'UNSUPPORTED_FACE', message: 'failed to read a face surface type; skipping' });\n continue;\n }\n if (t.value === 'PLANE') planarFaces.push(face);\n else if (t.value === 'CYLINDRE') cylFaces.push(face);\n else {\n warnings.push({\n code: 'UNSUPPORTED_FACE',\n message: `UNSUPPORTED_FACE: surface type '${t.value}' is not a planar panel or cylindrical bend; the unfold ignores it and may be incomplete`,\n });\n }\n }\n\n const thicknessResult = detectThickness(planarFaces);\n if (!thicknessResult.ok) return thicknessResult;\n const thickness = thicknessResult.value;\n\n const flats = pairFlats(planarFaces, thickness, warnings);\n if (flats.length === 0) {\n return err(\n validationError('NO_FLATS', 'no planar panel pairs detected; not a recognizable sheet-metal solid')\n );\n }\n\n const bends = pairBends(cylFaces, warnings);\n\n const graph = buildBendGraph(flats, bends, warnings);\n const layout = layoutForeign(flats, graph, thickness, kFactor, warnings);\n if (!layout.ok) return layout;\n\n return ok({ pattern: layout.value.pattern, report: layout.value.report, warnings });\n}\n\n/**\n * Detect the sheet thickness as the smallest gap between an antiparallel pair of\n * planar faces (the two faces of one flat panel). For a roughly-uniform-thickness\n * part this gap is the same across panels; a spread beyond tolerance warns.\n */\nfunction detectThickness(planar: Face[]): Result<number> {\n const gaps: number[] = [];\n for (let i = 0; i < planar.length; i += 1) {\n for (let j = i + 1; j < planar.length; j += 1) {\n const fa = planar[i];\n const fb = planar[j];\n if (fa === undefined || fb === undefined) continue;\n const na = faceNormal(fa);\n const nb = faceNormal(fb);\n if (vecDot(na, nb) > -0.99) continue; // need antiparallel (opposite faces of a panel)\n const ca = faceCenter(fa);\n const cb = faceCenter(fb);\n const gap = Math.abs(vecDot(vecSub(cb, ca), na));\n if (gap > GEOM_TOL) gaps.push(gap);\n }\n }\n if (gaps.length === 0) {\n return err(validationError('NO_THICKNESS', 'could not detect a sheet thickness (no opposed planar pair)'));\n }\n gaps.sort((a, b) => a - b);\n return ok(gaps[0] as number);\n}\n\n/**\n * Pair planar faces into flat panels: each panel is two parallel faces a\n * `thickness` apart with overlapping footprints. Greedy nearest-match by gap.\n */\nfunction pairFlats(planar: Face[], thickness: number, warnings: SheetMetalWarning[]): DetectedFlat[] {\n const used = new Set<number>();\n const flats: DetectedFlat[] = [];\n for (let i = 0; i < planar.length; i += 1) {\n if (used.has(i)) continue;\n const fa = planar[i];\n if (fa === undefined) continue;\n const na = faceNormal(fa);\n const ca = faceCenter(fa);\n let best = -1;\n let bestErr = Infinity;\n for (let j = 0; j < planar.length; j += 1) {\n if (j === i || used.has(j)) continue;\n const fb = planar[j];\n if (fb === undefined) continue;\n const nb = faceNormal(fb);\n if (vecDot(na, nb) > -0.99) continue;\n const cb = faceCenter(fb);\n const gap = Math.abs(vecDot(vecSub(cb, ca), na));\n const e = Math.abs(gap - thickness);\n if (e < bestErr) {\n bestErr = e;\n best = j;\n }\n }\n if (best < 0 || bestErr > thickness * 0.5 + GEOM_TOL) {\n // No usable antiparallel partner at the sheet thickness. A bend-edge cap or\n // rim band is plate-thin in one in-plane direction (≈ thickness) — expected,\n // skip quietly. A face that is wide in BOTH in-plane directions is a real\n // panel; dropping it means non-uniform thickness or unrecognised topology, so\n // flag it. (Area alone can't tell them apart — a long rim is large by area.)\n const db = getBounds(fa);\n const ext = [db.xMax - db.xMin, db.yMax - db.yMin, db.zMax - db.zMin].sort((p, q) => q - p);\n const inPlaneMin = ext[1] ?? 0;\n if (inPlaneMin > thickness * 4) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `a panel-sized planar face (${(ext[0] ?? 0).toFixed(1)}×${inPlaneMin.toFixed(1)}) has no opposite face at the sheet thickness ${thickness.toFixed(3)}; omitted (possible non-uniform thickness)`,\n });\n }\n continue;\n }\n const fb = planar[best] as Face;\n used.add(i);\n used.add(best);\n const areaA = measureArea(fa);\n const areaB = measureArea(fb);\n let area: number;\n if (areaA.ok && areaB.ok) area = (areaA.value + areaB.value) / 2;\n else if (areaA.ok) area = areaA.value;\n else if (areaB.ok) area = areaB.value;\n else {\n // Neither face area is measurable: fall back to the panel's bounding-box\n // footprint so developedArea isn't silently zero, and flag the estimate.\n const b = getBounds(fa);\n const dx = b.xMax - b.xMin;\n const dy = b.yMax - b.yMin;\n const dz = b.zMax - b.zMin;\n area = Math.max(dx * dy, dy * dz, dx * dz);\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `flat-${flats.length}: face area unmeasurable; using a bounding-box estimate (${area.toFixed(2)})`,\n });\n }\n flats.push({\n id: `flat-${flats.length}`,\n faces: [fa, fb],\n normal: na,\n center: vecScale(vecAdd(ca, faceCenter(fb)), 0.5),\n area,\n });\n }\n if (flats.length === 0 && planar.length > 0) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: 'no parallel planar face pairs matched the detected thickness; the part may have non-uniform thickness',\n });\n }\n return flats;\n}\n\n/**\n * Pair cylindrical faces into bends: each bend has an inner + outer coaxial face\n * (same axis, radii a thickness apart) or, failing a pair, a single fitted face.\n */\nfunction pairBends(cyl: Face[], warnings: SheetMetalWarning[]): DetectedBend[] {\n interface Fitted {\n face: Face;\n fit: FittedCylinder;\n }\n const fitted: Fitted[] = [];\n for (const face of cyl) {\n const fit = fitCylinder(face);\n if (fit === null) {\n warnings.push({\n code: 'UNSUPPORTED_FACE',\n message: 'a cylindrical face did not fit a cylinder within tolerance; the bend is ignored',\n });\n continue;\n }\n fitted.push({ face, fit });\n }\n\n const used = new Set<number>();\n const bends: DetectedBend[] = [];\n for (let i = 0; i < fitted.length; i += 1) {\n if (used.has(i)) continue;\n const a = fitted[i];\n if (a === undefined) continue;\n let mate = -1;\n for (let j = i + 1; j < fitted.length; j += 1) {\n if (used.has(j)) continue;\n const b = fitted[j];\n if (b === undefined) continue;\n if (Math.abs(vecDot(a.fit.axisDir, b.fit.axisDir)) < 0.99) continue;\n if (distanceToAxis(b.fit.axisOrigin, a.fit.axisOrigin, a.fit.axisDir) > GEOM_TOL * 10) continue;\n mate = j;\n break;\n }\n const faces: Face[] = [a.face];\n let innerRadius = a.fit.radius;\n let fit = a.fit;\n if (mate >= 0) {\n const b = fitted[mate] as Fitted;\n faces.push(b.face);\n innerRadius = Math.min(a.fit.radius, b.fit.radius);\n fit = a.fit.radius <= b.fit.radius ? a.fit : b.fit;\n used.add(mate);\n }\n used.add(i);\n bends.push({\n id: `bend-${bends.length}`,\n faces,\n fit,\n innerRadius,\n angleDeg: (fit.angleSpan * 180) / Math.PI,\n });\n }\n return bends;\n}\n\ninterface BendGraphEdge {\n bend: DetectedBend;\n flats: [number, number];\n}\n\ninterface BendGraph {\n edges: BendGraphEdge[];\n}\n\n/**\n * Connect bends to the flats they touch: a bend's cylindrical face shares edges\n * with exactly the two flats tangent to it. A bend that touches fewer than two\n * detected flats is dropped (it is a free rim); more than two is ambiguous and\n * warned. Spanning-tree / seam handling happens in {@link layoutForeign}.\n */\nfunction buildBendGraph(\n flats: DetectedFlat[],\n bends: DetectedBend[],\n warnings: SheetMetalWarning[]\n): BendGraph {\n const edges: BendGraphEdge[] = [];\n for (const bend of bends) {\n const touching: number[] = [];\n for (let fi = 0; fi < flats.length; fi += 1) {\n const flat = flats[fi];\n if (flat === undefined) continue;\n if (bendTouchesFlat(bend, flat)) touching.push(fi);\n }\n if (touching.length < 2) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `bend '${bend.id}' connects ${touching.length} flats (expected 2); ignored`,\n featureId: bend.id,\n });\n continue;\n }\n if (touching.length > 2) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `bend '${bend.id}' touches ${touching.length} flats; using the first two`,\n featureId: bend.id,\n });\n }\n edges.push({ bend, flats: [touching[0] as number, touching[1] as number] });\n }\n return { edges };\n}\n\n/** True if any of the bend's faces shares an edge with either face of the flat. */\nfunction bendTouchesFlat(bend: DetectedBend, flat: DetectedFlat): boolean {\n for (const bf of bend.faces) {\n for (const ff of flat.faces) {\n if (sharedEdges(bf, ff).length > 0) return true;\n }\n }\n return false;\n}\n\ninterface ForeignLayout {\n pattern: FlatPattern;\n report: BendReport;\n}\n\n/**\n * Lay out detected flats into the developed plane. A spanning tree over the bend\n * graph (BFS from flat 0) places each flat as a rectangle and each tree bend as a\n * developed strip; non-tree bends become seam cuts (warned). The developed area\n * is the sum of flat mid-surface areas plus each developed-strip area, computed\n * directly from detected geometry. Bend direction is read from the cylinder\n * centre relative to the parent flat's outward normal.\n */\nfunction layoutForeign(\n flats: DetectedFlat[],\n graph: BendGraph,\n thickness: number,\n kFactor: number,\n warnings: SheetMetalWarning[]\n): Result<ForeignLayout> {\n const adjacency = new Map<number, BendGraphEdge[]>();\n for (let i = 0; i < flats.length; i += 1) adjacency.set(i, []);\n for (const e of graph.edges) {\n adjacency.get(e.flats[0])?.push(e);\n adjacency.get(e.flats[1])?.push(e);\n }\n\n const visited = new Set<number>([0]);\n const treeEdges = new Set<BendGraphEdge>();\n const treeBends: { edge: BendGraphEdge; parent: number; child: number }[] = [];\n const queue: number[] = [0];\n while (queue.length > 0) {\n const cur = queue.shift();\n if (cur === undefined) break;\n for (const e of adjacency.get(cur) ?? []) {\n if (treeEdges.has(e)) continue;\n const next = e.flats[0] === cur ? e.flats[1] : e.flats[0];\n if (visited.has(next)) continue;\n visited.add(next);\n treeEdges.add(e);\n treeBends.push({ edge: e, parent: cur, child: next });\n queue.push(next);\n }\n }\n\n for (const e of graph.edges) {\n if (treeEdges.has(e)) continue;\n warnings.push({\n code: 'SEAM_CUT',\n message: `closed profile: bend '${e.bend.id}' becomes a seam cut`,\n featureId: e.bend.id,\n });\n }\n\n // Each bend's strip width = the bend cylinder's axial extent (its span).\n const bendSpan = new Map<DetectedBend, number>();\n for (const e of graph.edges) bendSpan.set(e.bend, bendAxialExtent(e.bend));\n\n // 2D placement: develop each flat into the plane preserving its real fold\n // direction (perpendicular to the bend axis), so an L-bracket lays out L-shaped,\n // not collapsed into a straight chain. Each placed flat carries a consistent\n // 3D→2D affine map (`m2`): a 3D point on the flat's plane maps to 2D via its\n // in-plane basis, so the bend line, edges and develop-out direction are all\n // derived in 3D then mapped to 2D — keeping signs/edges consistent. The root is\n // laid at the origin; a child is placed past its developed strip, out from the\n // shared bend line. The developed AREA is geometry-exact (Σ flat mid-surface\n // areas + Σ developed-strip areas).\n const placed = new Map<number, PlacedFlat>();\n const root = flats[0] as DetectedFlat;\n const rootAxis = treeBends[0]?.edge.bend.fit.axisDir ?? perpBasis(root.normal).e1;\n const rootBasis = planeBasis(root.normal, rootAxis);\n placed.set(0, {\n flat: root,\n a: rootBasis.along,\n b: rootBasis.out,\n o3: root.center,\n o2: [0, 0],\n a2: [1, 0],\n b2: [0, 1],\n });\n\n let developedArea = 0;\n for (const f of flats) developedArea += f.area;\n\n const bendReportRows: BendReport['bends'] = [];\n const rects: Rect2[] = [];\n const bendLines: FlatPattern['bendLines'] = [];\n rects.push(flatRect2(placed.get(0) as PlacedFlat));\n\n for (const tb of treeBends) {\n const bend = tb.edge.bend;\n const dev = developedLength(bend.angleDeg, thickness, { innerRadius: bend.innerRadius, kFactor }, (w) => warnings.push(w));\n if (!dev.ok) return dev;\n const parentPlace = placed.get(tb.parent);\n const parent = flats[tb.parent] as DetectedFlat;\n const child = flats[tb.child] as DetectedFlat;\n if (parentPlace === undefined) continue;\n const direction = bendDirection(bend, parent);\n const axis = bend.fit.axisDir;\n const span = bendSpan.get(bend) ?? bendAxialExtent(bend);\n\n const placement = placeChildFlat(parentPlace, child, bend, axis, span, dev.value);\n placed.set(tb.child, placement.child);\n\n rects.push(placement.strip);\n rects.push(flatRect2(placement.child));\n bendLines.push({\n id: bend.id,\n line: line([placement.bendA[0], placement.bendA[1], 0], [placement.bendB[0], placement.bendB[1], 0]),\n angleDeg: bend.angleDeg,\n direction,\n inward: [-placement.outDir2[0], -placement.outDir2[1]],\n });\n developedArea += dev.value * span;\n\n bendReportRows.push({\n id: bend.id,\n angleDeg: bend.angleDeg,\n radius: bend.innerRadius,\n allowance: dev.value,\n flatLength: placement.runLen,\n direction,\n });\n }\n\n const bbox = aabb2(rects);\n const outline = buildRectOutline2(bbox);\n const outlineWire = wireLoop(outline);\n if (!outlineWire.ok) return outlineWire;\n\n const pattern: FlatPattern = {\n outline: outlineWire.value,\n bendLines,\n holes: [],\n formCuts: [],\n formMarkers: [],\n formHinges: [],\n loftedDevelopments: [],\n developedArea,\n };\n const report: BendReport = {\n bends: bendReportRows,\n totalFlatSize: [bbox.x1 - bbox.x0, bbox.y1 - bbox.y0],\n };\n return ok({ pattern, report });\n}\n\n/**\n * A placed flat: its detected geometry plus a consistent 3D→2D affine map. A 3D\n * point P on the flat's plane maps to `o2 + (P−o3)·a · a2 + (P−o3)·b · b2`, where\n * (a, b) is the flat's in-plane 3D basis and (a2, b2) the 2D images of those axes.\n */\ninterface PlacedFlat {\n flat: DetectedFlat;\n a: Vec3;\n b: Vec3;\n o3: Vec3;\n o2: [number, number];\n a2: [number, number];\n b2: [number, number];\n}\n\ninterface Rect2 {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\n/** Map a 3D in-plane point through a placed flat's affine map. */\nfunction mapPoint(p: PlacedFlat, point: Vec3): [number, number] {\n const da = vecDot(vecSub(point, p.o3), p.a);\n const db = vecDot(vecSub(point, p.o3), p.b);\n return [p.o2[0] + da * p.a2[0] + db * p.b2[0], p.o2[1] + da * p.a2[1] + db * p.b2[1]];\n}\n\n/** 3D in-plane basis of a flat: `along` parallel to `axis`, `out` perpendicular. */\nfunction planeBasis(normal: Vec3, axis: Vec3): { along: Vec3; out: Vec3 } {\n const proj = vecSub(axis, vecScale(normal, vecDot(axis, normal)));\n const along = vecLength(proj) > GEOM_TOL ? vecNormalize(proj) : perpBasis(normal).e1;\n const out = vecNormalize(vecCross(normal, along));\n return { along, out };\n}\n\n/** AABB rectangle of a placed flat in 2D (mapping its mid-surface sample corners). */\nfunction flatRect2(p: PlacedFlat): Rect2 {\n const samples = sampleFace(p.flat.faces[0], 4);\n const pts2 = samples.map((s) => mapPoint(p, s.point));\n return rectFrom(pts2);\n}\n\ninterface ChildPlacement {\n child: PlacedFlat;\n strip: Rect2;\n bendA: [number, number];\n bendB: [number, number];\n outDir2: [number, number];\n runLen: number;\n}\n\n/**\n * Place a child flat past its developed bend strip. The shared bend line is the\n * bend axis projected into the parent's plane; the child develops `out` from it on\n * the side away from the parent. Both the bend line and the develop-out direction\n * are computed in 3D then mapped to 2D through the parent's affine map, so the 2D\n * placement stays consistent with the real geometry regardless of basis sign.\n */\nfunction placeChildFlat(\n parent: PlacedFlat,\n childFlat: DetectedFlat,\n bend: DetectedBend,\n axis: Vec3,\n span: number,\n dev: number\n): ChildPlacement {\n // In-plane bend axis direction (the strip-width direction).\n const axisInPlane = vecNormalize(\n vecSub(axis, vecScale(parent.flat.normal, vecDot(axis, parent.flat.normal)))\n );\n // The shared bend line is where the bend meets the parent: the bend axis line\n // projected onto the parent plane, positioned over the parent/child along-axis\n // overlap (the fit's axial origin is arbitrary, so the line is placed by the\n // parent's footprint, not the fit point). Its mid-point along the axis is the\n // centre of the parent footprint along the axis; it spans `span` (the bend's\n // axial extent).\n const axisLineMid = projectToPlane(bend.fit.axisOrigin, parent.flat.normal, parent.o3);\n const lineMid = parentFootprintCentreAlong(parent, axisInPlane, axisLineMid);\n const toBend = vecSub(axisLineMid, parent.flat.center);\n let outDir3 = vecSub(toBend, vecScale(axisInPlane, vecDot(toBend, axisInPlane)));\n if (vecLength(outDir3) < GEOM_TOL) outDir3 = vecNormalize(vecCross(parent.flat.normal, axisInPlane));\n else outDir3 = vecNormalize(outDir3);\n\n const bend3A = vecSub(lineMid, vecScale(axisInPlane, span / 2));\n const bend3B = vecAdd(lineMid, vecScale(axisInPlane, span / 2));\n const bendA = mapPoint(parent, bend3A);\n const bendB = mapPoint(parent, bend3B);\n\n // 2D develop-out direction = image of `outDir3`; 2D along = image of axisInPlane.\n const outBase2 = mapPoint(parent, vecAdd(lineMid, outDir3));\n const lineMid2 = mapPoint(parent, lineMid);\n const outDir2 = unit2([outBase2[0] - lineMid2[0], outBase2[1] - lineMid2[1]]);\n const along2 = unit2([bendB[0] - bendA[0], bendB[1] - bendA[1]]);\n\n const stripFarA: [number, number] = [bendA[0] + outDir2[0] * dev, bendA[1] + outDir2[1] * dev];\n const childBasis = planeBasis(childFlat.normal, axis);\n const runLen = inPlaneRun(childFlat, childBasis.out);\n\n // The child's 2D frame: origin maps the child corner that develops onto\n // `stripFarA` — the corner at minimum bend-axis position (the bend-line start)\n // and minimum run (nearest the bend). `a2`=along2, `b2`=outDir2. Its 3D basis\n // `a`=axisInPlane (shared bend axis, oriented to match `along2`), `b`=child run\n // direction pointing away from the bend.\n const childRunDir = runDirectionAway(childFlat, childBasis.out, bend.fit.axisOrigin);\n const child: PlacedFlat = {\n flat: childFlat,\n a: axisInPlane,\n b: childRunDir,\n o3: childNearCorner(childFlat, axisInPlane, childRunDir),\n o2: stripFarA,\n a2: along2,\n b2: outDir2,\n };\n const stripFarB: [number, number] = [bendB[0] + outDir2[0] * dev, bendB[1] + outDir2[1] * dev];\n const strip = rectFrom([bendA, bendB, stripFarA, stripFarB]);\n return { child, strip, bendA, bendB, outDir2, runLen };\n}\n\n/** Project a point onto a plane (point `o`, unit normal `n`). */\nfunction projectToPlane(p: Vec3, n: Vec3, o: Vec3): Vec3 {\n return vecSub(p, vecScale(n, vecDot(vecSub(p, o), n)));\n}\n\n/**\n * A point on the parent plane at the centre of the parent's footprint along the\n * bend axis, keeping the bend's out-position (so the bend line sits on the parent's\n * edge but is centred over the parent's along-extent). This pins the bend line to\n * the parent footprint rather than the fit's arbitrary axial origin.\n */\nfunction parentFootprintCentreAlong(parent: PlacedFlat, axisInPlane: Vec3, axisRef: Vec3): Vec3 {\n const samples = sampleFace(parent.flat.faces[0], 4);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const v = vecDot(s.point, axisInPlane);\n min = Math.min(min, v);\n max = Math.max(max, v);\n }\n const mid = (min + max) / 2;\n const refAlong = vecDot(axisRef, axisInPlane);\n return vecAdd(axisRef, vecScale(axisInPlane, mid - refAlong));\n}\n\n/** In-plane run extent of a flat along `out` (perpendicular to the bend axis). */\nfunction inPlaneRun(flat: DetectedFlat, out: Vec3): number {\n const samples = sampleFace(flat.faces[0], 4);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const v = vecDot(s.point, out);\n min = Math.min(min, v);\n max = Math.max(max, v);\n }\n return Number.isFinite(max - min) ? max - min : 0;\n}\n\n/** Run direction of a child flat pointing away from the bend axis. */\nfunction runDirectionAway(flat: DetectedFlat, out: Vec3, axisOrigin: Vec3): Vec3 {\n const toCenter = vecSub(flat.center, axisOrigin);\n return vecDot(toCenter, out) >= 0 ? out : vecScale(out, -1);\n}\n\n/**\n * The child corner that develops onto the strip-far near point: minimum along the\n * (oriented) bend axis and minimum along the run (nearest the bend). Searched over\n * the in-plane bounds so `(P−o3)·a ∈ [0, span]` and `(P−o3)·b ∈ [0, runLen]`.\n */\nfunction childNearCorner(flat: DetectedFlat, axis: Vec3, run: Vec3): Vec3 {\n const samples = sampleFace(flat.faces[0], 4);\n let minAxis = Infinity;\n let minRun = Infinity;\n for (const s of samples) {\n minAxis = Math.min(minAxis, vecDot(s.point, axis));\n minRun = Math.min(minRun, vecDot(s.point, run));\n }\n // Reconstruct the corner in the plane: shift a reference sample to the\n // (minAxis, minRun) coordinates so `(P−corner)·axis ∈ [0, span]` and\n // `(P−corner)·run ∈ [0, runLen]` over the flat.\n const ref = samples[0]?.point ?? flat.center;\n const da = minAxis - vecDot(ref, axis);\n const db = minRun - vecDot(ref, run);\n return vecAdd(vecAdd(ref, vecScale(axis, da)), vecScale(run, db));\n}\n\nfunction unit2(v: [number, number]): [number, number] {\n const len = Math.hypot(v[0], v[1]);\n return len < 1e-12 ? [1, 0] : [v[0] / len, v[1] / len];\n}\n\nfunction rectFrom(pts: [number, number][]): Rect2 {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of pts) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x0, y0, x1, y1 };\n}\n\nfunction aabb2(rects: Rect2[]): Rect2 {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const r of rects) {\n x0 = Math.min(x0, r.x0);\n y0 = Math.min(y0, r.y0);\n x1 = Math.max(x1, r.x1);\n y1 = Math.max(y1, r.y1);\n }\n if (!Number.isFinite(x0)) return { x0: 0, y0: 0, x1: 0, y1: 0 };\n return { x0, y0, x1, y1 };\n}\n\nfunction buildRectOutline2(b: Rect2): ReturnType<typeof line>[] {\n return [\n line([b.x0, b.y0, 0], [b.x1, b.y0, 0]),\n line([b.x1, b.y0, 0], [b.x1, b.y1, 0]),\n line([b.x1, b.y1, 0], [b.x0, b.y1, 0]),\n line([b.x0, b.y1, 0], [b.x0, b.y0, 0]),\n ];\n}\n\n/** Axial extent of a bend (its cylindrical face span along the fitted axis). */\nfunction bendAxialExtent(bend: DetectedBend): number {\n const face = bend.faces[0];\n if (face === undefined) return 0;\n const axis = bend.fit.axisDir;\n const samples = sampleFace(face, 6);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const a = vecDot(s.point, axis);\n min = Math.min(min, a);\n max = Math.max(max, a);\n }\n return Number.isFinite(max - min) ? max - min : 0;\n}\n\n/**\n * Bend direction: 'up' if the cylinder axis sits on the +normal side of the\n * parent flat's mid-surface, 'down' otherwise.\n */\nfunction bendDirection(bend: DetectedBend, parent: DetectedFlat): 'up' | 'down' {\n const toAxis = vecSub(bend.fit.axisOrigin, parent.center);\n return vecDot(toAxis, parent.normal) >= 0 ? 'up' : 'down';\n}\n\nfunction faceNormal(face: Face): Vec3 {\n return vecNormalize(normalAt(face, faceCenter(face)));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"foreignUnfoldFns.js","sourceRoot":"","sources":["../src/foreignUnfoldFns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAyB,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAO3Q,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,6EAA6E;AAC7E,MAAM,QAAQ,GAAG,IAAI,CAAC;AAqBtB;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAU,EAAE,CAAS;IACvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,K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,CAAC,OAAO,CAAC;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACpC,IAAI,GAAG,GAAG,QAAQ,CAAC;IACnB,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IACpB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAChC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACvB,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,IAAkB,EAAE,MAAoB;IAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { getBounds } from './geometryOps.js';\nimport type { Solid, Face } from './types.js';\nimport {type Result, type Vec3, ok, err, validationError, getFaces, getSurfaceType, pointOnSurface, normalAt, faceCenter, sharedEdges, measureArea, isValid, vecAdd, vecSub, vecScale, vecDot, vecCross, vecLength, vecNormalize, line, wireLoop} from '@faicad/faijs/api';\nimport type {\n UnfoldResult,\n FlatPattern,\n BendReport,\n SheetMetalWarning,\n} from './types.js';\nimport { developedLength } from './allowanceFns.js';\n\n/** Default neutral-axis K-factor for a purely geometric unfold (mid-surface). */\nconst DEFAULT_FOREIGN_K = 0.5;\n/** Relative tolerance for the cylinder-fit residual (fraction of the radius). */\nconst FIT_RESIDUAL_TOL = 1e-2;\n/** Absolute tolerance for matching parallel planes / coincident geometry. */\nconst GEOM_TOL = 1e-4;\n\n/** A fitted cylinder recovered numerically from a face's sampled points + normals. */\nexport interface FittedCylinder {\n /** A point on the axis line. */\n axisOrigin: Vec3;\n /** Unit axis direction. */\n axisDir: Vec3;\n /** Fitted radius (mean distance from the axis line to the sampled points). */\n radius: number;\n /** Angular extent swept by the face about the axis, in radians. */\n angleSpan: number;\n /** Max relative residual of the fit (fraction of radius); small for a true cylinder. */\n residual: number;\n}\n\ninterface Sample {\n point: Vec3;\n normal: Vec3;\n}\n\n/**\n * Sample a regular grid of surface points and their normals across the face's UV\n * bounds. `pointOnSurface` takes normalized (0-1) UV; `normalAt` re-projects the\n * sampled point to UV internally, so the pair holds for true cylinders/planes but\n * is not an exact-UV guarantee for degenerate parameterizations.\n */\nfunction sampleFace(face: Face, n: number): Sample[] {\n const samples: Sample[] = [];\n for (let i = 0; i < n; i += 1) {\n const u = n === 1 ? 0.5 : i / (n - 1);\n for (let j = 0; j < n; j += 1) {\n const v = n === 1 ? 0.5 : j / (n - 1);\n const point = pointOnSurface(face, u, v);\n const normal = normalAt(face, point);\n const len = vecLength(normal);\n if (len < GEOM_TOL) continue;\n samples.push({ point, normal: vecScale(normal, 1 / len) });\n }\n }\n return samples;\n}\n\n/**\n * Numerically fit a cylinder to a face.\n *\n * Every normal of a cylinder is perpendicular to the axis, so the axis direction\n * is the common perpendicular of the sampled normals: it is recovered as the\n * sign-aligned average of the cross products of pairs of non-parallel sampled\n * normals (each such cross product lies along ±axis). The axis LINE and RADIUS\n * are then found by projecting the sample points onto the plane ⟂ axis and\n * fitting a circle (algebraic least squares); the radius is the mean distance\n * from the axis line to the points. The angular span is the extent of the\n * projected points about the fitted centre. Returns `null` when the surface\n * does not fit a cylinder within {@link FIT_RESIDUAL_TOL}.\n *\n * @param face - the B-rep face to fit.\n * @returns the fitted cylinder, or null if the face is not cylindrical.\n */\nexport function fitCylinder(face: Face): FittedCylinder | null {\n const surf = getSurfaceType(face);\n // OCCT keeps exact cylinders as 'cylinder', but applyMatrix (gp_GTrsf) and\n // boolean ops (intersect/cut) can re-parameterise them to 'bspline' — the\n // numeric fit below works on either; other types fail the residual check.\n if (!surf.ok || (surf.value !== 'cylinder' && surf.value !== 'bspline')) return null;\n\n const samples = sampleFace(face, 6);\n if (samples.length < 4) return null;\n\n const axisDir = axisFromNormals(samples.map((s) => s.normal));\n if (axisDir === null) return null;\n\n // Project points onto the plane ⟂ axis (in a local 2D basis) and fit a circle.\n const basis = perpBasis(axisDir);\n const pts2: [number, number][] = samples.map((s) => [\n vecDot(s.point, basis.e1),\n vecDot(s.point, basis.e2),\n ]);\n const circle = fitCircle2(pts2);\n if (circle === null) return null;\n\n // Lift the 2D centre back to a 3D point on the axis: use the axial component of\n // an arbitrary sample so the origin sits at a real location on the face.\n const axial = vecDot(samples[0]?.point ?? [0, 0, 0], axisDir);\n const axisOrigin = vecAdd(\n vecAdd(vecScale(basis.e1, circle.cx), vecScale(basis.e2, circle.cy)),\n vecScale(axisDir, axial)\n );\n\n // Radius = mean distance from the axis line to the sampled points; residual is\n // the max relative deviation from that radius (a true cylinder is near zero).\n let sumR = 0;\n for (const s of samples) sumR += distanceToAxis(s.point, axisOrigin, axisDir);\n const radius = sumR / samples.length;\n if (radius < GEOM_TOL) return null;\n let maxDev = 0;\n for (const s of samples) {\n const d = distanceToAxis(s.point, axisOrigin, axisDir);\n maxDev = Math.max(maxDev, Math.abs(d - radius));\n }\n const residual = maxDev / radius;\n if (residual > FIT_RESIDUAL_TOL) return null;\n\n const angleSpan = angularExtent(pts2, circle.cx, circle.cy);\n return { axisOrigin, axisDir, radius, angleSpan, residual };\n}\n\n/**\n * Axis direction as the common perpendicular of the cylinder normals: average the\n * cross products of pairs of sufficiently non-parallel normals, aligning each to a\n * consistent hemisphere before summing so they don't cancel. Returns `null` if no\n * pair is non-parallel (a degenerate/near-planar sample).\n */\nfunction axisFromNormals(normals: Vec3[]): Vec3 | null {\n let acc: Vec3 = [0, 0, 0];\n let ref: Vec3 | null = null;\n for (let i = 0; i < normals.length; i += 1) {\n for (let j = i + 1; j < normals.length; j += 1) {\n const a = normals[i];\n const b = normals[j];\n if (a === undefined || b === undefined) continue;\n const c = vecCross(a, b);\n const len = vecLength(c);\n if (len < 1e-3) continue;\n let unit = vecScale(c, 1 / len);\n if (ref === null) ref = unit;\n else if (vecDot(unit, ref) < 0) unit = vecScale(unit, -1);\n acc = vecAdd(acc, unit);\n }\n }\n if (vecLength(acc) < GEOM_TOL) return null;\n return vecNormalize(acc);\n}\n\n/** An orthonormal pair spanning the plane perpendicular to `axis`. */\nfunction perpBasis(axis: Vec3): { e1: Vec3; e2: Vec3 } {\n const seed: Vec3 = Math.abs(axis[0]) < 0.9 ? [1, 0, 0] : [0, 1, 0];\n const e1 = vecNormalize(vecCross(axis, seed));\n const e2 = vecNormalize(vecCross(axis, e1));\n return { e1, e2 };\n}\n\n/** Perpendicular distance from `p` to the line through `o` with unit direction `d`. */\nfunction distanceToAxis(p: Vec3, o: Vec3, d: Vec3): number {\n const w = vecSub(p, o);\n const along = vecDot(w, d);\n const perp = vecSub(w, vecScale(d, along));\n return vecLength(perp);\n}\n\n/** Algebraic (Kåsa) least-squares circle fit to 2D points. */\nfunction fitCircle2(pts: [number, number][]): { cx: number; cy: number; r: number } | null {\n const n = pts.length;\n if (n < 3) return null;\n let sx = 0;\n let sy = 0;\n let sxx = 0;\n let syy = 0;\n let sxy = 0;\n let sxz = 0;\n let syz = 0;\n let sz = 0;\n for (const [x, y] of pts) {\n const z = x * x + y * y;\n sx += x;\n sy += y;\n sxx += x * x;\n syy += y * y;\n sxy += x * y;\n sxz += x * z;\n syz += y * z;\n sz += z;\n }\n // Solve the normal equations for [A, B, C] in A·x + B·y + C = z (= x²+y²).\n const m = [\n [sxx, sxy, sx],\n [sxy, syy, sy],\n [sx, sy, n],\n ];\n const rhs = [sxz, syz, sz];\n const sol = solve3(m, rhs);\n if (sol === null) return null;\n const [a, b, c] = sol;\n const cx = a / 2;\n const cy = b / 2;\n const r2 = c + cx * cx + cy * cy;\n if (r2 <= 0) return null;\n return { cx, cy, r: Math.sqrt(r2) };\n}\n\n/** Solve a 3×3 linear system by Cramer's rule; `null` if (near-)singular. */\nfunction solve3(m: number[][], rhs: number[]): [number, number, number] | null {\n const det = det3(m);\n if (Math.abs(det) < 1e-12) return null;\n const mx = [\n [rhs[0] ?? 0, m[0]?.[1] ?? 0, m[0]?.[2] ?? 0],\n [rhs[1] ?? 0, m[1]?.[1] ?? 0, m[1]?.[2] ?? 0],\n [rhs[2] ?? 0, m[2]?.[1] ?? 0, m[2]?.[2] ?? 0],\n ];\n const my = [\n [m[0]?.[0] ?? 0, rhs[0] ?? 0, m[0]?.[2] ?? 0],\n [m[1]?.[0] ?? 0, rhs[1] ?? 0, m[1]?.[2] ?? 0],\n [m[2]?.[0] ?? 0, rhs[2] ?? 0, m[2]?.[2] ?? 0],\n ];\n const mz = [\n [m[0]?.[0] ?? 0, m[0]?.[1] ?? 0, rhs[0] ?? 0],\n [m[1]?.[0] ?? 0, m[1]?.[1] ?? 0, rhs[1] ?? 0],\n [m[2]?.[0] ?? 0, m[2]?.[1] ?? 0, rhs[2] ?? 0],\n ];\n return [det3(mx) / det, det3(my) / det, det3(mz) / det];\n}\n\nfunction det3(m: number[][]): number {\n const a = m[0] ?? [];\n const b = m[1] ?? [];\n const c = m[2] ?? [];\n return (\n (a[0] ?? 0) * ((b[1] ?? 0) * (c[2] ?? 0) - (b[2] ?? 0) * (c[1] ?? 0)) -\n (a[1] ?? 0) * ((b[0] ?? 0) * (c[2] ?? 0) - (b[2] ?? 0) * (c[0] ?? 0)) +\n (a[2] ?? 0) * ((b[0] ?? 0) * (c[1] ?? 0) - (b[1] ?? 0) * (c[0] ?? 0))\n );\n}\n\n/** Angular extent (radians) spanned by 2D points about a centre. */\nfunction angularExtent(pts: [number, number][], cx: number, cy: number): number {\n const angles = pts.map(([x, y]) => Math.atan2(y - cy, x - cx)).sort((a, b) => a - b);\n if (angles.length < 2) return 0;\n // Largest gap between consecutive sorted angles (wrapping); the span is 2π minus it.\n let maxGap = (angles[0] ?? 0) + 2 * Math.PI - (angles[angles.length - 1] ?? 0);\n for (let i = 1; i < angles.length; i += 1) {\n maxGap = Math.max(maxGap, (angles[i] ?? 0) - (angles[i - 1] ?? 0));\n }\n return 2 * Math.PI - maxGap;\n}\n\n// ---------------------------------------------------------------------------\n// Foreign-solid unfold\n// ---------------------------------------------------------------------------\n\n/** A detected flat panel: a pair of large parallel planar faces a thickness apart. */\ninterface DetectedFlat {\n id: string;\n /** The two parallel planar faces (outer + inner) of the panel. */\n faces: [Face, Face];\n /** Mid-surface plane normal (unit). */\n normal: Vec3;\n /** Centroid of the mid-surface. */\n center: Vec3;\n /** Mid-surface area (mean of the two face areas). */\n area: number;\n}\n\n/** A detected bend: a pair of coaxial inner/outer cylindrical faces. */\ninterface DetectedBend {\n id: string;\n faces: Face[];\n fit: FittedCylinder;\n /** Inner radius (smaller of the fitted pair). */\n innerRadius: number;\n /** Swept angle in degrees. */\n angleDeg: number;\n}\n\n/**\n * Unfold an ARBITRARY imported sheet-metal solid with no feature tree, by\n * detecting its geometry numerically. The supported class is roughly-uniform-\n * thickness solids whose panels are planar and whose bends are cylindrical:\n *\n * 1. Classify faces by surface type — planar faces are panel faces, cylindrical\n * faces are bend faces. Any other surface type is reported `UNSUPPORTED_FACE`.\n * 2. Pair the two large parallel planar faces of each flat panel (a thickness\n * apart); pair the inner/outer cylindrical faces of each bend and fit its\n * axis + inner radius + swept angle via {@link fitCylinder}.\n * 3. Build a bend graph (flats = nodes; a bend connects the two flats it shares\n * edges with), take a spanning tree from a root flat, and turn any non-tree\n * bend into a seam cut (warned).\n * 4. Walk the tree replacing each cylindrical bend region with a developed strip\n * of length `developedLength(angle, thickness, { innerRadius, kFactor })`\n * (`kFactor` defaults to the {@link DEFAULT_FOREIGN_K} mid-surface), laying\n * each flat out into the plane. Bend direction (up/down) is read from the\n * cylinder centre relative to the parent flat.\n *\n * Non-fatal warnings ride inside the Ok payload; the function fails only when the\n * input is not a recognizable sheet-metal solid at all.\n *\n * @param solid - the foreign solid to unfold.\n * @param opts - optional k-factor override.\n * @returns the unfold result, or an error.\n */\nexport function unfoldForeignSolid(\n solid: Solid,\n opts?: { kFactor?: number | undefined }\n): Result<UnfoldResult> {\n if (!isValid(solid)) {\n return err(validationError('INVALID_SOLID', 'foreign solid is not a valid B-rep'));\n }\n const kFactor = opts?.kFactor ?? DEFAULT_FOREIGN_K;\n if (!Number.isFinite(kFactor) || kFactor < 0 || kFactor > 1) {\n return err(validationError('INVALID_K_FACTOR', `kFactor must be in [0, 1], got ${kFactor}`));\n }\n\n const warnings: SheetMetalWarning[] = [];\n const faces = getFaces(solid);\n if (faces.length === 0) {\n return err(validationError('EMPTY_SOLID', 'foreign solid has no faces'));\n }\n\n const planarFaces: Face[] = [];\n const cylFaces: Face[] = [];\n for (const face of faces) {\n const t = getSurfaceType(face);\n if (!t.ok) {\n warnings.push({ code: 'UNSUPPORTED_FACE', message: 'failed to read a face surface type; skipping' });\n continue;\n }\n if (t.value === 'plane') {\n planarFaces.push(face);\n } else if (t.value === 'cylinder') {\n cylFaces.push(face);\n } else if (fitCylinder(face) !== null) {\n // A numerically-fittable bspline/other surface IS a cylindrical bend\n // (OCCT re-parameterises exact cylinders through transforms/booleans).\n cylFaces.push(face);\n } else {\n warnings.push({\n code: 'UNSUPPORTED_FACE',\n message: `UNSUPPORTED_FACE: surface type '${t.value}' is not a planar panel or cylindrical bend; the unfold ignores it and may be incomplete`,\n });\n }\n }\n\n const thicknessResult = detectThickness(planarFaces);\n if (!thicknessResult.ok) return thicknessResult;\n const thickness = thicknessResult.value;\n\n const flats = pairFlats(planarFaces, thickness, warnings);\n if (flats.length === 0) {\n return err(\n validationError('NO_FLATS', 'no planar panel pairs detected; not a recognizable sheet-metal solid')\n );\n }\n\n const bends = pairBends(cylFaces, warnings);\n\n const graph = buildBendGraph(flats, bends, warnings);\n const layout = layoutForeign(flats, graph, thickness, kFactor, warnings);\n if (!layout.ok) return layout;\n\n return ok({ pattern: layout.value.pattern, report: layout.value.report, warnings });\n}\n\n/**\n * Detect the sheet thickness as the smallest gap between an antiparallel pair of\n * planar faces (the two faces of one flat panel). For a roughly-uniform-thickness\n * part this gap is the same across panels; a spread beyond tolerance warns.\n */\nfunction detectThickness(planar: Face[]): Result<number> {\n const gaps: number[] = [];\n for (let i = 0; i < planar.length; i += 1) {\n for (let j = i + 1; j < planar.length; j += 1) {\n const fa = planar[i];\n const fb = planar[j];\n if (fa === undefined || fb === undefined) continue;\n const na = faceNormal(fa);\n const nb = faceNormal(fb);\n if (vecDot(na, nb) > -0.99) continue; // need antiparallel (opposite faces of a panel)\n const ca = faceCenter(fa);\n const cb = faceCenter(fb);\n const gap = Math.abs(vecDot(vecSub(cb, ca), na));\n if (gap > GEOM_TOL) gaps.push(gap);\n }\n }\n if (gaps.length === 0) {\n return err(validationError('NO_THICKNESS', 'could not detect a sheet thickness (no opposed planar pair)'));\n }\n gaps.sort((a, b) => a - b);\n return ok(gaps[0] as number);\n}\n\n/**\n * Pair planar faces into flat panels: each panel is two parallel faces a\n * `thickness` apart with overlapping footprints. Greedy nearest-match by gap.\n */\nfunction pairFlats(planar: Face[], thickness: number, warnings: SheetMetalWarning[]): DetectedFlat[] {\n const used = new Set<number>();\n const flats: DetectedFlat[] = [];\n for (let i = 0; i < planar.length; i += 1) {\n if (used.has(i)) continue;\n const fa = planar[i];\n if (fa === undefined) continue;\n const na = faceNormal(fa);\n const ca = faceCenter(fa);\n let best = -1;\n let bestErr = Infinity;\n for (let j = 0; j < planar.length; j += 1) {\n if (j === i || used.has(j)) continue;\n const fb = planar[j];\n if (fb === undefined) continue;\n const nb = faceNormal(fb);\n if (vecDot(na, nb) > -0.99) continue;\n const cb = faceCenter(fb);\n const gap = Math.abs(vecDot(vecSub(cb, ca), na));\n const e = Math.abs(gap - thickness);\n if (e < bestErr) {\n bestErr = e;\n best = j;\n }\n }\n if (best < 0 || bestErr > thickness * 0.5 + GEOM_TOL) {\n // No usable antiparallel partner at the sheet thickness. A bend-edge cap or\n // rim band is plate-thin in one in-plane direction (≈ thickness) — expected,\n // skip quietly. A face that is wide in BOTH in-plane directions is a real\n // panel; dropping it means non-uniform thickness or unrecognised topology, so\n // flag it. (Area alone can't tell them apart — a long rim is large by area.)\n const db = getBounds(fa);\n const ext = [db.xMax - db.xMin, db.yMax - db.yMin, db.zMax - db.zMin].sort((p, q) => q - p);\n const inPlaneMin = ext[1] ?? 0;\n if (inPlaneMin > thickness * 4) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `a panel-sized planar face (${(ext[0] ?? 0).toFixed(1)}×${inPlaneMin.toFixed(1)}) has no opposite face at the sheet thickness ${thickness.toFixed(3)}; omitted (possible non-uniform thickness)`,\n });\n }\n continue;\n }\n const fb = planar[best] as Face;\n used.add(i);\n used.add(best);\n const areaA = measureArea(fa);\n const areaB = measureArea(fb);\n let area: number;\n if (Number.isFinite(areaA) && Number.isFinite(areaB)) area = (areaA + areaB) / 2;\n else if (Number.isFinite(areaA)) area = areaA;\n else if (Number.isFinite(areaB)) area = areaB;\n else {\n // Neither face area is measurable: fall back to the panel's bounding-box\n // footprint so developedArea isn't silently zero, and flag the estimate.\n const b = getBounds(fa);\n const dx = b.xMax - b.xMin;\n const dy = b.yMax - b.yMin;\n const dz = b.zMax - b.zMin;\n area = Math.max(dx * dy, dy * dz, dx * dz);\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `flat-${flats.length}: face area unmeasurable; using a bounding-box estimate (${area.toFixed(2)})`,\n });\n }\n flats.push({\n id: `flat-${flats.length}`,\n faces: [fa, fb],\n normal: na,\n center: vecScale(vecAdd(ca, faceCenter(fb)), 0.5),\n area,\n });\n }\n if (flats.length === 0 && planar.length > 0) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: 'no parallel planar face pairs matched the detected thickness; the part may have non-uniform thickness',\n });\n }\n return flats;\n}\n\n/**\n * Pair cylindrical faces into bends: each bend has an inner + outer coaxial face\n * (same axis, radii a thickness apart) or, failing a pair, a single fitted face.\n */\nfunction pairBends(cyl: Face[], warnings: SheetMetalWarning[]): DetectedBend[] {\n interface Fitted {\n face: Face;\n fit: FittedCylinder;\n }\n const fitted: Fitted[] = [];\n for (const face of cyl) {\n const fit = fitCylinder(face);\n if (fit === null) {\n warnings.push({\n code: 'UNSUPPORTED_FACE',\n message: 'a cylindrical face did not fit a cylinder within tolerance; the bend is ignored',\n });\n continue;\n }\n fitted.push({ face, fit });\n }\n\n const used = new Set<number>();\n const bends: DetectedBend[] = [];\n for (let i = 0; i < fitted.length; i += 1) {\n if (used.has(i)) continue;\n const a = fitted[i];\n if (a === undefined) continue;\n let mate = -1;\n for (let j = i + 1; j < fitted.length; j += 1) {\n if (used.has(j)) continue;\n const b = fitted[j];\n if (b === undefined) continue;\n if (Math.abs(vecDot(a.fit.axisDir, b.fit.axisDir)) < 0.99) continue;\n if (distanceToAxis(b.fit.axisOrigin, a.fit.axisOrigin, a.fit.axisDir) > GEOM_TOL * 10) continue;\n mate = j;\n break;\n }\n const faces: Face[] = [a.face];\n let innerRadius = a.fit.radius;\n let fit = a.fit;\n if (mate >= 0) {\n const b = fitted[mate] as Fitted;\n faces.push(b.face);\n innerRadius = Math.min(a.fit.radius, b.fit.radius);\n fit = a.fit.radius <= b.fit.radius ? a.fit : b.fit;\n used.add(mate);\n }\n used.add(i);\n bends.push({\n id: `bend-${bends.length}`,\n faces,\n fit,\n innerRadius,\n angleDeg: (fit.angleSpan * 180) / Math.PI,\n });\n }\n return bends;\n}\n\ninterface BendGraphEdge {\n bend: DetectedBend;\n flats: [number, number];\n}\n\ninterface BendGraph {\n edges: BendGraphEdge[];\n}\n\n/**\n * Connect bends to the flats they touch: a bend's cylindrical face shares edges\n * with exactly the two flats tangent to it. A bend that touches fewer than two\n * detected flats is dropped (it is a free rim); more than two is ambiguous and\n * warned. Spanning-tree / seam handling happens in {@link layoutForeign}.\n */\nfunction buildBendGraph(\n flats: DetectedFlat[],\n bends: DetectedBend[],\n warnings: SheetMetalWarning[]\n): BendGraph {\n const edges: BendGraphEdge[] = [];\n for (const bend of bends) {\n const touching: number[] = [];\n for (let fi = 0; fi < flats.length; fi += 1) {\n const flat = flats[fi];\n if (flat === undefined) continue;\n if (bendTouchesFlat(bend, flat)) touching.push(fi);\n }\n if (touching.length < 2) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `bend '${bend.id}' connects ${touching.length} flats (expected 2); ignored`,\n featureId: bend.id,\n });\n continue;\n }\n if (touching.length > 2) {\n warnings.push({\n code: 'DETECTION_INCOMPLETE',\n message: `bend '${bend.id}' touches ${touching.length} flats; using the first two`,\n featureId: bend.id,\n });\n }\n edges.push({ bend, flats: [touching[0] as number, touching[1] as number] });\n }\n return { edges };\n}\n\n/** True if any of the bend's faces shares an edge with either face of the flat. */\nfunction bendTouchesFlat(bend: DetectedBend, flat: DetectedFlat): boolean {\n for (const bf of bend.faces) {\n for (const ff of flat.faces) {\n if (sharedEdges(bf, ff).length > 0) return true;\n }\n }\n return false;\n}\n\ninterface ForeignLayout {\n pattern: FlatPattern;\n report: BendReport;\n}\n\n/**\n * Lay out detected flats into the developed plane. A spanning tree over the bend\n * graph (BFS from flat 0) places each flat as a rectangle and each tree bend as a\n * developed strip; non-tree bends become seam cuts (warned). The developed area\n * is the sum of flat mid-surface areas plus each developed-strip area, computed\n * directly from detected geometry. Bend direction is read from the cylinder\n * centre relative to the parent flat's outward normal.\n */\nfunction layoutForeign(\n flats: DetectedFlat[],\n graph: BendGraph,\n thickness: number,\n kFactor: number,\n warnings: SheetMetalWarning[]\n): Result<ForeignLayout> {\n const adjacency = new Map<number, BendGraphEdge[]>();\n for (let i = 0; i < flats.length; i += 1) adjacency.set(i, []);\n for (const e of graph.edges) {\n adjacency.get(e.flats[0])?.push(e);\n adjacency.get(e.flats[1])?.push(e);\n }\n\n const visited = new Set<number>([0]);\n const treeEdges = new Set<BendGraphEdge>();\n const treeBends: { edge: BendGraphEdge; parent: number; child: number }[] = [];\n const queue: number[] = [0];\n while (queue.length > 0) {\n const cur = queue.shift();\n if (cur === undefined) break;\n for (const e of adjacency.get(cur) ?? []) {\n if (treeEdges.has(e)) continue;\n const next = e.flats[0] === cur ? e.flats[1] : e.flats[0];\n if (visited.has(next)) continue;\n visited.add(next);\n treeEdges.add(e);\n treeBends.push({ edge: e, parent: cur, child: next });\n queue.push(next);\n }\n }\n\n for (const e of graph.edges) {\n if (treeEdges.has(e)) continue;\n warnings.push({\n code: 'SEAM_CUT',\n message: `closed profile: bend '${e.bend.id}' becomes a seam cut`,\n featureId: e.bend.id,\n });\n }\n\n // Each bend's strip width = the bend cylinder's axial extent (its span).\n const bendSpan = new Map<DetectedBend, number>();\n for (const e of graph.edges) bendSpan.set(e.bend, bendAxialExtent(e.bend));\n\n // 2D placement: develop each flat into the plane preserving its real fold\n // direction (perpendicular to the bend axis), so an L-bracket lays out L-shaped,\n // not collapsed into a straight chain. Each placed flat carries a consistent\n // 3D→2D affine map (`m2`): a 3D point on the flat's plane maps to 2D via its\n // in-plane basis, so the bend line, edges and develop-out direction are all\n // derived in 3D then mapped to 2D — keeping signs/edges consistent. The root is\n // laid at the origin; a child is placed past its developed strip, out from the\n // shared bend line. The developed AREA is geometry-exact (Σ flat mid-surface\n // areas + Σ developed-strip areas).\n const placed = new Map<number, PlacedFlat>();\n const root = flats[0] as DetectedFlat;\n const rootAxis = treeBends[0]?.edge.bend.fit.axisDir ?? perpBasis(root.normal).e1;\n const rootBasis = planeBasis(root.normal, rootAxis);\n placed.set(0, {\n flat: root,\n a: rootBasis.along,\n b: rootBasis.out,\n o3: root.center,\n o2: [0, 0],\n a2: [1, 0],\n b2: [0, 1],\n });\n\n let developedArea = 0;\n for (const f of flats) developedArea += f.area;\n\n const bendReportRows: BendReport['bends'] = [];\n const rects: Rect2[] = [];\n const bendLines: FlatPattern['bendLines'] = [];\n rects.push(flatRect2(placed.get(0) as PlacedFlat));\n\n for (const tb of treeBends) {\n const bend = tb.edge.bend;\n const dev = developedLength(bend.angleDeg, thickness, { innerRadius: bend.innerRadius, kFactor }, (w) => warnings.push(w));\n if (!dev.ok) return dev;\n const parentPlace = placed.get(tb.parent);\n const parent = flats[tb.parent] as DetectedFlat;\n const child = flats[tb.child] as DetectedFlat;\n if (parentPlace === undefined) continue;\n const direction = bendDirection(bend, parent);\n const axis = bend.fit.axisDir;\n const span = bendSpan.get(bend) ?? bendAxialExtent(bend);\n\n const placement = placeChildFlat(parentPlace, child, bend, axis, span, dev.value);\n placed.set(tb.child, placement.child);\n\n rects.push(placement.strip);\n rects.push(flatRect2(placement.child));\n bendLines.push({\n id: bend.id,\n line: line([placement.bendA[0], placement.bendA[1], 0], [placement.bendB[0], placement.bendB[1], 0]),\n angleDeg: bend.angleDeg,\n direction,\n inward: [-placement.outDir2[0], -placement.outDir2[1]],\n });\n developedArea += dev.value * span;\n\n bendReportRows.push({\n id: bend.id,\n angleDeg: bend.angleDeg,\n radius: bend.innerRadius,\n allowance: dev.value,\n flatLength: placement.runLen,\n direction,\n });\n }\n\n const bbox = aabb2(rects);\n const outline = buildRectOutline2(bbox);\n const outlineWire = wireLoop(outline);\n if (!outlineWire.ok) return outlineWire;\n\n const pattern: FlatPattern = {\n outline: outlineWire.value,\n bendLines,\n holes: [],\n formCuts: [],\n formMarkers: [],\n formHinges: [],\n loftedDevelopments: [],\n developedArea,\n };\n const report: BendReport = {\n bends: bendReportRows,\n totalFlatSize: [bbox.x1 - bbox.x0, bbox.y1 - bbox.y0],\n };\n return ok({ pattern, report });\n}\n\n/**\n * A placed flat: its detected geometry plus a consistent 3D→2D affine map. A 3D\n * point P on the flat's plane maps to `o2 + (P−o3)·a · a2 + (P−o3)·b · b2`, where\n * (a, b) is the flat's in-plane 3D basis and (a2, b2) the 2D images of those axes.\n */\ninterface PlacedFlat {\n flat: DetectedFlat;\n a: Vec3;\n b: Vec3;\n o3: Vec3;\n o2: [number, number];\n a2: [number, number];\n b2: [number, number];\n}\n\ninterface Rect2 {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\n/** Map a 3D in-plane point through a placed flat's affine map. */\nfunction mapPoint(p: PlacedFlat, point: Vec3): [number, number] {\n const da = vecDot(vecSub(point, p.o3), p.a);\n const db = vecDot(vecSub(point, p.o3), p.b);\n return [p.o2[0] + da * p.a2[0] + db * p.b2[0], p.o2[1] + da * p.a2[1] + db * p.b2[1]];\n}\n\n/** 3D in-plane basis of a flat: `along` parallel to `axis`, `out` perpendicular. */\nfunction planeBasis(normal: Vec3, axis: Vec3): { along: Vec3; out: Vec3 } {\n const proj = vecSub(axis, vecScale(normal, vecDot(axis, normal)));\n const along = vecLength(proj) > GEOM_TOL ? vecNormalize(proj) : perpBasis(normal).e1;\n const out = vecNormalize(vecCross(normal, along));\n return { along, out };\n}\n\n/** AABB rectangle of a placed flat in 2D (mapping its mid-surface sample corners). */\nfunction flatRect2(p: PlacedFlat): Rect2 {\n const samples = sampleFace(p.flat.faces[0], 4);\n const pts2 = samples.map((s) => mapPoint(p, s.point));\n return rectFrom(pts2);\n}\n\ninterface ChildPlacement {\n child: PlacedFlat;\n strip: Rect2;\n bendA: [number, number];\n bendB: [number, number];\n outDir2: [number, number];\n runLen: number;\n}\n\n/**\n * Place a child flat past its developed bend strip. The shared bend line is the\n * bend axis projected into the parent's plane; the child develops `out` from it on\n * the side away from the parent. Both the bend line and the develop-out direction\n * are computed in 3D then mapped to 2D through the parent's affine map, so the 2D\n * placement stays consistent with the real geometry regardless of basis sign.\n */\nfunction placeChildFlat(\n parent: PlacedFlat,\n childFlat: DetectedFlat,\n bend: DetectedBend,\n axis: Vec3,\n span: number,\n dev: number\n): ChildPlacement {\n // In-plane bend axis direction (the strip-width direction).\n const axisInPlane = vecNormalize(\n vecSub(axis, vecScale(parent.flat.normal, vecDot(axis, parent.flat.normal)))\n );\n // The shared bend line is where the bend meets the parent: the bend axis line\n // projected onto the parent plane, positioned over the parent/child along-axis\n // overlap (the fit's axial origin is arbitrary, so the line is placed by the\n // parent's footprint, not the fit point). Its mid-point along the axis is the\n // centre of the parent footprint along the axis; it spans `span` (the bend's\n // axial extent).\n const axisLineMid = projectToPlane(bend.fit.axisOrigin, parent.flat.normal, parent.o3);\n const lineMid = parentFootprintCentreAlong(parent, axisInPlane, axisLineMid);\n const toBend = vecSub(axisLineMid, parent.flat.center);\n let outDir3 = vecSub(toBend, vecScale(axisInPlane, vecDot(toBend, axisInPlane)));\n if (vecLength(outDir3) < GEOM_TOL) outDir3 = vecNormalize(vecCross(parent.flat.normal, axisInPlane));\n else outDir3 = vecNormalize(outDir3);\n\n const bend3A = vecSub(lineMid, vecScale(axisInPlane, span / 2));\n const bend3B = vecAdd(lineMid, vecScale(axisInPlane, span / 2));\n const bendA = mapPoint(parent, bend3A);\n const bendB = mapPoint(parent, bend3B);\n\n // 2D develop-out direction = image of `outDir3`; 2D along = image of axisInPlane.\n const outBase2 = mapPoint(parent, vecAdd(lineMid, outDir3));\n const lineMid2 = mapPoint(parent, lineMid);\n const outDir2 = unit2([outBase2[0] - lineMid2[0], outBase2[1] - lineMid2[1]]);\n const along2 = unit2([bendB[0] - bendA[0], bendB[1] - bendA[1]]);\n\n const stripFarA: [number, number] = [bendA[0] + outDir2[0] * dev, bendA[1] + outDir2[1] * dev];\n const childBasis = planeBasis(childFlat.normal, axis);\n const runLen = inPlaneRun(childFlat, childBasis.out);\n\n // The child's 2D frame: origin maps the child corner that develops onto\n // `stripFarA` — the corner at minimum bend-axis position (the bend-line start)\n // and minimum run (nearest the bend). `a2`=along2, `b2`=outDir2. Its 3D basis\n // `a`=axisInPlane (shared bend axis, oriented to match `along2`), `b`=child run\n // direction pointing away from the bend.\n const childRunDir = runDirectionAway(childFlat, childBasis.out, bend.fit.axisOrigin);\n const child: PlacedFlat = {\n flat: childFlat,\n a: axisInPlane,\n b: childRunDir,\n o3: childNearCorner(childFlat, axisInPlane, childRunDir),\n o2: stripFarA,\n a2: along2,\n b2: outDir2,\n };\n const stripFarB: [number, number] = [bendB[0] + outDir2[0] * dev, bendB[1] + outDir2[1] * dev];\n const strip = rectFrom([bendA, bendB, stripFarA, stripFarB]);\n return { child, strip, bendA, bendB, outDir2, runLen };\n}\n\n/** Project a point onto a plane (point `o`, unit normal `n`). */\nfunction projectToPlane(p: Vec3, n: Vec3, o: Vec3): Vec3 {\n return vecSub(p, vecScale(n, vecDot(vecSub(p, o), n)));\n}\n\n/**\n * A point on the parent plane at the centre of the parent's footprint along the\n * bend axis, keeping the bend's out-position (so the bend line sits on the parent's\n * edge but is centred over the parent's along-extent). This pins the bend line to\n * the parent footprint rather than the fit's arbitrary axial origin.\n */\nfunction parentFootprintCentreAlong(parent: PlacedFlat, axisInPlane: Vec3, axisRef: Vec3): Vec3 {\n const samples = sampleFace(parent.flat.faces[0], 4);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const v = vecDot(s.point, axisInPlane);\n min = Math.min(min, v);\n max = Math.max(max, v);\n }\n const mid = (min + max) / 2;\n const refAlong = vecDot(axisRef, axisInPlane);\n return vecAdd(axisRef, vecScale(axisInPlane, mid - refAlong));\n}\n\n/** In-plane run extent of a flat along `out` (perpendicular to the bend axis). */\nfunction inPlaneRun(flat: DetectedFlat, out: Vec3): number {\n const samples = sampleFace(flat.faces[0], 4);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const v = vecDot(s.point, out);\n min = Math.min(min, v);\n max = Math.max(max, v);\n }\n return Number.isFinite(max - min) ? max - min : 0;\n}\n\n/** Run direction of a child flat pointing away from the bend axis. */\nfunction runDirectionAway(flat: DetectedFlat, out: Vec3, axisOrigin: Vec3): Vec3 {\n const toCenter = vecSub(flat.center, axisOrigin);\n return vecDot(toCenter, out) >= 0 ? out : vecScale(out, -1);\n}\n\n/**\n * The child corner that develops onto the strip-far near point: minimum along the\n * (oriented) bend axis and minimum along the run (nearest the bend). Searched over\n * the in-plane bounds so `(P−o3)·a ∈ [0, span]` and `(P−o3)·b ∈ [0, runLen]`.\n */\nfunction childNearCorner(flat: DetectedFlat, axis: Vec3, run: Vec3): Vec3 {\n const samples = sampleFace(flat.faces[0], 4);\n let minAxis = Infinity;\n let minRun = Infinity;\n for (const s of samples) {\n minAxis = Math.min(minAxis, vecDot(s.point, axis));\n minRun = Math.min(minRun, vecDot(s.point, run));\n }\n // Reconstruct the corner in the plane: shift a reference sample to the\n // (minAxis, minRun) coordinates so `(P−corner)·axis ∈ [0, span]` and\n // `(P−corner)·run ∈ [0, runLen]` over the flat.\n const ref = samples[0]?.point ?? flat.center;\n const da = minAxis - vecDot(ref, axis);\n const db = minRun - vecDot(ref, run);\n return vecAdd(vecAdd(ref, vecScale(axis, da)), vecScale(run, db));\n}\n\nfunction unit2(v: [number, number]): [number, number] {\n const len = Math.hypot(v[0], v[1]);\n return len < 1e-12 ? [1, 0] : [v[0] / len, v[1] / len];\n}\n\nfunction rectFrom(pts: [number, number][]): Rect2 {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const [x, y] of pts) {\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return { x0, y0, x1, y1 };\n}\n\nfunction aabb2(rects: Rect2[]): Rect2 {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n for (const r of rects) {\n x0 = Math.min(x0, r.x0);\n y0 = Math.min(y0, r.y0);\n x1 = Math.max(x1, r.x1);\n y1 = Math.max(y1, r.y1);\n }\n if (!Number.isFinite(x0)) return { x0: 0, y0: 0, x1: 0, y1: 0 };\n return { x0, y0, x1, y1 };\n}\n\nfunction buildRectOutline2(b: Rect2): ReturnType<typeof line>[] {\n return [\n line([b.x0, b.y0, 0], [b.x1, b.y0, 0]),\n line([b.x1, b.y0, 0], [b.x1, b.y1, 0]),\n line([b.x1, b.y1, 0], [b.x0, b.y1, 0]),\n line([b.x0, b.y1, 0], [b.x0, b.y0, 0]),\n ];\n}\n\n/** Axial extent of a bend (its cylindrical face span along the fitted axis). */\nfunction bendAxialExtent(bend: DetectedBend): number {\n const face = bend.faces[0];\n if (face === undefined) return 0;\n const axis = bend.fit.axisDir;\n const samples = sampleFace(face, 6);\n let min = Infinity;\n let max = -Infinity;\n for (const s of samples) {\n const a = vecDot(s.point, axis);\n min = Math.min(min, a);\n max = Math.max(max, a);\n }\n return Number.isFinite(max - min) ? max - min : 0;\n}\n\n/**\n * Bend direction: 'up' if the cylinder axis sits on the +normal side of the\n * parent flat's mid-surface, 'down' otherwise.\n */\nfunction bendDirection(bend: DetectedBend, parent: DetectedFlat): 'up' | 'down' {\n const toAxis = vecSub(bend.fit.axisOrigin, parent.center);\n return vecDot(toAxis, parent.normal) >= 0 ? 'up' : 'down';\n}\n\nfunction faceNormal(face: Face): Vec3 {\n return vecNormalize(normalAt(face, faceCenter(face)));\n}\n"]}
|
package/dist/formFns.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Result } from '@faicad/faijs/
|
|
1
|
+
import { type Result } from '@faicad/faijs/api';
|
|
2
2
|
import type { FormSpec, SheetMetalPart } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Add a form feature (louver or emboss/dimple) to a named flat region.
|
|
@@ -25,7 +25,7 @@ import type { FormSpec, SheetMetalPart } from './types.js';
|
|
|
25
25
|
* @param spec - the form specification.
|
|
26
26
|
* @returns the updated part with the form feature recorded, or an error.
|
|
27
27
|
*/
|
|
28
|
-
export declare function addForm(part: SheetMetalPart, spec: FormSpec): Result<SheetMetalPart
|
|
28
|
+
export declare function addForm(part: SheetMetalPart, spec: FormSpec): Promise<Result<SheetMetalPart>>;
|
|
29
29
|
/**
|
|
30
30
|
* A louver vent on a region; see {@link addForm}.
|
|
31
31
|
* @param part - the sheet metal part to form.
|
|
@@ -40,7 +40,7 @@ export declare function louver(part: SheetMetalPart, opts: {
|
|
|
40
40
|
width: number;
|
|
41
41
|
height: number;
|
|
42
42
|
direction?: 'up' | 'down';
|
|
43
|
-
}): Result<SheetMetalPart
|
|
43
|
+
}): Promise<Result<SheetMetalPart>>;
|
|
44
44
|
/**
|
|
45
45
|
* An emboss (raised) or dimple (recessed) round form on a region; see {@link addForm}.
|
|
46
46
|
* @param part - the sheet metal part to form.
|
|
@@ -54,5 +54,5 @@ export declare function emboss(part: SheetMetalPart, opts: {
|
|
|
54
54
|
diameter: number;
|
|
55
55
|
height: number;
|
|
56
56
|
kind: 'dimple' | 'emboss';
|
|
57
|
-
}): Result<SheetMetalPart
|
|
57
|
+
}): Promise<Result<SheetMetalPart>>;
|
|
58
58
|
//# sourceMappingURL=formFns.d.ts.map
|
package/dist/formFns.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formFns.d.ts","sourceRoot":"","sources":["../src/formFns.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formFns.d.ts","sourceRoot":"","sources":["../src/formFns.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,MAAM,EAAsL,MAAM,mBAAmB,CAAC;AACnO,OAAO,KAAK,EAAE,QAAQ,EAAe,cAAc,EAAE,MAAM,YAAY,CAAC;AAYxE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAanG;AAiKD;;;;;GAKG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAEjC;AAED;;;;;GAKG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAE,GAC1G,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAUjC"}
|