From 2b6f679f75ccd68e96c4d0c1b2b6f5e9534bdc4b Mon Sep 17 00:00:00 2001 From: Jaeyoung Lee Date: Mon, 7 Jul 2025 11:09:53 +0900 Subject: [PATCH] =?UTF-8?q?[1153]=EC=99=B8=EC=A4=84=20=EC=A7=80=EB=B6=95?= =?UTF-8?q?=EA=B3=BC=20=EB=A7=9E=EB=B0=B0=20=EC=A7=80=EB=B6=95=EC=9D=98=20?= =?UTF-8?q?=EC=A1=B0=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/qpolygon-utils.js | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index 231a511b..1f06feb3 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -2181,7 +2181,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => { const isAlreadyRidge = baseGableRidgeLines.find( (line) => (line.x1 === ridgePoint[0] && line.y1 === ridgePoint[1] && line.x2 === ridgePoint[2] && line.y2 === ridgePoint[3]) || - (line.x1 === ridgePoint[2] && line.y1 === ridgePoint[3] && line.x2 === ridgePoint[0] && line.y2 === ridgePoint[1]), + (line.x1 === ridgePoint[2] && line.y1 === ridgePoint[3] && line.x2 === ridgePoint[0] && line.y2 === ridgePoint[1]) || + segmentsOverlap(line, { x1: ridgePoint[0], y1: ridgePoint[1], x2: ridgePoint[2], y2: ridgePoint[3] }), ) if (baseRidgeCount < getMaxRidge(baseLines.length) && !isAlreadyRidge) { const ridgeLine = drawRidgeLine(ridgePoint, canvas, roof, textMode) @@ -2974,6 +2975,41 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => { } } } + } else { + if (ridgeLine) { + const ridgeEdge = { vertex1: { x: ridgeLine.x1, y: ridgeLine.y1 }, vertex2: { x: ridgeLine.x2, y: ridgeLine.y2 } } + const prevRoofEdge = { vertex1: { x: prevRoof.x1, y: prevRoof.y1 }, vertex2: { x: prevRoof.x2, y: prevRoof.y2 } } + const nextRoofEdge = { vertex1: { x: nextRoof.x1, y: nextRoof.y1 }, vertex2: { x: nextRoof.x2, y: nextRoof.y2 } } + const isPrevRoof = edgesIntersection(prevRoofEdge, ridgeEdge) + const isNextRoof = edgesIntersection(nextRoofEdge, ridgeEdge) + if (isPrevRoof && isPointOnLine(ridgeLine, isPrevRoof)) { + polygonPoints.push({ x: isPrevRoof.x, y: isPrevRoof.y }) + } else { + polygonPoints.push({ x: prevRoof.x1, y: prevRoof.y1 }) + } + if (isNextRoof && isPointOnLine(ridgeLine, isNextRoof)) { + polygonPoints.push({ x: isNextRoof.x, y: isNextRoof.y }) + } else { + polygonPoints.push({ x: nextRoof.x2, y: nextRoof.y2 }) + } + + roof.lines + .filter((line) => line !== currentRoof && line !== prevRoof && line !== nextRoof) + .forEach((line) => { + const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } } + const intersection = edgesIntersection(ridgeEdge, lineEdge) + if (intersection && isPointOnLine(ridgeLine, intersection)) { + const size1 = Math.sqrt(Math.pow(line.x1 - intersection.x, 2) + Math.pow(line.y1 - intersection.y, 2)) + const size2 = Math.sqrt(Math.pow(line.x2 - intersection.x, 2) + Math.pow(line.y2 - intersection.y, 2)) + if (size1 < size2) { + polygonPoints.push({ x: line.x2, y: line.y2 }) + } else { + polygonPoints.push({ x: line.x1, y: line.y1 }) + } + polygonPoints.push({ x: intersection.x, y: intersection.y }) + } + }) + } } /** 중복되는 포인트 제거 */ const uniquePoints = []