/* 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", "logic/B06_Section_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) }));