Files
Aislo/resources/tester/helper_139_6_pipe_fit.cjs
T
eomsangdonandClaude Sonnet 5.5 db83a06a6b test(508-1b 옛 헬퍼 공용 불러오기 1/7): 헬퍼 26 곳 loadTs 베낌 걷고 makeLoader 로 — 공용 불러오기에 옵션 넷(requireFor · interop · cache · fileStub) 늘림
- helper_ts_stub_loader: 옛 헬퍼가 저마다 다르게 쓰던 것(풀이 함수 직접 · esModuleInterop · 캐시 끔 · 파일 통째 대역)을 옵션으로 · 기본 풀이는 그대로
- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침
- 확인: 이 묶음 헬퍼를 쓰는 시험 241 개 전 241 통과 → 후 241 통과 (비교 = 시험별 junit)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 17:06:06 +09:00

72 lines
2.8 KiB
JavaScript

/* 139-6 노견을 넓힌 유출 쪽 관 길이 맞춤 헬퍼 — 설계선 엔진(`common_util_cross_design`)으로 노견 확장
* 설계를 내고 배수관 기하(`_Cross_Culvert_Geom`)를 돌림. 입력 = B07 픽스처 배관 측점(85.052 · 유출 좌).
* 표준단면 수치 = 인자 JSON 파일(파이썬 config 그대로 · 거울 시험과 같은 방식).
* 짝 = `test_139_6_pipe_fit.py`.
*/
const fs = require("fs");
const path = require("path");
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
const ROOT = path.join(__dirname, "..", "..");
const noop = new Proxy({}, { get: () => () => "" });
globalThis.document = { addEventListener: () => undefined };
const { loadTs } = makeLoader({
root: ROOT,
requireFor: (full) => {
const resolve = (base) =>
fs.existsSync(base) && fs.statSync(base).isFile() ? base : `${base}.ts`;
const req = (r) => {
if (r.startsWith("@ui/") || r.startsWith("@config/")) return noop;
if (r.startsWith("@util/"))
return loadTs(resolve(path.join(ROOT, "common_util", r.slice(6))));
return loadTs(resolve(path.join(path.dirname(full), r)));
};
return req;
},
});
const { computeCrossDesign } = loadTs(
path.join(ROOT, "common_util", "common_util_cross_design.ts"),
);
const { computeCulvertLayout, REVET_EMBED_DEPTH_M } = loadTs(
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Culvert_Geom.ts"),
);
const { cutLength } = loadTs(
path.join(ROOT, "B06_Section", "logic", "B06_Section_UI_Cross_Culvert_Solve.ts"),
);
const sections = JSON.parse(
fs.readFileSync(path.join(__dirname, "fixtures", "b07_cross_overlay_sections.json"), "utf8"),
).cross_sections;
const section = sections.find((s) => s.culvert && !s.culvert.hidden_pipe);
const d = section.design;
const standard = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
const designOf = (extendLeft) =>
computeCrossDesign(section.samples, d.design_elevation_m, {
groundType: d.ground_type,
sectionMode: d.section_mode,
ditchSide: d.ditch_side,
ditchType: d.ditch_type ?? "standard",
paved: !!d.paved,
standard,
shoulderExtendLeftM: extendLeft,
});
const r3 = (v) => Math.round(v * 1000) / 1000;
const run = (extendLeft) => {
const design = designOf(extendLeft);
const s = { ...section, design };
const layout = computeCulvertLayout(s, section.samples, undefined, "L");
const wall = layout.walls.find((w) => w.role === "outlet");
const edge = design.road_edges.left;
return {
edge: r3(edge.offset_m),
extend: design.shoulder_extend_left_m ?? 0,
pureHeight: r3(wall.height + REVET_EMBED_DEPTH_M),
lengthM: layout.pipe.lengthM,
cut: r3(cutLength(layout.pipeCorners)),
slope: r3(layout.fillSlope.ratio),
};
};
process.stdout.write(JSON.stringify({ base: run(0), shifted: run(1.0), shifted2: run(1.3) }));