Merge pull request 'dev' (#188) from dev into prd-deploy

Reviewed-on: #188
This commit is contained in:
ysCha 2025-07-08 13:43:59 +09:00
commit dc685f8594

View File

@ -2181,7 +2181,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const isAlreadyRidge = baseGableRidgeLines.find( const isAlreadyRidge = baseGableRidgeLines.find(
(line) => (line) =>
(line.x1 === ridgePoint[0] && line.y1 === ridgePoint[1] && line.x2 === ridgePoint[2] && line.y2 === ridgePoint[3]) || (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) { if (baseRidgeCount < getMaxRidge(baseLines.length) && !isAlreadyRidge) {
const ridgeLine = drawRidgeLine(ridgePoint, canvas, roof, textMode) 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 = [] const uniquePoints = []
@ -4891,20 +4927,41 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
prevEndPoint.y = Big(intersection.y) prevEndPoint.y = Big(intersection.y)
} }
} }
const overlapLine = baseHipLines.find((line) => isPointOnLine(line, { x: prevEndPoint.x.toNumber(), y: prevEndPoint.y.toNumber() })) const overlapLine = baseHipLines.find(
(line) =>
isPointOnLineNew({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: line.x1, y: line.y1 }) ||
isPointOnLineNew({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: line.x2, y: line.y2 }),
)
if (overlapLine) { if (overlapLine) {
let size1, size2
if ( if (
isPointOnLine({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: overlapLine.x1, y: overlapLine.y1 }) isPointOnLineNew({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: overlapLine.x1, y: overlapLine.y1 })
) { ) {
prevEndPoint.x = Big(overlapLine.x1) size1 = Math.sqrt(Math.pow(x1 - overlapLine.x1, 2) + Math.pow(y1 - overlapLine.y1, 2))
prevEndPoint.y = Big(overlapLine.y1)
} }
if ( if (
isPointOnLine({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: overlapLine.x2, y: overlapLine.y2 }) isPointOnLineNew({ x1: x1, y1: y1, x2: prevEndPoint.x.toNumber(), y2: prevEndPoint.y.toNumber() }, { x: overlapLine.x2, y: overlapLine.y2 })
) { ) {
prevEndPoint.x = Big(overlapLine.x2) size2 = Math.sqrt(Math.pow(x1 - overlapLine.x2, 2) + Math.pow(y1 - overlapLine.y2, 2))
prevEndPoint.y = Big(overlapLine.y2) }
if (size1 && size2) {
if (size1 < size2) {
prevEndPoint.x = Big(overlapLine.x1)
prevEndPoint.y = Big(overlapLine.y1)
} else {
prevEndPoint.x = Big(overlapLine.x2)
prevEndPoint.y = Big(overlapLine.y2)
}
} else {
if (size1) {
prevEndPoint.x = Big(overlapLine.x1)
prevEndPoint.y = Big(overlapLine.y1)
}
if (size2) {
prevEndPoint.x = Big(overlapLine.x2)
prevEndPoint.y = Big(overlapLine.y2)
}
} }
} }
const intersectRidgeLine = [] const intersectRidgeLine = []
@ -5016,20 +5073,41 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
} }
} }
const overlapLine = baseHipLines.find((line) => isPointOnLine(line, { x: nextEndPoint.x.toNumber(), y: nextEndPoint.y.toNumber() })) // const overlapLine = baseHipLines.find((line) => isPointOnLine(line, { x: nextEndPoint.x.toNumber(), y: nextEndPoint.y.toNumber() }))
const overlapLine = baseHipLines.find(
(line) =>
isPointOnLineNew({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: line.x1, y: line.y1 }) ||
isPointOnLineNew({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: line.x2, y: line.y2 }),
)
if (overlapLine) { if (overlapLine) {
let size1, size2
if ( if (
isPointOnLine({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: overlapLine.x1, y: overlapLine.y1 }) isPointOnLineNew({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: overlapLine.x1, y: overlapLine.y1 })
) { ) {
nextEndPoint.x = Big(overlapLine.x1) size1 = Math.sqrt(Math.pow(x2 - overlapLine.x1, 2) + Math.pow(y2 - overlapLine.y1, 2))
nextEndPoint.y = Big(overlapLine.y1)
} }
if ( if (
isPointOnLine({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: overlapLine.x2, y: overlapLine.y2 }) isPointOnLineNew({ x1: x2, y1: y2, x2: nextEndPoint.x.toNumber(), y2: nextEndPoint.y.toNumber() }, { x: overlapLine.x2, y: overlapLine.y2 })
) { ) {
nextEndPoint.x = Big(overlapLine.x2) size2 = Math.sqrt(Math.pow(x2 - overlapLine.x2, 2) + Math.pow(y2 - overlapLine.y2, 2))
nextEndPoint.y = Big(overlapLine.y2) }
if (size1 && size2) {
if (size1 < size2) {
nextEndPoint.x = Big(overlapLine.x1)
nextEndPoint.y = Big(overlapLine.y1)
} else {
nextEndPoint.x = Big(overlapLine.x2)
nextEndPoint.y = Big(overlapLine.y2)
}
} else {
if (size1) {
nextEndPoint.x = Big(overlapLine.x1)
nextEndPoint.y = Big(overlapLine.y1)
}
if (size2) {
nextEndPoint.x = Big(overlapLine.x2)
nextEndPoint.y = Big(overlapLine.y2)
}
} }
} }