- 새 칸 design.structure_note_cad — 스키마 · 재계산 남김 · 세션 초안 structure-note-cads · [저장] patch - 상세 모달 글 상자 → 빈 CAD(cad_host bare · 높이 고정 · 닫으면 destroy · 고칠 때마다 초안) - 처음 열 때 칸이 없으면 옛 글 줄마다 Text · 없으면 횡단배수 주인 측점만 미리 넣음 - 시험 test_260_note_cad · helper_260_note_cad Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNMXVCZXMpHpVvqmFkeChL
112 lines
3.9 KiB
JavaScript
112 lines
3.9 KiB
JavaScript
/* PLAN 260 단위검증 헬퍼 — [상세] 표 위 CAD 칸 · 옛 글 옮김 · 횡단배수 미리 넣음.
|
|
* `B06_Section_UI_Cross_Detail_Cad.ts` 를 그 자리에서 트랜스파일해 Node 로 돌린다(CAD · 세션 · 서버 = 흉내).
|
|
* 결과는 표준출력에 JSON 한 벌. 확장자 `.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),
|
|
],
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|