From 59539e4a6041c0f31015f90a169216ce48b5c130 Mon Sep 17 00:00:00 2001 From: Jaeyoung Lee Date: Tue, 15 Jul 2025 15:01:03 +0900 Subject: [PATCH] =?UTF-8?q?[1186,=201178]=20=EB=8F=99=EC=9D=B4=EB=8F=99,?= =?UTF-8?q?=20=ED=98=95=EC=9D=B4=EB=8F=99=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useMovementSetting.js | 1 + src/util/qpolygon-utils.js | 69 ++++++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/hooks/roofcover/useMovementSetting.js b/src/hooks/roofcover/useMovementSetting.js index 19e44d2e..9f29f880 100644 --- a/src/hooks/roofcover/useMovementSetting.js +++ b/src/hooks/roofcover/useMovementSetting.js @@ -135,6 +135,7 @@ export function useMovementSetting(id) { const outerLines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') outerLines.forEach((line) => line.set({ visible: true })) canvas.renderAll() + initEvent() } }, []) diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index bf685ad8..3f71712c 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -319,7 +319,7 @@ const isValidPoints = (points) => { const point1 = points[i] const point2 = points[(i + 1) % points.length] const point3 = points[(i + 2) % points.length] - + // x값이 같은 연속된 3개 점 확인 if (point1.x === point2.x && point2.x === point3.x) { return false @@ -2768,6 +2768,70 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => { /** 4각*/ if (prevLineRidge === nextLineRidge) { polygonPoints.push({ x: ridgeLine.x1, y: ridgeLine.y1 }, { x: ridgeLine.x2, y: ridgeLine.y2 }) + /** 포인트가 직각 사각형인지 확인하여 아닌경우 직각인 다각형 포인트로 변경한다.*/ + const checkPoints = getSortedPoint(polygonPoints, baseHipLines) + let hasDiagonal = false + if (checkPoints < 4) { + hasDiagonal = true + } else { + checkPoints.forEach((point, index) => { + const nextPoint = checkPoints[(index + 1) % checkPoints.length] + if (point.x !== nextPoint.x && point.y !== nextPoint.y) { + hasDiagonal = true + } + }) + } + if (hasDiagonal) { + const vectorX = Math.sign(currentRoof.x1 - ridgeLine.x1) + const vectorY = Math.sign(currentRoof.y1 - ridgeLine.y1) + const ridgeMinX = Math.min(ridgeLine.x1, ridgeLine.x2) + const ridgeMaxX = Math.max(ridgeLine.x1, ridgeLine.x2) + const ridgeMinY = Math.min(ridgeLine.y1, ridgeLine.y2) + const ridgeMaxY = Math.max(ridgeLine.y1, ridgeLine.y2) + if ( + (!isPointOnLineNew(prevRoof, { x: ridgeLine.x1, y: ridgeLine.y1 }) && + !isPointOnLineNew(nextRoof, { x: ridgeLine.x1, y: ridgeLine.y1 })) || + (!isPointOnLineNew(prevRoof, { x: ridgeLine.x2, y: ridgeLine.y2 }) && !isPointOnLineNew(nextRoof, { x: ridgeLine.x2, y: ridgeLine.y2 })) + ) { + roof.lines + .filter((line) => line !== currentRoof && line !== prevRoof && line !== nextRoof) + .filter((line) => + ridgeLine.y1 === ridgeLine.y2 + ? vectorY === Math.sign(line.y1 - ridgeLine.y1) && + ridgeMinX <= line.x1 && + line.x1 <= ridgeMaxX && + ridgeMinX <= line.x2 && + line.x2 <= ridgeMaxX + : vectorX === Math.sign(line.x1 - ridgeLine.x1) && + ridgeMinY <= line.y1 && + line.y1 <= ridgeMaxY && + ridgeMinY <= line.y2 && + line.y2 <= ridgeMaxY, + ) + .forEach((line) => { + if (ridgeLine.y1 === ridgeLine.y2) { + if (vectorY === Math.sign(line.y1 - ridgeLine.y1)) { + polygonPoints.push({ x: line.x1, y: line.y1 }) + } + if (vectorY === Math.sign(line.y2 - ridgeLine.y1)) { + polygonPoints.push({ x: line.x2, y: line.y2 }) + } + } else { + if (vectorX === Math.sign(line.x1 - ridgeLine.x1)) { + polygonPoints.push({ x: line.x1, y: line.y1 }) + } + if (vectorX === Math.sign(line.x2 - ridgeLine.x1)) { + polygonPoints.push({ x: line.x2, y: line.y2 }) + } + } + }) + } + if ( + !isPointOnLineNew(prevRoof, { x: ridgeLine.x2, y: ridgeLine.y2 }) && + !isPointOnLineNew(nextRoof, { x: ridgeLine.x2, y: ridgeLine.y2 }) + ) { + } + } } else { /** 6각이상*/ let isOverLap = @@ -3427,6 +3491,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => { const checkRidgePoint = checkRidgePoints.find((point) => point.checkPoint) + if (!checkRidgePoint) return /** 마루에서 현재라인으로 향하는 외벽선까지의 포인트를 확인 하여 처리*/ let checkEdge if (currentVectorX === 0) { @@ -4123,7 +4188,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => { isOppNext, ) ) { - const size = Big(isOppNext.x).minus(midx).abs().pow(2).plus(Big(isOppNext.y).minus(midY).abs().pow(2)).sqrt().toNumber() + const size = Big(isOppNext.x).minus(midX).abs().pow(2).plus(Big(isOppNext.y).minus(midY).abs().pow(2)).sqrt().toNumber() ridgePoints.push({ x: isOppNext.x, y: isOppNext.y, size }) } }