견적서 item 멀티모듈 대응 추가
This commit is contained in:
parent
c253cfe07e
commit
4e1b7cc010
@ -359,8 +359,8 @@ export const useTrestle = () => {
|
|||||||
return (
|
return (
|
||||||
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
rack.value.moduleTpRows1 === leftRowsInfo.rowsInfo[0].count &&
|
Number(rack.value.moduleTpRows1) === leftRowsInfo.rowsInfo[0].count &&
|
||||||
rack.value.moduleTpRows2 === leftRowsInfo.rowsInfo[1].count
|
Number(rack.value.moduleTpRows2) === leftRowsInfo.rowsInfo[1].count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
@ -376,8 +376,8 @@ export const useTrestle = () => {
|
|||||||
return (
|
return (
|
||||||
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
rack.value.moduleTpRows1 === rightRowsInfo.rowsInfo[0].count &&
|
Number(rack.value.moduleTpRows1) === rightRowsInfo.rowsInfo[0].count &&
|
||||||
rack.value.moduleTpRows2 === rightRowsInfo.rowsInfo[1].count
|
Number(rack.value.moduleTpRows2) === rightRowsInfo.rowsInfo[1].count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
@ -393,8 +393,8 @@ export const useTrestle = () => {
|
|||||||
return (
|
return (
|
||||||
rack.value.moduleTpCd === centerRowsInfo.moduleTotalTp &&
|
rack.value.moduleTpCd === centerRowsInfo.moduleTotalTp &&
|
||||||
rack.value.moduleRows === centerRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
rack.value.moduleRows === centerRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
rack.value.moduleTpRows1 === centerRowsInfo.rowsInfo[0].count &&
|
Number(rack.value.moduleTpRows1) === centerRowsInfo.rowsInfo[0].count &&
|
||||||
rack.value.moduleTpRows2 === centerRowsInfo.rowsInfo[1].count
|
Number(rack.value.moduleTpRows2) === centerRowsInfo.rowsInfo[1].count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
@ -488,8 +488,8 @@ export const useTrestle = () => {
|
|||||||
return (
|
return (
|
||||||
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
rack.value.moduleTpCd === leftRowsInfo.moduleTotalTp &&
|
||||||
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
rack.value.moduleRows === leftRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
rack.value.moduleTpRows1 === leftRowsInfo.rowsInfo[0].count &&
|
Number(rack.value.moduleTpRows1) === leftRowsInfo.rowsInfo[0].count &&
|
||||||
rack.value.moduleTpRows2 === leftRowsInfo.rowsInfo[1].count
|
Number(rack.value.moduleTpRows2) === leftRowsInfo.rowsInfo[1].count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
@ -564,8 +564,8 @@ export const useTrestle = () => {
|
|||||||
return (
|
return (
|
||||||
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
rack.value.moduleTpCd === rightRowsInfo.moduleTotalTp &&
|
||||||
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
rack.value.moduleRows === rightRowsInfo.rowsInfo.reduce((acc, row) => acc + row.count, 0) &&
|
||||||
rack.value.moduleTpRows1 === rightRowsInfo.rowsInfo[0].count &&
|
Number(rack.value.moduleTpRows1) === rightRowsInfo.rowsInfo[0].count &&
|
||||||
rack.value.moduleTpRows2 === rightRowsInfo.rowsInfo[1].count
|
Number(rack.value.moduleTpRows2) === rightRowsInfo.rowsInfo[1].count
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})?.value.racks
|
})?.value.racks
|
||||||
@ -743,19 +743,32 @@ export const useTrestle = () => {
|
|||||||
let result
|
let result
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south': {
|
case 'south': {
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
heightArr.forEach((height) => {
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'north': {
|
case 'north': {
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
heightArr.forEach((height) => {
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'east': {
|
case 'east': {
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((width) => {
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'west': {
|
case 'west': {
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((width) => {
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -779,27 +792,47 @@ export const useTrestle = () => {
|
|||||||
case 'south': {
|
case 'south': {
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
topLeftPoint = { x: x - width / 2, y: y - height }
|
heightArr.forEach((h) => {
|
||||||
|
topLeftPoint = { x: x - width / 2, y: y - h }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y))
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'north': {
|
case 'north': {
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
topLeftPoint = { x: x + width / 2, y: y + height }
|
heightArr.forEach((h) => {
|
||||||
|
topLeftPoint = { x: x + width / 2, y: y + h }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y))
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'east': {
|
case 'east': {
|
||||||
topLeftPoint = { x: x - width, y: y + height / 2 }
|
widthArr.forEach((w) => {
|
||||||
|
topLeftPoint = { x: x - w, y: y + height / 2 }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'west': {
|
case 'west': {
|
||||||
topLeftPoint = { x: x + width, y: y - height / 2 }
|
widthArr.forEach((w) => {
|
||||||
|
topLeftPoint = { x: x + w, y: y - height / 2 }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
const findNextRightModule = (currentPoint, centerPoints, direction) => {
|
const findNextRightModule = (currentPoint, centerPoints, direction) => {
|
||||||
@ -816,25 +849,44 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south': {
|
case 'south': {
|
||||||
topRightPoint = { x: x + width / 2, y: y - height }
|
heightArr.forEach((h) => {
|
||||||
|
topRightPoint = { x: x + width / 2, y: y - h }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y))
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'north': {
|
case 'north': {
|
||||||
topRightPoint = { x: x - width / 2, y: y + height }
|
heightArr.forEach((h) => {
|
||||||
|
topRightPoint = { x: x - width / 2, y: y + h }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y))
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'east': {
|
case 'east': {
|
||||||
topRightPoint = { x: x - width, y: y - height / 2 }
|
widthArr.forEach((w) => {
|
||||||
|
topRightPoint = { x: x + w, y: y + height / 2 }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'west': {
|
case 'west': {
|
||||||
topRightPoint = { x: x + width, y: y + height / 2 }
|
widthArr.forEach((w) => {
|
||||||
|
topRightPoint = { x: x - w, y: y - height / 2 }
|
||||||
|
if (result) return
|
||||||
|
result = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1575,8 +1627,13 @@ export const useTrestle = () => {
|
|||||||
//widthArr 중복 제거 1이상 차이가 나지 않으면 같은 너비로 간주
|
//widthArr 중복 제거 1이상 차이가 나지 않으면 같은 너비로 간주
|
||||||
widthArr = removeCloseValues(Array.from(new Set(widthArr)))
|
widthArr = removeCloseValues(Array.from(new Set(widthArr)))
|
||||||
heightArr = removeCloseValues(Array.from(new Set(heightArr)))
|
heightArr = removeCloseValues(Array.from(new Set(heightArr)))
|
||||||
|
const widthAvg = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length
|
||||||
|
const heightAvg = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length
|
||||||
|
widthArr.push(widthAvg)
|
||||||
|
heightArr.push(heightAvg)
|
||||||
centerPoints.forEach((centerPoint, index) => {
|
centerPoints.forEach((centerPoint, index) => {
|
||||||
|
// widthArr의 평균값을 추가한다.
|
||||||
|
|
||||||
centerPoint.widthArr = [...widthArr]
|
centerPoint.widthArr = [...widthArr]
|
||||||
|
|
||||||
centerPoint.heightArr = [...heightArr]
|
centerPoint.heightArr = [...heightArr]
|
||||||
@ -1610,8 +1667,8 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
const vertical = ['south', 'north'].includes(direction) ? moduleSurface.trestleDetail.moduleIntvlVer : moduleSurface.trestleDetail.moduleIntvlHor
|
const vertical = ['south', 'north'].includes(direction) ? moduleSurface.trestleDetail.moduleIntvlVer : moduleSurface.trestleDetail.moduleIntvlHor
|
||||||
|
|
||||||
const maxX = 2 + horizontal * 3
|
const maxX = 2 + (horizontal / 10) * 3
|
||||||
const maxY = 2 + vertical * 3
|
const maxY = 2 + (vertical / 10) * 3
|
||||||
|
|
||||||
if (centerPoints.length === 0) return
|
if (centerPoints.length === 0) return
|
||||||
|
|
||||||
@ -1643,50 +1700,97 @@ export const useTrestle = () => {
|
|||||||
let bottomCell
|
let bottomCell
|
||||||
let bottomLeftPoint
|
let bottomLeftPoint
|
||||||
let bottomRightPoint
|
let bottomRightPoint
|
||||||
let leftBottomCnt
|
let leftBottomCnt = 0
|
||||||
let rightBottomCnt
|
let rightBottomCnt = 0
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south':
|
case 'south':
|
||||||
//widthArr의 값을 전부 더한 후 widthArr의 길이로 나누어 평균값을 구한다.
|
//widthArr의 값을 전부 더한 후 widthArr의 길이로 나누어 평균값을 구한다.
|
||||||
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
bottomLeftPoint = { x: x - width / 2, y: y + height }
|
if (bottomCell) return
|
||||||
bottomRightPoint = { x: x + width / 2, y: y + height }
|
bottomCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY)
|
||||||
|
if (leftBottomCnt === 0) {
|
||||||
|
bottomLeftPoint = { x: x - width / 2, y: y + h }
|
||||||
|
leftBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightBottomCnt === 0) {
|
||||||
|
bottomRightPoint = { x: x + width / 2, y: y + h }
|
||||||
|
rightBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'north':
|
case 'north':
|
||||||
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
||||||
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
height = heightArr.reduce((acc, num) => acc + num, 0) / heightArr.length + vertical
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
bottomLeftPoint = { x: x + width / 2, y: y - height }
|
if (bottomCell) return
|
||||||
bottomRightPoint = { x: x - width / 2, y: y - height }
|
bottomCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY)
|
||||||
|
if (leftBottomCnt === 0) {
|
||||||
|
bottomLeftPoint = { x: x + width / 2, y: y - h }
|
||||||
|
leftBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightBottomCnt === 0) {
|
||||||
|
bottomRightPoint = { x: x - width / 2, y: y - h }
|
||||||
|
rightBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'east':
|
case 'east':
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
if (bottomCell) return
|
||||||
bottomLeftPoint = { x: x + width, y: y + height / 2 }
|
bottomCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
bottomRightPoint = { x: x + width, y: y - height / 2 }
|
if (leftBottomCnt === 0) {
|
||||||
|
bottomLeftPoint = { x: x + w, y: y + height / 2 }
|
||||||
|
leftBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightBottomCnt === 0) {
|
||||||
|
bottomRightPoint = { x: x + w, y: y - height / 2 }
|
||||||
|
rightBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'west':
|
case 'west':
|
||||||
bottomCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
width = widthArr.reduce((acc, num) => acc + num, 0) / widthArr.length + horizontal
|
if (bottomCell) return
|
||||||
bottomLeftPoint = { x: x - width, y: y - height / 2 }
|
bottomCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
bottomRightPoint = { x: x - width, y: y + height / 2 }
|
if (leftBottomCnt === 0) {
|
||||||
|
bottomLeftPoint = { x: x - w, y: y - height / 2 }
|
||||||
|
leftBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightBottomCnt === 0) {
|
||||||
|
bottomRightPoint = { x: x - w, y: y + height / 2 }
|
||||||
|
rightBottomCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bottomCell.length === 1) {
|
if (bottomCell) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 바로 아래에 셀이 없는 경우 물떼세 배치가 왼쪽 되어있는 셀을 찾는다.
|
// 바로 아래에 셀이 없는 경우 물떼세 배치가 왼쪽 되어있는 셀을 찾는다.
|
||||||
leftBottomCnt = centerPoints.filter(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
|
||||||
).length
|
|
||||||
rightBottomCnt = centerPoints.filter(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
|
||||||
).length
|
|
||||||
|
|
||||||
if (leftBottomCnt + rightBottomCnt === 1) {
|
if (leftBottomCnt + rightBottomCnt === 1) {
|
||||||
exposedHalfBottom++
|
exposedHalfBottom++
|
||||||
@ -1703,54 +1807,100 @@ export const useTrestle = () => {
|
|||||||
// 노출상면 및 접면 체크
|
// 노출상면 및 접면 체크
|
||||||
|
|
||||||
centerPoints.forEach((centerPoint, index) => {
|
centerPoints.forEach((centerPoint, index) => {
|
||||||
let { x, y, width, height } = { ...centerPoint }
|
let { x, y, width, height, widthArr, heightArr } = { ...centerPoint }
|
||||||
|
|
||||||
let topCell
|
let topCell
|
||||||
let topLeftPoint
|
let topLeftPoint
|
||||||
let topRightPoint
|
let topRightPoint
|
||||||
let leftTopCnt
|
let leftTopCnt = 0
|
||||||
let rightTopCnt
|
let rightTopCnt = 0
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south':
|
case 'south':
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
topLeftPoint = { x: x - width / 2, y: y - height }
|
if (topCell) return
|
||||||
topRightPoint = { x: x + width / 2, y: y - height }
|
topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY)
|
||||||
|
if (leftTopCnt === 0) {
|
||||||
|
topLeftPoint = { x: x - width / 2, y: y - h }
|
||||||
|
leftTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightTopCnt === 0) {
|
||||||
|
topRightPoint = { x: x + width / 2, y: y - h }
|
||||||
|
rightTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'north':
|
case 'north':
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
topLeftPoint = { x: x + width / 2, y: y + height }
|
if (topCell) return
|
||||||
topRightPoint = { x: x - width / 2, y: y + height }
|
topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY)
|
||||||
|
if (leftTopCnt === 0) {
|
||||||
|
topLeftPoint = { x: x + width / 2, y: y + h }
|
||||||
|
leftTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightTopCnt === 0) {
|
||||||
|
topRightPoint = { x: x - width / 2, y: y + h }
|
||||||
|
rightTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'east':
|
case 'east':
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
topLeftPoint = { x: x - width, y: y + height / 2 }
|
if (topCell) return
|
||||||
topRightPoint = { x: x - width, y: y - height / 2 }
|
topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
|
if (leftTopCnt === 0) {
|
||||||
|
topLeftPoint = { x: x - w, y: y + height / 2 }
|
||||||
|
leftTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rightTopCnt === 0) {
|
||||||
|
topRightPoint = { x: x - w, y: y - height / 2 }
|
||||||
|
rightTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'west':
|
case 'west':
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
topCell = centerPoints.filter((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
topLeftPoint = { x: x + width, y: y - height / 2 }
|
if (topCell) return
|
||||||
topRightPoint = { x: x + width, y: y + height / 2 }
|
topCell = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
|
if (leftTopCnt === 0) {
|
||||||
|
topLeftPoint = { x: x + w, y: y - height / 2 }
|
||||||
|
leftTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
if (rightTopCnt === 0) {
|
||||||
|
topRightPoint = { x: x + w, y: y + height / 2 }
|
||||||
|
rightTopCnt = centerPoints.filter(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
||||||
|
).length
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (topCell.length === 1) {
|
if (topCell) {
|
||||||
touchDimension++
|
touchDimension++
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
leftTopCnt = centerPoints.filter(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < maxX && Math.abs(centerPoint.y - topLeftPoint.y) < maxY,
|
|
||||||
).length
|
|
||||||
rightTopCnt = centerPoints.filter(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < maxX && Math.abs(centerPoint.y - topRightPoint.y) < maxY,
|
|
||||||
).length
|
|
||||||
|
|
||||||
if (leftTopCnt + rightTopCnt === 2) {
|
if (leftTopCnt + rightTopCnt === 2) {
|
||||||
touchDimension++
|
touchDimension++
|
||||||
return
|
return
|
||||||
@ -1981,6 +2131,34 @@ export const useTrestle = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 키값의 차이가 2이하인 경우 한개로 합침
|
||||||
|
function mergeCloseKeys(data) {
|
||||||
|
// 키 값을 숫자로 변환 후 정렬
|
||||||
|
const keys = Object.keys(data)
|
||||||
|
.map(parseFloat)
|
||||||
|
.sort((a, b) => a - b)
|
||||||
|
const result = {}
|
||||||
|
|
||||||
|
let baseKey = keys[0]
|
||||||
|
result[baseKey.toString()] = [...data[baseKey.toString()]]
|
||||||
|
|
||||||
|
for (let i = 1; i < keys.length; i++) {
|
||||||
|
const currentKey = keys[i]
|
||||||
|
const prevKey = baseKey
|
||||||
|
|
||||||
|
if (Math.abs(currentKey - prevKey) <= 2) {
|
||||||
|
// 키 차이가 2 이하인 경우 병합
|
||||||
|
result[baseKey.toString()].push(...data[currentKey.toString()])
|
||||||
|
} else {
|
||||||
|
// 새로운 그룹 시작
|
||||||
|
baseKey = currentKey
|
||||||
|
result[baseKey.toString()] = [...data[currentKey.toString()]]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
// 가장 왼쪽에 있는 모듈을 기준으로 같은 단에 있는 모듈들 파라미터 생성
|
// 가장 왼쪽에 있는 모듈을 기준으로 같은 단에 있는 모듈들 파라미터 생성
|
||||||
const getMostLeftModules = (surface, exposedBottomModules) => {
|
const getMostLeftModules = (surface, exposedBottomModules) => {
|
||||||
const { direction, modules, isChidory } = surface
|
const { direction, modules, isChidory } = surface
|
||||||
@ -2001,7 +2179,7 @@ export const useTrestle = () => {
|
|||||||
|
|
||||||
if (direction === 'south') {
|
if (direction === 'south') {
|
||||||
// 모듈의 top으로 groupBy
|
// 모듈의 top으로 groupBy
|
||||||
const groupedByTop = modules.reduce((acc, module) => {
|
let groupedByTop = modules.reduce((acc, module) => {
|
||||||
const key = module.top
|
const key = module.top
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = []
|
acc[key] = []
|
||||||
@ -2009,10 +2187,11 @@ export const useTrestle = () => {
|
|||||||
acc[key].push(module)
|
acc[key].push(module)
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
groupedByTop = mergeCloseKeys(groupedByTop)
|
||||||
// groupedByTop의 키값을 기준으로 정렬한 데이터를 배열로 변환
|
// groupedByTop의 키값을 기준으로 정렬한 데이터를 배열로 변환
|
||||||
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => b[0].top - a[0].top)
|
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => b[0].top - a[0].top)
|
||||||
} else if (direction === 'north') {
|
} else if (direction === 'north') {
|
||||||
const groupedByTop = modules.reduce((acc, module) => {
|
let groupedByTop = modules.reduce((acc, module) => {
|
||||||
const key = module.top
|
const key = module.top
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = []
|
acc[key] = []
|
||||||
@ -2020,9 +2199,10 @@ export const useTrestle = () => {
|
|||||||
acc[key].push(module)
|
acc[key].push(module)
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
groupedByTop = mergeCloseKeys(groupedByTop)
|
||||||
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => a[0].top - b[0].top)
|
sameLineModuleList = Object.values(groupedByTop).sort((a, b) => a[0].top - b[0].top)
|
||||||
} else if (direction === 'east') {
|
} else if (direction === 'east') {
|
||||||
const groupedByLeft = modules.reduce((acc, module) => {
|
let groupedByLeft = modules.reduce((acc, module) => {
|
||||||
const key = module.left
|
const key = module.left
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = []
|
acc[key] = []
|
||||||
@ -2030,9 +2210,10 @@ export const useTrestle = () => {
|
|||||||
acc[key].push(module)
|
acc[key].push(module)
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
groupedByLeft = mergeCloseKeys(groupedByLeft)
|
||||||
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => b[0].left - a[0].left)
|
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => b[0].left - a[0].left)
|
||||||
} else if (direction === 'west') {
|
} else if (direction === 'west') {
|
||||||
const groupedByLeft = modules.reduce((acc, module) => {
|
let groupedByLeft = modules.reduce((acc, module) => {
|
||||||
const key = module.left
|
const key = module.left
|
||||||
if (!acc[key]) {
|
if (!acc[key]) {
|
||||||
acc[key] = []
|
acc[key] = []
|
||||||
@ -2040,6 +2221,8 @@ export const useTrestle = () => {
|
|||||||
acc[key].push(module)
|
acc[key].push(module)
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
//groupedByLeft의 키값의 차이가 2이하인 경우 같은 라인으로 합친다.
|
||||||
|
groupedByLeft = mergeCloseKeys(groupedByLeft)
|
||||||
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left)
|
sameLineModuleList = Object.values(groupedByLeft).sort((a, b) => a[0].left - b[0].left)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2219,80 +2402,243 @@ export const useTrestle = () => {
|
|||||||
case 'south':
|
case 'south':
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
halfBottomLeftPoint = { x: x - width / 2, y: y + height }
|
if (!bottomModule) {
|
||||||
halfBottomRightPoint = { x: x + width / 2, y: y + height }
|
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY)
|
||||||
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
}
|
||||||
halfTopLeftPoint = { x: x - width / 2, y: y - height }
|
if (!topModule) {
|
||||||
halfTopRightPoint = { x: x + width / 2, y: y - height }
|
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY)
|
||||||
leftPoint = { x: x - width, y: y }
|
}
|
||||||
rightPoint = { x: x + width, y: y }
|
if (!halfBottomLeftModule) {
|
||||||
bottomLeftModule = { x: x - width, y: y + height }
|
halfBottomLeftPoint = { x: x - width / 2, y: y + h }
|
||||||
bottomRightModule = { x: x + width, y: y + height }
|
halfBottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfBottomRightModule) {
|
||||||
|
halfBottomRightPoint = { x: x + width / 2, y: y + h }
|
||||||
|
halfBottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopLeftModule) {
|
||||||
|
halfTopLeftPoint = { x: x - width / 2, y: y - h }
|
||||||
|
halfTopLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopRightModule) {
|
||||||
|
halfTopRightPoint = { x: x + width / 2, y: y - h }
|
||||||
|
halfTopRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (leftModule) {
|
||||||
|
leftPoint = { x: x - width, y: y }
|
||||||
|
leftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (rightModule) {
|
||||||
|
rightPoint = { x: x + width, y: y }
|
||||||
|
rightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (bottomLeftModule) {
|
||||||
|
bottomLeftPoint = { x: x - width, y: y + h }
|
||||||
|
bottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (bottomRightModule) {
|
||||||
|
bottomRightPoint = { x: x + width, y: y + h }
|
||||||
|
bottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'north':
|
case 'north':
|
||||||
width = width + horizontal
|
width = width + horizontal
|
||||||
height = height + vertical
|
height = height + vertical
|
||||||
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - height)) < maxY)
|
heightArr.forEach((h) => {
|
||||||
halfBottomLeftPoint = { x: x + width / 2, y: y - height }
|
if (!bottomModule) {
|
||||||
halfBottomRightPoint = { x: x - width / 2, y: y - height }
|
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y - h)) < maxY)
|
||||||
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + height)) < maxY)
|
}
|
||||||
halfTopLeftPoint = { x: x + width / 2, y: y + height }
|
if (!topModule) {
|
||||||
halfTopRightPoint = { x: x - width / 2, y: y + height }
|
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - x) < maxX && Math.abs(centerPoint.y - (y + h)) < maxY)
|
||||||
leftPoint = { x: x + width, y: y }
|
}
|
||||||
rightPoint = { x: x - width, y: y }
|
if (!halfBottomLeftModule) {
|
||||||
bottomLeftModule = { x: x + width, y: y - height }
|
halfBottomLeftPoint = { x: x + width / 2, y: y - h }
|
||||||
bottomRightModule = { x: x - width, y: y - height }
|
halfBottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfBottomRightModule) {
|
||||||
|
halfBottomRightPoint = { x: x - width / 2, y: y - h }
|
||||||
|
halfBottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopLeftModule) {
|
||||||
|
halfTopLeftPoint = { x: x + width / 2, y: y + h }
|
||||||
|
halfTopLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopRightModule) {
|
||||||
|
halfTopRightPoint = { x: x - width / 2, y: y + h }
|
||||||
|
halfTopRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (leftModule) {
|
||||||
|
leftPoint = { x: x + width, y: y }
|
||||||
|
leftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (rightModule) {
|
||||||
|
rightPoint = { x: x - width, y: y }
|
||||||
|
rightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (bottomLeftModule) {
|
||||||
|
bottomLeftPoint = { x: x + width, y: y - h }
|
||||||
|
bottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (bottomRightModule) {
|
||||||
|
bottomRightPoint = { x: x - width, y: y - h }
|
||||||
|
bottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'east':
|
case 'east':
|
||||||
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
width = width + horizontal
|
if (!bottomModule) {
|
||||||
halfBottomLeftPoint = { x: x + width, y: y + height / 2 }
|
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
halfBottomRightPoint = { x: x + width, y: y - height / 2 }
|
}
|
||||||
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
if (!topModule) {
|
||||||
halfTopLeftPoint = { x: x - width, y: y + height / 2 }
|
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
halfTopRightPoint = { x: x - width, y: y - height / 2 }
|
}
|
||||||
leftPoint = { x: x, y: y + height }
|
if (!halfBottomLeftModule) {
|
||||||
rightPoint = { x: x, y: y - height }
|
halfBottomLeftPoint = { x: x + w, y: y - height / 2 }
|
||||||
bottomLeftModule = { x: x + width, y: y + height }
|
halfBottomLeftModule = centerPoints.find(
|
||||||
bottomRightModule = { x: x + width, y: y - height }
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfBottomRightModule) {
|
||||||
|
halfBottomRightPoint = { x: x + w, y: y - height / 2 }
|
||||||
|
halfBottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopLeftModule) {
|
||||||
|
halfTopLeftPoint = { x: x - w, y: y + height / 2 }
|
||||||
|
halfTopLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopRightModule) {
|
||||||
|
halfTopRightPoint = { x: x - w, y: y - height / 2 }
|
||||||
|
halfTopRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!leftModule) {
|
||||||
|
leftPoint = { x: x, y: y + height }
|
||||||
|
leftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!rightModule) {
|
||||||
|
rightPoint = { x: x, y: y - height }
|
||||||
|
rightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!bottomLeftModule) {
|
||||||
|
bottomLeftPoint = { x: x + w, y: y + height }
|
||||||
|
bottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!bottomRightModule) {
|
||||||
|
bottomRightPoint = { x: x + w, y: y - height }
|
||||||
|
bottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case 'west':
|
case 'west':
|
||||||
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
widthArr.forEach((w) => {
|
||||||
width = width + horizontal
|
if (!bottomModule) {
|
||||||
halfBottomLeftPoint = { x: x - width, y: y - height / 2 }
|
bottomModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x - w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
halfBottomRightPoint = { x: x - width, y: y + height / 2 }
|
}
|
||||||
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + width)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
if (!topModule) {
|
||||||
halfTopLeftPoint = { x: x + width, y: y - height / 2 }
|
topModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - (x + w)) < maxX && Math.abs(centerPoint.y - y) < maxY)
|
||||||
halfTopRightPoint = { x: x + width, y: y + height / 2 }
|
}
|
||||||
leftPoint = { x: x, y: y - height }
|
if (!halfBottomLeftModule) {
|
||||||
rightPoint = { x: x, y: y + height }
|
halfBottomLeftPoint = { x: x - w, y: y - height / 2 }
|
||||||
bottomLeftModule = { x: x - width, y: y - height }
|
halfBottomLeftModule = centerPoints.find(
|
||||||
bottomRightModule = { x: x - width, y: y + height }
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfBottomRightModule) {
|
||||||
|
halfBottomRightPoint = { x: x - w, y: y + height / 2 }
|
||||||
|
halfBottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopLeftModule) {
|
||||||
|
halfTopLeftPoint = { x: x + w, y: y - height / 2 }
|
||||||
|
halfTopLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!halfTopRightModule) {
|
||||||
|
halfTopRightPoint = { x: x + w, y: y + height / 2 }
|
||||||
|
halfTopRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!leftModule) {
|
||||||
|
leftPoint = { x: x, y: y - height }
|
||||||
|
leftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!rightModule) {
|
||||||
|
rightPoint = { x: x, y: y + height }
|
||||||
|
rightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!bottomLeftModule) {
|
||||||
|
bottomLeftPoint = { x: x - w, y: y - height }
|
||||||
|
bottomLeftModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - bottomLeftPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!bottomRightModule) {
|
||||||
|
bottomRightPoint = { x: x - w, y: y + height }
|
||||||
|
bottomRightModule = centerPoints.find(
|
||||||
|
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < maxX && Math.abs(centerPoint.y - bottomRightPoint.y) < maxY,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
halfTopLeftModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - halfTopLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfTopLeftPoint.y) < maxY,
|
|
||||||
)
|
|
||||||
halfTopRightModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - halfTopRightPoint.x) < maxX && Math.abs(centerPoint.y - halfTopRightPoint.y) < maxY,
|
|
||||||
)
|
|
||||||
halfBottomLeftModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - halfBottomLeftPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomLeftPoint.y) < maxY,
|
|
||||||
)
|
|
||||||
halfBottomRightModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - halfBottomRightPoint.x) < maxX && Math.abs(centerPoint.y - halfBottomRightPoint.y) < maxY,
|
|
||||||
)
|
|
||||||
leftModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - leftPoint.x) < maxX && Math.abs(centerPoint.y - leftPoint.y) < maxY)
|
|
||||||
rightModule = centerPoints.find((centerPoint) => Math.abs(centerPoint.x - rightPoint.x) < maxX && Math.abs(centerPoint.y - rightPoint.y) < maxY)
|
|
||||||
bottomLeftModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - bottomLeftModule.x) < maxX && Math.abs(centerPoint.y - bottomLeftModule.y) < maxY,
|
|
||||||
)
|
|
||||||
bottomRightModule = centerPoints.find(
|
|
||||||
(centerPoint) => Math.abs(centerPoint.x - bottomRightModule.x) < maxX && Math.abs(centerPoint.y - bottomRightModule.y) < maxY,
|
|
||||||
)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bottomModule,
|
bottomModule,
|
||||||
topModule,
|
topModule,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user