가대 파라미터 생성 작업중

This commit is contained in:
hyojun.choi 2025-01-24 17:30:37 +09:00
parent 7e05602175
commit c8f126ee68
2 changed files with 531 additions and 103 deletions

View File

@ -174,6 +174,9 @@ export const SAVE_KEY = [
'turfPoints', 'turfPoints',
'tempIndex', 'tempIndex',
'surfaceId', 'surfaceId',
'moduleRowsTotCnt',
'seq',
'smartRackId',
] ]
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype] export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype]

View File

@ -3,6 +3,7 @@ import { canvasState } from '@/store/canvasAtom'
import { POLYGON_TYPE } from '@/common/common' import { POLYGON_TYPE } from '@/common/common'
import { moduleSelectionDataState } from '@/store/selectedModuleOptions' import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
import { getDegreeByChon, getTrestleLength } from '@/util/canvas-util' import { getDegreeByChon, getTrestleLength } from '@/util/canvas-util'
import { v4 as uuidv4 } from 'uuid'
// 회로 및 가대설정 // 회로 및 가대설정
export const useTrestle = () => { export const useTrestle = () => {
@ -33,14 +34,15 @@ export const useTrestle = () => {
alert('앞에서 셋팅 안됨') alert('앞에서 셋팅 안됨')
return return
} }
let isEaveBar = construction.setupCover
let moduleRowsTotCnt = 0
let isEaveBar = construction.setupCover
let isSnowGuard = construction.setupSnowCover let isSnowGuard = construction.setupSnowCover
const direction = parent.direction const direction = parent.direction
const rack = surface.trestleDetail.rack const rack = surface.trestleDetail.rack
let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail let { rackQty, rackIntvlPct, rackYn, cvrPlvrYn } = surface.trestleDetail
rackYn = 'N' // rackYn = 'N'
rackQty = 5 // rackQty = 5
cvrPlvrYn = 'Y' cvrPlvrYn = 'Y'
if (!rack) { if (!rack) {
@ -112,6 +114,7 @@ export const useTrestle = () => {
stroke: 'blue', stroke: 'blue',
strokeWidth: 4, strokeWidth: 4,
selectable: false, selectable: false,
surfaceId: surface.id,
parentId: module.id, parentId: module.id,
}) })
canvas.add(eaveBar) canvas.add(eaveBar)
@ -141,6 +144,7 @@ export const useTrestle = () => {
stroke: 'blue', stroke: 'blue',
strokeWidth: 4, strokeWidth: 4,
selectable: false, selectable: false,
surfaceId: surface.id,
parentId: module.id, parentId: module.id,
}) })
canvas.add(halfEaveBar) canvas.add(halfEaveBar)
@ -296,6 +300,8 @@ export const useTrestle = () => {
return rack.value.moduleRows === centerRows return rack.value.moduleRows === centerRows
})?.value.racks })?.value.racks
moduleRowsTotCnt = Math.max(leftRows, rightRows, centerRows)
if (rackYn === 'Y') { if (rackYn === 'Y') {
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn) drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
@ -356,7 +362,7 @@ export const useTrestle = () => {
const leftRacks = rackInfos.find((rack) => { const leftRacks = rackInfos.find((rack) => {
return rack.value.moduleRows === leftRows return rack.value.moduleRows === leftRows
})?.value.racks })?.value.racks
moduleRowsTotCnt = Math.max(leftRows, moduleRowsTotCnt)
if (rackYn === 'Y') { if (rackYn === 'Y') {
drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn) drawRacks(leftRacks, rackQty, rackIntvlPct, module, direction, 'L', rackYn)
} }
@ -409,6 +415,8 @@ export const useTrestle = () => {
const rightRacks = rackInfos.find((rack) => { const rightRacks = rackInfos.find((rack) => {
return rack.value.moduleRows === rightRows return rack.value.moduleRows === rightRows
})?.value.racks })?.value.racks
moduleRowsTotCnt = Math.max(rightRows, moduleRowsTotCnt)
// 해당 rack으로 그려준다. // 해당 rack으로 그려준다.
if (rackYn === 'Y') { if (rackYn === 'Y') {
drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn) drawRacks(rightRacks, rackQty, rackIntvlPct, module, direction, 'R', rackYn)
@ -417,12 +425,16 @@ export const useTrestle = () => {
module.set({ rightRows }) module.set({ rightRows })
}) })
surface.set({ moduleRowsTotCnt })
if (rackYn === 'N') { if (rackYn === 'N') {
// rack이 없을경우 // rack이 없을경우
installBracketWithOutRack(surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) installBracketWithOutRack(surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory)
} else if (rackYn === 'Y') { } else if (rackYn === 'Y') {
installBracket(surface) installBracket(surface)
} }
console.log(getTrestleParams(surface))
}) })
} }
@ -612,32 +624,69 @@ export const useTrestle = () => {
switch (direction) { switch (direction) {
case 'south': { case 'south': {
rackInfos.forEach((rackInfo) => { rackInfos.forEach((rackInfo) => {
const { rackLen, itemId, supFitQty, supFitIntvlPct } = rackInfo const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo
let rackLength = getTrestleLength(rackLen, degree) / 10
const rackLength = getTrestleLength(rackLen, degree) / 10 if (smartRackYn === 'Y') {
let smartRackId = uuidv4()
smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
rackLength = getTrestleLength(setRackTpLen, degree) / 10
if (setRackTpCd === 'RACK') {
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
name: 'smartRack',
stroke: 'blue',
strokeWidth: 4,
selectable: false,
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY - rackLength], { parentId: module.id,
name: 'rack', surfaceId: surface.id,
stroke: 'red', supFitQty,
strokeWidth: 4, supFitIntvlPct,
selectable: false, rackLen,
fill: 'red', rackRowsCd,
shadow: { seq,
color: 'black', // Outline color smartRackId,
blur: 10, rackId: itemId,
offsetX: 0, direction: 'top',
offsetY: 0, })
}, canvas.add(rack)
parentId: module.id, canvas.renderAll()
supFitQty, } else if (setRackTpCd === 'INTVL') {
supFitIntvlPct, startPointY -= rackLength + 8
rackLen, }
rackId: itemId, })
direction: 'top', } else {
}) const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY - rackLength], {
name: 'rack',
stroke: 'red',
strokeWidth: 4,
selectable: false,
fill: 'red',
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
supFitQty,
supFitIntvlPct,
rackLen,
rackRowsCd,
rackId: itemId,
direction: 'top',
})
canvas.add(rack) canvas.add(rack)
canvas.renderAll() canvas.renderAll()
}
startPointY -= rackLength + 8 startPointY -= rackLength + 8
}) })
@ -646,32 +695,68 @@ export const useTrestle = () => {
} }
case 'east': { case 'east': {
rackInfos.forEach((rackInfo) => { rackInfos.forEach((rackInfo) => {
const { rackLen, itemId, supFitQty, supFitIntvlPct } = rackInfo const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo
const rackLength = getTrestleLength(rackLen, degree) / 10 let rackLength = getTrestleLength(rackLen, degree) / 10
if (smartRackYn === 'Y') {
let smartRackId = uuidv4()
smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
rackLength = getTrestleLength(setRackTpLen, degree) / 10
if (setRackTpCd === 'RACK') {
const rack = new fabric.Line([startPointX, startPointY, startPointX - rackLength, startPointY], {
name: 'smartRack',
stroke: 'blue',
strokeWidth: 4,
selectable: false,
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
supFitQty,
supFitIntvlPct,
rackLen,
rackRowsCd,
seq,
smartRackId,
rackId: itemId,
direction: 'left',
})
canvas.add(rack)
canvas.renderAll()
} else if (setRackTpCd === 'INTVL') {
startPointX -= rackLength
}
})
} else {
const rack = new fabric.Line([startPointX, startPointY, startPointX - rackLength, startPointY], {
name: 'rack',
stroke: 'red',
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
strokeWidth: 4,
selectable: false,
supFitQty,
supFitIntvlPct,
rackLen,
rackYn,
rackRowsCd,
rackId: itemId,
direction: 'left',
})
const rack = new fabric.Line([startPointX, startPointY, startPointX - rackLength, startPointY], { canvas.add(rack)
name: 'rack', canvas.renderAll()
stroke: 'red', }
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
strokeWidth: 4,
selectable: false,
supFitQty,
supFitIntvlPct,
rackLen,
rackYn,
rackId: itemId,
direction: 'left',
})
canvas.add(rack)
canvas.renderAll()
startPointX -= rackLength + 8 startPointX -= rackLength + 8
}) })
@ -680,31 +765,66 @@ export const useTrestle = () => {
case 'west': { case 'west': {
rackInfos.forEach((rackInfo) => { rackInfos.forEach((rackInfo) => {
const { rackLen, itemId, supFitQty, supFitIntvlPct } = rackInfo const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo
let rackLength = getTrestleLength(rackLen, degree) / 10
if (smartRackYn === 'Y') {
let smartRackId = uuidv4()
smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
rackLength = getTrestleLength(setRackTpLen, degree) / 10
if (setRackTpCd === 'RACK') {
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
name: 'smartRack',
stroke: 'blue',
strokeWidth: 4,
selectable: false,
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
supFitQty,
supFitIntvlPct,
rackLen,
rackRowsCd,
seq,
smartRackId,
rackId: itemId,
direction: 'right',
})
canvas.add(rack)
canvas.renderAll()
} else if (setRackTpCd === 'INTVL') {
startPointX += rackLength + 8
}
})
} else {
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
name: 'rack',
stroke: 'red',
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
strokeWidth: 4,
selectable: false,
supFitQty,
supFitIntvlPct,
rackLen,
rackRowsCd,
rackId: itemId,
direction: 'right',
})
const rackLength = getTrestleLength(rackLen, degree) / 10 canvas.add(rack)
canvas.renderAll()
const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], { }
name: 'rack',
stroke: 'red',
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
strokeWidth: 4,
selectable: false,
supFitQty,
supFitIntvlPct,
rackLen,
rackId: itemId,
direction: 'right',
})
canvas.add(rack)
canvas.renderAll()
startPointX += rackLength + 8 startPointX += rackLength + 8
}) })
@ -712,32 +832,66 @@ export const useTrestle = () => {
} }
case 'north': { case 'north': {
rackInfos.forEach((rackInfo) => { rackInfos.forEach((rackInfo) => {
const { rackLen, itemId, supFitQty, supFitIntvlPct } = rackInfo const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo
let rackLength = getTrestleLength(rackLen, degree) / 10
const rackLength = getTrestleLength(rackLen, degree) / 10 if (smartRackYn === 'Y') {
let smartRackId = uuidv4()
const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY + rackLength], { smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => {
name: 'rack', rackLength = getTrestleLength(setRackTpLen, degree) / 10
stroke: 'red', if (setRackTpCd === 'RACK') {
shadow: { const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], {
color: 'black', // Outline color name: 'smartRack',
blur: 10, stroke: 'blue',
offsetX: 0, strokeWidth: 4,
offsetY: 0, selectable: false,
}, shadow: {
parentId: module.id, color: 'black', // Outline color
strokeWidth: 4, blur: 10,
selectable: false, offsetX: 0,
supFitQty, offsetY: 0,
supFitIntvlPct, },
rackLen, parentId: module.id,
rackId: itemId, surfaceId: surface.id,
direction: 'bottom', supFitQty,
}) supFitIntvlPct,
rackLen,
canvas.add(rack) rackRowsCd,
canvas.renderAll() seq,
smartRackId,
rackId: itemId,
direction: 'right',
})
canvas.add(rack)
canvas.renderAll()
} else if (setRackTpCd === 'INTVL') {
startPointY += rackLength + 8
}
})
} else {
const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY + rackLength], {
name: 'rack',
stroke: 'red',
shadow: {
color: 'black', // Outline color
blur: 10,
offsetX: 0,
offsetY: 0,
},
parentId: module.id,
surfaceId: surface.id,
strokeWidth: 4,
selectable: false,
supFitQty,
supFitIntvlPct,
rackLen,
rackRowsCd,
rackId: itemId,
direction: 'bottom',
})
canvas.add(rack)
canvas.renderAll()
}
startPointY += rackLength + 8 startPointY += rackLength + 8
}) })
break break
@ -777,6 +931,7 @@ export const useTrestle = () => {
fill: 'green', fill: 'green',
name: 'bracket', name: 'bracket',
parentId: rack.parentId, parentId: rack.parentId,
surfaceId: surface.id,
width: bracketLength, width: bracketLength,
height: bracketLength, height: bracketLength,
selectable: false, selectable: false,
@ -795,6 +950,7 @@ export const useTrestle = () => {
fill: 'green', fill: 'green',
name: 'bracket', name: 'bracket',
parentId: rack.parentId, parentId: rack.parentId,
surfaceId: surface.id,
width: bracketLength, width: bracketLength,
height: bracketLength, height: bracketLength,
selectable: false, selectable: false,
@ -812,6 +968,7 @@ export const useTrestle = () => {
top: y2 - bracketLength / 3, top: y2 - bracketLength / 3,
fill: 'green', fill: 'green',
parentId: rack.parentId, parentId: rack.parentId,
surfaceId: surface.id,
name: 'bracket', name: 'bracket',
width: bracketLength, width: bracketLength,
height: bracketLength, height: bracketLength,
@ -831,6 +988,7 @@ export const useTrestle = () => {
fill: 'green', fill: 'green',
name: 'bracket', name: 'bracket',
parentId: rack.parentId, parentId: rack.parentId,
surfaceId: surface.id,
width: bracketLength, width: bracketLength,
height: bracketLength, height: bracketLength,
selectable: false, selectable: false,
@ -845,9 +1003,10 @@ export const useTrestle = () => {
//랙 없음 인 경우 지지금구 설치 //랙 없음 인 경우 지지금구 설치
const installBracketWithOutRack = (surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) => { const installBracketWithOutRack = (surface, exposedBottomModules, leftExposedHalfBottomModules, rightExposedHalfBottomPoints, isChidory) => {
let { rackQty, rackIntvlPct, moduleIntvlHor, moduleIntvlVer } = surface.trestleDetail let { rackQty, rackIntvlPct, moduleIntvlHor, moduleIntvlVer, lessSupFitQty, lessSupFitIntvlPct } = surface.trestleDetail
const direction = surface.direction const direction = surface.direction
rackQty = 3 rackQty = lessSupFitQty
rackIntvlPct = lessSupFitIntvlPct
canvas.renderAll() canvas.renderAll()
exposedBottomModules.forEach((module) => { exposedBottomModules.forEach((module) => {
@ -990,6 +1149,7 @@ export const useTrestle = () => {
fill: 'green', fill: 'green',
name: 'bracket', name: 'bracket',
parentId: module.id, parentId: module.id,
surfaceId: module.surfaceId,
width: 10, width: 10,
height: 10, height: 10,
selectable: false, selectable: false,
@ -1318,5 +1478,270 @@ export const useTrestle = () => {
return groups return groups
} }
return { apply } const getTrestleParams = (surface) => {
const result = calculateForApi(surface)
const eaveBar = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'eaveBar')
const halfEaveBar = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'halfEaveBar')
const rackList = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'rack')
const smartRackList = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'smartRack')
// smartRackList을 smartRackId 기준으로 그룹화 한 배열
const smartRackGroup = smartRackList.reduce((acc, cur) => {
if (!acc[cur.smartRackId]) {
acc[cur.smartRackId] = []
}
acc[cur.smartRackId].push(cur)
return acc
}, {})
const bracketList = canvas.getObjects().filter((obj) => obj.surfaceId === surface.id && obj.name === 'bracket')
let rackParams = rackList.map((rack, index) => {
return {
seq: index,
rackId: rack.rackId,
rackFittingCnt: rack.supFitQty,
rackRows: rack.rackRowsCd,
}
})
return {
exposedLowerBottomTotCnt: result.exposedBottom, // 노출 최하면 갯수
exposedHalfBottomTotCnt: result.exposedHalfBottom, // 노출 반하면 갯수
exposedTopTotCnt: result.exposedTop, // 노출 상면 총 수
exposedHalfTopTotCnt: result.exposedHalfTop, // 노출 반상면 총 수
exposedBottomTotCnt: result.exposedBottomPoints.length, // 노출 하면 수
touchedSurfaceTotCnt: result.touchDimension, // 접면 총 수
touchedHalfSurfaceTotCnt: result.halfTouchDimension, // 반접면 총 수
moduleRowsTotCnt: surface.moduleRowsTotCnt, // 모듈 총 단 수
eavesTotCnt: eaveBar.length,
eavesHalfTotCnt: halfEaveBar.length,
racks: rackParams,
rackTotCnt: rackList.length + smartRackGroup.length,
rackFittingCnt: bracketList.length,
moduleRows: getMostLeftModules(surface),
}
}
// 가장 왼쪽에 있는 모듈을 기준으로 같은 단에 있는 모듈들 파라미터 생성
const getMostLeftModules = (surface) => {
const { direction, modules } = surface
const parent = canvas.getObjects().find((obj) => obj.id === surface.parentId)
const roofMaterialIndex = parent.roofMaterial.index
const construction = moduleSelectionData?.roofConstructions?.find((construction) => construction.roofIndex === roofMaterialIndex).construction
let isEaveBar = construction.setupCover
let isSnowGuard = construction.setupSnowCover
let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail
cvrPlvrYn = 'Y'
if (rackYn === 'N') {
rackQty = lessSupFitQty
}
// 같은 단에 있는 모듈들의 리스트
let sameLineModuleList = []
let result = []
if (direction === 'south') {
// 모듈의 top으로 groupBy
const groupedByTop = modules.reduce((acc, module) => {
const key = module.top
if (!acc[key]) {
acc[key] = []
}
acc[key].push(module)
return acc
}, {})
// groupedByTop의 키값을 기준으로 정렬한 데이터를 배열로 변환
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => b[0].top - a[0].top)
} else if (direction === 'north') {
const groupedByTop = modules.reduce((acc, module) => {
const key = module.top
if (!acc[key]) {
acc[key] = []
}
acc[key].push(module)
return acc
}, {})
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => a[0].top - b[0].top)
} else if (direction === 'east') {
const groupedByLeft = modules.reduce((acc, module) => {
const key = module.left
if (!acc[key]) {
acc[key] = []
}
acc[key].push(module)
return acc
}, {})
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left)
} else if (direction === 'west') {
const groupedByLeft = modules.reduce((acc, module) => {
const key = module.left
if (!acc[key]) {
acc[key] = []
}
acc[key].push(module)
return acc
}, {})
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => b[0].left - a[0].left)
}
sameLineModuleList.forEach((modules, index) => {
const moduleRowResultData = {
seq: index,
moduleItemId: modules[0].moduleInfo.itemId,
moduleTpCd: modules[0].moduleInfo.itemTp,
moduleCnt: modules.length,
exposedBottomCnt: 0,
exposedHalfBottomCnt: 0,
exposedTopCnt: 0,
exposedHalfTopCnt: 0,
touchedSurfaceCnt: 0,
touchedHalfSurfaceCnt: 0,
exposedBottomBracketCnt: 0,
exposedHalfBottomBracketCnt: 0,
exposedTopBracketCnt: 0,
exposedHalfTopBracketCnt: 0,
touchedSurfaceBracketCnt: 0,
touchedHalfSurfaceBracketCnt: 0,
eavesCnt: 0,
eavesHalfCnt: 0,
exposedSideEavesCnt: 0,
}
if (direction === 'south') {
modules.sort((a, b) => a.left - b.left)
} else if (direction === 'north') {
modules.sort((a, b) => b.left - a.left)
} else if (direction === 'east') {
modules.sort((a, b) => a.top - b.top)
} else if (direction === 'west') {
modules.sort((a, b) => b.top - a.top)
}
// 모듈 하면,최하면 등 구해야함
modules.forEach((module, index) => {
// 해당 모듈 주변에 다른 모듈이 있는지 확인
let { bottomModule, topModule, bottomLeftModule, bottomRightModule, topLeftModule, topRightModule } = findSideModule(module, surface)
if (bottomModule) {
moduleRowResultData.touchedSurfaceCnt++
}
if (!bottomModule) {
if (bottomLeftModule && bottomRightModule) {
moduleRowResultData.touchedSurfaceCnt++
} else if ((bottomLeftModule && !bottomRightModule) || (!bottomLeftModule && bottomRightModule)) {
moduleRowResultData.touchedHalfSurfaceCnt++
moduleRowResultData.exposedHalfBottomCnt++
if (cvrPlvrYn === 'Y') {
moduleRowResultData.eavesHalfCnt++
}
} else {
moduleRowResultData.exposedBottomCnt++
if (isEaveBar) {
moduleRowResultData.eavesCnt++
}
}
}
if (!topModule) {
if ((topLeftModule && !topRightModule) || (!topLeftModule && topRightModule)) {
moduleRowResultData.exposedHalfTopCnt++
} else if (!topLeftModule && !topRightModule) {
moduleRowResultData.exposedTopCnt++
}
}
})
result.push(moduleRowResultData)
})
if (isEaveBar) {
}
return result
}
// 해당 모듈이 해당 설치면에서 상하좌우, 대각선에 있는지 확인
const findSideModule = (module, surface) => {
const { direction, modules } = surface
let { rackYn, cvrPlvrYn, moduleIntvlHor, moduleIntvlVer, rackQty, lessSupFitQty } = surface.trestleDetail
const centerPoints = modules.map((module) => {
return module.getCenterPoint()
})
const horizontal = ['south', 'north'].includes(direction) ? moduleIntvlHor : moduleIntvlVer
const vertical = ['south', 'north'].includes(direction) ? moduleIntvlVer : moduleIntvlHor
const maxX = 2 + horizontal * 3
const maxY = 2 + vertical * 3
let { width, height } = { ...module }
let { x, y } = { ...module.getCenterPoint() }
let bottomLeftPoint
let bottomRightPoint
let topLeftPoint
let topRightPoint
let bottomModule
let topModule
let bottomLeftModule
let bottomRightModule
let topLeftModule
let topRightModule
switch (direction) {
case 'south':
width = width + horizontal
height = height + vertical
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
bottomLeftPoint = { x: x - width / 2, y: y + height }
bottomRightPoint = { x: x + width / 2, y: y + height }
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
topLeftPoint = { x: x - width / 2, y: y - height }
topRightPoint = { x: x + width / 2, y: y - height }
break
case 'north':
width = width + horizontal
height = height + vertical
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
bottomLeftPoint = { x: x + width / 2, y: y - height }
bottomRightPoint = { x: x - width / 2, y: y - height }
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
topLeftPoint = { x: x + width / 2, y: y + height }
topRightPoint = { x: x - width / 2, y: y + height }
break
case 'east':
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
width = width + horizontal
bottomLeftPoint = { x: x + width, y: y + height / 2 }
bottomRightPoint = { x: x + width, y: y - height / 2 }
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
topLeftPoint = { x: x - width, y: y + height / 2 }
topRightPoint = { x: x - width, y: y - height / 2 }
break
case 'west':
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
width = width + horizontal
bottomLeftPoint = { x: x - width, y: y - height / 2 }
bottomRightPoint = { x: x - width, y: y + height / 2 }
topLeftPoint = { x: x + width, y: y - height / 2 }
topRightPoint = { x: x + width, y: y + height / 2 }
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
break
}
topLeftModule = centerPoints.find(
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
)
topRightModule = centerPoints.find(
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
)
bottomLeftModule = centerPoints.find(
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
)
bottomRightModule = centerPoints.find(
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
)
return { bottomModule, topModule, bottomLeftModule, bottomRightModule, topLeftModule, topRightModule }
}
return { apply, getTrestleParams }
} }