This commit is contained in:
hyojun.choi 2025-07-11 14:09:57 +09:00
commit 929304456a

View File

@ -744,21 +744,21 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
/** baseLine을 기준으로 확인용 polygon 작성 */ /** baseLine을 기준으로 확인용 polygon 작성 */
const checkWallPolygon = new QPolygon(baseLinePoints, {}) const checkWallPolygon = new QPolygon(baseLinePoints, {})
/** // /**
* 외벽선이 시계방향인지 시계반대 방향인지 확인 // * 외벽선이 시계방향인지 시계반대 방향인지 확인
* @type {boolean} // * @type {boolean}
*/ // */
let counterClockwise = true // let counterClockwise = true
let signedArea = 0 // let signedArea = 0
//
baseLinePoints.forEach((point, index) => { // baseLinePoints.forEach((point, index) => {
const nextPoint = baseLinePoints[(index + 1) % baseLinePoints.length] // const nextPoint = baseLinePoints[(index + 1) % baseLinePoints.length]
signedArea += point.x * nextPoint.y - point.y * nextPoint.x // signedArea += point.x * nextPoint.y - point.y * nextPoint.x
}) // })
//
if (signedArea > 0) { // if (signedArea > 0) {
counterClockwise = false // counterClockwise = false
} // }
const drawEavesFirstLines = [] const drawEavesFirstLines = []
const drawEavesSecondLines = [] const drawEavesSecondLines = []
@ -780,6 +780,15 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
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)
// const checkLine = new fabric.Line([currentLine.x1, currentLine.y1, currentLine.x2, currentLine.y2], {
// stroke: 'red',
// strokeWidth: 4,
// parentId: roofId,
// name: 'checkLine',
// })
// canvas.add(checkLine)
// canvas.renderAll()
const checkScale = Big(10) const checkScale = Big(10)
const xVector = Big(nextLine.x2).minus(Big(nextLine.x1)) const xVector = Big(nextLine.x2).minus(Big(nextLine.x1))
const yVector = Big(nextLine.y2).minus(Big(nextLine.y1)) const yVector = Big(nextLine.y2).minus(Big(nextLine.y1))
@ -3039,6 +3048,26 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
}) })
polygonPoints = getSortedPoint(uniquePoints, baseHipLines) polygonPoints = getSortedPoint(uniquePoints, baseHipLines)
/*polygonPoints.forEach((point) => {
const checkCircle = new fabric.Circle({
left: point.x,
top: point.y,
radius: 4,
fill: 'red',
parentId: roofId,
name: 'checkCircle',
})
canvas.add(checkCircle)
canvas.renderAll()
/!** 확인용 라인 제거 *!/
canvas
.getObjects()
.filter((obj) => obj.name === 'checkCircle' || obj.name === 'checkLine')
.forEach((obj) => canvas.remove(obj))
canvas.renderAll()
})*/
polygonPoints.forEach((currentPoint, index) => { polygonPoints.forEach((currentPoint, index) => {
const nextPoint = polygonPoints[(index + 1) % polygonPoints.length] const nextPoint = polygonPoints[(index + 1) % polygonPoints.length]
const points = [currentPoint.x, currentPoint.y, nextPoint.x, nextPoint.y] const points = [currentPoint.x, currentPoint.y, nextPoint.x, nextPoint.y]
@ -3077,6 +3106,15 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const nextLine = nextBaseLine.line const nextLine = nextBaseLine.line
let { x1, x2, y1, y2 } = currentBaseLine let { x1, x2, y1, y2 } = currentBaseLine
/*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 currentDegree = getDegreeByChon(currentLine.attributes.pitch) const currentDegree = getDegreeByChon(currentLine.attributes.pitch)
@ -3097,11 +3135,11 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
.forEach((line) => { .forEach((line) => {
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } } const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
const intersection = edgesIntersection(checkEdge, lineEdge) const intersection = edgesIntersection(checkEdge, lineEdge)
if (intersection) { if (intersection && isPointOnLine(line, intersection)) {
intersectionRoofs.push({ intersectionRoofs.push({
line, line,
intersection, intersection,
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(), size: Math.sqrt(Math.pow(intersection.x - currentMidX.toNumber(), 2) + Math.pow(intersection.y - currentMidY.toNumber(), 2)),
}) })
} }
}) })
@ -3115,11 +3153,11 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
.forEach((line) => { .forEach((line) => {
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } } const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
const intersection = edgesIntersection(checkEdge, lineEdge) const intersection = edgesIntersection(checkEdge, lineEdge)
if (intersection) { if (intersection && isPointOnLine(line, intersection)) {
intersectionRoofs.push({ intersectionRoofs.push({
line, line,
intersection, intersection,
size: Big(intersection.x).minus(currentMidX).abs().pow(2).plus(Big(intersection.y).minus(currentMidY).abs().pow(2)).sqrt(), size: Math.sqrt(Math.pow(intersection.x - currentMidX.toNumber(), 2) + Math.pow(intersection.y - currentMidY.toNumber(), 2)),
}) })
} }
}) })