From 85506c5a58afb1ebfbd26f4fc411e0f5fd3f0657 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 7 Aug 2024 17:46:59 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=B4=ED=95=9C=EB=A3=A8=ED=94=84=20?= =?UTF-8?q?=EB=B0=A9=EC=96=B4=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/qpolygon-utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index 74ab4dce..639455c9 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -1008,6 +1008,7 @@ export const splitPolygonWithLines = (polygon) => { routes.push(startLine.startPoint) routes.push(startLine.endPoint) //hip끼리 만나는 경우는 아무것도 안해도됨 + let count = 0 if (!isSamePoint(startLine.endPoint, arrivalPoint)) { // polygon line까지 추가 const allLinesCopy = [...allLines, ...polygon.lines] @@ -1015,7 +1016,8 @@ export const splitPolygonWithLines = (polygon) => { let currentPoint = startLine.endPoint let currentLine = startLine - while (!isSamePoint(currentPoint, arrivalPoint)) { + while (!isSamePoint(currentPoint, arrivalPoint) && count <= polygon.points.length) { + count++ // startHip에서 만나는 출발선 두개. 두개의 선을 출발하여 arrivalPoint에 도착할 때 까지 count를 세고, 더 낮은 count를 가진 길을 선택한다. let connectedLines = allLinesCopy.filter((line) => isSamePoint(line.startPoint, currentPoint) || isSamePoint(line.endPoint, currentPoint)) @@ -1052,8 +1054,10 @@ export const splitPolygonWithLines = (polygon) => { } } - routes.push(endLine.startPoint) - roofs.push(routes) + if (count <= polygon.points.length - 1) { + routes.push(endLine.startPoint) + roofs.push(routes) + } }) // 중복 제거