diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 82ba40c1..081eedc2 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -431,7 +431,16 @@ export default function Roof2(props) { { x: 450, y: 850 }, ] - const polygon = new QPolygon(type2, { + const test1 = [ + { x: 381, y: 178 }, + { x: 381, y: 659.3 }, + { x: 773.3, y: 659.3 }, + { x: 773.3, y: 497.9 }, + { x: 1457, y: 497.9 }, + { x: 1457, y: 178 }, + ] + + const polygon = new QPolygon(test1, { fill: 'transparent', stroke: 'green', strokeWidth: 1, diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index 69102461..679562ec 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -1334,10 +1334,9 @@ const drawRidge = (roof, canvas) => { let xEqualInnerLines = anotherRoof.filter((roof) => roof.x1 === roof.x2 && isInnerLine(prevRoof, currentRoof, nextRoof, roof)), //x가 같은 내부선 yEqualInnerLines = anotherRoof.filter((roof) => roof.y1 === roof.y2 && isInnerLine(prevRoof, currentRoof, nextRoof, roof)) //y가 같은 내부선 - console.log('xEqualInnerLines', xEqualInnerLines, 'yEqualInnerLines', yEqualInnerLines) let ridgeBaseLength = Math.round(currentRoof.attributes.planeSize / 2), // 지붕의 기반 길이 ridgeMaxLength = Math.min(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize), // 지붕의 최대 길이. 이전, 다음 벽 중 짧은 길이 - ridgeAcrossLength = Math.abs(ridgeMaxLength - currentRoof.attributes.planeSize) // 맞은편 벽까지의 길이 - 지붕의 기반 길이 + ridgeAcrossLength = Math.abs(Math.max(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize) - currentRoof.attributes.planeSize) // 맞은편 벽까지의 길이 - 지붕의 기반 길이 let acrossRoof = anotherRoof .filter((roof) => { @@ -1348,8 +1347,6 @@ const drawRidge = (roof, canvas) => { } }) .reduce((prev, current) => { - console.log('prev', prev, 'current', current) - console.log('currentRoof', currentRoof) let hasBetweenRoof = false if (current.x1 === current.x2) { hasBetweenRoof = roofLines @@ -1379,19 +1376,15 @@ const drawRidge = (roof, canvas) => { currentX2 = Math.abs(currentRoof.x1 - currentX2) < Math.abs(currentRoof.x1 - line.x1) ? currentX2 : line.x1 }) } - console.log('line :', line) const isX1Between = (line.x1 > currentRoof.x1 && line.x1 < currentX2) || (line.x1 > currentX2 && line.x1 < currentRoof.x1) const isX2Between = (line.x2 > currentRoof.x1 && line.x2 < currentX2) || (line.x2 > currentX2 && line.x2 < currentRoof.x1) const isY1Between = (line.y1 > currentRoof.y1 && line.y1 < current.y1) || (line.y1 > currentRoof.y1 && line.y1 < current.y1) const isY2Between = (line.y2 > currentRoof.y1 && line.y2 < current.y1) || (line.y2 > currentRoof.y1 && line.y2 < current.y1) - console.log('isX1Between', isX1Between, 'isX2Between', isX2Between, 'isY1Between', isY1Between, 'isY2Between', isY2Between) return isX1Between && isX2Between && isY1Between && isY2Between }) } - console.log('hasBetweenRoof', hasBetweenRoof) - if (prev !== undefined) { if (currentRoof.x1 === currentRoof.x2) { return Math.abs(currentRoof.y1 - prev.y1) > Math.abs(currentRoof.y1 - current.y1) ? prev : current @@ -1429,6 +1422,7 @@ const drawRidge = (roof, canvas) => { ridgeBaseLength = ridgeBaseLength / 10 ridgeMaxLength = ridgeMaxLength / 10 ridgeAcrossLength = ridgeAcrossLength / 10 + if (ridgeBaseLength > 0 && ridgeMaxLength > 0 && ridgeAcrossLength > 0) { let ridgeLength = Math.min(ridgeMaxLength, ridgeAcrossLength) if (currentRoof.x1 === currentRoof.x2) {