Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F3mdb91125mPoC6tpsQx4P
61 lines
2.6 KiB
JavaScript
61 lines
2.6 KiB
JavaScript
/* 139-3 세월교 수평 헬퍼 — `_Cross_Ford_Geom`(computeFordLayout · fordDropOf)를 그 자리에서 트랜스파일해
|
|
* 73-4 픽스처 세월교(173.087)로 돌림. 짝 = `test_139_3_ford_level.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 noop = new Proxy({}, { get: () => () => "" });
|
|
|
|
function loadTs(file) {
|
|
const full = path.resolve(file);
|
|
if (cache.has(full)) return cache.get(full);
|
|
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
cache.set(full, box.exports);
|
|
const localRequire = (request) => {
|
|
if (request.startsWith("@ui/") || request.startsWith("@config/")) return noop;
|
|
if (request.startsWith("@util/"))
|
|
return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`));
|
|
return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
cache.set(full, box.exports);
|
|
return box.exports;
|
|
}
|
|
|
|
const { computeFordLayout, fordAdjustOf } = loadTs(
|
|
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Ford_Geom.ts"),
|
|
);
|
|
const sections = JSON.parse(
|
|
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
|
|
).cross_sections;
|
|
const ford = sections.find((s) => s.ford);
|
|
const r3 = (v) => Math.round(v * 1000) / 1000;
|
|
const run = (stored) => {
|
|
const layout = computeFordLayout(ford, ford.samples, fordAdjustOf(stored));
|
|
return {
|
|
slab: layout.sides.map((s) => r3(s.slabTopElevation)),
|
|
pipeEnds: layout.sides.map((s) => r3(s.pipeEnd.elevation)),
|
|
tops: layout.sides.map((s) => r3(s.top.elevation)),
|
|
heights: layout.sides.map((s) => r3(s.heightM)),
|
|
wallX: layout.sides.map((s) => r3(s.top.offset)),
|
|
dropM: r3(layout.adjust.dropM),
|
|
};
|
|
};
|
|
const wall = (o) => ({ heightM: null, lateralM: 0, slopeM: 0, ...o });
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
base: run(null),
|
|
drop: run({ inlet: wall(), outlet: wall(), dropM: 0.4 }),
|
|
up: run({ inlet: wall(), outlet: wall(), dropM: -1 }),
|
|
lateral: run({ inlet: wall({ lateralM: 1 }), outlet: wall({ lateralM: -2 }), dropM: 0 }),
|
|
// 옛 저장 — 유입 높이 + 0.6 · 유출 대각 1.2(= 수직 1.0) → 평균 내림 0.8 언저리
|
|
old: run({ inlet: wall({ heightM: 2.1 }), outlet: wall({ slopeM: 1.2 }) }),
|
|
}),
|
|
);
|