Files
Aislo/resources/tester/helper_178_3_slope_tiers.cjs
T
eomsangdonandClaude Opus 5.5 a8a1471d71 feat(b05,b06): 사면안정 흙막이 · 옹벽 추가 단 상자 · 단마다 형태 · 높이 횡단 형상 (178-3)
- 추가 단 상자 = 유출 흙막이 상자 양식 · 공용 [추가] · [빼기] · 흙막이 형태 · 높이 · 옹벽 높이(콘크리트) · 키 tier_{n}_*
- 정의 그룹 종류 덧붙임 명세(ADDON_SPECS) — 좌측 폼만 · 그룹 상자 · 목록 · M02 그대로
- 벽 제원 짝(TS tierExtras · 파이썬 tier_extras) · 단 수 = 1 + 상자 수 · 횡단 단 조정 m · h
- 새 시험 test_178_3_slope_tiers · walls_mirror extras 대조

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015sDZSjFvoiDjdGpgj3muc3
2026-10-10 12:02:54 +09:00

113 lines
4.6 KiB
JavaScript

/* 178-3 사면안정 흙막이 · 옹벽 「추가 단」 헬퍼 — 화면 TS 를 그 자리에서 트랜스파일해 Node 로 돌림.
* ① 명세 상자 저장 왕복(readState → writeOptions) ② 구조물 정본 → 벽 제원(`wallSpecsFrom`) → 횡단 형상
* (`computeRevetmentLayout`) 단 수 · 단마다 형태 · 높이. 입력 측점 = 73-4 픽스처(helper_79 와 같은 180 측점).
* 결과 = 표준출력 JSON 한 벌 · 짝 = `test_178_3_slope_tiers.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 design = (f) => path.join(ROOT, "A00_Common", "design", f);
const spec = loadTs(design("design_structure_spec.ts"));
const { ADDON_SPECS } = loadTs(design("design_structure_slope_tier.ts"));
const { STRUCTURE_SPECS } = loadTs(design("design_structure_pipe.ts"));
const { wallSpecsFrom } = loadTs(path.join(ROOT, "common_util", "common_util_structure_walls.ts"));
const { computeRevetmentLayout } = loadTs(
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Revetment.ts"),
);
const r3 = (v) => Math.round(v * 1000) / 1000;
const out = {};
// ① 저장 왕복 — 상자 둘(흙막이) · 하나(옹벽) · 빈 상자(값 없이 추가만)
const soil = ADDON_SPECS.soil_guard;
const wall = ADDON_SPECS.retaining_wall;
const soilOptions = {
form: "돌쌓기(찰)",
height_m: 2,
tier_1_form: "콘크리트",
tier_1_height: 2,
tier_2_form: "돌망태",
tier_2_height: 1.2,
};
const soilState = spec.readState(soil, soilOptions);
out.roundTrip = {
items: Object.fromEntries(
Object.entries(ADDON_SPECS).map(([k, s]) => [k, s.containers[0].items.map((i) => i.id)]),
),
soilState: soilState.tier,
soilBack: spec.writeOptions(soil, soilState),
wallBack: spec.writeOptions(wall, { tier: [{ height: "1.8" }] }),
emptyBox: spec.writeOptions(soil, { tier: [{}] }),
notMainSpecs: Object.keys(ADDON_SPECS).filter((k) => k in STRUCTURE_SPECS),
};
// ② 형상 — 정본 → 벽 제원 → 횡단 단
const fixture = JSON.parse(
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
);
const base = fixture.cross_sections.find((s) => Math.abs(s.chainage_m - 180) < 0.6);
const names = new Map([
["soil_guard", "흙막이"],
["retaining_wall", "옹벽"],
]);
function shape(typeId, options) {
const [wallSpec] = wallSpecsFrom(
[{ structure_id: "t", type_id: typeId, chainage_m: 180, start_m: 170, end_m: 190, options }],
names,
);
const section = JSON.parse(JSON.stringify(base));
section.revetment = { ...wallSpec, side: "우" };
const layout = computeRevetmentLayout(section, null);
return {
tiers: wallSpec.tiers,
extras: wallSpec.extras,
requested: layout?.requestedTiers ?? null,
walls: (layout?.walls ?? []).map((w) => ({ form: w.form, pure: r3(w.height + 0.5) })),
};
}
out.soil2 = shape("soil_guard", soilOptions);
out.wall1 = shape("retaining_wall", { height_m: 2.5, tier_1_height: 1.8 });
out.emptyBox = shape("soil_guard", { form: "돌망태", height_m: 2, tier_1_form: "" });
out.legacy = shape("soil_guard", { form: "돌망태", height_m: 2, tiers: 2 });
out.none = shape("retaining_wall", { height_m: 2.5 });
process.stdout.write(JSON.stringify(out));