From 44b2f66a8f66ca5333229c12eacf517236c8c92c Mon Sep 17 00:00:00 2001 From: yscha Date: Sat, 13 Dec 2025 03:14:21 +0900 Subject: [PATCH] =?UTF-8?q?wallines=20index=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/skeleton-utils.js | 88 ++++---------------------------------- 1 file changed, 8 insertions(+), 80 deletions(-) diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index ab6a9e7a..12b42919 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -766,15 +766,19 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { }); }; - const sortedWallLines = sortCurrentRoofLines(wall.lines); + // const sortedWallLines = sortCurrentRoofLines(wall.lines); // roofLines의 방향에 맞춰 currentRoofLines 조정 후 정렬 const alignedCurrentRoofLines = alignLineDirection(currentRoofLines, roofLines); const sortedCurrentRoofLines = sortCurrentRoofLines(alignedCurrentRoofLines); - const sortedRoofLines = sortCurrentRoofLines(roofLines); + // const sortedRoofLines = sortCurrentRoofLines(roofLines); const sortedWallBaseLines = sortCurrentRoofLines(wall.baseLines); - const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines); + // const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines); const sortRoofLines = sortBaseLinesByWallLines(roofLines, wallLines); + // 원본 wallLines를 복사하여 사용 + const sortedWallLines = [...wallLines]; + const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, sortedWallLines); + const sortedRoofLines = sortBaseLinesByWallLines(roofLines, sortedWallLines); //wall.lines 는 기본 벽 라인 //wall.baseLine은 움직인라인 @@ -1487,12 +1491,6 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { }); } - // const polygon = canvas.getObjects().find(obj => obj.type === 'QPolygon' && obj.id === roofId); - // if (polygon) { - // removeMatchingLines(polygon, wallLine); - // canvas.requestRenderAll(); - // } - if (findPoints.length > 0) { // 모든 점에 대해 라인 업데이트를 누적 return findPoints.reduce((innerLines, point) => { @@ -1500,42 +1498,6 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { }, [...innerLines]); } - - - const polygon = canvas.getObjects().find(obj => obj.type === 'QPolygon' && obj.id === roofId); - - if (polygon && polygon.lines) { - // Find all lines that match your condition (e.g., stroke color) - const linesToRemoves = polygon.lines.filter(line => - line.stroke === '#1083E3' // Your condition here - ); - - // Remove each matching line - linesToRemoves.forEach(lineToRemove => { - const index = polygon.lines.indexOf(lineToRemove); - if (index > -1) { - polygon.lines.splice(index, 1); - } - - // Remove from canvas if needed - if (lineToRemove.canvas) { - lineToRemove.canvas.remove(lineToRemove); - } - }); - - // Update polygon points - const newPoints = polygon.lines.map(line => { - return { x: line.x1, y: line.y1 }; - }); - - polygon.set({ points: newPoints }); - polygon.initLines(); - canvas.requestRenderAll(); - } - -// Usage - - return innerLines; } @@ -3511,38 +3473,4 @@ export const sortBaseLinesByWallLines = (baseLines, wallLines) => { } return sortedBaseLines; -}; - -function removeMatchingLines(polygon, roofLine) { - if (!polygon.lines) return; - - // Find lines that match the roofLine coordinates - const linesToRemove = polygon.lines.filter(line => { - return (line.x1 === roofLine.x1 && line.y1 === roofLine.y1 && - line.x2 === roofLine.x2 && line.y2 === roofLine.y2) || - (line.x1 === roofLine.x2 && line.y1 === roofLine.y2 && - line.x2 === roofLine.x1 && line.y2 === roofLine.y1); - }); - - // Remove the matching lines - linesToRemove.forEach(lineToRemove => { - const index = polygon.lines.indexOf(lineToRemove); - if (index > -1) { - polygon.lines.splice(index, 1); - } - if (lineToRemove.canvas) { - lineToRemove.canvas.remove(lineToRemove); - } - }); - - // Update polygon points - if (linesToRemove.length > 0) { - const newPoints = polygon.lines.map(line => { - return { x: line.x1, y: line.y1 }; - }); - - polygon.set({ points: newPoints }); - polygon.initLines(); - - } -} +}; \ No newline at end of file