Files
Aislo/resources/tester/helper_152_3_chute_cut.cjs
T
eomsangdonandClaude Opus 5.5 1f638cd1c5 feat(b06): 도수로 · 돌붙임 띠 = 묻힌 유출 끝 3도 절토 조각까지(152-3)
- 띠 조각 거름 한 벌 isChuteSegment — 성토 + 내림 · 수평 절토 조각 · 오르막 복합경사 절토 뺌
- B06 관 · 흙막이 띠 · B05 3D 띠가 같은 거름 · 박스 · 세월교 본체 끝은 성토만 그대로
- 띠 툴팁 절토 조각 = 「3도 절토선 따라」 · 새 시험 test_152_3_chute_cut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3mdb91125mPoC6tpsQx4P
2026-10-09 19:13:04 +09:00

113 lines
4.6 KiB
JavaScript

/* 152-3 도수로 띠 절토 조각 헬퍼 — 묻힌 유출 끝 3도 절토선에도 띠 · 오르막 복합경사 절토엔 띠 없음.
* 화면 TS(`_Cross_Wall_Hatch` 거름 · 단면 · B05 3D `chuteBands`)를 그 자리에서 돌림 · 짝 = `test_152_3_chute_cut.py`.
* 입력 = 139-4 와 같은 픽스처(박스 352.14 · 배관 85.052 원지반 고친 사본).
*/
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);
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}.ts`);
const { computeStoredLayouts } = loadTs(B06("B06_Section_Structure_Layouts"));
const { isChuteSegment, chuteBandOutline } = loadTs(B06("B06_Section_UI_Cross_Wall_Hatch"));
const { chuteBands } = loadTs(
path.join(ROOT, "B05_Profile", "B05_Profile_UI_Corridor_Structures_Chute.ts"),
);
const fixture = (name) =>
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", name), "utf8")).cross_sections;
const clone = (v) => JSON.parse(JSON.stringify(v));
const r3 = (v) => Math.round(v * 1000) / 1000;
const CHUTE = { structure: "돌붙임", thickness_m: 0.3 };
/** 유출 조각마다 — 종류 · 오르막 · 띠 섬 · 띠 윗면이 그 선 · 아랫면이 선 아래(두께). */
function study(section, list) {
const culvert = computeStoredLayouts(section, list).culvert;
const segments = culvert.outletFill.segments;
const kept = segments.filter(isChuteSegment);
return {
segments: segments.map((g) => {
const [a, b] = [g.points[0], g.points[g.points.length - 1]];
const band = isChuteSegment(g) ? chuteBandOutline(g.points, CHUTE.thickness_m) : null;
const top = band?.top ?? [];
const bottom = band ? band.outline.slice(top.length) : [];
return {
kind: g.kind ?? "fill",
rises: b.elevation > a.elevation + 1e-6,
band: !!band,
topIsLine: !!band && top.length === g.points.length,
below: band
? r3(
Math.min(...top.map((p, i) => p.elevation - bottom[bottom.length - 1 - i].elevation)),
)
: null,
};
}),
// 3D 띠(관 · 흙막이 = isChuteSegment) · 기본 거름(박스 · 세월교 본체 끝 = 성토만)
bands3d: chuteBands(segments, CHUTE, isChuteSegment).length,
bands3dFillOnly: chuteBands(segments, CHUTE).length,
kept: kept.length,
};
}
const out = {};
const bodies = fixture("b06_73_4_body_guard_sections.json");
out.box = study(
bodies.find((s) => Math.abs(s.chainage_m - 352.14) < 0.6),
bodies,
);
const pipes = fixture("b07_cross_overlay_sections.json");
const pipe = pipes.find((s) => s.culvert && !s.culvert.hidden_pipe);
const base = computeStoredLayouts(pipe, pipes).culvert;
const tail = base.outletFill.segments[base.outletFill.segments.length - 1];
const start = tail.points[0];
const outward = Math.sign(tail.points[1].offset - start.offset) || 1;
function reshaped(rise, slope) {
const s = clone(pipe);
for (const p of s.samples) {
const t = ((p.offset_m ?? 0) - start.offset) * outward;
if (t >= 0 && typeof p.elevation_m === "number")
p.elevation_m = start.elevation + rise + slope * t;
}
return study(
s,
pipes.map((x) => (x === pipe ? s : x)),
);
}
out.pipeBase = study(pipe, pipes);
out.pipeDown = reshaped(0.3, -0.15); // 3도 선이 원지반을 만남
out.pipeUp = reshaped(0.3, 0.1); // 오르막 → 복합경사 절토
process.stdout.write(JSON.stringify(out));