- 엔진: Engine_Cad_Basin 배경선만 꼭짓점 목록 폴리선(id 는 옛 폴리선과 같음) · 노선 · 유역 · 표 · 도각은 옛 꼴 그대로 · B05 · B06 길 손대지 않음 - CAD 앱: PolyLineEntity.fromJson 이 자식 없고 꼭짓점 목록이면 선분으로 펼침(색 · 굵기 · 층 = 부모) · 다시 내보내면 옛 꼴 - DXF 내보내기 · B09 도면 인쇄 PDF: 꼭짓점 목록 폴리선 = 열린 선(해치만 닫음) - 검증_sub2 유역도 5 m 23.17 → 3.22 MB · 10 m 11.91 → 1.77 MB · 좌표 · id · 색 해시 전후 같음 · B05 · B06 등고선 · 배수 응답 해시 같음 - 시험: test_514_3_b07_basin_light 새로 · vitest cad/polyline-points-514-3 새로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
/**
|
|
* 514-3 — 가벼운 폴리선(자식 대신 꼭짓점 목록 · B07 유역도 배경선)을 CAD 가 선분으로 펼치는지.
|
|
* 실행: cd B07_DesignDetail/openwebcad && npx vitest run --config <include 를 이 파일로 바꾼 vitest.tmp.config.ts>
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
import { EntityName, type JsonEntity } from "../../../B07_DesignDetail/openwebcad/src/entities/Entity";
|
|
import type { LineEntity } from "../../../B07_DesignDetail/openwebcad/src/entities/LineEntity";
|
|
import {
|
|
PolyLineEntity,
|
|
type PolyLineJsonData,
|
|
} from "../../../B07_DesignDetail/openwebcad/src/entities/PolyLineEntity";
|
|
|
|
const light: JsonEntity<PolyLineJsonData> = {
|
|
id: "p1",
|
|
type: EntityName.PolyLine,
|
|
lineColor: "#6b7684",
|
|
lineWidth: 1,
|
|
layerId: "b08-basin-contour",
|
|
shapeData: { points: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 2 }] },
|
|
};
|
|
|
|
describe("514-3 가벼운 폴리선", () => {
|
|
it("꼭짓점 n 개 = 선분 n-1 개 · 색 · 층 · id 는 부모 것", async () => {
|
|
const poly = await PolyLineEntity.fromJson(light);
|
|
expect(poly.id).toBe("p1");
|
|
expect(poly.numberOfSegments()).toBe(2);
|
|
const lines = poly.getEntities() as LineEntity[];
|
|
expect(lines.map((line) => [line.lineColor, line.layerId])).toEqual([
|
|
["#6b7684", "b08-basin-contour"],
|
|
["#6b7684", "b08-basin-contour"],
|
|
]);
|
|
expect(lines[1].getStartPoint().y).toBe(0);
|
|
expect(lines[1].getEndPoint().y).toBe(2);
|
|
});
|
|
|
|
it("다시 내보내면 옛 꼴(자식 선분) — 편집 저장 길 그대로", async () => {
|
|
const json = await (await PolyLineEntity.fromJson(light)).toJson();
|
|
expect(json?.children?.length).toBe(2);
|
|
expect(json?.shapeData).toBeNull();
|
|
const again = await PolyLineEntity.fromJson(json as JsonEntity<PolyLineJsonData>);
|
|
expect(again.numberOfSegments()).toBe(2);
|
|
});
|
|
|
|
it("꼭짓점 하나 · 빈 값 = 선분 없음", async () => {
|
|
const one = await PolyLineEntity.fromJson({ ...light, shapeData: { points: [{ x: 0, y: 0 }] } });
|
|
const none = await PolyLineEntity.fromJson({ ...light, shapeData: null });
|
|
expect([one.numberOfSegments(), none.numberOfSegments()]).toEqual([0, 0]);
|
|
});
|
|
});
|