노출하면, 상면, 접면 계산 작업중
This commit is contained in:
parent
83476af5f3
commit
943c7fd4b2
@ -47,6 +47,8 @@ export function useModuleBasicSetting() {
|
||||
flowDirection: roof.direction,
|
||||
})
|
||||
|
||||
setupSurface.setViewLengthText(false)
|
||||
|
||||
canvas.add(setupSurface)
|
||||
//지붕면 선택 금지
|
||||
roof.set({
|
||||
@ -559,6 +561,7 @@ export function useModuleBasicSetting() {
|
||||
opacity: 0.8,
|
||||
parentId: moduleSetupSurface.parentId,
|
||||
})
|
||||
tempModule.setViewLengthText(false)
|
||||
canvas?.add(tempModule)
|
||||
moduleSetupArray.push(tempModule)
|
||||
}
|
||||
@ -625,6 +628,106 @@ export function useModuleBasicSetting() {
|
||||
})
|
||||
|
||||
setModuleIsSetup(moduleSetupArray)
|
||||
|
||||
console.log(calculateForApi(moduleSetupArray))
|
||||
}
|
||||
|
||||
const calculateForApi = (moduleSetupArray) => {
|
||||
const centerPoints = []
|
||||
moduleSetupArray.forEach((module, index) => {
|
||||
module.tempIndex = index
|
||||
const { x, y } = module.getCenterPoint()
|
||||
const { width, height } = module
|
||||
centerPoints.push({ x, y, width, height })
|
||||
const circle = new fabric.Circle({
|
||||
radius: 5,
|
||||
fill: 'red',
|
||||
name: 'redCircle',
|
||||
left: x - 5,
|
||||
top: y - 5,
|
||||
index: index,
|
||||
selectable: false,
|
||||
})
|
||||
canvas.add(circle)
|
||||
})
|
||||
|
||||
//완전 노출 하면
|
||||
let exposedBottom = 0
|
||||
// 반 노출 하면
|
||||
let exposedHalfBottom = 0
|
||||
// 완전 노출 상면
|
||||
let exposedTop = 0
|
||||
//반 노출 상면
|
||||
let exposedHalfTop = 0
|
||||
// 완전 접면
|
||||
let touchDimension = 0
|
||||
//반접면
|
||||
let halfTouchDimension = 0
|
||||
|
||||
// 노출하면 체크
|
||||
centerPoints.forEach((centerPoint, index) => {
|
||||
const { x, y, width, height } = centerPoint
|
||||
// centerPoints중에 현재 centerPoint와 x값이 같고, y값이 y-height값과 같은 centerPoint가 있는지 확인
|
||||
const bottomCell = centerPoints.filter((centerPoint) => centerPoint.x === x && Math.abs(centerPoint.y - (y + height)) < 2)
|
||||
if (bottomCell.length === 1) {
|
||||
touchDimension++
|
||||
return
|
||||
}
|
||||
|
||||
// 바로 아래에 셀이 없는 경우 물떼세 배치가 왼쪽 되어있는 셀을 찾는다.
|
||||
const leftBottomCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x - width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2,
|
||||
).length
|
||||
const rightBottomCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x + width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2,
|
||||
).length
|
||||
if (leftBottomCnt + rightBottomCnt === 2) {
|
||||
touchDimension++
|
||||
return
|
||||
}
|
||||
if (leftBottomCnt + rightBottomCnt === 1) {
|
||||
halfTouchDimension++
|
||||
exposedHalfBottom++
|
||||
return
|
||||
}
|
||||
if (leftBottomCnt + rightBottomCnt === 0) {
|
||||
exposedBottom++
|
||||
return
|
||||
}
|
||||
})
|
||||
// 노출상면 체크
|
||||
|
||||
centerPoints.forEach((centerPoint, index) => {
|
||||
const { x, y, width, height } = centerPoint
|
||||
const topCell = centerPoints.filter((centerPoint) => centerPoint.x === x && Math.abs(centerPoint.y - (y - height)) < 2)
|
||||
if (topCell.length === 1) {
|
||||
return
|
||||
}
|
||||
|
||||
const leftTopCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x - width) < 2) && Math.abs(centerPoint.y - (y - height)) < 2,
|
||||
).length
|
||||
const rightTopCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x + width / 2) < 2) && Math.abs(centerPoint.y - (y - height)) < 2,
|
||||
).length
|
||||
|
||||
if (leftTopCnt + rightTopCnt === 1) {
|
||||
exposedHalfTop++
|
||||
return
|
||||
}
|
||||
if (leftTopCnt + rightTopCnt === 0) {
|
||||
exposedTop++
|
||||
return
|
||||
}
|
||||
})
|
||||
return {
|
||||
exposedBottom,
|
||||
exposedHalfBottom,
|
||||
exposedTop,
|
||||
exposedHalfTop,
|
||||
touchDimension,
|
||||
halfTouchDimension,
|
||||
}
|
||||
}
|
||||
|
||||
const coordToTurfPolygon = (points) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user