마루 지붕 마루 부분 오류에 대해 수정
This commit is contained in:
parent
0fc08e94d0
commit
211a365bf8
@ -1782,8 +1782,13 @@ export function useMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wall.lines.forEach((line, index) => {
|
wall.lines.forEach((line, index) => {
|
||||||
|
const lineLength = Math.sqrt(
|
||||||
|
Math.pow(Math.round(Math.abs(line.x1 - line.x2) * 10), 2) + Math.pow(Math.round(Math.abs(line.y1 - line.y2) * 10), 2),
|
||||||
|
)
|
||||||
line.attributes.roofId = roof.id
|
line.attributes.roofId = roof.id
|
||||||
line.attributes.currentRoof = roof.lines[index].id
|
line.attributes.currentRoof = roof.lines[index].id
|
||||||
|
line.attributes.planeSize = lineLength
|
||||||
|
line.attributes.actualSize = lineLength
|
||||||
})
|
})
|
||||||
|
|
||||||
setRoof(roof)
|
setRoof(roof)
|
||||||
|
|||||||
@ -1,13 +1,6 @@
|
|||||||
import { fabric } from 'fabric'
|
import { fabric } from 'fabric'
|
||||||
import { QLine } from '@/components/fabric/QLine'
|
import { QLine } from '@/components/fabric/QLine'
|
||||||
import {
|
import { calculateIntersection, distanceBetweenPoints, findClosestPoint, getDegreeByChon, getDirectionByPoint } from '@/util/canvas-util'
|
||||||
calculateIntersection,
|
|
||||||
distanceBetweenPoints,
|
|
||||||
findClosestPoint,
|
|
||||||
getDegreeByChon,
|
|
||||||
getDirectionByPoint,
|
|
||||||
isPointOnLine,
|
|
||||||
} from '@/util/canvas-util'
|
|
||||||
|
|
||||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||||
import * as turf from '@turf/turf'
|
import * as turf from '@turf/turf'
|
||||||
@ -1307,14 +1300,19 @@ const drawRidge = (roof, canvas) => {
|
|||||||
prevRoof = index === 0 ? wallLines[wallLines.length - 1] : wallLines[index - 1]
|
prevRoof = index === 0 ? wallLines[wallLines.length - 1] : wallLines[index - 1]
|
||||||
nextRoof = index === wallLines.length - 1 ? wallLines[0] : index === wallLines.length ? wallLines[1] : wallLines[index + 1]
|
nextRoof = index === wallLines.length - 1 ? wallLines[0] : index === wallLines.length ? wallLines[1] : wallLines[index + 1]
|
||||||
|
|
||||||
if (prevRoof.direction !== nextRoof.direction && currentWall.length <= currentRoof.length) {
|
const angle1 = calculateAngle(prevRoof.startPoint, prevRoof.endPoint)
|
||||||
ridgeRoof.push({ index: index, roof: currentRoof, length: currentRoof.length })
|
const angle2 = calculateAngle(nextRoof.startPoint, nextRoof.endPoint)
|
||||||
|
|
||||||
|
if (Math.abs(angle1 - angle2) === 180 && currentWall.attributes.planeSize <= currentRoof.attributes.planeSize) {
|
||||||
|
ridgeRoof.push({ index: index, roof: currentRoof, length: currentRoof.attributes.planeSize })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 지붕의 길이가 짧은 순으로 정렬
|
// 지붕의 길이가 짧은 순으로 정렬
|
||||||
ridgeRoof.sort((a, b) => a.length - b.length)
|
ridgeRoof.sort((a, b) => a.length - b.length)
|
||||||
|
|
||||||
|
console.log('ridgeRoof', ridgeRoof)
|
||||||
|
|
||||||
ridgeRoof.forEach((item) => {
|
ridgeRoof.forEach((item) => {
|
||||||
if (getMaxRidge(roofLines.length) > roof.ridges.length) {
|
if (getMaxRidge(roofLines.length) > roof.ridges.length) {
|
||||||
let index = item.index,
|
let index = item.index,
|
||||||
@ -1336,28 +1334,26 @@ 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가 같은 내부선
|
||||||
|
|
||||||
let ridgeBaseLength = Math.round((currentRoof.length / 2) * 10) / 10, // 지붕의 기반 길이
|
console.log('xEqualInnerLines', xEqualInnerLines, 'yEqualInnerLines', yEqualInnerLines)
|
||||||
ridgeMaxLength = Math.min(prevRoof.length, nextRoof.length), // 지붕의 최대 길이. 이전, 다음 벽 중 짧은 길이
|
let ridgeBaseLength = Math.round(currentRoof.attributes.planeSize / 2), // 지붕의 기반 길이
|
||||||
ridgeAcrossLength = Math.round((ridgeMaxLength - currentRoof.length) * 10) / 10 // 맞은편 벽까지의 길이 - 지붕의 기반 길이
|
ridgeMaxLength = Math.min(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize), // 지붕의 최대 길이. 이전, 다음 벽 중 짧은 길이
|
||||||
|
ridgeAcrossLength = Math.abs(ridgeMaxLength - currentRoof.attributes.planeSize) // 맞은편 벽까지의 길이 - 지붕의 기반 길이
|
||||||
|
|
||||||
let acrossRoof = anotherRoof
|
let acrossRoof = anotherRoof
|
||||||
.filter((roof) => {
|
.filter((roof) => {
|
||||||
if (roof.x1 === roof.x2) {
|
const angle1 = calculateAngle(currentRoof.startPoint, currentRoof.endPoint)
|
||||||
if ((nextRoof.direction === 'right' && roof.x1 > currentRoof.x1) || (nextRoof.direction === 'left' && roof.x1 < currentRoof.x1)) {
|
const angle2 = calculateAngle(roof.startPoint, roof.endPoint)
|
||||||
return roof
|
if (Math.abs(angle1 - angle2) === 180) {
|
||||||
}
|
return roof
|
||||||
}
|
|
||||||
if (roof.y1 === roof.y2) {
|
|
||||||
if ((nextRoof.direction === 'top' && roof.y1 < currentRoof.y1) || (nextRoof.direction === 'bottom' && roof.y1 > currentRoof.y1)) {
|
|
||||||
return roof
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.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
|
||||||
.filter((roof) => roof !== current && roof !== currentRoof)
|
.filter((roof) => roof !== current)
|
||||||
.some((line) => {
|
.some((line) => {
|
||||||
let currentY2 = currentRoof.y2
|
let currentY2 = currentRoof.y2
|
||||||
if (yEqualInnerLines.length > 0) {
|
if (yEqualInnerLines.length > 0) {
|
||||||
@ -1369,12 +1365,13 @@ const drawRidge = (roof, canvas) => {
|
|||||||
const isY2Between = (line.y2 > currentRoof.y1 && line.y2 < currentY2) || (line.y2 > currentY2 && line.y2 < currentRoof.y1)
|
const isY2Between = (line.y2 > currentRoof.y1 && line.y2 < currentY2) || (line.y2 > currentY2 && line.y2 < currentRoof.y1)
|
||||||
const isX1Between = (line.x1 > currentRoof.x1 && line.x1 < current.x1) || (line.x1 > currentRoof.x1 && line.x1 < current.x1)
|
const isX1Between = (line.x1 > currentRoof.x1 && line.x1 < current.x1) || (line.x1 > currentRoof.x1 && line.x1 < current.x1)
|
||||||
const isX2Between = (line.x2 > currentRoof.x1 && line.x2 < current.x1) || (line.x2 > currentRoof.x1 && line.x2 < current.x1)
|
const isX2Between = (line.x2 > currentRoof.x1 && line.x2 < current.x1) || (line.x2 > currentRoof.x1 && line.x2 < current.x1)
|
||||||
|
|
||||||
return isY1Between && isY2Between && isX1Between && isX2Between
|
return isY1Between && isY2Between && isX1Between && isX2Between
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (current.y1 === current.y2) {
|
if (current.y1 === current.y2) {
|
||||||
hasBetweenRoof = wallLines
|
hasBetweenRoof = roofLines
|
||||||
.filter((roof) => roof !== current && roof !== currentRoof)
|
.filter((roof) => roof !== current)
|
||||||
.some((line) => {
|
.some((line) => {
|
||||||
let currentX2 = currentRoof.x2
|
let currentX2 = currentRoof.x2
|
||||||
if (xEqualInnerLines.length > 0) {
|
if (xEqualInnerLines.length > 0) {
|
||||||
@ -1382,15 +1379,19 @@ 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
|
||||||
@ -1412,20 +1413,22 @@ const drawRidge = (roof, canvas) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, undefined)
|
}, undefined)
|
||||||
|
|
||||||
if (acrossRoof !== undefined) {
|
if (acrossRoof !== undefined) {
|
||||||
if (currentRoof.x1 === currentRoof.x2) {
|
if (currentRoof.x1 === currentRoof.x2) {
|
||||||
if (ridgeAcrossLength < Math.abs(currentRoof.x1 - acrossRoof.x1)) {
|
if (ridgeAcrossLength < Math.abs(currentRoof.x1 - acrossRoof.x1)) {
|
||||||
ridgeAcrossLength = Math.round((Math.round(Math.abs(currentRoof.x1 - acrossRoof.x1) * 10) / 10 - currentRoof.length) * 10) / 10
|
ridgeAcrossLength = Math.round(Math.round(Math.abs(currentRoof.x1 - acrossRoof.x1) * 10) - currentRoof.attributes.planeSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentRoof.y1 === currentRoof.y2) {
|
if (currentRoof.y1 === currentRoof.y2) {
|
||||||
if (ridgeAcrossLength < Math.abs(currentRoof.y1 - acrossRoof.y1)) {
|
if (ridgeAcrossLength < Math.abs(currentRoof.y1 - acrossRoof.y1)) {
|
||||||
ridgeAcrossLength = Math.round((Math.round(Math.abs(currentRoof.y1 - acrossRoof.y1) * 10) / 10 - currentRoof.length) * 10) / 10
|
ridgeAcrossLength = Math.round(Math.round(Math.abs(currentRoof.y1 - acrossRoof.y1) * 10) - currentRoof.attributes.planeSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ridgeBaseLength = ridgeBaseLength / 10
|
||||||
|
ridgeMaxLength = ridgeMaxLength / 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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user