import type { PierModel } from '../core/geometry'; import { pairEccentricities } from '../core/bearing-layout'; /** * Drawing values of one bearing (도면값), overlaid as dashed outlines (승인 2026-10-26). * All lengths in mm; elx in m. */ export interface BearingDrawingRef { elx?: number; h1: number; h2: number; h3: number; h4: number; E: number; A: number; B: number; } /** * 교량받침 상세 · 단면 (elevation) for one pair (승인 2026-10-26): the model's blocks, mortar, bearing body, * and solplate per bearing, with the drawing heights overlaid as dashed outlines. x is the 교축 (n), y the EL (up). * Labels: EL.X (mortar top), h1 (block), h2 (mortar), h3 (bearing), h4 (solplate), E = h1 + h2 + h3 + h4. */ export function bearingSectionSvg(m: PierModel, pairIndex: number, refs?: { front?: BearingDrawingRef; back?: BearingDrawingRef }): string { const pair = pairEccentricities(m.blocks)[pairIndex]; if (!pair) return ''; const f = m.blocks.find((b) => b.no === pair.frontNo && b.row === '전열')!; const k = m.blocks.find((b) => b.no === pair.backNo && b.row === '후열')!; const nc = (f.n + k.n) / 2; const elc = (f.bottom + k.bottom) / 2; const X = (n: number) => (n - nc) * 1000; const Y = (el: number) => -(el - elc) * 1000; const parts: string[] = []; // Blocks: one stepped outline for 일체, else one per bearing. const ib = m.integratedBlocks.find((x) => x.frontNo === pair.frontNo); if (ib) { const x0 = X(ib.n - 1.25); const x1 = X(ib.n + 1.25); const xm = X(ib.n); parts.push(``); } else { for (const b of [f, k]) { parts.push(``); } } // Mortar, bearing body and solplate per bearing, from the model. for (const [b, ref] of [[f, refs?.front], [k, refs?.back]] as const) { const pad = 1000; parts.push(``); if (b.plan) { const { A, margin, h3, T } = b.plan; const L = A + margin; const bodyTop = b.padTop + h3 / 1000; parts.push(``); const drop = (L * Math.abs(b.plan.S)) / 200; const t1 = T + drop; const t2 = T - drop; const x0 = X(b.n) - L / 2; const x1 = X(b.n) + L / 2; parts.push(``); } if (ref) { // Drawing heights from the block bottom, dashed (overlay). const base = b.bottom; const dBlockTop = base + (ref.h1 ?? 0) / 1000; const dPad = dBlockTop + ref.h2 / 1000; const dBody = dPad + ref.h3 / 1000; const dSol = dBody + ref.h4 / 1000; parts.push(``); parts.push(``); parts.push(``); } // EL.X at the mortar top, bearing number. parts.push(``); parts.push(`${b.no} · EL.X ${b.padTop.toFixed(3)}`); parts.push(`h1 ${Math.round((b.top - b.bottom) * 1000)}`); } return `${parts.join('')}`; }