top,bottom = in, 할당제외
This commit is contained in:
parent
7b8b995e1c
commit
f2b527b77c
@ -444,15 +444,30 @@ export function useRoofAllocationSetting(id) {
|
||||
const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL)
|
||||
roofBases.forEach((roofBase) => {
|
||||
try {
|
||||
const roofEaveHelpLines = canvas.getObjects().filter((obj) => obj.lineName === 'eaveHelpLine' && obj.roofId === roofBase.id)
|
||||
// 지붕 할당 로직에 extensionLine 추가
|
||||
const roofEaveHelpLines = canvas.getObjects().filter((obj) =>
|
||||
(obj.lineName === 'eaveHelpLine' || obj.lineName === 'extensionLine') &&
|
||||
obj.roofId === roofBase.id
|
||||
)
|
||||
// console.log('roofBase.id:', roofBase.id)
|
||||
// console.log('roofEaveHelpLines:', roofEaveHelpLines)
|
||||
// console.log('extensionLines found:', roofEaveHelpLines.filter(l => l.lineName === 'extensionLine'))
|
||||
if (roofEaveHelpLines.length > 0) {
|
||||
if (roofBase.lines) {
|
||||
// Filter out any eaveHelpLines that are already in lines to avoid duplicates
|
||||
const existingEaveLineIds = new Set(roofBase.lines.map((line) => line.id))
|
||||
const newEaveLines = roofEaveHelpLines.filter((line) => !existingEaveLineIds.has(line.id))
|
||||
// Filter out lines from roofBase.lines that share any points with newEaveLines
|
||||
|
||||
// extensionLine과 일반 eaveHelpLine 분리
|
||||
const extensionLines = newEaveLines.filter(line => line.lineName === 'extensionLine')
|
||||
const normalEaveLines = newEaveLines.filter(line => line.lineName === 'eaveHelpLine')
|
||||
// console.log('extensionLines count:', extensionLines.length)
|
||||
// console.log('normalEaveLines count:', normalEaveLines.length)
|
||||
|
||||
// 일반 eaveHelpLine만 Overlap 판단에 사용
|
||||
const linesToKeep = roofBase.lines.filter(roofLine => {
|
||||
const shouldRemove = newEaveLines.some(eaveLine => {
|
||||
const shouldRemove = normalEaveLines.some(eaveLine => {
|
||||
// 1. 기본적인 포인트 일치 확인
|
||||
const rX1 = roofLine.x1, rY1 = roofLine.y1, rX2 = roofLine.x2, rY2 = roofLine.y2;
|
||||
const eX1 = eaveLine.x1, eY1 = eaveLine.y1, eX2 = eaveLine.x2, eY2 = eaveLine.y2;
|
||||
@ -501,7 +516,9 @@ export function useRoofAllocationSetting(id) {
|
||||
return !shouldRemove;
|
||||
});
|
||||
// Combine remaining lines with newEaveLines
|
||||
roofBase.lines = [...linesToKeep, ...newEaveLines];
|
||||
roofBase.lines = [...linesToKeep, ...normalEaveLines, ...extensionLines];
|
||||
// console.log('Final roofBase.lines count:', roofBase.lines.length)
|
||||
// console.log('extensionLines in final:', roofBase.lines.filter(l => l.lineName === 'extensionLine').length)
|
||||
} else {
|
||||
roofBase.lines = [...roofEaveHelpLines]
|
||||
}
|
||||
|
||||
@ -821,7 +821,7 @@ export const usePolygon = () => {
|
||||
if (innerLine.attributes && polygonLine.attributes.type) {
|
||||
// innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경
|
||||
if (polygonLine.length < innerLine.length) {
|
||||
if (polygonLine.lineName !== 'eaveHelpLine' || polygonLine.lineName !== 'eaveHelpLine') {
|
||||
if (polygonLine.lineName !== 'eaveHelpLine' && polygonLine.lineName !== 'extensionLine') {
|
||||
polygonLine.need = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,6 +465,36 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
// 6. 마루이동(용마루 위치 수동 조정)이 설정된 경우 movingLineFromSkeleton 결과로 대체
|
||||
if (moveFlowLine !== 0 || moveUpDown !== 0) {
|
||||
const movedPoints = movingLineFromSkeleton(roofId, canvas)
|
||||
console.log("movedPoints:::", movedPoints);
|
||||
|
||||
// movedPoints를 roof 경계로 확장
|
||||
// 이번 이동에서 실제로 변경된 포인트만 구분하여, 변경되지 않은 축만 roof 경계로 확장
|
||||
const oldPoints = canvas?.skeleton?.lastPoints ?? roofLinePoints
|
||||
const tolerance = 0.1
|
||||
const correctedPoints = movedPoints.map((mp, i) => {
|
||||
const rp = roofLinePoints[i]
|
||||
const op = oldPoints[i]
|
||||
if (!rp || !op) return mp
|
||||
const xMatch = Math.abs(mp.x - rp.x) < tolerance
|
||||
const yMatch = Math.abs(mp.y - rp.y) < tolerance
|
||||
if (xMatch && yMatch) return mp
|
||||
// 이번 이동에서 실제로 변경된 축 판별 (oldPoints vs movedPoints)
|
||||
const xMoved = Math.abs(mp.x - op.x) >= tolerance
|
||||
const yMoved = Math.abs(mp.y - op.y) >= tolerance
|
||||
let newX = mp.x
|
||||
let newY = mp.y
|
||||
// 이번에 이동되지 않았는데 roof 경계와 다른 축만 교정
|
||||
if (!xMoved && !xMatch) newX = rp.x
|
||||
if (!yMoved && !yMatch) newY = rp.y
|
||||
if (newX !== mp.x || newY !== mp.y) {
|
||||
console.log(`point[${i}] 교정: mp=(${mp.x}, ${mp.y}) → (${newX}, ${newY}), op=(${op.x}, ${op.y}), xMoved=${xMoved}, yMoved=${yMoved}`)
|
||||
}
|
||||
return { x: newX, y: newY }
|
||||
})
|
||||
|
||||
// roofLineContactPoints = correctedPoints
|
||||
// changRoofLinePoints = correctedPoints
|
||||
|
||||
roofLineContactPoints = movedPoints
|
||||
changRoofLinePoints = movedPoints
|
||||
}
|
||||
@ -828,11 +858,11 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
|
||||
//roofline 외곽선 설정
|
||||
|
||||
console.log('index::::', index)
|
||||
console.log('roofLine:', roofLine.x1, roofLine.y1, roofLine.x2, roofLine.y2)
|
||||
console.log('wallLine:', wallLine.x1, wallLine.y1, wallLine.x2, wallLine.y2)
|
||||
console.log('wallBaseLine:', wallBaseLine.x1, wallBaseLine.y1, wallBaseLine.x2, wallBaseLine.y2)
|
||||
console.log('isSamePoint result:', isSameLine2(wallBaseLine, wallLine))
|
||||
// console.log('index::::', index)
|
||||
// console.log('roofLine:', roofLine.x1, roofLine.y1, roofLine.x2, roofLine.y2)
|
||||
// console.log('wallLine:', wallLine.x1, wallLine.y1, wallLine.x2, wallLine.y2)
|
||||
// console.log('wallBaseLine:', wallBaseLine.x1, wallBaseLine.y1, wallBaseLine.x2, wallBaseLine.y2)
|
||||
// console.log('isSamePoint result:', isSameLine2(wallBaseLine, wallLine))
|
||||
|
||||
const isCollinear = (l1, l2, tolerance = 0.1) => {
|
||||
const slope1 = Math.abs(l1.x2 - l1.x1) < tolerance ? Infinity : (l1.y2 - l1.y1) / (l1.x2 - l1.x1)
|
||||
@ -871,7 +901,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
|
||||
//현재 roof는 무조건 시계방향
|
||||
|
||||
const getAddLine = (p1, p2, stroke = '') => {
|
||||
const getAddLine = (p1, p2, stroke = '', lineType = 'eaveHelpLine') => {
|
||||
movedLines.push({ index, p1, p2 })
|
||||
|
||||
const dx = Math.abs(p2.x - p1.x);
|
||||
@ -884,14 +914,14 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
fontSize: roof.fontSize,
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
name: 'eaveHelpLine',
|
||||
lineName: 'eaveHelpLine',
|
||||
name: lineType,
|
||||
lineName: lineType,
|
||||
visible: true,
|
||||
roofId: roofId,
|
||||
selectable: true,
|
||||
hoverCursor: 'pointer',
|
||||
attributes: {
|
||||
type: 'eaveHelpLine',
|
||||
type: lineType,
|
||||
isStart: true,
|
||||
pitch: wallLine.attributes.pitch,
|
||||
planeSize: calcLinePlaneSize({ x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y }),
|
||||
@ -970,7 +1000,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
const pLineX = sortRoofLines[prevIndex].x1
|
||||
|
||||
getAddLine({ x: newPStart.x, y: newPStart.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
|
||||
getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange')
|
||||
// getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: newPointX, y: roofLine.y2 }, 'orange')
|
||||
|
||||
if (Math.abs(wallBaseLine.y1 - wallLine.y1) < 0.1) {
|
||||
getAddLine({ x: pLineX, y: pLineY }, { x: newPointX, y: pLineY }, 'green')
|
||||
@ -1000,7 +1030,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
const pLineX = sortRoofLines[nextIndex].x2
|
||||
|
||||
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
|
||||
getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: newPointX, y: roofLine.y1 }, 'orange')
|
||||
// getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: newPointX, y: roofLine.y1 }, 'orange')
|
||||
|
||||
if (Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) {
|
||||
getAddLine({ x: pLineX, y: pLineY }, { x: newPointX, y: pLineY }, 'green')
|
||||
@ -1179,7 +1209,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
const pLineX = sortRoofLines[nextIndex].x2
|
||||
|
||||
getAddLine({ x: newPEnd.x, y: newPEnd.y }, { x: ePoint.x, y: ePoint.y }, 'blue')
|
||||
getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: newPointX, y: roofLine.y1 }, 'orange')
|
||||
//getAddLine({ x: roofLine.x1, y: Big(roofLine.y1).minus(moveDist).toNumber() }, { x: newPointX, y: Big(roofLine.y1).minus(moveDist).toNumber()}, 'orange')
|
||||
|
||||
if (Math.abs(wallBaseLine.y2 - wallLine.y2) < 0.1) {
|
||||
getAddLine({ x: pLineX, y: pLineY }, { x: newPointX, y: pLineY }, 'green')
|
||||
@ -1384,6 +1414,56 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
//getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange')
|
||||
getAddLine(newPStart, newPEnd, 'red')
|
||||
}
|
||||
if(!isStartEnd.start && !isStartEnd.end){
|
||||
console.log('top_in start and end false')
|
||||
|
||||
const moveDistY1 = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
|
||||
const moveDistX1 = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber()
|
||||
const moveDistX2 = Big(wallLine.x2).minus(wallBaseLine.x2).abs().toNumber()
|
||||
const moveDistY2 = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber()
|
||||
|
||||
const sPoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 }
|
||||
const ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 }
|
||||
|
||||
|
||||
if(moveDistX1 > 0) {
|
||||
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'top_in_start' })
|
||||
|
||||
if(moveDistY1 > moveDistX1){
|
||||
const dist = moveDistY1 - moveDistX1
|
||||
// console.log('Creating extensionLine (Y1 > X1):', { sPoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: sPoint.x, y: sPoint.y }, { x: roofLine.x1, y: roofLine.y1 + dist }, 'orange','extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}else{
|
||||
const dist = moveDistX1 - moveDistY1
|
||||
// console.log('Creating extensionLine (X1 > Y1):', { sPoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: sPoint.x, y: sPoint.y }, { x: roofLine.x1 - dist, y: roofLine.y1 }, 'orange','extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
}
|
||||
|
||||
}
|
||||
if(moveDistX2 > 0) {
|
||||
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'top_in_end' })
|
||||
|
||||
if(moveDistY2 > moveDistX2){
|
||||
const dist = moveDistY2 - moveDistX2
|
||||
// getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2, y: roofLine.y2 - dist }, 'red')
|
||||
// console.log('Creating extensionLine (Y2 > X2):', { ePoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: ePoint.x, y: ePoint.y }, { x: roofLine.x2, y: roofLine.y2 + dist }, 'orange', 'extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}else{
|
||||
const dist = moveDistX2 - moveDistY2
|
||||
// getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2 - dist, y: roofLine.y2 }, 'red')
|
||||
// console.log('Creating extensionLine (X2 > Y2):', { ePoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: ePoint.x, y: ePoint.y }, { x: roofLine.x2 + dist, y: roofLine.y2 }, 'orange', 'extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (condition === 'top_out') {
|
||||
console.log('top_out isStartEnd:::::::', isStartEnd)
|
||||
|
||||
@ -1557,6 +1637,57 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
|
||||
//getAddLine({ x: roofLine.x1, y: roofLine.y1 }, { x: roofLine.x1, y: newPointY }, 'orange')
|
||||
getAddLine(newPStart, newPEnd, 'red')
|
||||
}
|
||||
|
||||
if(!isStartEnd.start && !isStartEnd.end){
|
||||
|
||||
console.log('isStartEnd:::::', isStartEnd)
|
||||
|
||||
const moveDistY1 = Big(wallLine.y1).minus(wallBaseLine.y1).abs().toNumber()
|
||||
const moveDistX1 = Big(wallLine.x1).minus(wallBaseLine.x1).abs().toNumber()
|
||||
const moveDistX2 = Big(wallLine.x2).minus(wallBaseLine.x2).abs().toNumber()
|
||||
const moveDistY2 = Big(wallLine.y2).minus(wallBaseLine.y2).abs().toNumber()
|
||||
|
||||
const sPoint = { x: wallBaseLine.x1, y: wallBaseLine.y1 }
|
||||
const ePoint = { x: wallBaseLine.x2, y: wallBaseLine.y2 }
|
||||
|
||||
|
||||
if(moveDistX1 > 0) {
|
||||
findPoints.push({ x: sPoint.x, y: sPoint.y, position: 'bottom_in_start' })
|
||||
|
||||
if(moveDistY1 > moveDistX1){
|
||||
const dist = moveDistY1 - moveDistX1
|
||||
// console.log('Creating extensionLine (Y1 > X1):', { sPoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: sPoint.x, y: sPoint.y }, { x: roofLine.x1, y: roofLine.y1 - dist }, 'orange','extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}else{
|
||||
const dist = moveDistX1 - moveDistY1
|
||||
// console.log('Creating extensionLine (X1 > Y1):', { sPoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: sPoint.x, y: sPoint.y }, { x: roofLine.x1 + dist, y: roofLine.y1 }, 'orange','extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
}
|
||||
|
||||
}
|
||||
if(moveDistX2 > 0) {
|
||||
findPoints.push({ x: ePoint.x, y: ePoint.y, position: 'bottom_in_end' })
|
||||
|
||||
if(moveDistY2 > moveDistX2){
|
||||
const dist = moveDistY2 - moveDistX2
|
||||
// getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2, y: roofLine.y2 - dist }, 'red')
|
||||
// console.log('Creating extensionLine (Y2 > X2):', { ePoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: ePoint.x, y: ePoint.y }, { x: roofLine.x2, y: roofLine.y2 - dist }, 'orange', 'extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}else{
|
||||
const dist = moveDistX2 - moveDistY2
|
||||
// getAddLine({ x: roofLine.x2, y: roofLine.y2 }, { x: roofLine.x2 - dist, y: roofLine.y2 }, 'red')
|
||||
// console.log('Creating extensionLine (X2 > Y2):', { ePoint, roofLine, dist, roofId })
|
||||
const createdLine = getAddLine({ x: ePoint.x, y: ePoint.y }, { x: roofLine.x2 - dist, y: roofLine.y2 }, 'orange', 'extensionLine')
|
||||
console.log('extensionLine created - length:', createdLine.length, 'coords:', { x1: createdLine.x1, y1: createdLine.y1, x2: createdLine.x2, y2: createdLine.y2 })
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (condition === 'bottom_out') {
|
||||
console.log('bottom_out isStartEnd:::::::', isStartEnd)
|
||||
if (isStartEnd.start) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user