[1153]외줄 지붕과 맞배 지붕의 조합

This commit is contained in:
Jaeyoung Lee 2025-07-07 11:09:53 +09:00
parent 3ab5aec767
commit 2b6f679f75

View File

@ -2181,7 +2181,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const isAlreadyRidge = baseGableRidgeLines.find(
(line) =>
(line.x1 === ridgePoint[0] && line.y1 === ridgePoint[1] && line.x2 === ridgePoint[2] && line.y2 === ridgePoint[3]) ||
(line.x1 === ridgePoint[2] && line.y1 === ridgePoint[3] && line.x2 === ridgePoint[0] && line.y2 === ridgePoint[1]),
(line.x1 === ridgePoint[2] && line.y1 === ridgePoint[3] && line.x2 === ridgePoint[0] && line.y2 === ridgePoint[1]) ||
segmentsOverlap(line, { x1: ridgePoint[0], y1: ridgePoint[1], x2: ridgePoint[2], y2: ridgePoint[3] }),
)
if (baseRidgeCount < getMaxRidge(baseLines.length) && !isAlreadyRidge) {
const ridgeLine = drawRidgeLine(ridgePoint, canvas, roof, textMode)
@ -2974,6 +2975,41 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
}
}
}
} else {
if (ridgeLine) {
const ridgeEdge = { vertex1: { x: ridgeLine.x1, y: ridgeLine.y1 }, vertex2: { x: ridgeLine.x2, y: ridgeLine.y2 } }
const prevRoofEdge = { vertex1: { x: prevRoof.x1, y: prevRoof.y1 }, vertex2: { x: prevRoof.x2, y: prevRoof.y2 } }
const nextRoofEdge = { vertex1: { x: nextRoof.x1, y: nextRoof.y1 }, vertex2: { x: nextRoof.x2, y: nextRoof.y2 } }
const isPrevRoof = edgesIntersection(prevRoofEdge, ridgeEdge)
const isNextRoof = edgesIntersection(nextRoofEdge, ridgeEdge)
if (isPrevRoof && isPointOnLine(ridgeLine, isPrevRoof)) {
polygonPoints.push({ x: isPrevRoof.x, y: isPrevRoof.y })
} else {
polygonPoints.push({ x: prevRoof.x1, y: prevRoof.y1 })
}
if (isNextRoof && isPointOnLine(ridgeLine, isNextRoof)) {
polygonPoints.push({ x: isNextRoof.x, y: isNextRoof.y })
} else {
polygonPoints.push({ x: nextRoof.x2, y: nextRoof.y2 })
}
roof.lines
.filter((line) => line !== currentRoof && line !== prevRoof && line !== nextRoof)
.forEach((line) => {
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
const intersection = edgesIntersection(ridgeEdge, lineEdge)
if (intersection && isPointOnLine(ridgeLine, intersection)) {
const size1 = Math.sqrt(Math.pow(line.x1 - intersection.x, 2) + Math.pow(line.y1 - intersection.y, 2))
const size2 = Math.sqrt(Math.pow(line.x2 - intersection.x, 2) + Math.pow(line.y2 - intersection.y, 2))
if (size1 < size2) {
polygonPoints.push({ x: line.x2, y: line.y2 })
} else {
polygonPoints.push({ x: line.x1, y: line.y1 })
}
polygonPoints.push({ x: intersection.x, y: intersection.y })
}
})
}
}
/** 중복되는 포인트 제거 */
const uniquePoints = []