From ac40a4a64c2f3191f7978b62063966a03400641f Mon Sep 17 00:00:00 2001 From: ysCha Date: Mon, 22 Dec 2025 17:23:49 +0900 Subject: [PATCH] =?UTF-8?q?=ED=95=A0=EB=8B=B9=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useRoofAllocationSetting.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index f93e230d..3ebaa56c 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -473,7 +473,20 @@ export function useRoofAllocationSetting(id) { // Filter out any eaveHelpLines that are already in lines to avoid duplicates const existingEaveLineIds = new Set(roofBase.lines.map((line) => line.id)) const newEaveLines = roofEaveHelpLines.filter((line) => !existingEaveLineIds.has(line.id)) - roofBase.lines = [...newEaveLines] + // Filter out lines from roofBase.lines that share any points with newEaveLines + const linesToKeep = roofBase.lines.filter(roofLine => { + return !newEaveLines.some(eaveLine => { + // Check if any endpoint of roofLine matches any endpoint of eaveLine + return ( + // Check if any endpoint of roofLine matches any endpoint of eaveLine + (Math.abs(roofLine.x1 - eaveLine.x1) < 0.1 && Math.abs(roofLine.y1 - eaveLine.y1) < 0.1) || // p1 matches p1 + (Math.abs(roofLine.x2 - eaveLine.x2) < 0.1 && Math.abs(roofLine.y2 - eaveLine.y2) < 0.1) // p2 matches p2 + ); + }); + }); + +// Combine remaining lines with newEaveLines + roofBase.lines = [...linesToKeep, ...newEaveLines]; } else { roofBase.lines = [...roofEaveHelpLines] }