From 83107a801de30dac12d22c84831f60df5852546b Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 10 Jun 2026 16:50:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A7=80=EB=B6=95=EB=A9=B4=20=ED=95=A0?= =?UTF-8?q?=EB=8B=B9=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePolygon.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 729cd8ec..288caf88 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1266,6 +1266,13 @@ export const usePolygon = () => { polygonLine.attributes = { ...polygonLine.attributes, isStart: true } }) + // [지붕면 공유변 fix] 보조선(innerLines)도 isStart=true 로 표시해 외곽선과 동일한 distance 페널티(+1000)를 + // 받게 한다. 미설정 시 보조선(빗변)이 페널티 없이 항상 최단으로 선택돼, 면이 외곽 변(예: 직사각형 + // 왼쪽변)을 두고 빗변으로 우회 → 오각형이 생긴다. (isValidPoint 가 type=default 끝점을 막아 면 자체는 안 늘어남) + innerLines.forEach((line) => { + line.attributes = { ...line.attributes, isStart: true } + }) + let allLines = [...polygonLines, ...innerLines] // allLines를 전부 돌면서 교차점이 있는 경우 그 line을 잘라서 allLines에 추가 @@ -2047,7 +2054,11 @@ export const usePolygon = () => { // 현재 남아있는 line들로 그래프 생성 const graph = {} - for (const line of remainingLines.filter((line2) => line2 !== startLine)) { + // [지붕면 공유변 fix] graph 는 startLine 자신만 제외한 전체 allLines 로 구성한다. + // remainingLines(이미 사용된 startLine 이 제거됨)로 만들면, 두 면이 공유하는 외곽 변이 먼저 처리된 + // 면에서 소비되어 다음 면 graph 에서 사라지고 그 면이 빗변으로 우회한다. startLine 소비는 후보 + // 목록(remainingLines)에서만 하고, 경로 탐색용 graph 에는 항상 남겨 공유 변을 재사용하게 한다. + for (const line of allLines.filter((line2) => line2 !== startLine)) { const p1 = line.startPoint const p2 = line.endPoint const key1 = pointToKey(p1)