diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index 0c0d8dcb..ab6a9e7a 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -802,7 +802,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const currentRoofLine = currentRoofLines[index]; const moveLine = sortedBaseLines[index] const wallBaseLine = sortedBaseLines[index] - console.log("wallBaseLine", wallBaseLine); + //console.log("wallBaseLine", wallBaseLine); //roofline 외곽선 설정 @@ -1228,6 +1228,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink') } //getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2, y: newPointY }, 'orange') + } if(isStartEnd.end){ @@ -1248,6 +1249,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { getAddLine({ x: pLineX, y: pLineY }, { x: pLineX, y: newPointY }, 'green') getAddLine({ x: pLineX, y: newPointY }, { x: sPoint.x, y: sPoint.y }, 'pink') } + + //getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange') } @@ -1484,6 +1487,12 @@ 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) => { @@ -1491,6 +1500,42 @@ 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; } @@ -1532,6 +1577,7 @@ function processEavesEdge(roofId, canvas, skeleton, edgeResult, skeletonLines) { if(!outerLine) { outerLine = findMatchingLine(edgeResult.Polygon, roof, roof.points); console.log('Has matching line:', outerLine); + //if(outerLine === null) return } let pitch = outerLine?.attributes?.pitch??0 @@ -3465,4 +3511,38 @@ export const sortBaseLinesByWallLines = (baseLines, wallLines) => { } return sortedBaseLines; -}; \ No newline at end of file +}; + +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(); + + } +}