- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침 - 확인: 이 묶음 헬퍼를 쓰는 시험 428 개 전 417 통과 → 후 417 통과 (시험별 junit 대조 · 어긋남 0) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
2.2 KiB
JavaScript
76 lines
2.2 KiB
JavaScript
/* 90-2 도수로 · 돌붙임 띠 헬퍼 — `appendChuteBand`(B06_Section_UI_Cross_Wall_Hatch.ts)를 그 자리에서
|
|
* 트랜스파일해 흉내 DOM 에 그림 · 결과 = 띠 꼭짓점(m) · 돌 수(표준출력 JSON). 짝 = `test_90_chute_band.py`.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const { loadTs } = makeLoader({
|
|
root: ROOT,
|
|
requireFor: (full) => (request) => loadTs(path.join(path.dirname(full), `${request}.ts`)),
|
|
});
|
|
|
|
class Node {
|
|
constructor(tag) {
|
|
this.tag = tag;
|
|
this.attrs = {};
|
|
this.children = [];
|
|
}
|
|
setAttribute(k, v) {
|
|
this.attrs[k] = String(v);
|
|
}
|
|
getAttribute(k) {
|
|
return this.attrs[k] ?? null;
|
|
}
|
|
append(...kids) {
|
|
this.children.push(...kids);
|
|
}
|
|
set textContent(v) {
|
|
this.text = v;
|
|
}
|
|
}
|
|
globalThis.document = { createElementNS: (_ns, tag) => new Node(tag) };
|
|
|
|
const { appendChuteBand } = loadTs(
|
|
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Wall_Hatch.ts"),
|
|
);
|
|
const SCALE = 100;
|
|
const run = (line) => {
|
|
const layer = new Node("g");
|
|
appendChuteBand(
|
|
layer,
|
|
[{ points: line }],
|
|
{ structure: "돌붙임", thickness_m: 0.3 },
|
|
(o) => o * SCALE,
|
|
(e) => -e * SCALE,
|
|
);
|
|
const band = layer.children.find((k) => k.tag === "polygon");
|
|
const group = layer.children.find((k) => k.tag === "g");
|
|
const points = band.attrs.points.split(" ").map((p) => {
|
|
const [px, py] = p.split(",").map(Number);
|
|
return { offset: px / SCALE, elevation: -py / SCALE };
|
|
});
|
|
return {
|
|
points,
|
|
stones: group.children.filter((k) => k.tag === "rect").length,
|
|
clipped: group.attrs["clip-path"]?.startsWith("url(#") ?? false,
|
|
title: band.children[0]?.text ?? "",
|
|
};
|
|
};
|
|
const out = {
|
|
// 좌측 유출(+ 바깥) · 성토 1:1.2 → 단 사이 수평 조각 → 다시 성토(흙막이 단 사이 포함)
|
|
left: run([
|
|
{ offset: 5, elevation: 10 },
|
|
{ offset: 7.4, elevation: 8 },
|
|
{ offset: 8.4, elevation: 8 },
|
|
{ offset: 10.8, elevation: 6 },
|
|
]),
|
|
// 우측 유출(− 바깥) · 곧은 성토 한 줄
|
|
right: run([
|
|
{ offset: -5, elevation: 10 },
|
|
{ offset: -8.6, elevation: 7 },
|
|
]),
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|