- 새 B07_DesignDetail_Engine_Cad_CulvertNote = TS culvertNoteEntities · stationNoLabel 짝(두 파일 머리 표시) - 횡단 장 만들 때 CAD 칸 없음 · 옛 글 없음 · 배수관 주인 측점 = 정본 pipe_points 로 미리 넣음 칸을 얹은 사본 - 지운 칸(빈 엔티티) · 옛 글 · 설계 없음 · 이웃 측점 = 그대로 - 시험 test_260_note_cad 거울 9쌍(같은 입력 → 같은 엔티티) · 정본 읽기 · B07 그림 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNMXVCZXMpHpVvqmFkeChL
121 lines
4.5 KiB
JavaScript
121 lines
4.5 KiB
JavaScript
/* PLAN 260 단위검증 헬퍼 — [상세] 표 위 CAD 칸 · 옛 글 옮김 · 횡단배수 미리 넣음.
|
|
* `B06_Section_UI_Cross_Detail_Cad.ts` 를 그 자리에서 트랜스파일해 Node 로 돌린다(CAD · 세션 · 서버 = 흉내).
|
|
* 결과는 표준출력에 JSON 한 벌 · 인자 `mirror` = 표준입력 입력으로 거울 결과(260-4). 확장자 `.cjs` 까닭은 `helper_108_drag_box_hit.cjs` 머리와 같다.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const STUBS = {
|
|
"@ui/cad_host/cad_host": { createCadHost: () => ({}) },
|
|
"../A00_Common/b_page_state": { readState: () => null, writeState: () => undefined },
|
|
"../A00_Common/design/design_selection": { PIPE_MATCH_M: 0.51 },
|
|
"../B04_PreProcess/B04_PreProcess_Api_Fetch": { fetchDetailPipePoints: async () => ({}) },
|
|
"../B05_Profile/B05_Profile_Api_Pipes_Draft": { readPendingPipes: () => null },
|
|
};
|
|
|
|
function loadTs(file) {
|
|
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
const localRequire = (request) => {
|
|
if (STUBS[request]) return STUBS[request];
|
|
throw new Error(`흉내 없는 모듈: ${request}`);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
return box.exports;
|
|
}
|
|
|
|
const cad = loadTs(path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Detail_Cad.ts"));
|
|
|
|
const wall = (role, form, height, length) => ({
|
|
role,
|
|
structure: "기슭막이",
|
|
revet_form: form,
|
|
revet_height_m: height,
|
|
revet_length_m: length,
|
|
});
|
|
const culvert = (extra = {}) => ({
|
|
type: "pipe",
|
|
chainage_m: 1433,
|
|
pipe_kind: null,
|
|
diameter_m: 1.2,
|
|
min_cover_m: 0.5,
|
|
inlet: wall("inlet", "돌쌓기(찰)", 2, 10),
|
|
outlet: wall("outlet", "돌쌓기(메)", 2, 10),
|
|
...extra,
|
|
});
|
|
const section = (spec, design = { pipe_length_m: 22 }, chainage = 1433) => ({
|
|
chainage_m: chainage,
|
|
station_id: "s",
|
|
samples: [],
|
|
culvert: spec,
|
|
design,
|
|
});
|
|
const CHUTE = { chute_add_1_structure: "돌붙임", chute_add_1_bond: "찰붙임", chute_add_1_area: 10 };
|
|
|
|
/** 엔티티 → 비교하기 쉬운 꼴(종류 · 글 · 자리 · 색). */
|
|
const brief = (entities) =>
|
|
entities.map((entity) => ({
|
|
type: entity.type,
|
|
label: entity.shapeData.label ?? null,
|
|
align: entity.shapeData.options?.textAlign ?? null,
|
|
x: entity.shapeData.basePoint?.x ?? entity.shapeData.center?.x ?? null,
|
|
y: entity.shapeData.basePoint?.y ?? entity.shapeData.center?.y ?? null,
|
|
color: entity.lineColor,
|
|
layer: entity.layerId,
|
|
}));
|
|
const run = (sec, options) => brief(cad.culvertNoteEntities(sec, "NO.71+13", options));
|
|
|
|
const out = {
|
|
full: run(section(culvert()), CHUTE),
|
|
noLength: run(section(culvert(), {}), {}),
|
|
basin: run(
|
|
section(
|
|
culvert({
|
|
inlet: {
|
|
role: "inlet",
|
|
structure: "집수정",
|
|
basin_form: "L",
|
|
basin_height_m: 1.7,
|
|
basin_length_m: 2,
|
|
},
|
|
}),
|
|
),
|
|
{},
|
|
),
|
|
chuteFallback: run(section(culvert({ chute: { structure: "도수로", thickness_m: 0.45 } })), {}),
|
|
noSides: run(
|
|
section(
|
|
culvert({
|
|
inlet: { role: "inlet", structure: "" },
|
|
outlet: { role: "outlet", structure: "" },
|
|
}),
|
|
),
|
|
{},
|
|
),
|
|
none: run(section(undefined), CHUTE),
|
|
ford: run(section(culvert({ body: "ford" })), CHUTE),
|
|
hidden: run(section(culvert({ hidden_pipe: true })), CHUTE),
|
|
neighbour: run(section(culvert(), { pipe_length_m: 22 }, 1440), CHUTE),
|
|
legacy: brief(cad.legacyNoteEntities("\nL형 측구 \n\n집수정 보강\n")),
|
|
legacyEmpty: cad.legacyNoteEntities(" ").length,
|
|
station: [
|
|
cad.stationNoLabel(1433, 20),
|
|
cad.stationNoLabel(1420, 20),
|
|
cad.stationNoLabel(1439.97, 20),
|
|
],
|
|
};
|
|
// 거울(260-4) — 시험이 표준입력으로 준 같은 입력 [{section, station, options, chainage, interval}]
|
|
// → TS 엔티티 · 측점 이름(파이썬 짝 `_Engine_Cad_CulvertNote` 와 대조)
|
|
if (process.argv[2] === "mirror") {
|
|
const cases = JSON.parse(fs.readFileSync(0, "utf8"));
|
|
const mirrored = cases.map((item) => ({
|
|
entities: cad.culvertNoteEntities(item.section, item.station, item.options),
|
|
station: cad.stationNoLabel(item.chainage, item.interval),
|
|
}));
|
|
process.stdout.write(JSON.stringify(mirrored));
|
|
} else process.stdout.write(JSON.stringify(out));
|