지붕 보조선 작성 수정 중
This commit is contained in:
parent
ead3429912
commit
410da6f541
@ -879,6 +879,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
const currentLine = currentBaseLine.line
|
const currentLine = currentBaseLine.line
|
||||||
const prevLine = prevBaseLine.line
|
const prevLine = prevBaseLine.line
|
||||||
const nextLine = nextBaseLine.line
|
const nextLine = nextBaseLine.line
|
||||||
|
const currentAngle = calculateAngle(currentLine.startPoint, currentLine.endPoint)
|
||||||
const prevAngle = calculateAngle(prevLine.startPoint, prevLine.endPoint)
|
const prevAngle = calculateAngle(prevLine.startPoint, prevLine.endPoint)
|
||||||
const nextAngle = calculateAngle(nextLine.startPoint, nextLine.endPoint)
|
const nextAngle = calculateAngle(nextLine.startPoint, nextLine.endPoint)
|
||||||
|
|
||||||
@ -918,7 +919,6 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
drawEavesSecondLines.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
drawEavesSecondLines.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
||||||
}
|
}
|
||||||
} else if (gableType.includes(nextLine.attributes?.type) && gableType.includes(prevLine.attributes?.type)) {
|
} else if (gableType.includes(nextLine.attributes?.type) && gableType.includes(prevLine.attributes?.type)) {
|
||||||
console.log('currentLine :', currentBaseLine.size, 'prevAngle :', prevAngle, 'nextAngle :', nextAngle)
|
|
||||||
if (Big(prevAngle).minus(Big(nextAngle)).abs().eq(180)) {
|
if (Big(prevAngle).minus(Big(nextAngle)).abs().eq(180)) {
|
||||||
const checkPoints = {
|
const checkPoints = {
|
||||||
x: currentMidX.plus(checkScale.times(Math.sign(xVector.toNumber()))).toNumber(),
|
x: currentMidX.plus(checkScale.times(Math.sign(xVector.toNumber()))).toNumber(),
|
||||||
@ -934,10 +934,12 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
drawGableRidgeSecond.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
drawGableRidgeSecond.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
|
if (currentAngle !== prevAngle && currentAngle !== nextAngle) {
|
||||||
drawGablePolygonSecond.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
drawGablePolygonSecond.push({ currentBaseLine, prevBaseLine, nextBaseLine })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (gableType.includes(currentLine.attributes?.type)) {
|
if (gableType.includes(currentLine.attributes?.type)) {
|
||||||
if (eavesType.includes(nextLine.attributes?.type)) {
|
if (eavesType.includes(nextLine.attributes?.type)) {
|
||||||
@ -1034,44 +1036,158 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
const nextVectorY = Math.sign(Big(nextLine.y2).minus(Big(nextLine.y1)))
|
const nextVectorY = Math.sign(Big(nextLine.y2).minus(Big(nextLine.y1)))
|
||||||
|
|
||||||
/** 현재라인의 기준점*/
|
/** 현재라인의 기준점*/
|
||||||
const currentMidX = Big(x1).plus(Big(x2)).div(2).plus(Big(prevVectorX).times(currentLine.attributes.offset))
|
let currentMidX = Big(x1).plus(Big(x2)).div(2).plus(Big(prevVectorX).times(currentLine.attributes.offset))
|
||||||
const currentMidY = Big(y1).plus(Big(y2)).div(2).plus(Big(prevVectorY).times(currentLine.attributes.offset))
|
let currentMidY = Big(y1).plus(Big(y2)).div(2).plus(Big(prevVectorY).times(currentLine.attributes.offset))
|
||||||
|
|
||||||
/** 마루 반대 좌표*/
|
/** 마루 반대 좌표*/
|
||||||
let oppositeMidX = currentMidX,
|
let oppositeMidX = currentMidX,
|
||||||
oppositeMidY = currentMidY
|
oppositeMidY = currentMidY
|
||||||
|
|
||||||
|
/** 한개의 지붕선을 둘로 나누어서 처리 하는 경우 */
|
||||||
if (prevAngle === beforePrevAngle || nextAngle === afterNextAngle) {
|
if (prevAngle === beforePrevAngle || nextAngle === afterNextAngle) {
|
||||||
console.log('지붕선 분할 : start')
|
|
||||||
const checkLine1 = new fabric.Line([prevLine.x1, prevLine.y1, prevLine.x2, prevLine.y2], {
|
|
||||||
stroke: 'red',
|
|
||||||
strokeWidth: 4,
|
|
||||||
parentId: roofId,
|
|
||||||
name: 'checkLine',
|
|
||||||
})
|
|
||||||
const checkLine2 = new fabric.Line([nextLine.x1, nextLine.y1, nextLine.x2, nextLine.y2], {
|
|
||||||
stroke: 'blue',
|
|
||||||
strokeWidth: 4,
|
|
||||||
parentId: roofId,
|
|
||||||
name: 'checkLine',
|
|
||||||
})
|
|
||||||
const checkPoint = new fabric.Circle({
|
|
||||||
left: currentMidX.toNumber(),
|
|
||||||
top: currentMidY.toNumber(),
|
|
||||||
radius: 5,
|
|
||||||
fill: 'red',
|
|
||||||
parentId: roofId,
|
|
||||||
name: 'checkPoint',
|
|
||||||
})
|
|
||||||
canvas.add(checkLine1)
|
|
||||||
canvas.add(checkLine2)
|
|
||||||
canvas.add(checkPoint)
|
|
||||||
canvas.renderAll()
|
|
||||||
|
|
||||||
if (currentVectorX === 0) {
|
if (currentVectorX === 0) {
|
||||||
} else {
|
const addLength = Big(currentLine.y1).minus(Big(currentLine.y2)).abs().div(2)
|
||||||
|
const ridgeVector = Math.sign(prevLine.x1 - currentLine.x1)
|
||||||
|
oppositeMidX = Big(prevLine.x1).plus(Big(addLength).times(ridgeVector))
|
||||||
|
|
||||||
|
const ridgeEdge = {
|
||||||
|
vertex1: { x: oppositeMidX.toNumber(), y: oppositeMidY.toNumber() },
|
||||||
|
vertex2: { x: currentMidX.toNumber(), y: currentMidY.toNumber() },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ridgeVectorX = Math.sign(ridgeEdge.vertex1.x - ridgeEdge.vertex2.x)
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => line.x1 === line.x2)
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const is = edgesIntersection(ridgeEdge, lineEdge)
|
||||||
|
if (is) {
|
||||||
|
const isVectorX = Math.sign(ridgeEdge.vertex1.x - is.x)
|
||||||
|
if (
|
||||||
|
isVectorX === ridgeVectorX &&
|
||||||
|
((line.x1 <= currentMidX && line.x2 >= currentMidX) || (line.x2 <= currentMidX && line.x1 >= currentMidX))
|
||||||
|
) {
|
||||||
|
currentMidX = Big(is.x)
|
||||||
|
currentMidY = Big(is.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const addLength = Big(currentLine.x1).minus(Big(currentLine.x2)).abs().div(2)
|
||||||
|
const ridgeVector = Math.sign(prevLine.y1 - currentLine.y1)
|
||||||
|
oppositeMidY = Big(prevLine.y1).plus(addLength.times(ridgeVector))
|
||||||
|
|
||||||
|
const ridgeEdge = {
|
||||||
|
vertex1: { x: oppositeMidX.toNumber(), y: oppositeMidY.toNumber() },
|
||||||
|
vertex2: { x: currentMidX.toNumber(), y: currentMidY.toNumber() },
|
||||||
|
}
|
||||||
|
const ridgeVectorY = Math.sign(ridgeEdge.vertex1.y - ridgeEdge.vertex2.y)
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => line.y1 === line.y2)
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const is = edgesIntersection(ridgeEdge, lineEdge)
|
||||||
|
if (is) {
|
||||||
|
const isVectorY = Math.sign(ridgeEdge.vertex1.y - is.y)
|
||||||
|
if (
|
||||||
|
isVectorY === ridgeVectorY &&
|
||||||
|
((line.x1 <= currentMidX && line.x2 >= currentMidX) || (line.x2 <= currentMidX && line.x1 >= currentMidX))
|
||||||
|
) {
|
||||||
|
currentMidX = Big(is.x)
|
||||||
|
currentMidY = Big(is.y)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const prevHipEdge = { vertex1: { x: oppositeMidX.toNumber(), y: oppositeMidY.toNumber() }, vertex2: { x: prevLine.x1, y: prevLine.y1 } }
|
||||||
|
const prevHipVectorX = Math.sign(prevHipEdge.vertex1.x - prevHipEdge.vertex2.x)
|
||||||
|
const prevHipVectorY = Math.sign(prevHipEdge.vertex1.y - prevHipEdge.vertex2.y)
|
||||||
|
const prevIsPoints = []
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => (Math.sign(prevLine.x1 - prevLine.x2) === 0 ? line.x1 === line.x2 : line.y1 === line.y2))
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const is = edgesIntersection(prevHipEdge, lineEdge)
|
||||||
|
if (is) {
|
||||||
|
const isVectorX = Math.sign(prevHipEdge.vertex1.x - is.x)
|
||||||
|
const isVectorY = Math.sign(prevHipEdge.vertex1.y - is.y)
|
||||||
|
if (isVectorX === prevHipVectorX && isVectorY === prevHipVectorY) {
|
||||||
|
const size = Big(prevHipEdge.vertex1.x)
|
||||||
|
.minus(Big(is.x))
|
||||||
|
.abs()
|
||||||
|
.pow(2)
|
||||||
|
.plus(Big(prevHipEdge.vertex1.y).minus(Big(is.y)).abs().pow(2))
|
||||||
|
.sqrt()
|
||||||
|
.toNumber()
|
||||||
|
prevIsPoints.push({ is, size })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (prevIsPoints.length > 0) {
|
||||||
|
const prevIs = prevIsPoints.sort((a, b) => a.size - b.size)[0].is
|
||||||
|
const prevHipLine = drawHipLine(
|
||||||
|
[prevIs.x, prevIs.y, oppositeMidX.toNumber(), oppositeMidY.toNumber()],
|
||||||
|
canvas,
|
||||||
|
roof,
|
||||||
|
textMode,
|
||||||
|
null,
|
||||||
|
prevDegree,
|
||||||
|
prevDegree,
|
||||||
|
)
|
||||||
|
baseHipLines.push({ x1: prevLine.x1, y1: prevLine.y1, x2: oppositeMidX.toNumber(), y2: oppositeMidY.toNumber(), line: prevHipLine })
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextHipEdge = { vertex1: { x: oppositeMidX.toNumber(), y: oppositeMidY.toNumber() }, vertex2: { x: nextLine.x2, y: nextLine.y2 } }
|
||||||
|
const nextHipVectorX = Math.sign(nextHipEdge.vertex1.x - nextHipEdge.vertex2.x)
|
||||||
|
const nextHipVectorY = Math.sign(nextHipEdge.vertex1.y - nextHipEdge.vertex2.y)
|
||||||
|
const nextIsPoints = []
|
||||||
|
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => (Math.sign(nextLine.x1 - nextLine.x2) === 0 ? line.x1 === line.x2 : line.y1 === line.y2))
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const is = edgesIntersection(nextHipEdge, lineEdge)
|
||||||
|
if (is) {
|
||||||
|
const isVectorX = Math.sign(nextHipEdge.vertex1.x - is.x)
|
||||||
|
const isVectorY = Math.sign(nextHipEdge.vertex1.y - is.y)
|
||||||
|
if (isVectorX === nextHipVectorX && isVectorY === nextHipVectorY) {
|
||||||
|
const size = Big(nextHipEdge.vertex1.x)
|
||||||
|
.minus(Big(is.x))
|
||||||
|
.abs()
|
||||||
|
.pow(2)
|
||||||
|
.plus(Big(nextHipEdge.vertex1.y).minus(Big(is.y)).abs().pow(2))
|
||||||
|
.sqrt()
|
||||||
|
.toNumber()
|
||||||
|
nextIsPoints.push({ is, size })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (nextIsPoints.length > 0) {
|
||||||
|
const nextIs = nextIsPoints.sort((a, b) => a.size - b.size)[0].is
|
||||||
|
const nextHipLine = drawHipLine(
|
||||||
|
[nextIs.x, nextIs.y, oppositeMidX.toNumber(), oppositeMidY.toNumber()],
|
||||||
|
canvas,
|
||||||
|
roof,
|
||||||
|
textMode,
|
||||||
|
null,
|
||||||
|
nextDegree,
|
||||||
|
nextDegree,
|
||||||
|
)
|
||||||
|
baseHipLines.push({ x1: nextLine.x2, y1: nextLine.y2, x2: oppositeMidX.toNumber(), y2: oppositeMidY.toNumber(), line: nextHipLine })
|
||||||
|
}
|
||||||
|
|
||||||
|
if (baseRidgeCount < getMaxRidge(baseLines.length)) {
|
||||||
|
const ridgeLine = drawRidgeLine(
|
||||||
|
[currentMidX.toNumber(), currentMidY.toNumber(), oppositeMidX.toNumber(), oppositeMidY.toNumber()],
|
||||||
|
canvas,
|
||||||
|
roof,
|
||||||
|
textMode,
|
||||||
|
)
|
||||||
|
baseGableRidgeLines.push(ridgeLine)
|
||||||
|
baseRidgeCount++
|
||||||
|
}
|
||||||
console.log('지붕선 분할 : end')
|
console.log('지붕선 분할 : end')
|
||||||
} else {
|
} else {
|
||||||
if (beforePrevBaseLine === afterNextBaseLine) {
|
if (beforePrevBaseLine === afterNextBaseLine) {
|
||||||
@ -1236,7 +1352,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
y: currentMidY.plus(Big(nextVectorY).times(nextBaseLine.size)).toNumber(),
|
y: currentMidY.plus(Big(nextVectorY).times(nextBaseLine.size)).toNumber(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
let hipEdge = { vertex1: { x: nextLine.x2, y: nextLine.y2 }, vertex2: { x: nextEndPoint.x, y: nextEndPoint.y } }
|
let hipEdge = {
|
||||||
|
vertex1: { x: nextLine.x2, y: nextLine.y2 },
|
||||||
|
vertex2: { x: nextEndPoint.x, y: nextEndPoint.y },
|
||||||
|
}
|
||||||
let intersection = edgesIntersection(ridgeEdge, hipEdge)
|
let intersection = edgesIntersection(ridgeEdge, hipEdge)
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
nextHipCoords = { x1: nextLine.x2, y1: nextLine.y2, x2: intersection.x, y2: intersection.y }
|
nextHipCoords = { x1: nextLine.x2, y1: nextLine.y2, x2: intersection.x, y2: intersection.y }
|
||||||
@ -1283,7 +1402,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
y: currentMidY.plus(Big(prevVectorY).times(prevBaseLine.size)).toNumber(),
|
y: currentMidY.plus(Big(prevVectorY).times(prevBaseLine.size)).toNumber(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
let hipEdge = { vertex1: { x: prevLine.x1, y: prevLine.y1 }, vertex2: { x: prevEndPoint.x, y: prevEndPoint.y } }
|
let hipEdge = {
|
||||||
|
vertex1: { x: prevLine.x1, y: prevLine.y1 },
|
||||||
|
vertex2: { x: prevEndPoint.x, y: prevEndPoint.y },
|
||||||
|
}
|
||||||
let intersection = edgesIntersection(ridgeEdge, hipEdge)
|
let intersection = edgesIntersection(ridgeEdge, hipEdge)
|
||||||
if (intersection) {
|
if (intersection) {
|
||||||
prevHipCoords = { x1: prevLine.x1, y1: prevLine.y1, x2: intersection.x, y2: intersection.y }
|
prevHipCoords = { x1: prevLine.x1, y1: prevLine.y1, x2: intersection.x, y2: intersection.y }
|
||||||
@ -1299,6 +1421,136 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
prevOppositeMidY = currentMidY
|
prevOppositeMidY = currentMidY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const currentMidEdge = {
|
||||||
|
vertex1: { x: currentMidX.toNumber(), y: currentMidY.toNumber() },
|
||||||
|
vertex2: {
|
||||||
|
x: currentVectorX === 0 ? nextLine.x2 : currentMidX.toNumber(),
|
||||||
|
y: currentVectorX === 0 ? currentMidY.toNumber() : nextLine.y2,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
let oppositeLines = []
|
||||||
|
drawBaseLines
|
||||||
|
.filter((line, index) => {
|
||||||
|
const currentLine = line.line
|
||||||
|
const nextLine = drawBaseLines[(index + 1) % drawBaseLines.length].line
|
||||||
|
const prevLine = drawBaseLines[(index - 1 + drawBaseLines.length) % drawBaseLines.length].line
|
||||||
|
console.log('line.startPoint :', currentLine.startPoint, 'line.endPoint :', currentLine.endPoint)
|
||||||
|
const angle = calculateAngle(currentLine.startPoint, currentLine.endPoint)
|
||||||
|
const prevAngle = calculateAngle(prevLine.startPoint, prevLine.endPoint)
|
||||||
|
const nextAngle = calculateAngle(nextLine.startPoint, nextLine.endPoint)
|
||||||
|
if (angle === prevAngle || angle === nextAngle) {
|
||||||
|
const sameAngleLine = angle === prevAngle ? prevLine : nextLine
|
||||||
|
if (gableType.includes(currentLine.attributes.type) && !gableType.includes(sameAngleLine.attributes.type)) {
|
||||||
|
switch (currentAngle) {
|
||||||
|
case 90:
|
||||||
|
return angle === -90
|
||||||
|
case -90:
|
||||||
|
return angle === 90
|
||||||
|
case 0:
|
||||||
|
return angle === 180
|
||||||
|
case 180:
|
||||||
|
return angle === 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const intersection = edgesIntersection(currentMidEdge, lineEdge)
|
||||||
|
if (intersection) {
|
||||||
|
if (line.x1 <= intersection.x && line.x2 >= intersection.x && line.y1 <= intersection.y && line.y2 >= intersection.y) {
|
||||||
|
oppositeLines.push({
|
||||||
|
line,
|
||||||
|
intersection,
|
||||||
|
size: Big(intersection.x)
|
||||||
|
.minus(currentMidX)
|
||||||
|
.abs()
|
||||||
|
.pow(2)
|
||||||
|
.plus(Big(intersection.y).minus(currentMidY).abs().pow(2))
|
||||||
|
.sqrt()
|
||||||
|
.toNumber(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (oppositeLines.length > 0) {
|
||||||
|
const oppositePoint = oppositeLines.sort((a, b) => a.size - b.size)[0].intersection
|
||||||
|
const checkEdge = { vertex1: { x: currentMidX.toNumber(), y: currentMidY.toNumber() }, vertex2: { x: oppositePoint.x, y: oppositePoint.y } }
|
||||||
|
const oppositeRoofPoints = []
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => {
|
||||||
|
const angle = calculateAngle(line.startPoint, line.endPoint)
|
||||||
|
switch (currentAngle) {
|
||||||
|
case 90:
|
||||||
|
return angle === -90
|
||||||
|
case -90:
|
||||||
|
return angle === 90
|
||||||
|
case 0:
|
||||||
|
return angle === 180
|
||||||
|
case 180:
|
||||||
|
return angle === 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const intersection = edgesIntersection(checkEdge, lineEdge)
|
||||||
|
if (
|
||||||
|
intersection &&
|
||||||
|
((line.x1 <= intersection.x && line.x2 >= intersection.x && line.y1 <= intersection.y && line.y2 >= intersection.y) ||
|
||||||
|
(line.x1 >= intersection.x && line.x2 <= intersection.x && line.y1 >= intersection.y && line.y2 <= intersection.y))
|
||||||
|
) {
|
||||||
|
oppositeRoofPoints.push({
|
||||||
|
line,
|
||||||
|
intersection,
|
||||||
|
size: Big(intersection.x)
|
||||||
|
.minus(currentMidX.toNumber())
|
||||||
|
.abs()
|
||||||
|
.pow(2)
|
||||||
|
.plus(Big(intersection.y).minus(currentMidY.toNumber()).abs().pow(2))
|
||||||
|
.sqrt()
|
||||||
|
.toNumber(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const oppositeRoofPoint = oppositeRoofPoints.sort((a, b) => a.size - b.size)[0].intersection
|
||||||
|
oppositeMidX = Big(oppositeRoofPoint.x)
|
||||||
|
oppositeMidY = Big(oppositeRoofPoint.y)
|
||||||
|
|
||||||
|
const currentRoofPoints = []
|
||||||
|
roof.lines
|
||||||
|
.filter((line) => {
|
||||||
|
const angle = calculateAngle(line.startPoint, line.endPoint)
|
||||||
|
return currentAngle === angle
|
||||||
|
})
|
||||||
|
.forEach((line) => {
|
||||||
|
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
|
||||||
|
const intersection = edgesIntersection(checkEdge, lineEdge)
|
||||||
|
if (
|
||||||
|
intersection &&
|
||||||
|
((line.x1 <= intersection.x && line.x2 >= intersection.x && line.y1 <= intersection.y && line.y2 >= intersection.y) ||
|
||||||
|
(line.x1 >= intersection.x && line.x2 <= intersection.x && line.y1 >= intersection.y && line.y2 <= intersection.y))
|
||||||
|
) {
|
||||||
|
currentRoofPoints.push({
|
||||||
|
line,
|
||||||
|
intersection,
|
||||||
|
size: Big(intersection.x)
|
||||||
|
.minus(currentMidX.toNumber())
|
||||||
|
.abs()
|
||||||
|
.pow(2)
|
||||||
|
.plus(Big(intersection.y).minus(currentMidY.toNumber()).abs().pow(2))
|
||||||
|
.sqrt()
|
||||||
|
.toNumber(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const currentRoofPoint = currentRoofPoints.sort((a, b) => a.size - b.size)[0].intersection
|
||||||
|
currentMidX = Big(currentRoofPoint.x)
|
||||||
|
currentMidY = Big(currentRoofPoint.y)
|
||||||
|
} else {
|
||||||
const checkPrevSize = currentMidX.minus(prevOppositeMidX).pow(2).plus(currentMidY.minus(prevOppositeMidY).pow(2)).sqrt()
|
const checkPrevSize = currentMidX.minus(prevOppositeMidX).pow(2).plus(currentMidY.minus(prevOppositeMidY).pow(2)).sqrt()
|
||||||
const checkNextSize = currentMidX.minus(nextOppositeMidX).pow(2).plus(currentMidY.minus(nextOppositeMidY).pow(2)).sqrt()
|
const checkNextSize = currentMidX.minus(nextOppositeMidX).pow(2).plus(currentMidY.minus(nextOppositeMidY).pow(2)).sqrt()
|
||||||
|
|
||||||
@ -1344,7 +1596,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
})
|
})
|
||||||
const intersect = intersectPoints.sort((a, b) => a.size - b.size)[0]
|
const intersect = intersectPoints.sort((a, b) => a.size - b.size)[0]
|
||||||
if (intersect) {
|
if (intersect) {
|
||||||
const degree = intersect.line.attributes.pitch > 0 ? getDegreeByChon(intersect.line.attributes.pitch) : intersect.line.attributes.degree
|
const degree =
|
||||||
|
intersect.line.attributes.pitch > 0 ? getDegreeByChon(intersect.line.attributes.pitch) : intersect.line.attributes.degree
|
||||||
const hipLine = drawHipLine(
|
const hipLine = drawHipLine(
|
||||||
[intersect.intersection.x, intersect.intersection.y, nextOppositeMidX.toNumber(), nextOppositeMidY.toNumber()],
|
[intersect.intersection.x, intersect.intersection.y, nextOppositeMidX.toNumber(), nextOppositeMidY.toNumber()],
|
||||||
canvas,
|
canvas,
|
||||||
@ -1407,7 +1660,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
const intersect = intersectPoints.sort((a, b) => a.size - b.size)[0]
|
const intersect = intersectPoints.sort((a, b) => a.size - b.size)[0]
|
||||||
|
|
||||||
if (intersect) {
|
if (intersect) {
|
||||||
const degree = intersect.line.attributes.pitch > 0 ? getDegreeByChon(intersect.line.attributes.pitch) : intersect.line.attributes.degree
|
const degree =
|
||||||
|
intersect.line.attributes.pitch > 0 ? getDegreeByChon(intersect.line.attributes.pitch) : intersect.line.attributes.degree
|
||||||
const hipLine = drawHipLine(
|
const hipLine = drawHipLine(
|
||||||
[intersect.intersection.x, intersect.intersection.y, prevOppositeMidX.toNumber(), prevOppositeMidY.toNumber()],
|
[intersect.intersection.x, intersect.intersection.y, prevOppositeMidX.toNumber(), prevOppositeMidY.toNumber()],
|
||||||
canvas,
|
canvas,
|
||||||
@ -1430,6 +1684,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
oppositeMidX = prevOppositeMidX
|
oppositeMidX = prevOppositeMidX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (baseRidgeCount < getMaxRidge(baseLines.length)) {
|
if (baseRidgeCount < getMaxRidge(baseLines.length)) {
|
||||||
/** 마루가 맞은편 외벽선에 닿는 경우 해당 부분까지로 한정한다. */
|
/** 마루가 맞은편 외벽선에 닿는 경우 해당 부분까지로 한정한다. */
|
||||||
const ridgeEdge = {
|
const ridgeEdge = {
|
||||||
@ -1459,7 +1714,6 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const ridgeLine = drawRidgeLine([currentMidX, currentMidY, oppositeMidX, oppositeMidY], canvas, roof, textMode)
|
const ridgeLine = drawRidgeLine([currentMidX, currentMidY, oppositeMidX, oppositeMidY], canvas, roof, textMode)
|
||||||
baseGableRidgeLines.push(ridgeLine)
|
baseGableRidgeLines.push(ridgeLine)
|
||||||
baseRidgeCount++
|
baseRidgeCount++
|
||||||
@ -2190,6 +2444,15 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
|
|||||||
let prevLineRidges = [],
|
let prevLineRidges = [],
|
||||||
nextLineRidges = []
|
nextLineRidges = []
|
||||||
|
|
||||||
|
const checkLine = new fabric.Line([x1, y1, x2, y2], {
|
||||||
|
stroke: 'red',
|
||||||
|
strokeWidth: 4,
|
||||||
|
parentId: roofId,
|
||||||
|
name: 'checkLine',
|
||||||
|
})
|
||||||
|
canvas.add(checkLine)
|
||||||
|
canvas.renderAll()
|
||||||
|
|
||||||
const currentVectorX = Math.sign(currentLine.x2 - currentLine.x1)
|
const currentVectorX = Math.sign(currentLine.x2 - currentLine.x1)
|
||||||
const currentVectorY = Math.sign(currentLine.y2 - currentLine.y1)
|
const currentVectorY = Math.sign(currentLine.y2 - currentLine.y1)
|
||||||
const prevVectorX = Math.sign(prevLine.x2 - prevLine.x1)
|
const prevVectorX = Math.sign(prevLine.x2 - prevLine.x1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user