남측 빗면, 평면일때 적용

This commit is contained in:
yjnoh 2025-02-08 20:14:05 +09:00
parent 0c1c7452d6
commit ff5c3c5d4c

View File

@ -861,74 +861,76 @@ export function useModuleBasicSetting(tabNum) {
startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin } startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
} }
} }
} else { }
//밑에가 평면이면 좌측으로 붙여서 배치 //밑에가 평면이면 좌측으로 붙여서 배치
if (flowLines.bottom.type === 'flat') { if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
startPoint = flowLines.left startPoint = flowLines.left
} }
const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측 const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1 let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
let totalTopEndPoint = maxTopEndPoint - startPoint.y1 let totalTopEndPoint = maxTopEndPoint - startPoint.y1
let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width) let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width)
let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width) let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width)
let diffTopEndPoint = Math.abs(totalTopEndPoint / height) let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1) let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1)
let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음 let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음
if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함 if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
for (let j = 0; j < diffTopEndPoint; j++) { for (let j = 0; j < diffTopEndPoint; j++) {
bottomMargin = j === 0 ? 0 : intvVer * j bottomMargin = j === 0 ? 0 : intvVer * j
for (let i = 0; i <= totalWidth; i++) { for (let i = 0; i <= totalWidth; i++) {
leftMargin = i === 0 ? 0 : intvHor * i leftMargin = i === 0 ? 0 : intvHor * i
chidoriLength = 0 chidoriLength = 0
if (isChidori && !isMaxSetup) { if (isChidori && !isMaxSetup) {
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
} }
square = [ square = [
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], [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 - bottomMargin],
[startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - 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 - height - bottomMargin],
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
] ]
let squarePolygon = turf.polygon([square]) let squarePolygon = turf.polygon([square])
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1) let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] })) let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module } moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon }) let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true)) let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects) let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
if (disjointFromTrestle && isDisjoint) { if (disjointFromTrestle && isDisjoint) {
if (index > 0) { if (index > 0) {
setupModule.forEach((item) => { setupModule.forEach((item) => {
const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true))) const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
if (!isOverlap) { if (!isOverlap) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
} canvas.renderAll()
}) }
} else { })
//최초 한번은 그냥 그린다
//겹치는지 확인해서 포함된 모듈만 그린다
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
}
} else { } else {
//디버깅용 //최초 한번은 그냥 그린다
// tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule) 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()
} }
} }
} }
@ -972,8 +974,14 @@ export function useModuleBasicSetting(tabNum) {
} }
} }
const maxRightEndPoint = surfaceMaxLines.right.x1 - 100 //최 우측 console.log('flowLines.top', flowLines.top)
const maxTopEndPoint = surfaceMaxLines.top.y1 - 50 //최 상단
if (flowLines.left.type === 'flat') {
startPoint = flowLines.top
}
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단 const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단
let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌 let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌
@ -1139,19 +1147,22 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
}) })
} else { } else {
//최초 한번은 그냥 그린다 //최초 한번은 그냥 그린다
//겹치는지 확인해서 포함된 모듈만 그린다 //겹치는지 확인해서 포함된 모듈만 그린다
// canvas?.add(tempModule) canvas?.add(tempModule)
// moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
// moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
} else { } else {
//디버깅용 //디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule) // canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }
@ -1242,6 +1253,7 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
}) })
} else { } else {
@ -1250,11 +1262,13 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
} else { } else {
//디버깅용 //디버깅용
// tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
// canvas?.add(tempModule) // canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }