import type { PierModel } from '../core/geometry'; import type { CastLayout } from '../core/rebar/cast-layout'; /** Front and section projections of the same centre lines used in the 3D scene. */ export function castRebarSvg(model: PierModel, layout: CastLayout): string { const bars = layout.bars.filter(b => b.columnIndex === 0); if (!bars.length) return '

입력 오류를 확인하세요. 생성된 기둥·말뚝 철근이 없습니다.

'; const pts = bars.flatMap(b => b.pts); const bottom = pts.reduce((a, p) => Math.min(a, p[1]), Infinity); const top = pts.reduce((a, p) => Math.max(a, p[1]), -Infinity); const diameter = model.columnDiameterMm / 1000; const scale = Math.min(180 / diameter, 480 / (top - bottom)); const x = (v: number) => 130 + (v - model.columns[0].s) * scale; const y = (v: number) => 35 + (top - v) * scale; const colour = (kind: string) => kind === 'main' ? '#0f5c66' : kind === 'coupler' ? '#0b3f46' : '#6b3fa0'; const front = bars.map(b => ``).join(''); const sectionHeight = model.groundEl + Math.min(1, (model.columns[0].top - model.groundEl) / 2); const sectionScale = 140 / diameter; const section = bars.filter(b => b.kind === 'main' && b.pts[0][1] <= sectionHeight && b.pts.at(-1)![1] >= sectionHeight).map(b => { const p = b.pts[0]; return ``; }).join(''); return ` 정면 · 실제 생성 경로 ${front} 지반고 EL ${model.groundEl.toFixed(3)} 기둥 주철근 단면${section} 단부·저부 P6 미확정 사항은 알림 참조 · 길이 단위 mm`; }