Files
Aislo/resources/tester/helper_73_4_body_guard.cjs
T
eomsangdonandClaude Opus 5.5 e9539fcb12 feat(B06): 흙막이 기본 자리 제일 위 · 연동 형상 색 구분 · 세월교 · 박스 흙막이 형상(79-5 · 79-6 · 79-7)
- 79-5 관 보호공 · 독립 기슭막이 · 옹벽 기본 자리 = 성토사면 제일 위(d 0) · 관은 m 단위 맞춤이 사면 아래로 미는 만큼만
- 79-6 연동 벽 = 옅은 청회색 점선 · 연동 벽을 고르면 주 횡단도 옅은 빨강 테두리 · 연동 측점 카드만 고르면 좌측 패널은 일반 측점 · 세월교 측벽 판정면 = ㄴ 을 감싸는 사각형
- 79-7 세월교 · 박스 흙막이 = 배면이 본체 끝에 붙고 윗면 = 본체 윗면 · 높이 빈 칸 = 본체 끝 높이(박스 2.0 → 2.5 = 상판 + 내공 + 저판) · 세월교 흙막이 쪽 ㄴ형 측벽 걷음 · 끝 절토 = 수평공간(새 칸 · 기본 1 m) 뒤 절토 경사 · 면적에 듦
- 79-7 박스 본체 늘 수평(좌 · 우 표고 한 값) · 박스 날개벽 끝 절 · 성토선(세월교와 같은 체계)
- 수평공간 칸 = 파이썬 _guard_set ↔ TS guardSet 짝 · 구조물정의 이름 표 · B05 저장 칸 목록
- 시험: test_79_guard_shape(새) · test_73_4_body_guard · test_65_ford_defaults · test_user_values_survive 맞춤

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYJJRCfHfdCGNhmXTjQKV7
2026-10-08 00:16:05 +09:00

118 lines
4.6 KiB
JavaScript

/* 73-4 세월교 · 박스 흙막이 횡단 기하 헬퍼 — 화면 TS(`B06_Section_Structure_Layouts` · `_Cross_Body_Guard`)를
* 그 자리에서 트랜스파일해 Node 로 돌림. 입력 = 픽스처(검증_sub7 상세 일부) · 결과 = 표준출력 JSON 한 벌.
* 짝 = `test_73_4_body_guard.py`.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
const cache = new Map();
// 화면 전용 모듈(토스트 · 글) — 기하 계산엔 안 쓰임
const STUBS = {
"@ui/ui_template_toast": { showToast: () => undefined },
};
function loadTs(file) {
const full = path.resolve(file);
if (cache.has(full)) return cache.get(full);
if (full.endsWith(".json")) {
const data = JSON.parse(fs.readFileSync(full, "utf8"));
cache.set(full, data);
return data;
}
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
compilerOptions: {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2020,
esModuleInterop: true,
},
}).outputText;
const box = { exports: {} };
cache.set(full, box.exports);
const localRequire = (request) => {
if (STUBS[request]) return STUBS[request];
const alias = { "@util/": "common_util", "@ui/": "ui_template", "@config/": "config" };
for (const [prefix, dir] of Object.entries(alias))
if (request.startsWith(prefix))
return loadTs(resolve(path.join(ROOT, dir, request.slice(prefix.length))));
return loadTs(resolve(path.join(path.dirname(full), request)));
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const resolve = (base) =>
[base, `${base}.ts`, path.join(base, "index.ts")].find(
(p) => fs.existsSync(p) && fs.statSync(p).isFile(),
) ?? `${base}.ts`;
const B06 = (f) => path.join(ROOT, "B06_Section", f);
const { computeStoredLayouts, structureAreaRows, trimOfLayouts } = loadTs(
B06("B06_Section_Structure_Layouts.ts"),
);
const { bodyGuardBase } = loadTs(B06("B06_Section_UI_Cross_Body_Guard.ts"));
const fixture = JSON.parse(
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
);
const sections = fixture.cross_sections;
const at = (c) => sections.find((s) => Math.abs(s.chainage_m - c) < 0.6);
const round = (v) => Math.round(v * 1000) / 1000;
/** 벽마다 배면 ↔ 본체 끝 자리 차이(m) · 벽 윗면 ↔ 본체 윗면 표고 차이(79-7 — 벽 배면이 본체 끝에 붙음). */
function fronts(section) {
const layouts = computeStoredLayouts(section, sections);
const base = bodyGuardBase(section, section.samples);
const walls = layouts.culvert?.walls ?? [];
return {
walls: walls.map((w) => {
const end = base.ends[w.role];
return {
role: w.role,
form: w.form,
dOffset: round(w.bottomBack.offset - end.offset),
dElevation: round(Math.max(...w.points.map((p) => p.elevation)) - end.top),
front: round(w.bottomBack.offset),
};
}),
bodyX: layouts.culvert?.bodyX ?? null,
applied: layouts.culvert?.revetShift
? { inlet: layouts.culvert.revetShift.inlet.x, outlet: layouts.culvert.revetShift.outlet.x }
: null,
trimSame:
JSON.stringify(trimOfLayouts(layouts)) === JSON.stringify(layouts.culvert?.designTrim),
pipeLength: null,
};
}
const out = {};
const box = at(352.14);
const ford = at(173.09);
out.box = fronts(box);
out.ford = fronts(ford);
// 박스를 좌우로 1 m 늘리면 벽 전면도 1 m 따라 나감(연동 = 본체 기준 자리)
const moved = JSON.parse(JSON.stringify(box));
moved.design.box_adjust = { left: { lengthM: 1, riseM: 0 }, right: { lengthM: 1, riseM: 0 } };
const swapped = sections.map((s) => (s === box ? moved : s));
const movedLayouts = computeStoredLayouts(moved, swapped);
const base = bodyGuardBase(moved, moved.samples);
out.boxMoved = movedLayouts.culvert.walls.map((w) => ({
role: w.role,
dOffset: round(w.bottomBack.offset - base.ends[w.role].offset),
front: round(w.bottomBack.offset),
}));
// 연동 옆 측점(340 · 360) — 소유 측점 벽이 섬
out.linked = [340, 360].map((c) => {
const s = at(c);
return { chainage: c, walls: computeStoredLayouts(s, sections)?.culvert?.walls.length ?? 0 };
});
// 면적 행 — 서버 Node 진입점과 같은 함수(`structureAreaRows`)
out.areas = structureAreaRows(sections).filter((r) =>
[173.087, 352.14].some((c) => Math.abs(r.chainage_m - c) < 0.6),
);
process.stdout.write(JSON.stringify(out));