흐름방향 좌우 치조 오류 수정

This commit is contained in:
yjnoh 2025-02-25 11:21:04 +09:00
parent c66be448b9
commit 408e359e80

View File

@ -910,9 +910,6 @@ export function useModuleBasicSetting(tabNum) {
//혼합모듈일때는 mixModuleMaxRows 값이 0 이상임
let moduleMaxRows = tmpModuleData.mixModuleMaxRows === 0 ? tmpModuleData.moduleMaxRows : tmpModuleData.mixModuleMaxRows
// 혼합모듈 포함 총 모듈 설치 높이 갯수
// const totalModuleMaxRows = tmpModuleData.moduleMaxRows
//모듈의 넓이 높이를 가져옴 (복시도 촌수 적용)
//1번 깔았던 모듈 기준으로 잡야아함
let { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
@ -925,46 +922,12 @@ export function useModuleBasicSetting(tabNum) {
}
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.bottom
const moduleArray = []
// const moduleMaxRows = module
//밑에가 곡선이면 모듈의 넓이를 가지고 계산한다
// if (isCenter) {
// //중앙배치일 경우에는 계산한다
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'flat' && flowLines.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.top.type === 'flat') {
// //상단까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const heightLength = Math.abs(flowLines.left.y1 - flowLines.left.y2) //옆에에 길이에서 반을 가른다
// const heightMargin = Math.abs(heightLength - height * Math.floor(heightLength / height)) / 2
// startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
// }
// }
// }
//밑에가 평면이면 좌측으로 붙여서 배치
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
// startPoint = flowLines.left
// }
// let leftEnd = new fabric.Circle({ left: surfaceMaxLines.left.x1 - 2.5, top: surfaceMaxLines.left.y1 - 2.5, radius: 5, fill: 'green' })
// let rightEnd = new fabric.Circle({ left: surfaceMaxLines.right.x1 - 2.5, top: surfaceMaxLines.right.y1 - 2.5, radius: 5, fill: 'green' })
// let topEnd = new fabric.Circle({ left: surfaceMaxLines.top.x1 - 2.5, top: surfaceMaxLines.top.y1 - 2.5, radius: 5, fill: 'green' })
// canvas?.add(leftEnd)
// canvas?.add(rightEnd)
// canvas?.add(topEnd)
// canvas.renderAll()
let calcAreaWidth = flowLines.right.x1 - flowLines.left.x1 //오른쪽 x에서 왼쪽 x를 뺀 가운데를 찾는 로직
let calcModuleWidthCount = calcAreaWidth / (width + intvHor) //뺀 공간에서 모듈을 몇개를 넣을수 있는지 확인하는 로직
let calcMaxModuleWidthCount = calcModuleWidthCount > moduleMaxCols ? moduleMaxCols : calcModuleWidthCount //최대 모듈 단수가 있기 때문에 최대 단수보다 카운트가 크면 최대 단수로 씀씀
// let totalModuleWidthCount = isChidori ? Math.abs(calcMaxModuleWidthCount) : Math.floor(calcMaxModuleWidthCount) //치조배치일경우는 한개 더 넣는다
let totalModuleWidthCount = Math.floor(calcMaxModuleWidthCount) //치조배치일경우는 한개 더 넣는다
let calcAreaHeight = flowLines.bottom.y1 - flowLines.top.y1
@ -976,10 +939,6 @@ export function useModuleBasicSetting(tabNum) {
//근데 양변이 곡선이면 중앙에 맞추기 위해 아래와 위의 길이를 재서 모듈의 길이를 나눠서 들어갈수 있는 갯수가 동일하면 가운데로 정렬 시킨다
if (flowLines.left.type === 'curve' && flowLines.right.type === 'curve') {
startPointX = flowLines.left.x1 + (calcAreaWidth - totalModuleWidthCount * width) / 2
// if (flowLines.left.x1 < flowLines.bottom.x1) {
// startPointX = flowLines.left.x1
// }
}
let heightMargin = 0
@ -992,9 +951,8 @@ export function useModuleBasicSetting(tabNum) {
isChidoriLine = installedModuleHeightCount % 2 != 0 ? true : false //첫번째에서 짝수에서 끝났으면 홀수는 치도리가 아님 짝수는 치도리
}
let isInstall = false
for (let i = 0; i < calcModuleHeightCount; i++) {
let isInstall = false
let moduleY = flowLines.bottom.y1 - height * i - 1 //살짝 여유를 준다
//두번째 모듈 -> 혼합일 경우의 설치될 모듈 높이를 계산
@ -1002,12 +960,6 @@ export function useModuleBasicSetting(tabNum) {
moduleY = installedLastHeightCoord - intvVer
}
//전체 설치 간으 모듈이랑 같으면 반복을 멈춘다
//사용안함 전체를 위로 올리기로 했음
// if (totalModuleMaxRows === installedModuleHeightCount) {
// break
// }
//첫번째는 붙여서 두번째는 마진을 주고 설치
heightMargin = i === 0 ? 0 : intvVer * i
@ -1055,21 +1007,6 @@ export function useModuleBasicSetting(tabNum) {
isInstall = true
//마지막에 설치된 모듈의 Y 좌표
installedLastHeightCoord = moduleY - height - heightMargin
// if (j === 0) {
// let startCircle = new fabric.Rect({
// left: surfaceMaxLines.left.x1,
// top: installedLastHeightCoord,
// stroke: 'red',
// strokeWidth: 1,
// width: 5,
// height: 5,
// fill: 'red',
// originX: 'center',
// originY: 'center',
// })
// canvas.add(startCircle)
// }
} else {
//디버깅용
// tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
@ -1081,75 +1018,6 @@ export function useModuleBasicSetting(tabNum) {
++installedModuleHeightCount
}
}
// }
// else {
// //밑바닥이 직선이 아닐때
// //모양이 이상할때
// let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
// let totalTopEndPoint = maxTopEndPoint - startPoint.y1
// let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width)
// let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width)
// let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
// let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1)
// let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음
// if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
// for (let j = 0; j < diffTopEndPoint; j++) {
// bottomMargin = j === 0 ? 0 : intvVer * j
// for (let i = 0; i <= totalWidth; i++) {
// leftMargin = i === 0 ? 0 : intvHor * i
// chidoriLength = 0
// if (isChidori && !isMaxSetup) {
// chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
// }
// square = [
// [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
// [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
// [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin],
// [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin],
// [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
// ]
// let squarePolygon = turf.polygon([square])
// let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
// let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
// moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
// let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
// let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
// let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
// if (disjointFromTrestle && isDisjoint) {
// if (moduleIndex > 0) {
// setupModule.forEach((item) => {
// const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
// if (!isOverlap) {
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// })
// } else {
// //최초 한번은 그냥 그린다
// //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// } else {
// //디버깅용
// tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
// canvas?.add(tempModule)
// canvas.renderAll()
// }
// }
// }
// }
setupModule.push(moduleArray)
})
@ -1194,40 +1062,7 @@ export function useModuleBasicSetting(tabNum) {
//흐름 방향이 북쪽(위)
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.bottom
const moduleArray = []
// const moduleMaxRows = module
// if (isCenter) {
// //중앙배치일 경우에는 계산한다
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'flat' && flowLines.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.top.type === 'flat') {
// //상단까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const heightLength = Math.abs(flowLines.left.y1 - flowLines.left.y2) //옆에에 길이에서 반을 가른다
// const heightMargin = Math.abs(heightLength - height * Math.floor(heightLength / height)) / 2
// startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
// }
// }
// }
//밑에가 평면이면 좌측으로 붙여서 배치
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
// startPoint = flowLines.left
// }
// let leftEnd = new fabric.Circle({ left: surfaceMaxLines.left.x1 - 2.5, top: surfaceMaxLines.left.y1 - 2.5, radius: 5, fill: 'green' })
// let rightEnd = new fabric.Circle({ left: surfaceMaxLines.right.x1 - 2.5, top: surfaceMaxLines.right.y1 - 2.5, radius: 5, fill: 'green' })
// let bottomEnd = new fabric.Circle({ left: surfaceMaxLines.bottom.x1 - 2.5, top: surfaceMaxLines.bottom.y1 - 2.5, radius: 5, fill: 'green' })
// canvas?.add(leftEnd)
// canvas?.add(rightEnd)
// canvas?.add(bottomEnd)
// canvas.renderAll()
let calcAreaWidth = flowLines.right.x1 - flowLines.left.x1 //오른쪽 x에서 왼쪽 x를 뺀 가운데를 찾는 로직
let calcModuleWidthCount = calcAreaWidth / (width + intvHor) //뺀 공간에서 모듈을 몇개를 넣을수 있는지 확인하는 로직
@ -1243,12 +1078,7 @@ export function useModuleBasicSetting(tabNum) {
//근데 양변이 곡선이면 중앙에 맞추기 위해 아래와 위의 길이를 재서 모듈의 길이를 나눠서 들어갈수 있는 갯수가 동일하면 가운데로 정렬 시킨다
if (flowLines.left.type === 'curve' && flowLines.right.type === 'curve') {
// const calcTopWidth = Math.abs(flowLines.top.x1 - flowLines.top.x2)
// const calcTopModuleWidthCount = calcTopWidth / (width + intvHor)
// if (Math.floor(calcMaxModuleWidthCount) === Math.floor(calcTopModuleWidthCount)) {
startPointX = flowLines.right.x1 - (calcAreaWidth - totalModuleWidthCount * width) / 2
// }
}
let heightMargin = 0
@ -1260,20 +1090,14 @@ export function useModuleBasicSetting(tabNum) {
isChidoriLine = installedModuleHeightCount % 2 != 0 ? true : false //첫번째에서 짝수에서 끝났으면 홀수는 치도리가 아님 짝수는 치도리
}
let isInstall = false
for (let i = 0; i < calcModuleHeightCount; i++) {
let isInstall = false
let moduleY = flowLines.top.y1 + height * i //탑의 y점에서부터 아래로 그려 내려간다
if (moduleIndex > 0) {
moduleY = installedLastHeightCoord + intvVer + 1
}
//전체 설치 간으 모듈이랑 같으면 반복을 멈춘다
// if (totalModuleMaxRows === installedModuleHeightCount) {
// break
// }
heightMargin = i === 0 ? 0 : intvVer * i //모듈간에 마진이 있어 마진값도 넣음
for (let j = 0; j < totalModuleWidthCount; j++) {
//모듈 열수 만큼 반복
@ -1314,28 +1138,13 @@ export function useModuleBasicSetting(tabNum) {
isInstall = true
// if (j === 0) {
// let startCircle = new fabric.Rect({
// left: surfaceMaxLines.left.x1,
// top: installedLastHeightCoord,
// stroke: 'red',
// strokeWidth: 1,
// width: 5,
// height: 5,
// fill: 'red',
// originX: 'center',
// originY: 'center',
// })
// canvas.add(startCircle)
// }
//마지막에 설치된 모듈의 Y 좌표
installedLastHeightCoord = moduleY + height + heightMargin
} else {
//디버깅용
// tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
// canvas?.add(tempModule)
// canvas.renderAll()
tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
canvas?.add(tempModule)
canvas.renderAll()
}
}
if (isInstall) {
@ -1343,114 +1152,6 @@ export function useModuleBasicSetting(tabNum) {
}
}
// checkedModule.forEach((module, index) => {
// const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
// const flowLines = getFlowLines(moduleSetupSurface, height)
// let startPoint = flowLines.top
// // if (flowLines.top.type === 'flat' && flowLines.right.type === 'curve') {
// // startPoint = flowLines.right
// // }
// const moduleArray = []
// if (isCenter) {
// //중앙배치일 경우에는 계산한다
// if (flowLines.top.type === 'flat' && flowLines.left.type === 'flat' && flowLines.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.bottom.type === 'flat') {
// //상단까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const heightLength = Math.abs(flowLines.left.y1 - flowLines.left.y2) //옆에에 길이에서 반을 가른다
// const heightMargin = Math.abs(heightLength - height * Math.floor(heightLength / height)) / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength, y1: startPoint.y1 - heightMargin }
// }
// }
// }
// // else {
// // //중앙배치가 아닐때도 흐름 방향 기준면으로 양면이 직선이면 가운데 배치
// // if (flowModuleLine.bottom.type === 'flat' && flowModuleLine.left.type === 'flat' && flowModuleLine.right.type === 'flat') {
// // //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// // const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// // const halfModuleWidthLength = width / 2
// // startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// // }
// // }
// const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
// const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
// const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단
// let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
// let totalRightEndPoint = maxLeftEndPoint - maxRightEndPoint
// let totalBottomEndPoint = maxBottomEndPoint - startPoint.y1
// let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width)
// let diffRightEndPoint = Math.ceil(Math.abs(totalRightEndPoint / width))
// let diffBottomEndPoint = Math.ceil(Math.abs(totalBottomEndPoint / height))
// let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1)
// let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음
// if (isMaxSetup) diffRightEndPoint = diffRightEndPoint * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
// startColPoint = Math.round(startColPoint - intvHor * diffRightEndPoint)
// for (let j = 0; j < diffBottomEndPoint; j++) {
// bottomMargin = j === 0 ? 0 : intvVer * j
// for (let i = 0; i < diffRightEndPoint; i++) {
// leftMargin = i === 0 ? 0 : intvHor * i
// chidoriLength = 0
// if (isChidori && !isMaxSetup) {
// chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
// }
// square = [
// [startColPoint + tempMaxWidth * i + chidoriLength + leftMargin, startPoint.y1 + height * j + bottomMargin],
// [startColPoint + tempMaxWidth * i + chidoriLength + leftMargin, startPoint.y1 + height * j + height + bottomMargin],
// [startColPoint + tempMaxWidth * i + width + chidoriLength + leftMargin, startPoint.y1 + height * j + height + bottomMargin],
// [startColPoint + tempMaxWidth * i + width + chidoriLength + leftMargin, startPoint.y1 + height * j + bottomMargin],
// [startColPoint + tempMaxWidth * i + chidoriLength + leftMargin, startPoint.y1 + height * j + bottomMargin],
// ]
// let squarePolygon = turf.polygon([square])
// let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
// let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
// // if (disjointFromTrestle && isDisjoint) {
// moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
// let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
// let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
// let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
// if (disjointFromTrestle && isDisjoint) {
// if (index > 0) {
// setupModule.forEach((item) => {
// const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
// if (!isOverlap) {
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// })
// } else {
// //최초 한번은 그냥 그린다
// //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// } else {
// //디버깅용
// // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
// // canvas?.add(tempModule)
// // canvas.renderAll()
// }
// }
// }
setupModule.push(moduleArray)
})
}
@ -1497,40 +1198,8 @@ export function useModuleBasicSetting(tabNum) {
}
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.bottom
const moduleArray = []
// const moduleMaxRows = module
//밑에가 곡선이면 모듈의 넓이를 가지고 계산한다
// if (isCenter) {
// //중앙배치일 경우에는 계산한다
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'flat' && flowLines.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.top.type === 'flat') {
// //상단까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const heightLength = Math.abs(flowLines.left.y1 - flowLines.left.y2) //옆에에 길이에서 반을 가른다
// const heightMargin = Math.abs(heightLength - height * Math.floor(heightLength / height)) / 2
// startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
// }
// }
// }
//밑에가 평면이면 좌측으로 붙여서 배치
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
// startPoint = flowLines.left
// }
// let leftEnd = new fabric.Circle({ left: surfaceMaxLines.left.x1 - 2.5, top: surfaceMaxLines.left.y1 - 2.5, radius: 5, fill: 'green' })
// let rightEnd = new fabric.Circle({ left: surfaceMaxLines.right.x1 - 2.5, top: surfaceMaxLines.right.y1 - 2.5, radius: 5, fill: 'green' })
// let topEnd = new fabric.Circle({ left: surfaceMaxLines.top.x1 - 2.5, top: surfaceMaxLines.top.y1 - 2.5, radius: 5, fill: 'green' })
// canvas?.add(leftEnd)
// canvas?.add(rightEnd)
// canvas?.add(topEnd)
// canvas.renderAll()
let calcAreaWidth = flowLines.bottom.y1 - flowLines.top.y1 //아래에서 y에서 위를 y를 뺀 가운데를 찾는 로직
let calcModuleWidthCount = calcAreaWidth / (height + intvHor) //뺀 공간에서 모듈을 몇개를 넣을수 있는지 확인하는 로직
@ -1546,12 +1215,7 @@ export function useModuleBasicSetting(tabNum) {
//근데 양변이 곡선이면 중앙에 맞추기 위해 아래와 위의 길이를 재서 모듈의 길이를 나눠서 들어갈수 있는 갯수가 동일하면 가운데로 정렬 시킨다
if (flowLines.top.type === 'curve' && flowLines.bottom.type === 'curve') {
// const calcTopWidth = Math.abs(flowLines.right.y1 - flowLines.right.y2)
// const calcTopModuleWidthCount = calcTopWidth / (height + intvVer)
// if (Math.floor(calcMaxModuleWidthCount) === Math.floor(calcTopModuleWidthCount)) {
startPointX = flowLines.top.y1 + (calcAreaWidth - totalModuleWidthCount * height) / 2
// }
}
let heightMargin = 0
@ -1564,9 +1228,8 @@ export function useModuleBasicSetting(tabNum) {
isChidoriLine = installedModuleHeightCount % 2 != 0 ? true : false //첫번째에서 짝수에서 끝났으면 홀수는 치도리가 아님 짝수는 치도리
}
let isInstall = false
for (let i = 0; i < calcModuleHeightCount; i++) {
let isInstall = false
let moduleY = flowLines.left.x1 + width * i + 1 //살짝 여유를 준다
//두번째 모듈 -> 혼합일 경우의 설치될 모듈 높이를 계산
@ -1574,11 +1237,6 @@ export function useModuleBasicSetting(tabNum) {
moduleY = installedLastHeightCoord + intvHor
}
//전체 설치 간으 모듈이랑 같으면 반복을 멈춘다
// if (totalModuleMaxRows === installedModuleHeightCount) {
// break
// }
//첫번째는 붙여서 두번째는 마진을 주고 설치
heightMargin = i === 0 ? 0 : intvHor * i
@ -1590,11 +1248,6 @@ export function useModuleBasicSetting(tabNum) {
chidoriLength = installedModuleHeightCount % 2 == 0 ? 0 : height / 2 - intvVer
}
//치도리 일때 는 짝수(1 기준) 일때만 치도리 라인으로 본다
if (isChidori && isChidoriLine) {
chidoriLength = width / 2 - height
}
let square = [
[moduleY + heightMargin, moduleX + height + widthMargin + chidoriLength],
[moduleY + heightMargin, moduleX + widthMargin + chidoriLength],
@ -1625,136 +1278,19 @@ export function useModuleBasicSetting(tabNum) {
isInstall = true
//마지막에 설치된 모듈의 Y 좌표
//디버깅용
// if (j === 0) {
// let startCircle = new fabric.Rect({
// left: surfaceMaxLines.left.x1,
// top: installedLastHeightCoord,
// stroke: 'red',
// strokeWidth: 1,
// width: 5,
// height: 5,
// fill: 'red',
// originX: 'center',
// originY: 'center',
// })
// canvas.add(startCircle)
// }
installedLastHeightCoord = moduleY + width + widthMargin
} else {
//디버깅용
// tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
// canvas?.add(tempModule)
// canvas.renderAll()
tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
canvas?.add(tempModule)
canvas.renderAll()
}
}
installedLastHeightCoord = moduleY + width + widthMargin
if (isInstall) {
++installedModuleHeightCount
}
}
// checkedModule.forEach((module, index) => {
// const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
// let flowLines = getFlowLines(moduleSetupSurface, width)
// //육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.left
// const moduleArray = []
// // if (flowLines.left.type === 'flat') {
// // const tempPoint = { ...flowLines.top }
// // startPoint = { ...flowLines.top, x1: tempPoint.x2, x2: tempPoint.x1 }
// // } else {
// // flowLines = getFlowLines(moduleSetupSurface, height)
// // const tempPoint = { ...flowLines.left }
// // startPoint = { ...flowLines.left, x1: tempPoint.x1 + 5, x2: tempPoint.x2, y1: tempPoint.y1 - 5 }
// // }
// //중앙배치일 경우에는 계산한다
// if (isCenter) {
// if (flowLines.left.type === 'flat' && flowLines.bottom.type === 'flat' && flowLines.top.type === 'flat') {
// //좌측 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.y1 + startPoint.y2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = height / 2
// startPoint = { ...startPoint, y1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.right.type === 'flat') {
// //우측까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const widthLength = Math.abs(flowLines.top.x1 - flowLines.top.x2) //옆에에 길이에서 반을 가른다
// const widthMargin = Math.abs(widthLength - width * Math.floor(widthLength / width)) / 2
// startPoint = { ...startPoint, x1: startPoint.x1 + widthMargin }
// }
// }
// }
// const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
// const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
// const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단
// let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌
// let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
// let totalHeight = Math.ceil(Math.abs(maxBottomEndPoint - maxTopEndPoint) / height)
// let totalWidth = Math.abs(startPoint.x1 - maxRightEndPoint) / width
// let startRowPoint = startPoint.y1 - height * Math.ceil(diffTopEndPoint)
// let tempMaxHeight = isMaxSetup ? height / 2 : height //최대배치인지 확인하려고 넣음
// if (isMaxSetup) totalHeight = totalHeight * 2 //최대배치시 2배로 늘려 서 반씩 검사
// for (let i = 0; i <= totalWidth; i++) {
// bottomMargin = i === 0 ? 0 : intvHor * i
// for (let j = 0; j < totalHeight; j++) {
// leftMargin = j === 0 ? 0 : intvVer * j
// chidoriLength = 0
// if (isChidori && !isMaxSetup) {
// chidoriLength = i % 2 === 0 ? 0 : height / 2
// }
// square = [
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + width + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + width + bottomMargin, startRowPoint + tempMaxHeight * j + height + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + height + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// ]
// let squarePolygon = turf.polygon([square])
// let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
// let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
// // if (disjointFromTrestle && isDisjoint) {
// moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
// let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
// let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
// let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
// if (disjointFromTrestle && isDisjoint) {
// if (index > 0) {
// setupModule.forEach((item) => {
// const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
// if (!isOverlap) {
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// })
// } else {
// //최초 한번은 그냥 그린다
// //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// } else {
// //디버깅용
// // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
// // canvas?.add(tempModule)
// // canvas.renderAll()
// }
// }
// }
setupModule.push(moduleArray)
})
}
@ -1799,40 +1335,7 @@ export function useModuleBasicSetting(tabNum) {
}
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.bottom
const moduleArray = []
// const moduleMaxRows = module
//밑에가 곡선이면 모듈의 넓이를 가지고 계산한다
// if (isCenter) {
// //중앙배치일 경우에는 계산한다
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'flat' && flowLines.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.top.type === 'flat') {
// //상단까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const heightLength = Math.abs(flowLines.left.y1 - flowLines.left.y2) //옆에에 길이에서 반을 가른다
// const heightMargin = Math.abs(heightLength - height * Math.floor(heightLength / height)) / 2
// startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
// }
// }
// }
//밑에가 평면이면 좌측으로 붙여서 배치
// if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
// startPoint = flowLines.left
// }
// let leftEnd = new fabric.Circle({ left: surfaceMaxLines.left.x1 - 2.5, top: surfaceMaxLines.left.y1 - 2.5, radius: 5, fill: 'green' })
// let bottomEnd = new fabric.Circle({ left: surfaceMaxLines.bottom.x1 - 2.5, top: surfaceMaxLines.bottom.y1 - 2.5, radius: 5, fill: 'green' })
// let topEnd = new fabric.Circle({ left: surfaceMaxLines.top.x1 - 2.5, top: surfaceMaxLines.top.y1 - 2.5, radius: 5, fill: 'green' })
// canvas?.add(leftEnd)
// canvas?.add(bottomEnd)
// canvas?.add(topEnd)
// canvas.renderAll()
let calcAreaWidth = flowLines.bottom.y1 - flowLines.top.y1 //아래에서 y에서 위를 y를 뺀 가운데를 찾는 로직
let calcModuleWidthCount = calcAreaWidth / (height + intvHor) //뺀 공간에서 모듈을 몇개를 넣을수 있는지 확인하는 로직
@ -1848,12 +1351,7 @@ export function useModuleBasicSetting(tabNum) {
//근데 양변이 곡선이면 중앙에 맞추기 위해 아래와 위의 길이를 재서 모듈의 길이를 나눠서 들어갈수 있는 갯수가 동일하면 가운데로 정렬 시킨다
if (flowLines.top.type === 'curve' && flowLines.bottom.type === 'curve') {
// const calcTopWidth = Math.abs(flowLines.right.y1 - flowLines.right.y2)
// const calcTopModuleWidthCount = calcTopWidth / (height + intvVer)
// if (Math.floor(calcMaxModuleWidthCount) === Math.floor(calcTopModuleWidthCount)) {
startPointX = flowLines.bottom.y2 - (calcAreaWidth - totalModuleWidthCount * height) / 2
// }
}
let heightMargin = 0
@ -1866,9 +1364,8 @@ export function useModuleBasicSetting(tabNum) {
isChidoriLine = installedModuleHeightCount % 2 != 0 ? true : false //첫번째에서 짝수에서 끝났으면 홀수는 치도리가 아님 짝수는 치도리
}
let isInstall = false
for (let i = 0; i < calcModuleHeightCount; i++) {
let isInstall = false
let moduleY = flowLines.right.x1 - width * i - 1 //살짝 여유를 준다
//두번째 모듈 -> 혼합일 경우의 설치될 모듈 높이를 계산
@ -1876,11 +1373,6 @@ export function useModuleBasicSetting(tabNum) {
moduleY = installedLastHeightCoord - intvHor
}
//전체 설치 간으 모듈이랑 같으면 반복을 멈춘다
// if (totalModuleMaxRows === installedModuleHeightCount) {
// break
// }
//첫번째는 붙여서 두번째는 마진을 주고 설치
heightMargin = i === 0 ? 0 : intvHor * i
@ -1893,9 +1385,9 @@ export function useModuleBasicSetting(tabNum) {
}
//치도리 일때 는 짝수(1 기준) 일때만 치도리 라인으로 본다
if (isChidori && isChidoriLine) {
chidoriLength = width / 2 - height
}
// if (isChidori && isChidoriLine) {
// chidoriLength = width / 2 - height
// }
let square = [
[moduleY - heightMargin, moduleX - height - widthMargin - chidoriLength],
@ -1923,25 +1415,9 @@ export function useModuleBasicSetting(tabNum) {
moduleArray.push(tempModule)
canvas.renderAll()
// ++installedModuleHeightCount
isInstall = true
//마지막에 설치된 모듈의 Y 좌표
// if (j === 0) {
// let startCircle = new fabric.Rect({
// left: surfaceMaxLines.left.x1,
// top: installedLastHeightCoord,
// stroke: 'red',
// strokeWidth: 1,
// width: 5,
// height: 5,
// fill: 'red',
// originX: 'center',
// originY: 'center',
// })
// canvas.add(startCircle)
// }
installedLastHeightCoord = moduleY - width - heightMargin
} else {
//디버깅용
// tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })
@ -1950,112 +1426,11 @@ export function useModuleBasicSetting(tabNum) {
}
}
installedLastHeightCoord = moduleY - width - heightMargin
if (isInstall) {
++installedModuleHeightCount
}
}
// checkedModule.forEach((module, index) => {
// const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
// let flowLines = getFlowLines(moduleSetupSurface, width)
// //육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.left
// const moduleArray = []
// // if (flowLines.left.type === 'flat') {
// // const tempPoint = { ...flowLines.top }
// // startPoint = { ...flowLines.top, x1: tempPoint.x2, x2: tempPoint.x1 }
// // } else {
// // flowLines = getFlowLines(moduleSetupSurface, height)
// // const tempPoint = { ...flowLines.left }
// // startPoint = { ...flowLines.left, x1: tempPoint.x1 + 5, x2: tempPoint.x2, y1: tempPoint.y1 - 5 }
// // }
// //중앙배치일 경우에는 계산한다
// if (isCenter) {
// if (flowLines.left.type === 'flat' && flowLines.bottom.type === 'flat' && flowLines.top.type === 'flat') {
// //좌측 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.y1 + startPoint.y2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = height / 2
// startPoint = { ...startPoint, y1: halfWidthLength - halfModuleWidthLength }
// if (flowLines.right.type === 'flat') {
// //우측까지 평면이면 직사각,정사각이라 가정하고 상자의 중심으로 계산
// const widthLength = Math.abs(flowLines.top.x1 - flowLines.top.x2) //옆에에 길이에서 반을 가른다
// const widthMargin = Math.abs(widthLength - width * Math.floor(widthLength / width)) / 2
// startPoint = { ...startPoint, x1: startPoint.x1 + widthMargin }
// }
// }
// }
// const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
// const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
// const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단
// let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌
// let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
// let totalHeight = Math.ceil(Math.abs(maxBottomEndPoint - maxTopEndPoint) / height)
// let totalWidth = Math.abs(startPoint.x1 - maxRightEndPoint) / width
// let startRowPoint = startPoint.y1 - height * Math.ceil(diffTopEndPoint)
// let tempMaxHeight = isMaxSetup ? height / 2 : height //최대배치인지 확인하려고 넣음
// if (isMaxSetup) totalHeight = totalHeight * 2 //최대배치시 2배로 늘려 서 반씩 검사
// for (let i = 0; i <= totalWidth; i++) {
// bottomMargin = i === 0 ? 0 : intvHor * i
// for (let j = 0; j < totalHeight; j++) {
// leftMargin = j === 0 ? 0 : intvVer * j
// chidoriLength = 0
// if (isChidori && !isMaxSetup) {
// chidoriLength = i % 2 === 0 ? 0 : height / 2
// }
// square = [
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + width + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + width + bottomMargin, startRowPoint + tempMaxHeight * j + height + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + height + leftMargin - chidoriLength],
// [startPoint.x1 + width * i + bottomMargin, startRowPoint + tempMaxHeight * j + leftMargin - chidoriLength],
// ]
// let squarePolygon = turf.polygon([square])
// let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
// let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
// // if (disjointFromTrestle && isDisjoint) {
// moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
// let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
// let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
// let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
// if (disjointFromTrestle && isDisjoint) {
// if (index > 0) {
// setupModule.forEach((item) => {
// const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
// if (!isOverlap) {
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// })
// } else {
// //최초 한번은 그냥 그린다
// //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule)
// moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule)
// canvas.renderAll()
// }
// } else {
// //디버깅용
// // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
// // canvas?.add(tempModule)
// // canvas.renderAll()
// }
// }
// }
setupModule.push(moduleArray)
})
}