From 414d6fa0c5ca5884684e44ad378a7240f83d6448 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Thu, 20 Mar 2025 17:59:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=98=EB=A7=88=20=EC=9A=A9=EB=A7=88?= =?UTF-8?q?=EB=A3=A8=20=EB=B0=A9=ED=96=A5=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/surface/useSurfaceShapeBatch.js | 75 ++++++++++++++--------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/src/hooks/surface/useSurfaceShapeBatch.js b/src/hooks/surface/useSurfaceShapeBatch.js index 4658e75a..6b239b03 100644 --- a/src/hooks/surface/useSurfaceShapeBatch.js +++ b/src/hooks/surface/useSurfaceShapeBatch.js @@ -1100,20 +1100,22 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) { } }) - const maxLine = polygon.lines - .filter((line) => line[coord1] === line[coord2]) - .sort( - (a, b) => - (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] - - (polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1], - )[0] + //직선 찾는 로직 + const maxLine = polygon.lines.filter((line) => line[coord1] === line[coord2]) + + if (maxLine.length > 0) { + const maxLineSorted = maxLine.reduce((a, b) => { + return (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] > + (polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1] + ? b + : a + }) - if (maxLine) { if ( - (polygon.direction === 'south' && maxLine.direction === 'left') || - (polygon.direction === 'north' && maxLine.direction === 'right') || - (polygon.direction === 'east' && maxLine.direction === 'bottom') || - (polygon.direction === 'west' && maxLine.direction === 'top') + (polygon.direction === 'south' && maxLineSorted.direction === 'left') || + (polygon.direction === 'north' && maxLineSorted.direction === 'right') || + (polygon.direction === 'east' && maxLineSorted.direction === 'bottom') || + (polygon.direction === 'west' && maxLineSorted.direction === 'top') ) { polygon.lines.forEach((line) => { if (line.attributes.type === LINE_TYPE.WALLLINE.EAVES) { @@ -1123,30 +1125,43 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) { } }) } + + if (maxLine.length === 1) { + const maxLineCoord = polygon.lines.reduce((a, b) => { + return (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] > + (polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1] + ? b + : a + }) + + const isRealEavesLine = polygon.lines.find((line) => line.attributes.type === LINE_TYPE.WALLLINE.EAVES) + if (isRealEavesLine) { + if (polygon.direction === 'south' || polygon.direction === 'north') { + const targetCoord = + polygon.direction === 'south' ? Math.max(maxLineCoord.y1, maxLineCoord.y2) : Math.min(maxLineCoord.y1, maxLineCoord.y2) + const realLineCoord = + polygon.direction === 'south' ? Math.max(isRealEavesLine.y1, isRealEavesLine.y2) : Math.min(isRealEavesLine.y1, isRealEavesLine.y2) + + if (targetCoord !== realLineCoord) { + isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE + } + } else if (polygon.direction === 'east' || polygon.direction === 'west') { + const targetCoord = polygon.direction === 'east' ? Math.max(maxLineCoord.x1, maxLineCoord.x2) : Math.min(maxLineCoord.x1, maxLineCoord.x2) + const realLineCoord = + polygon.direction === 'east' ? Math.max(isRealEavesLine.x1, isRealEavesLine.x2) : Math.min(isRealEavesLine.x1, isRealEavesLine.x2) + + if (targetCoord !== realLineCoord) { + isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE + } + } + } + } } /** * 진짜 처마 라인인지 확인하는 로직 -> 특정 모양에 따라 처마가 없는 경우가 있는데 위에 로직으로는 * 용마루도 처마로 만들어서 재보정 */ - const maxLineCoord = polygon.lines.sort( - (a, b) => - (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] - - (polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1], - )[0] - - const isRealEavesLine = polygon.lines.find((line) => line.attributes.type === LINE_TYPE.WALLLINE.EAVES) - if (isRealEavesLine) { - if (polygon.direction === 'south' || polygon.direction === 'north') { - if (maxLineCoord.y1 !== isRealEavesLine.y1) { - isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE - } - } else if (polygon.direction === 'east' || polygon.direction === 'west') { - if (maxLineCoord.x1 !== isRealEavesLine.x1) { - isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE - } - } - } } const updateFlippedPoints = (polygon) => {