From 7141c3ab87ab5c02e06272be3b01c857a500f9f8 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 24 Jan 2025 10:54:30 +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=EC=8B=9C=20=EC=97=90=EB=9F=AC=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePolygon.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 1bc2dffa..e1f127a5 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -859,6 +859,7 @@ export const usePolygon = () => { line.endPoint = endPoint }) + // polygon line에서 각각 출발한다. polygonLines.forEach((line) => { /*line.set({ strokeWidth: 5, stroke: 'green' }) canvas.add(line) @@ -872,9 +873,11 @@ export const usePolygon = () => { const startLine = line const visitPoints = [startPoint] const visitLines = [startLine] + let notVisitedLines = [] let cnt = 0 while (!isSamePoint(currentPoint, arrivalPoint)) { + //현재 점으로 부터 갈 수 있는 다른 라인을 찾는다. let nextLines = allLines.filter( (line2) => (isSamePoint(line2.startPoint, currentPoint) || isSamePoint(line2.endPoint, currentPoint)) && @@ -892,8 +895,13 @@ export const usePolygon = () => { ) } - if (!nextLines) { - break + if (nextLines.length === 0) { + //아직 안갔던 line중 0번째를 선택한다. + if (notVisitedLines.length === 0) { + break + } else { + // nextLines = [...notVisitedLines.shift().line] + } } let comparisonPoints = [] @@ -919,6 +927,14 @@ export const usePolygon = () => { nextLines.forEach((nextLine) => { if (isSamePoint(nextLine.startPoint, minDistancePoint) || isSamePoint(nextLine.endPoint, minDistancePoint)) { visitLines.push(nextLine) + } else { + notVisitedLines.push({ + line: nextLine, + endPoint: nextLine.endPoint, + startPoint: nextLine.startPoint, + currentPoint: { ...currentPoint }, + roofPoints: [...roofPoints], + }) } })