import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import * as XLSX from 'xlsx'; import * as THREE from 'three'; import { describe, expect, it } from 'vitest'; import { buildAbut } from '../src/core/abut/geometry'; import { parseAbutments, toAbutInput } from '../src/core/abut/parse'; import { buildMembers } from '../src/core/abut/members'; import { buildWings } from '../src/core/abut/wings'; import { buildAbutGroup } from '../src/view/abut-scene'; const RAG = fileURLToPath(new URL('../../../RAG/운곡교P1입력.xlsx', import.meta.url)); const rec = parseAbutments(XLSX.read(readFileSync(RAG), { type: 'buffer' })).abutments[0]; const input = toAbutInput(rec); const model = buildAbut(input); const members = buildMembers(model, { bottomEl: input.foundationBottomEl, pileLengthMm: input.pileLengthMm }); const wings = buildWings(model, members); const group = buildAbutGroup(model, members, wings); const named = (name: string) => group.getObjectByName(name) as THREE.Group | undefined; describe('교대 3D: 받침블럭과 접속슬래브 (spec §4.2, §4.8)', () => { it('has a block and a pad for each of the 5 bearings', () => { expect(named('blocks')?.children).toHaveLength(2 * model.bearings.length); }); it('draws the 접속슬래브 as one slab', () => { expect(named('slab')?.children).toHaveLength(1); }); it('the slab does not overlap either wing in plan (spec §4.8: 날개벽 안쪽면 + 20)', () => { // Axis frame: s along IP1 → IP3, t positive to the 전면, as toAxis() in abut-scene.ts. const axis = (p: { e: number; n: number }) => { const d = { e: p.e - model.ip1.e, n: p.n - model.ip1.n }; const f = { e: model.nLeft.e * model.frontSide, n: model.nLeft.n * model.frontSide }; return { s: d.e * model.u.e + d.n * model.u.n, t: d.e * f.e + d.n * f.n }; }; const inside = (x: number, y: number, poly: { s: number; t: number }[]) => { let c = false; for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) { if (poly[i].t > y !== poly[j].t > y && x < ((poly[j].s - poly[i].s) * (y - poly[i].t)) / (poly[j].t - poly[i].t) + poly[i].s) c = !c; } return c; }; const pos = (named('slab') as THREE.Group).children[0] as THREE.Mesh; const attr = pos.geometry.getAttribute('position'); const polys = wings.map((w) => w.corners.map(axis)); for (let i = 0; i < attr.count; i++) { for (const poly of polys) expect(inside(attr.getX(i), attr.getZ(i), poly)).toBe(false); } }); it('the slab reaches 7 m behind the 흉벽 back face and is 450 thick', () => { const box = new THREE.Box3().setFromObject(named('slab') as THREE.Group); expect(box.min.z).toBeCloseTo(members.shape.parapetBackM - 0.005 - 7, 2); expect(box.max.y - box.min.y).toBeGreaterThan(0.45); }); });