import type { PierModel } from '../core/geometry'; import { barDepths, barsAcross, type BlockRebarSettings } from '../core/rebar/bearing-block'; import { INTEGRATED_BLOCK } from '../core/integrated-block'; /** * 받침블럭 배근 · 단면 C–C (승인 2026-10-26, 시안 ③): a section along the 교축, through the blocks. x = 교축 (n), y = EL * (down from the highest block top). S2 bars are dots along the top, S1 bars are lines with legs down into the coping. * Dimensions: the block widths and gap, the bar layout (end · n@spacing = span), and the top cover. */ export function blockRebarSectionSvg(m: PierModel): string { const s: BlockRebarSettings = m.blockRebar; const depth = barDepths(s); const ib = m.integratedBlocks; const parts: string[] = []; const topRef = Math.max(...m.blocks.map((b) => b.top)); const Y = (el: number) => (topRef - el) * 1000; // Spans to draw: one 2500 span per 일체 pair, else one 1200 span per bearing. const spans = ib.length > 0 ? ib.map((x) => ({ nc: x.n, width: INTEGRATED_BLOCK.length, bottom: x.bottom, topL: x.topFront, topR: x.topBack, depthTopL: x.topFront, depthTopR: x.topBack, stepped: true })) : m.blocks.map((b) => ({ nc: b.n, width: 1200, bottom: b.bottom, topL: b.top, topR: b.top, depthTopL: b.top, depthTopR: b.top, stepped: false })); const nAll = spans.map((x) => x.nc); const nc = (Math.min(...nAll) + Math.max(...nAll)) / 2; const X = (n: number) => (n - nc) * 1000; for (const sp of spans) { const x0 = X(sp.nc - sp.width / 2000); const x1 = X(sp.nc + sp.width / 2000); if (sp.stepped) { const xm = X(sp.nc); parts.push(``); } else { parts.push(``); } // S2: dots along the top at the S2 depth (each half at its own top when stepped). const a2 = barsAcross(sp.width, s.spacingS2, s); for (let i = 0; i < a2.count; i++) { const xb = x0 + a2.firstEnd + i * a2.spacing; const top = sp.stepped && xb > (x0 + x1) / 2 ? sp.depthTopR : sp.depthTopL; parts.push(``); } // S1: a line across the block at the S1 depth, legs down into the coping at both ends. const low = sp.stepped ? Math.min(sp.topL, sp.topR) : sp.topL; const z1 = low - depth.S1 / 1000; const leg = s.legLength; parts.push(``); parts.push(``); parts.push(``); // Dimensions: the S2 layout under the span. const yDim = Y(sp.bottom) + 120; parts.push(`${a2.firstEnd.toFixed(1)} · ${a2.count - 1}@${a2.spacing}=${(a2.count - 1) * a2.spacing} · ${a2.firstEnd.toFixed(1)}`); parts.push(`${(sp.width).toFixed(0)}`); } return `${parts.join('')}`; }