import type { PierModel } from '../core/geometry'; import { bearingEdgeDistances, pairEccentricities } from '../core/bearing-layout'; /** Drawing values (A, B of the solplate, mm) of the front and back bearings, to overlay on the model (승인 2026-10-26). */ export interface BearingPlanOverlay { front: { A: number; B: number }; back: { A: number; B: number }; } /** Number of pairs the 상세 보기 chips can show (①–⑩ in the mockup). */ export const PAIR_CHIP_LABELS = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩']; /** * 교량받침 상세 · 평면 for one pair (승인 2026-10-26): the model's solplates and blocks, with the drawing values overlaid * as dashed outlines when given. 일체 draws the pair's block as one outline (2500 across the 교축 × 1200 along the 교각축); * 분리 draws two 1200 × 1200 outlines. x is the 교축 (n), y the 교각축 (s, downward); units mm. */ export function bearingPlanSvg(m: PierModel, pairIndex: number, overlay?: BearingPlanOverlay): 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 sc = (f.s + k.s) / 2; const X = (n: number) => (n - nc) * 1000; const Y = (s: number) => (s - sc) * 1000; const parts: string[] = []; // Block outline(s): 일체 = one 2500 × 1200 outline; 분리 = two 1200 × 1200 outlines. const ib = m.integratedBlocks.find((x) => x.frontNo === pair.frontNo); if (ib) { parts.push(``); parts.push(`C3 2500 (일체 블록 윤곽)`); } else { for (const b of [f, k]) { parts.push(``); } } // Solplates: the model's plan (A across the 교축, B along the 교각축), centred on each bearing. for (const b of [f, k]) { if (b.plan) { const { A, B } = b.plan; parts.push(``); } } // Drawing values overlaid (dashed red) on the same bearings (#1 겹쳐 보이게). if (overlay) { for (const [b, v] of [[f, overlay.front], [k, overlay.back]] as const) { parts.push(``); } } // Bearing centres and labels. for (const b of [f, k]) { parts.push(``); parts.push(`${b.no}`); } // Dimensions: C2 between the bearing centres, C4 and C5 from the bearing to the block edges (교축). const dist = bearingEdgeDistances(m); const d = (no: number) => dist.find((x) => x.no === no)!; parts.push(`C2 ${Math.round(Math.abs(k.n - f.n) * 1000)}`); parts.push(`C4 ${Math.round(d(f.no).leftMm ?? 0)}`); parts.push(`C5 ${Math.round(d(k.no).rightMm ?? 0)}`); return `${parts.join('')}`; }