지붕면 할당 로직 수정

This commit is contained in:
hyojun.choi 2026-06-10 16:50:46 +09:00
parent c0539f49ec
commit 83107a801d

View File

@ -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)