From b44066da61bca2f0190bae4269409083a3322f63 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Fri, 30 Oct 2026 14:59:19 +0900 Subject: [PATCH] =?UTF-8?q?fix(D=20=EC=98=88=EC=A0=95=EB=85=B8=EC=84=A0):?= =?UTF-8?q?=20=ED=86=A0=EB=A7=89=20=EC=A7=80=EC=9B=80=EC=9D=B4=20=EB=85=B8?= =?UTF-8?q?=EB=93=9C=20=EA=B8=B0=EB=A1=9D(594-1=20nodes)=EB=8F=84=20?= =?UTF-8?q?=EA=B0=99=EC=9D=B4=20=EC=9E=90=EB=A6=84=20=E2=80=94=20=EB=92=A4?= =?UTF-8?q?=EC=AA=BD=20=EC=B2=AB=20=EA=B8=B0=EB=A1=9D=20=3D=20=EC=97=86?= =?UTF-8?q?=EC=9D=8C=20(PLAN=20598-1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- D03_PlanAnalysis/logic/D03_PlanAnalysis_Select.ts | 14 ++++++-------- resources/tester/test_598_1_plan_select_layers.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/D03_PlanAnalysis/logic/D03_PlanAnalysis_Select.ts b/D03_PlanAnalysis/logic/D03_PlanAnalysis_Select.ts index bea304984..ba25df693 100644 --- a/D03_PlanAnalysis/logic/D03_PlanAnalysis_Select.ts +++ b/D03_PlanAnalysis/logic/D03_PlanAnalysis_Select.ts @@ -134,15 +134,13 @@ function nextPieceId(pieces: ReadonlyArray): string { return `p${Math.max(0, ...used) + 1}`; } -/** 꼭짓점 [a, b) 만 남긴 선 — 꼭짓점과 같은 길이 덧 칸(노드 기록 594-1)도 같이 자름 · 첫 기록 = 없음. */ +/** 꼭짓점 [a, b) 만 남긴 선 — 노드 기록(594-1)도 같이 자름 · 뒤쪽 첫 기록 = 없음(앞 노드가 사라짐). */ function cutVertices(entry: PlanLine, a: number, b: number): PlanLine { - const out: PlanLine & { nodes?: unknown[] } = { ...entry, vertices: entry.vertices.slice(a, b) }; - const nodes = (entry as { nodes?: unknown }).nodes; - if (Array.isArray(nodes) && nodes.length === entry.vertices.length) { - out.nodes = nodes.slice(a, b); - if (a > 0 && out.nodes.length) out.nodes[0] = null; - } - return out; + const vertices = entry.vertices.slice(a, b); + if (!entry.nodes) return { ...entry, vertices }; + const nodes = entry.nodes.slice(a, b); + if (a > 0 && nodes.length) nodes[0] = null; + return { ...entry, vertices, nodes }; } /** 토막 하나 지움 — 하나뿐 = 구역 지움 · 끝 토막 = 끝 점 뺌 · 가운데 = 구역 둘(뒤쪽 = 새 구역 · 갈래 아님) · diff --git a/resources/tester/test_598_1_plan_select_layers.py b/resources/tester/test_598_1_plan_select_layers.py index 3643d0aca..0ae23beea 100644 --- a/resources/tester/test_598_1_plan_select_layers.py +++ b/resources/tester/test_598_1_plan_select_layers.py @@ -52,6 +52,12 @@ writeFileSync(process.argv[2], JSON.stringify({ all: show(sel.removeAll(n)), nodes: sel.nodesAt(n, [200, 0]), moved: sel.movePointsAt([[200, 0], [5, 5]], [200, 0], [210, 5]), + nodes594: (() => { + const r = { kind: "length", length_m: 100, slope_pct: null }; + const withNodes = { ...n, lines: n.lines.map((l, i) => (i ? l : { ...l, nodes: [null, r, r, r] })) }; + const out = sel.removeSegment(withNodes, seg("main", 1)); + return out.lines.filter((l) => l.id !== "branch-1").map((l) => [l.id, l.nodes]); + })(), })); """ @@ -127,3 +133,8 @@ def test_끌어_고르기_전체_지점_노드(tmp_path: Path) -> None: assert got["all"] == {"lines": [], "pieces": []} assert got["nodes"] == [{"line": "main", "vertex": 2}] # 갈래 첫 점 뺌 assert got["moved"] == [[210, 5], [5, 5]] + rec = {"kind": "length", "length_m": 100, "slope_pct": None} + assert got["nodes594"] == [ + ["main", [None, rec]], + ["line-2", [None, rec]], + ] # 노드 기록 같이 · 뒤쪽 첫 = 없음