마루 지붕 오류 수정

This commit is contained in:
Jaeyoung Lee 2024-11-08 14:59:43 +09:00
parent a2ef62ca15
commit b4504c5b78
2 changed files with 12 additions and 9 deletions

View File

@ -431,7 +431,16 @@ export default function Roof2(props) {
{ x: 450, y: 850 }, { 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', fill: 'transparent',
stroke: 'green', stroke: 'green',
strokeWidth: 1, strokeWidth: 1,

View File

@ -1334,10 +1334,9 @@ const drawRidge = (roof, canvas) => {
let xEqualInnerLines = anotherRoof.filter((roof) => roof.x1 === roof.x2 && isInnerLine(prevRoof, currentRoof, nextRoof, roof)), //x가 같은 내부선 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가 같은 내부선 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), // 지붕의 기반 길이 let ridgeBaseLength = Math.round(currentRoof.attributes.planeSize / 2), // 지붕의 기반 길이
ridgeMaxLength = Math.min(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize), // 지붕의 최대 길이. 이전, 다음 벽 중 짧은 길이 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 let acrossRoof = anotherRoof
.filter((roof) => { .filter((roof) => {
@ -1348,8 +1347,6 @@ const drawRidge = (roof, canvas) => {
} }
}) })
.reduce((prev, current) => { .reduce((prev, current) => {
console.log('prev', prev, 'current', current)
console.log('currentRoof', currentRoof)
let hasBetweenRoof = false let hasBetweenRoof = false
if (current.x1 === current.x2) { if (current.x1 === current.x2) {
hasBetweenRoof = roofLines 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 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 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 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 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) 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 return isX1Between && isX2Between && isY1Between && isY2Between
}) })
} }
console.log('hasBetweenRoof', hasBetweenRoof)
if (prev !== undefined) { if (prev !== undefined) {
if (currentRoof.x1 === currentRoof.x2) { if (currentRoof.x1 === currentRoof.x2) {
return Math.abs(currentRoof.y1 - prev.y1) > Math.abs(currentRoof.y1 - current.y1) ? prev : current 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 ridgeBaseLength = ridgeBaseLength / 10
ridgeMaxLength = ridgeMaxLength / 10 ridgeMaxLength = ridgeMaxLength / 10
ridgeAcrossLength = ridgeAcrossLength / 10 ridgeAcrossLength = ridgeAcrossLength / 10
if (ridgeBaseLength > 0 && ridgeMaxLength > 0 && ridgeAcrossLength > 0) { if (ridgeBaseLength > 0 && ridgeMaxLength > 0 && ridgeAcrossLength > 0) {
let ridgeLength = Math.min(ridgeMaxLength, ridgeAcrossLength) let ridgeLength = Math.min(ridgeMaxLength, ridgeAcrossLength)
if (currentRoof.x1 === currentRoof.x2) { if (currentRoof.x1 === currentRoof.x2) {