Merge branch 'dev' of https://git.hanasys.jp/qcast3/qcast-front into feature/skeleton-dev

This commit is contained in:
ysCha 2025-12-30 10:52:45 +09:00
commit 265e4c3daf
8 changed files with 691 additions and 158 deletions

View File

@ -845,37 +845,33 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
// 먼저 좌표 업데이트
this.setCoords()
// 캔버스 줌과 viewport transform 고려한 좌표 변환
let localPoint = point
// viewport transform만 역변환 (캔버스 줌/팬 보정)
// 결과는 WORLD 좌표 (캔버스 좌표계)
let canvasPoint = point
if (this.canvas) {
const vpt = this.canvas.viewportTransform
if (vpt) {
// viewport transform 역변환
const inverted = fabric.util.invertTransform(vpt)
localPoint = fabric.util.transformPoint(point, inverted)
canvasPoint = fabric.util.transformPoint(point, inverted)
}
}
// 오브젝트의 transform matrix를 고려한 좌표 변환
const matrix = this.calcTransformMatrix()
const invertedMatrix = fabric.util.invertTransform(matrix)
const transformedPoint = fabric.util.transformPoint(localPoint, invertedMatrix)
// pathOffset을 고려한 최종 좌표 계산
const pathOffset = this.get('pathOffset')
const finalPoint = {
x: Number((transformedPoint.x + pathOffset.x).toFixed(this.toFixed)),
y: Number((transformedPoint.y + pathOffset.y).toFixed(this.toFixed)),
// canvasPoint는 WORLD 좌표
// inPolygonImproved에서 getCurrentPoints()도 WORLD 좌표를 반환
// 따라서 좌표 시스템이 일치함
const checkPoint = {
x: Number(canvasPoint.x.toFixed(this.toFixed)),
y: Number(canvasPoint.y.toFixed(this.toFixed)),
}
if (this.name === POLYGON_TYPE.ROOF && this.isFixed) {
const isInside = this.inPolygonImproved(finalPoint)
const isInside = this.inPolygonImproved(checkPoint)
if (!this.selectable) {
this.set('selectable', isInside)
}
return isInside
} else {
return this.inPolygonImproved(finalPoint)
return this.inPolygonImproved(checkPoint)
}
},

View File

@ -5,12 +5,13 @@ import StepUp from '@/components/floor-plan/modal/circuitTrestle/step/StepUp'
import { useMessage } from '@/hooks/useMessage'
import { usePopup } from '@/hooks/usePopup'
import PassivityCircuitAllocation from './step/type/PassivityCircuitAllocation'
import BasicSetting from '@/components/floor-plan/modal/basic/BasicSetting'
import { useMasterController } from '@/hooks/common/useMasterController'
import { useRecoilState, useRecoilValue } from 'recoil'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { GlobalDataContext } from '@/app/GlobalDataProvider'
import { POLYGON_TYPE } from '@/common/common'
import { POLYGON_TYPE, MENU } from '@/common/common'
import { useSwal } from '@/hooks/useSwal'
import { canvasState, canvasZoomState } from '@/store/canvasAtom'
import { canvasState, canvasZoomState, currentMenuState } from '@/store/canvasAtom'
import { useTrestle } from '@/hooks/module/useTrestle'
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
@ -29,11 +30,12 @@ const ALLOCATION_TYPE = {
}
export default function CircuitTrestleSetting({ id }) {
const { getMessage } = useMessage()
const { closePopup } = usePopup()
const { closePopup, addPopup } = usePopup()
const { apply, setViewCircuitNumberTexts, getEstimateData, clear: clearTrestle, setAllModuleSurfaceIsComplete } = useTrestle()
const { swalFire } = useSwal()
const { saveEstimate } = useEstimate()
const canvas = useRecoilValue(canvasState)
const setCurrentMenu = useSetRecoilState(currentMenuState)
const [canvasZoom, setCanvasZoom] = useRecoilState(canvasZoomState)
const [tabNum, setTabNum] = useState(1)
const [allocationType, setAllocationType] = useState(ALLOCATION_TYPE.AUTO)
@ -106,6 +108,167 @@ export default function CircuitTrestleSetting({ id }) {
}
}, [])
// rack reopen
useEffect(() => {
const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
if (modules.length === 0) {
return
}
/**
* 설치 모듈 크기 검증
* - 남쪽: 아래쪽 모듈이 위쪽 모듈보다 커야
* - 북쪽: 위쪽 모듈이 아래쪽 모듈보다 커야
* - 동쪽: 오른쪽 모듈이 왼쪽 모듈보다 커야
* - 서쪽: 왼쪽 모듈이 오른쪽 모듈보다 커야
*/
const validateModuleSizeForRack = (surface) => {
const { modules, direction, trestleDetail } = surface
const { rackYn, moduleIntvlHor, moduleIntvlVer } = trestleDetail
if (rackYn === 'N' || !modules || modules.length < 2) {
return true //
}
//
const centerPoints = modules.map((module) => {
const { x, y } = module.getCenterPoint()
const { width, height } = module
return {
x,
y,
width: Math.floor(width),
height: Math.floor(height),
area: Math.floor(width) * Math.floor(height),
}
})
//
const isVertical = direction === 'south' || direction === 'north'
const primaryInterval = isVertical ? moduleIntvlVer : moduleIntvlHor
const secondaryInterval = isVertical ? moduleIntvlHor : moduleIntvlVer
// :
const getSortFn = () => {
switch (direction) {
case 'south': return (a, b) => b.y - a.y // (y )
case 'north': return (a, b) => a.y - b.y // (y )
case 'east': return (a, b) => b.x - a.x // (x )
case 'west': return (a, b) => a.x - b.x // (x )
default: return () => 0
}
}
// ( )
const findTargetModules = (current, margin) => {
return centerPoints.filter(cp => {
const sameAxis = isVertical
? Math.abs(cp.x - current.x) < margin
: Math.abs(cp.y - current.y) < margin
const targetDirection = direction === 'south' ? cp.y < current.y
: direction === 'north' ? cp.y > current.y
: direction === 'east' ? cp.x < current.x
: cp.x > current.x
return sameAxis && targetDirection
})
}
//
const getClosestTarget = (filtered) => {
if (filtered.length === 0) return null
return filtered.reduce((closest, cp) => {
switch (direction) {
case 'south': return cp.y > closest.y ? cp : closest
case 'north': return cp.y < closest.y ? cp : closest
case 'east': return cp.x > closest.x ? cp : closest
case 'west': return cp.x < closest.x ? cp : closest
default: return closest
}
})
}
//
const getGap = (current, target) => {
if (isVertical) {
return direction === 'south'
? (current.y - current.height / 2) - (target.y + target.height / 2)
: (target.y - target.height / 2) - (current.y + current.height / 2)
} else {
return direction === 'east'
? (current.x - current.width / 2) - (target.x + target.width / 2)
: (target.x - target.width / 2) - (current.x + current.width / 2)
}
}
//
const isAdjacent = (current, target) => {
const gap = getGap(current, target)
return gap >= 0 && gap <= primaryInterval + 1
}
//
const sortedPoints = [...centerPoints].sort(getSortFn())
for (const current of sortedPoints) {
// 1. :
const directTargets = findTargetModules(current, secondaryInterval)
const closestTarget = getClosestTarget(directTargets)
if (closestTarget && isAdjacent(current, closestTarget) && closestTarget.area > current.area) {
return false //
}
// 2. :
const size = isVertical ? current.width : current.height
const halfOffset = (size + secondaryInterval) / 2
for (const sign of [-1, 1]) {
const offsetValue = sign * halfOffset
const findHalfTarget = centerPoints.filter((cp) => {
const offsetAxis = isVertical
? Math.abs(cp.x - (current.x + offsetValue)) <= primaryInterval
: Math.abs(cp.y - (current.y + offsetValue)) <= primaryInterval
const targetDirection = direction === 'south' ? cp.y < current.y
: direction === 'north' ? cp.y > current.y
: direction === 'east' ? cp.x < current.x
: cp.x > current.x
return offsetAxis && targetDirection
})
const closestHalf = getClosestTarget(findHalfTarget)
if (closestHalf && isAdjacent(current, closestHalf) && closestHalf.area > current.area) {
return false //
}
}
}
return true //
}
//
const moduleSetupSurfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
for (const surface of moduleSetupSurfaces) {
if (!validateModuleSizeForRack(surface)) {
swalFire({
text: getMessage('module.size.validation.rack.error'),
icon: 'error',
confirmFn: () => {
//
closePopup(id)
//
setCurrentMenu(MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING)
// /
const newPopupId = uuidv4()
clearTrestle()
setAllModuleSurfaceIsComplete(false)
addPopup(newPopupId, 1, <BasicSetting id={newPopupId} />)
},
})
return
}
}
}, [])
const capture = async (type) => {
beforeCapture(type)

View File

@ -103,17 +103,6 @@ export default function PassivityCircuitAllocation(props) {
surfaceType[`${surface.direction}-${surface.roofMaterial.pitch}`] = surface
})
if (surfaceList.length > 1) {
if (Object.keys(surfaceType).length > 1) {
swalFire({
text: getMessage('module.circuit.fix.not.same.roof.error'),
type: 'alert',
icon: 'warning',
})
return
}
}
if (!circuitNumber || circuitNumber === 0) {
swalFire({
text: getMessage('module.circuit.minimun.error'),
@ -145,7 +134,11 @@ export default function PassivityCircuitAllocation(props) {
originSurfaceList.concat(originSurfaceList).forEach((surface) => {
surfaceType[`${surface.direction}-${surface.roofMaterial.pitch}`] = surface
})
break
}
case 'OUTDMULTI': {
if (surfaceList.length > 1) {
if (Object.keys(surfaceType).length > 1) {
swalFire({
@ -156,10 +149,6 @@ export default function PassivityCircuitAllocation(props) {
return
}
}
break
}
case 'OUTDMULTI': {
if (selectedModels.length > 1) {
let result = false

View File

@ -84,6 +84,7 @@ export function useModule() {
canvas.renderAll()
})
const surfaceId = selectedModules[0].surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.move.module'),
@ -96,11 +97,15 @@ export function useModule() {
top: module.originCoords.top,
fill: module.originCoords.fill,
})
module.dirty = true
module.setCoords()
})
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
recalculateAllModulesCoords(surfaceId)
}
}
}
@ -157,6 +162,7 @@ export function useModule() {
activeModule.set({ strokeWidth: 3 })
canvas.renderAll()
const surfaceId = activeModule.surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.move.module'),
@ -165,11 +171,15 @@ export function useModule() {
confirmFn: () => {
modules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
recalculateAllModulesCoords(surfaceId)
}
}
@ -202,6 +212,7 @@ export function useModule() {
})
canvas.renderAll()
const surfaceId = surface.id
if (isWarning) {
swalFire({
title: getMessage('can.not.move.module'),
@ -210,11 +221,15 @@ export function useModule() {
confirmFn: () => {
modules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
recalculateAllModulesCoords(surfaceId)
}
})
}
@ -269,6 +284,7 @@ export function useModule() {
canvas.renderAll()
})
const surfaceId = surface.id
if (isWarning) {
swalFire({
title: getMessage('can.not.copy.module'),
@ -276,11 +292,13 @@ export function useModule() {
type: 'alert',
confirmFn: () => {
canvas.remove(...copyModules)
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
surface.set({ modules: [...surface.modules, ...copyModules] })
recalculateAllModulesCoords(surfaceId)
}
})
@ -333,6 +351,7 @@ export function useModule() {
}
})
const surfaceId = modules[0].surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.copy.module'),
@ -340,11 +359,13 @@ export function useModule() {
type: 'alert',
confirmFn: () => {
canvas.remove(...copyModules)
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
moduleSetupSurface.set({ modules: [...moduleSetupSurface.modules, ...copyModules] })
recalculateAllModulesCoords(surfaceId)
}
setModuleStatisticsData()
}
@ -426,6 +447,7 @@ export function useModule() {
})
activeModule.set({ strokeWidth: 3 })
const surfaceId = activeModule.surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.copy.module'),
@ -433,12 +455,14 @@ export function useModule() {
type: 'alert',
confirmFn: () => {
canvas.remove(...copyModules)
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
moduleSetupSurface.set({ modules: [...moduleSetupSurface.modules, ...copyModules] })
setModuleStatisticsData()
recalculateAllModulesCoords(surfaceId)
}
}
@ -477,6 +501,7 @@ export function useModule() {
}
if (width === -1) width = module.left - activeModule.left
module.set({ left: module.left - width })
module.dirty = true
module.setCoords()
canvas.renderAll()
if (isOverlapOtherModules(module, leftModules) || isOverlapObjects(module, objects) || isOutsideSurface(module, moduleSetupSurface)) {
@ -484,7 +509,7 @@ export function useModule() {
isWarning = true
}
})
canvas.renderAll()
canvas.requestRenderAll()
targetModules = rightModules
} else if (type === MODULE_REMOVE_TYPE.RIGHT) {
leftModules.forEach((module) => {
@ -495,6 +520,7 @@ export function useModule() {
}
if (width === -1) width = activeModule.left - module.left
module.set({ left: module.left + width })
module.dirty = true
module.setCoords()
canvas.renderAll()
if (isOverlapOtherModules(module, rightModules) || isOverlapObjects(module, objects) || isOutsideSurface(module, moduleSetupSurface)) {
@ -502,7 +528,7 @@ export function useModule() {
isWarning = true
}
})
canvas.renderAll()
canvas.requestRenderAll()
targetModules = leftModules
} else if (type === MODULE_REMOVE_TYPE.HORIZONTAL_SIDE) {
const sideModules = [...leftModules, ...rightModules]
@ -514,6 +540,7 @@ export function useModule() {
}
if (width === -1) width = activeModule.left - module.left
module.set({ left: module.left + width / 2 })
module.dirty = true
module.setCoords()
canvas.renderAll()
})
@ -526,6 +553,7 @@ export function useModule() {
}
if (width === -1) width = module.left - activeModule.left
module.set({ left: module.left - width / 2 })
module.dirty = true
module.setCoords()
canvas.renderAll()
})
@ -547,6 +575,7 @@ export function useModule() {
targetModules = sideModules
}
canvas.renderAll()
const surfaceId = activeModule.surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.remove.module'),
@ -557,17 +586,24 @@ export function useModule() {
canvas.add(...columnModules)
targetModules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
columnModules.forEach((module) => {
module.dirty = true
module.setCoords()
})
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
moduleSetupSurface.modules = moduleSetupSurface.modules.filter(
(module) => !columnModules.map((copyModule) => copyModule.id).includes(module.id),
)
setModuleStatisticsData()
recalculateAllModulesCoords(surfaceId)
}
setModuleStatisticsData()
}
const moduleRowRemove = (type) => {
@ -599,6 +635,7 @@ export function useModule() {
}
if (height === -1) height = module.top - activeModule.top
module.set({ top: module.top - height })
module.dirty = true
module.setCoords()
canvas.renderAll()
if (isOverlapOtherModules(module, topModules) || isOverlapObjects(module, objects) || isOutsideSurface(module, moduleSetupSurface)) {
@ -606,7 +643,7 @@ export function useModule() {
module.set({ fill: 'red' })
}
})
canvas.renderAll()
canvas.requestRenderAll()
targetModules = bottomModules
} else if (type === MODULE_REMOVE_TYPE.BOTTOM) {
topModules.forEach((module) => {
@ -617,6 +654,7 @@ export function useModule() {
}
if (height === -1) height = activeModule.top - module.top
module.set({ top: module.top + activeModule.height })
module.dirty = true
module.setCoords()
canvas.renderAll()
if (isOverlapOtherModules(module, bottomModules) || isOverlapObjects(module, objects) || isOutsideSurface(module, moduleSetupSurface)) {
@ -624,6 +662,7 @@ export function useModule() {
module.set({ fill: 'red' })
}
})
canvas.requestRenderAll()
targetModules = topModules
} else if (type === MODULE_REMOVE_TYPE.VERTICAL_SIDE) {
topModules.forEach((module) => {
@ -635,6 +674,7 @@ export function useModule() {
// if (height === -1) height = activeModule.top - module.top
if (height === -1) height = activeModule.height
module.set({ top: module.top + height / 2 })
module.dirty = true
module.setCoords()
})
@ -647,10 +687,11 @@ export function useModule() {
// if (height === -1) height = module.top - activeModule.top
if (height === -1) height = activeModule.height
module.set({ top: module.top - height / 2 })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
canvas.requestRenderAll()
const sideModules = [...topModules, ...bottomModules]
sideModules.forEach((module) => {
if (
@ -668,6 +709,7 @@ export function useModule() {
targetModules = sideModules
}
canvas.renderAll()
const surfaceId = activeModule.surfaceId
if (isWarning && type !== MODULE_REMOVE_TYPE.NONE) {
targetModules.forEach((rect) => rect.set({ fill: 'red' }))
swalFire({
@ -679,13 +721,20 @@ export function useModule() {
canvas.add(...rowModules)
targetModules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
rowModules.forEach((module) => {
module.dirty = true
module.setCoords()
})
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
}
setModuleStatisticsData()
recalculateAllModulesCoords(surfaceId)
}
const moduleColumnInsert = (type) => {
@ -756,6 +805,7 @@ export function useModule() {
module.setCoords()
})
canvas.renderAll()
const surfaceId = activeModule.surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.insert.module'),
@ -764,16 +814,19 @@ export function useModule() {
confirmFn: () => {
targetModules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.remove(...copyModules)
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
moduleSetupSurface.modules = [...moduleSetupSurface.modules, ...copyModules]
setModuleStatisticsData()
recalculateAllModulesCoords(surfaceId)
}
setModuleStatisticsData()
}
const isFixedModule = () => {
@ -863,6 +916,7 @@ export function useModule() {
})
canvas.renderAll()
const surfaceId = activeModule.surfaceId
if (isWarning) {
swalFire({
title: getMessage('can.not.insert.module'),
@ -871,16 +925,19 @@ export function useModule() {
confirmFn: () => {
targetModules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.remove(...copyModules)
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
moduleSetupSurface.modules = [...moduleSetupSurface.modules, ...copyModules]
setModuleStatisticsData()
recalculateAllModulesCoords(surfaceId)
}
setModuleStatisticsData()
}
const alignModule = (type, surfaceArray) => {
@ -924,6 +981,7 @@ export function useModule() {
}
})
canvas.renderAll()
const surfaceId = surface.id
if (isWarning) {
swalFire({
title: getMessage('can.not.align.module'),
@ -932,11 +990,15 @@ export function useModule() {
confirmFn: () => {
modules.forEach((module) => {
module.set({ top: module.originPos.top, left: module.originPos.left, fill: module.originPos.fill })
module.dirty = true
module.setCoords()
})
canvas.renderAll()
canvas.requestRenderAll()
recalculateAllModulesCoords(surfaceId)
},
})
} else {
recalculateAllModulesCoords(surfaceId)
}
})
}
@ -964,6 +1026,7 @@ export function useModule() {
canvas.remove(activeModule)
canvas.renderAll()
setModuleStatisticsData()
recalculateAllModulesCoords(activeModule.surfaceId)
}
const moduleRoofRemove = (surfaceArray) => {
@ -1049,6 +1112,38 @@ export function useModule() {
removeTrestleMaterials()
}
/**
* 모든 모듈의 좌표를 재계산
* / 삭제, 복사, 추가 호출하여 선택 영역(bounding box) 업데이트
* @param {string} surfaceId - 특정 surface의 모듈만 재계산 (선택적)
*/
const recalculateAllModulesCoords = (surfaceId = null) => {
if (!canvas) return
const modules = canvas
.getObjects()
.filter((obj) => obj.name === POLYGON_TYPE.MODULE)
.filter((obj) => (surfaceId ? obj.surfaceId === surfaceId : true))
// 모듈의 캐시를 초기화하고 좌표 재계산
modules.forEach((module) => {
// Fabric.js 내부 캐시 초기화
delete module.oCoords
delete module.aCoords
delete module.lineCoords
delete module.__corner
delete module.matrixCache
delete module.ownMatrixCache
// dirty 플래그 설정 및 좌표 재계산
module.dirty = true
module.setCoords()
})
// 렌더링
canvas.renderAll()
}
return {
moduleMove,
moduleMultiMove,
@ -1063,5 +1158,6 @@ export function useModule() {
modulesRemove,
moduleRoofRemove,
alignModule,
recalculateAllModulesCoords,
}
}

View File

@ -123,6 +123,7 @@ export function useModuleBasicSetting(tabNum) {
.getObjects()
.filter((roof) => roof.name === POLYGON_TYPE.ROOF)
.forEach((roof) => {
changeLineType(roof)
if (!roof.roofMaterial) return
const roofIndex = roof.roofMaterial.index //지붕의 지붕재의 순번
@ -168,6 +169,61 @@ export function useModuleBasicSetting(tabNum) {
}
}, [trestleDetailList])
const changeLineType = (polygon) => {
if (!polygon || !polygon.lines || polygon.lines.length === 0) return
const direction = polygon.direction
// 1. 모든 라인을 케라바(GABLE)로 초기화
polygon.lines.forEach((line) => {
line.attributes = {
...line.attributes,
type: LINE_TYPE.WALLLINE.GABLE,
}
})
// 방향에 따른 좌표 설정
const directionConfig = {
south: { coord1: 'y1', coord2: 'y2', findExtreme: Math.max },
north: { coord1: 'y1', coord2: 'y2', findExtreme: Math.min },
east: { coord1: 'x1', coord2: 'x2', findExtreme: Math.max },
west: { coord1: 'x1', coord2: 'x2', findExtreme: Math.min },
}
const config = directionConfig[direction] || directionConfig.south
const { coord1, coord2, findExtreme } = config
// 2. 직선만 필터링 (대각선 제외)
// 남/북: y1 === y2 인 경우 수평 직선
// 동/서: x1 === x2 인 경우 수직 직선
const straightLines = polygon.lines.filter((line) => line[coord1] === line[coord2])
if (straightLines.length === 0) return
// 3. 가장 끝에 있는 직선 찾기
// 남쪽: 가장 하단 (y값이 가장 큰), 북쪽: 가장 상단 (y값이 가장 작은)
// 동쪽: 가장 오른쪽 (x값이 가장 큰), 서쪽: 가장 왼쪽 (x값이 가장 작은)
const extremeValue = findExtreme(...straightLines.map((line) => line[coord1]))
const eavesLines = straightLines.filter((line) => line[coord1] === extremeValue)
// 4. 직선에 대해 타입 설정
straightLines.forEach((line) => {
if (eavesLines.includes(line)) {
// 가장 끝에 있는 직선은 eaves
line.attributes = {
...line.attributes,
type: LINE_TYPE.WALLLINE.EAVES,
}
} else {
// 나머지 직선은 ridge
line.attributes = {
...line.attributes,
type: LINE_TYPE.SUBLINE.RIDGE,
}
}
})
}
const roofOutlineColor = (roofIndex) => {
if (roofIndex === 1) {
return '#FFC000'

View File

@ -134,6 +134,7 @@
"modal.module.basic.settting.module.error10": "棟側の配置領域の値を{0} mm以上に変更してください。\n(屋根材: {1})",
"modal.module.basic.settting.module.error11": "ケラバ側の配置領域の値を{0} mm以上に変更してください。\n(屋根材: {1})",
"modal.module.basic.settting.module.error12": "施工方法を選択してください。\n(屋根材: {0})",
"module.size.validation.rack.error": "モジュール配置が不正です。 正しく配置し直してください。",
"modal.module.basic.setting.module.placement": "モジュールの配置",
"modal.module.basic.setting.module.placement.select.fitting.type": "設置形態を選択してください。",
"modal.module.basic.setting.module.placement.waterfowl.arrangement": "千鳥配置",

View File

@ -134,6 +134,7 @@
"modal.module.basic.settting.module.error10": "용마루쪽 값은 {0}mm 이상이어야 합니다.\n(지붕재: {1})",
"modal.module.basic.settting.module.error11": "케라바쪽 값은 {0}mm 이상이어야 합니다.\n(지붕재: {1})",
"modal.module.basic.settting.module.error12": "시공법을 선택해주세요.\n(지붕재: {0})",
"module.size.validation.rack.error": "모듈 배치가 잘못되었습니다. 올바르게 다시 배치해 주세요.",
"modal.module.basic.setting.module.placement": "모듈 배치",
"modal.module.basic.setting.module.placement.select.fitting.type": "설치형태를 선택합니다.",
"modal.module.basic.setting.module.placement.waterfowl.arrangement": "물떼새 배치",

View File

@ -1375,7 +1375,7 @@ export const drawGableRoof = (roofId, canvas, textMode) => {
innerLines.push(drawRoofLine(points, canvas, roof, textMode))
} else {
//다른방향 처리
innerLines.push(drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree))
}
} else if (analyze.isVertical) {
//현재라인이 수직선일때
@ -1384,7 +1384,7 @@ export const drawGableRoof = (roofId, canvas, textMode) => {
innerLines.push(drawRoofLine(points, canvas, roof, textMode))
} else {
//다른방향 처리
innerLines.push(drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree))
}
}
})
@ -2521,8 +2521,8 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
]
const gablePoint = [prevHipPoint[2], prevHipPoint[3], nextHipPoint[2], nextHipPoint[3]]
innerLines.push(drawHipLine(prevHipPoint, canvas, roof, textMode, null, prevDegree, prevDegree))
innerLines.push(drawHipLine(nextHipPoint, canvas, roof, textMode, null, nextDegree, nextDegree))
innerLines.push(drawHipLine(prevHipPoint, canvas, roof, textMode, prevDegree, prevDegree))
innerLines.push(drawHipLine(nextHipPoint, canvas, roof, textMode, nextDegree, nextDegree))
// innerLines.push(drawRoofLine(gablePoint, canvas, roof, textMode))
//양옆이 처마일경우 두개의 선, 아닐때 한개의 선, 좌우가 처마가 아닐때 안그려져야하는데 기존에 그려지는 경우가 있음 이유를 알 수 없음.
@ -2537,10 +2537,10 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
const nextDy = nextGablePoint[1] - nextGablePoint[3]
const nextGableLength = Math.sqrt(nextDx * nextDx + nextDy * nextDy)
if (prevGableLength >= 1) {
innerLines.push(drawHipLine(prevGablePoint, canvas, roof, textMode, null, prevDegree, prevDegree))
innerLines.push(drawHipLine(prevGablePoint, canvas, roof, textMode, prevDegree, prevDegree))
}
if (nextGableLength >= 1) {
innerLines.push(drawHipLine(nextGablePoint, canvas, roof, textMode, null, nextDegree, nextDegree))
innerLines.push(drawHipLine(nextGablePoint, canvas, roof, textMode, nextDegree, nextDegree))
}
const checkEdge = {
vertex1: { x: midPoint.x, y: midPoint.y },
@ -2690,13 +2690,13 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
let proceedRidges = [] // left: 이전, right:다음, point:그려지는 포인트, length:길이
let hipLines = []
ridgeEaves.forEach((currentLine) => {
/*const checkLine = new fabric.Line([currentLine.x1, currentLine.y1, currentLine.x2, currentLine.y2], {
const checkLine = new fabric.Line([currentLine.x1, currentLine.y1, currentLine.x2, currentLine.y2], {
stroke: 'red',
strokeWidth: 4,
parentId: roofId,
name: 'check',
})
canvas.add(checkLine).renderAll()*/
canvas.add(checkLine).renderAll()
let prevLine, nextLine, currentI, prevI, nextI
baseLines.forEach((baseLine, index) => {
if (baseLine === currentLine) {
@ -2741,6 +2741,10 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
const prevCheckPoint = [currentLine.x1, currentLine.y1, currentLine.x1 + pHipVector.x * 1000, currentLine.y1 + pHipVector.y * 1000]
const nextCheckPoint = [currentLine.x2, currentLine.y2, currentLine.x2 + nHipVector.x * 1000, currentLine.y2 + nHipVector.y * 1000]
/* const checkLine1 = new fabric.Line(prevCheckPoint, { stroke: 'red', strokeWidth: 4, parentId: roofId, name: 'check' })
const checkLine2 = new fabric.Line(nextCheckPoint, { stroke: 'green', strokeWidth: 4, parentID: roofId, name: 'check' })
canvas.add(checkLine1, checkLine2).renderAll()*/
const findRoofPoints = (points) => {
const hipEdge = { vertex1: { x: points[0], y: points[1] }, vertex2: { x: points[2], y: points[3] } }
const hipForwardVector = { x: Math.sign(hipEdge.vertex1.x - hipEdge.vertex2.x), y: Math.sign(hipEdge.vertex1.y - hipEdge.vertex2.y) }
@ -2772,7 +2776,15 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
})
isForwardPoints.sort((a, b) => a.length - b.length)
isBackwardPoints.sort((a, b) => a.length - b.length)
return { forward: isForwardPoints[0].intersect, backward: isBackwardPoints[0].intersect }
if (isForwardPoints.length > 0 && isBackwardPoints.length > 0) {
return { forward: isForwardPoints[0].intersect, backward: isBackwardPoints[0].intersect }
} else if (isForwardPoints.length === 0 && isBackwardPoints.length > 1) {
return { forward: isBackwardPoints[0].intersect, backward: isBackwardPoints[1].intersect }
} else if (isForwardPoints.length > 1 && isBackwardPoints.length === 0) {
return { forward: isForwardPoints[1].intersect, backward: isForwardPoints[0].intersect }
} else {
return null
}
}
const pRoofPoints = findRoofPoints(prevCheckPoint)
@ -3140,7 +3152,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
.filter((e) => e !== eaves)
.filter((e) => almostEqual(e.point.x2, eaves.point.x2) && almostEqual(e.point.y2, eaves.point.y2))
if (jointEaves.length === 1 && ridgeEaves.length > 1) {
innerLines.push(drawHipLine([point.x1, point.y1, point.x2, point.y2], canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine([point.x1, point.y1, point.x2, point.y2], canvas, roof, textMode, currentDegree, currentDegree))
pIndexEaves.push(index)
} else if (jointEaves.length === 2) {
console.log('jointEaves : ', jointEaves)
@ -3152,7 +3164,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
jointIndex.forEach((i) => {
const ev = proceedEaves[i]
const degree = getDegreeByChon(baseLines[ev.current].attributes.pitch)
innerLines.push(drawHipLine([ev.point.x1, ev.point.y1, ev.point.x2, ev.point.y2], canvas, roof, textMode, null, degree, degree))
innerLines.push(drawHipLine([ev.point.x1, ev.point.y1, ev.point.x2, ev.point.y2], canvas, roof, textMode, degree, degree))
pIndexEaves.push(i)
jointLines.push(ev.prev, ev.current)
jointVectors.push({ x: Math.sign(ev.point.x2 - ev.point.x1), y: Math.sign(ev.point.y2 - ev.point.y1) })
@ -3289,13 +3301,13 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
const gableLength2 = Math.sqrt(Math.pow(gablePoint2[2] - gablePoint2[0], 2) + Math.pow(gablePoint2[3] - gablePoint2[1], 2))
const gableLength3 = Math.sqrt(Math.pow(gablePoint3[2] - gablePoint3[0], 2) + Math.pow(gablePoint3[3] - gablePoint3[1], 2))
if (gableLength1 >= 1) {
innerLines.push(drawHipLine(gablePoint1, canvas, roof, textMode, null, prevDegree, prevDegree))
innerLines.push(drawHipLine(gablePoint1, canvas, roof, textMode, prevDegree, prevDegree))
}
if (gableLength2 >= 1) {
innerLines.push(drawRoofLine(gablePoint2, canvas, roof, textMode))
}
if (gableLength3 >= 1) {
innerLines.push(drawHipLine(gablePoint3, canvas, roof, textMode, null, nextDegree, nextDegree))
innerLines.push(drawHipLine(gablePoint3, canvas, roof, textMode, nextDegree, nextDegree))
}
const currentRoofLine = analyze.roofLine
@ -3350,8 +3362,8 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (hipIntersection) {
const prevHipPoint = [prevHipEdge.vertex1.x, prevHipEdge.vertex1.y, hipIntersection.x, hipIntersection.y]
const nextHipPoint = [nextHipEdge.vertex1.x, nextHipEdge.vertex1.y, hipIntersection.x, hipIntersection.y]
innerLines.push(drawHipLine(prevHipPoint, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(nextHipPoint, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(prevHipPoint, canvas, roof, textMode, currentDegree, currentDegree))
innerLines.push(drawHipLine(nextHipPoint, canvas, roof, textMode, currentDegree, currentDegree))
const midPoint = { x: hipIntersection.x, y: hipIntersection.y }
const checkEdge = {
@ -4426,19 +4438,19 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (length1 > 0 && !alreadyPoints(innerLines, point1)) {
if (cLine.type === TYPES.HIP) {
innerLines.push(drawHipLine(point1, canvas, roof, textMode, null, cLine.degree, cLine.degree))
innerLines.push(drawHipLine(point1, canvas, roof, textMode, cLine.degree, cLine.degree))
} else if (cLine.type === TYPES.RIDGE) {
innerLines.push(drawRidgeLine(point1, canvas, roof, textMode))
} else if (cLine.type === TYPES.NEW) {
const isDiagonal = Math.abs(point1[0] - point1[2]) >= 1 && Math.abs(point1[1] - point1[3]) >= 1
if (isDiagonal) {
innerLines.push(drawHipLine(point1, canvas, roof, textMode, null, cLine.degree, cLine.degree))
innerLines.push(drawHipLine(point1, canvas, roof, textMode, cLine.degree, cLine.degree))
} else {
innerLines.push(drawRidgeLine(point1, canvas, roof, textMode))
}
} else if (cLine.type === TYPES.GABLE_LINE) {
if (cLine.degree > 0) {
innerLines.push(drawHipLine(point1, canvas, roof, textMode, null, cLine.degree, cLine.degree))
innerLines.push(drawHipLine(point1, canvas, roof, textMode, cLine.degree, cLine.degree))
} else {
innerLines.push(drawRidgeLine(point1, canvas, roof, textMode))
}
@ -4447,19 +4459,19 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (length2 > 0 && !alreadyPoints(innerLines, point2)) {
if (pLine.type === TYPES.HIP) {
innerLines.push(drawHipLine(point2, canvas, roof, textMode, null, pLine.degree, pLine.degree))
innerLines.push(drawHipLine(point2, canvas, roof, textMode, pLine.degree, pLine.degree))
} else if (pLine.type === TYPES.RIDGE) {
innerLines.push(drawRidgeLine(point2, canvas, roof, textMode))
} else if (pLine.type === TYPES.NEW) {
const isDiagonal = Math.abs(point2[0] - point2[2]) >= 1 && Math.abs(point2[1] - point2[3]) >= 1
if (isDiagonal) {
innerLines.push(drawHipLine(point2, canvas, roof, textMode, null, pLine.degree, pLine.degree))
innerLines.push(drawHipLine(point2, canvas, roof, textMode, pLine.degree, pLine.degree))
} else {
innerLines.push(drawRidgeLine(point2, canvas, roof, textMode))
}
} else if (pLine.type === TYPES.GABLE_LINE) {
if (pLine.degree > 0) {
innerLines.push(drawHipLine(point2, canvas, roof, textMode, null, pLine.degree, pLine.degree))
innerLines.push(drawHipLine(point2, canvas, roof, textMode, pLine.degree, pLine.degree))
} else {
innerLines.push(drawRidgeLine(point2, canvas, roof, textMode))
}
@ -4486,13 +4498,13 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
} else if (oLine.type === TYPES.NEW) {
const isDiagonal = Math.abs(oPoint[0] - oPoint[2]) >= 1 && Math.abs(oPoint[1] - oPoint[3]) >= 1
if (isDiagonal) {
innerLines.push(drawHipLine(oPoint, canvas, roof, textMode, null, oLine.degree, oLine.degree))
innerLines.push(drawHipLine(oPoint, canvas, roof, textMode, oLine.degree, oLine.degree))
} else {
innerLines.push(drawRidgeLine(oPoint, canvas, roof, textMode))
}
} else if (oLine.type === TYPES.GABLE_LINE) {
if (oLine.degree > 0) {
innerLines.push(drawHipLine(oPoint, canvas, roof, textMode, null, oLine.degree, oLine.degree))
innerLines.push(drawHipLine(oPoint, canvas, roof, textMode, oLine.degree, oLine.degree))
} else {
innerLines.push(drawRidgeLine(oPoint, canvas, roof, textMode))
}
@ -4757,13 +4769,13 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (length > 0) {
if (currentLine.type === TYPES.HIP) {
innerLines.push(drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree))
} else if (currentLine.type === TYPES.RIDGE) {
innerLines.push(drawRidgeLine(points, canvas, roof, textMode))
} else if (currentLine.type === TYPES.NEW) {
const isDiagonal = Math.abs(points[0] - points[2]) >= 1 && Math.abs(points[1] - points[3]) >= 1
if (isDiagonal && almostEqual(Math.abs(points[0] - points[2]), Math.abs(points[1] - points[3]))) {
innerLines.push(drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree))
innerLines.push(drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree))
}
if (!isDiagonal) {
innerLines.push(drawRidgeLine(points, canvas, roof, textMode))
@ -4788,7 +4800,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
const isDiagonal = Math.abs(points[0].x - points[1].x) >= 1 && Math.abs(points[0].y - points[1].y) >= 1
if (isDiagonal) {
innerLines.push(
drawHipLine([points[0].x, points[0].y, points[1].x, points[1].y], canvas, roof, textMode, null, currentDegree, currentDegree),
drawHipLine([points[0].x, points[0].y, points[1].x, points[1].y], canvas, roof, textMode, currentDegree, currentDegree),
)
} else {
innerLines.push(drawRidgeLine([points[0].x, points[0].y, points[1].x, points[1].y], canvas, roof, textMode))
@ -4829,9 +4841,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (line.degree === 0) {
innerLines.push(drawRoofLine([line.start.x, line.start.y, line.end.x, line.end.y], canvas, roof, textMode))
} else {
innerLines.push(
drawHipLine([line.start.x, line.start.y, line.end.x, line.end.y], canvas, roof, textMode, null, line.degree, line.degree),
)
innerLines.push(drawHipLine([line.start.x, line.start.y, line.end.x, line.end.y], canvas, roof, textMode, line.degree, line.degree))
}
}
}
@ -4841,6 +4851,8 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
//케라바에서 파생된 하단 지붕 라인처리
const downRoofGable = []
//처마에서 파생된 하단 지붕 라인 처리
let downRoofEaves = []
baseLines.forEach((baseLine, index) => {
const nextLine = baseLines[(index + 1) % baseLines.length]
const prevLine = baseLines[(index - 1 + baseLines.length) % baseLines.length]
@ -4856,7 +4868,8 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
prevLineVector.x === nextLineVector.x &&
prevLineVector.y === nextLineVector.y &&
baseLine.attributes.type === LINE_TYPE.WALLLINE.EAVES &&
(prevLine.attributes.type === LINE_TYPE.WALLLINE.GABLE || nextLine.attributes.type === LINE_TYPE.WALLLINE.GABLE)
prevLine.attributes.type === LINE_TYPE.WALLLINE.GABLE &&
nextLine.attributes.type === LINE_TYPE.WALLLINE.GABLE
) {
downRoofGable.push({ currLine: baseLine, currIndex: index, type: 'A' })
}
@ -4869,6 +4882,17 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
) {
downRoofGable.push({ currLine: baseLine, currIndex: index, type: 'B' })
}
const originPoint = baseLine.attributes.originPoint
if (
prevLineVector.x === nextLineVector.x &&
prevLineVector.y === nextLineVector.y &&
baseLine.attributes.type === LINE_TYPE.WALLLINE.EAVES &&
(prevLine.attributes.type === LINE_TYPE.WALLLINE.EAVES || nextLine.attributes.type === LINE_TYPE.WALLLINE.EAVES) &&
((originPoint.x1 !== baseLine.x1 && originPoint.x2 !== baseLine.x2) || (originPoint.y1 !== baseLine.y1 && originPoint.y2 !== baseLine.y2))
) {
downRoofEaves.push({ currLine: baseLine, currIndex: index })
}
})
const downRoofLines = [] // 하단지붕 파생 라인 처리후 innerLines에 추가.
@ -5046,7 +5070,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (minPoint) {
const hipPoint = [roofLinePoint[0], roofLinePoint[1], minPoint.x, minPoint.y]
downRoofLines.push(
drawHipLine(hipPoint, canvas, roof, textMode, null, getDegreeByChon(currLine.attributes.pitch), getDegreeByChon(currLine.attributes.pitch)),
drawHipLine(hipPoint, canvas, roof, textMode, getDegreeByChon(currLine.attributes.pitch), getDegreeByChon(currLine.attributes.pitch)),
)
if (isLine) {
@ -5067,14 +5091,6 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
downRoofGable
.filter((l) => l.type === 'B')
.forEach(({ currLine, currIndex }) => {
const checkLine = new fabric.Line([currLine.x1, currLine.y1, currLine.x2, currLine.y2], {
stroke: 'red',
strokeWidth: 4,
parentId: roofId,
name: 'check',
})
canvas.add(checkLine).renderAll()
// 라인의 방향
const currVector = { x: Math.sign(clamp01(currLine.x1 - currLine.x2)), y: Math.sign(clamp01(currLine.y1 - currLine.y2)) }
@ -5148,9 +5164,6 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
orthogonalEndDistance = Infinity,
orthogonalEndLine
oppLines.forEach((line) => {
const checkLine = new fabric.Line([line.x1, line.y1, line.x2, line.y2], { stroke: 'red', strokeWidth: 4, parentId: roofId, name: 'check' })
canvas.add(checkLine).renderAll()
if (currVector.x === 0) {
//세로선
// 시작포인트와 가까운 포인트의 길이
@ -5242,7 +5255,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
getDegreeByChon(currLine.attributes.pitch),
getDegreeByChon(currLine.attributes.pitch),
),
@ -5253,7 +5266,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
getDegreeByChon(currLine.attributes.pitch),
getDegreeByChon(currLine.attributes.pitch),
),
@ -5261,6 +5274,226 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
}
})
//처마에서 파생된 하단 지붕 라인 처리.
downRoofEaves.forEach(({ currLine, currIndex }) => {
const prevIndex = (currIndex - 1 + baseLines.length) % baseLines.length
const nextIndex = (currIndex + 1) % baseLines.length
const analyze = analyzeLine(currLine)
const currMidX = (currLine.x1 + currLine.x2) / 2
const currMidY = (currLine.y1 + currLine.y2) / 2
const roofLine = analyze.roofLine
const roofVector = { x: Math.sign(clamp01(roofLine.x2 - roofLine.x1)), y: Math.sign(clamp01(roofLine.y2 - roofLine.y1)) }
const originPoint = currLine.attributes.originPoint
let isFlowInside // 조정된 형이 안쪽인지 바깥쪽인지 판단.
let flowDistance = 0 // 조정된 거리
if (analyze.isVertical) {
//세로선
flowDistance = Math.abs(currLine.x1 - originPoint.x1)
const isLeftIn = checkWallPolygon.inPolygon({ x: currMidX - 1, y: currMidY })
const vector = Math.sign(currLine.x1 - originPoint.x1)
isFlowInside = isLeftIn ? vector < 0 : vector > 0
} else if (analyze.isHorizontal) {
//가로선
flowDistance = Math.abs(currLine.y1 - originPoint.y1)
const isTopIn = checkWallPolygon.inPolygon({ x: currMidX, y: currMidY - 1 })
const vector = Math.sign(currLine.y1 - originPoint.y1)
isFlowInside = isTopIn ? vector < 0 : vector > 0
}
console.log('isFlowInside', isFlowInside)
const roofCheckPoint = { x: roofLine.x2 + roofVector.x, y: roofLine.y2 + roofVector.y }
console.log('roofCheck : ', roof.inPolygon(roofCheckPoint))
let otherLine = roof.inPolygon(roofCheckPoint) ? baseLines[nextIndex] : baseLines[prevIndex]
//상단 지붕
const upLine = isFlowInside ? otherLine : currLine
//하단 지붕
const downLine = isFlowInside ? currLine : otherLine
const allLinePoint = [
{ x: upLine.x1, y: upLine.y1 },
{ x: upLine.x2, y: upLine.y2 },
{ x: downLine.x1, y: downLine.y1 },
{ x: downLine.x2, y: downLine.y2 },
]
//두 라인이 만나는 포인트
let joinPoint
allLinePoint.forEach((point, i) => {
allLinePoint.forEach((point2, j) => {
if (i !== j && point.x === point2.x && point.y === point2.y) {
joinPoint = point
}
})
})
const upDegree = getDegreeByChon(upLine.attributes.pitch)
const upAnalyze = analyzeLine(upLine)
const upRoofLine = upAnalyze.roofLine
const addUpOffset = flowDistance //상단 지붕선의 추가길이
const upRoofVector = { x: Math.sign(clamp01(upRoofLine.x2 - upRoofLine.x1)), y: Math.sign(clamp01(upRoofLine.y2 - upRoofLine.y1)) }
const upRoofPoint = [] //상단 지붕선
let upHipStartPoint
if (roof.inPolygon({ x: upRoofLine.x2 + upRoofVector.x * addUpOffset, y: upRoofLine.y2 + upRoofVector.y * addUpOffset })) {
upRoofPoint.push(upRoofLine.x1, upRoofLine.y1, upRoofLine.x2 + upRoofVector.x * addUpOffset, upRoofLine.y2 + upRoofVector.y * addUpOffset)
upHipStartPoint = { x: upRoofLine.x1, y: upRoofLine.y1 }
} else {
upRoofPoint.push(upRoofLine.x1 - upRoofVector.x * addUpOffset, upRoofLine.y1 - upRoofVector.y * addUpOffset, upRoofLine.x2, upRoofLine.y2)
upHipStartPoint = { x: upRoofLine.x2, y: upRoofLine.y2 }
}
const downDegree = getDegreeByChon(downLine.attributes.pitch)
const downAnalyze = analyzeLine(downLine)
const downRoofLine = downAnalyze.roofLine
const addDownOffset = upLine.attributes.offset // 하단 지붕선의 추가길이
const downRoofVector = { x: Math.sign(clamp01(downRoofLine.x2 - downRoofLine.x1)), y: Math.sign(clamp01(downRoofLine.y2 - downRoofLine.y1)) }
const downRoofPoint = [] // 하단 지붕선
let downHipStartPoint
if (roof.inPolygon({ x: downRoofLine.x2 + downRoofVector.x * addDownOffset, y: downRoofLine.y2 + downRoofVector.y * addDownOffset })) {
downRoofPoint.push(
downRoofLine.x1,
downRoofLine.y1,
downRoofLine.x2 + downRoofVector.x * addDownOffset,
downRoofLine.y2 + downRoofVector.y * addDownOffset,
)
downHipStartPoint = { x: downRoofPoint[2], y: downRoofPoint[3] }
} else {
downRoofPoint.push(
downRoofLine.x1 - downRoofVector.x * addDownOffset,
downRoofLine.y1 - downRoofVector.y * addDownOffset,
downRoofLine.x2,
downRoofLine.y2,
)
downHipStartPoint = { x: downRoofPoint[0], y: downRoofPoint[1] }
}
const checkUpLine = new fabric.Line(upRoofPoint, { stroke: 'red', strokeWidth: 4, parentId: roofId, name: 'check' })
const checkDownLine = new fabric.Line(downRoofPoint, { stroke: 'yellow', strokeWidth: 4, parentId: roofId, name: 'check' })
canvas.add(checkUpLine, checkDownLine).renderAll()
//상단지붕선과 만나는 innerLines 조정
const upRoofEdge = { vertex1: { x: upRoofPoint[0], y: upRoofPoint[1] }, vertex2: { x: upRoofPoint[2], y: upRoofPoint[3] } }
let upHipVector = getHalfAngleVector(upLine, downLine)
const vectorCheckPoint = { x: joinPoint.x + upHipVector.x, y: joinPoint.y + upHipVector.y }
if (!checkWallPolygon.inPolygon(vectorCheckPoint)) {
upHipVector = { x: -upHipVector.x, y: -upHipVector.y }
}
const findUpP1 = { x: joinPoint.x, y: joinPoint.y }
const findUpP2 = { x: joinPoint.x + upHipVector.x, y: joinPoint.y + upHipVector.y }
// 상하단 지붕이 만나는 교점에서 파생되는 추녀마루 확인.
let joinHipLine = innerLines.find((line) => {
return isPointOnLineNew(line, findUpP1) && isPointOnLineNew(line, findUpP2)
})
if (joinHipLine) {
// 상단 지붕선과 추녀마루의 교점 파악.
const joinHipEdge = { vertex1: { x: joinHipLine.x1, y: joinHipLine.y1 }, vertex2: { x: joinHipLine.x2, y: joinHipLine.y2 } }
const intersectJoin = edgesIntersection(upRoofEdge, joinHipEdge)
// 연결된 추녀마루 포인트 조정
const pointVector1 = { x: Math.sign(clamp01(joinHipLine.x1 - intersectJoin.x)), y: Math.sign(clamp01(joinHipLine.y1 - intersectJoin.y)) }
const pointVector2 = { x: Math.sign(clamp01(joinHipLine.x2 - intersectJoin.x)), y: Math.sign(clamp01(joinHipLine.y2 - intersectJoin.y)) }
let joinEndPoint
if (pointVector1.x === upHipVector.x && pointVector1.y === upHipVector.y) {
joinHipLine.set({
x1: intersectJoin.x,
y1: intersectJoin.y,
x2: joinHipLine.x1,
y2: joinHipLine.y1,
})
joinHipLine.setCoords()
joinEndPoint = { x: joinHipLine.x1, y: joinHipLine.y1 }
} else if (pointVector2.x === upHipVector.x && pointVector2.y === upHipVector.y) {
joinHipLine.set({
x1: intersectJoin.x,
y1: intersectJoin.y,
x2: joinHipLine.x2,
y2: joinHipLine.y2,
})
joinHipLine.setCoords()
joinEndPoint = { x: joinHipLine.x2, y: joinHipLine.y2 }
}
let upSideLine
baseLines.forEach((line, index) => {
if (line === upLine) {
const upPrevLine = baseLines[(index - 1 + baseLines.length) % baseLines.length]
const upNextLine = baseLines[(index + 1) % baseLines.length]
upSideLine = upPrevLine === downLine ? upNextLine : upPrevLine
}
})
//상단 지붕선과 붙어있는 다른 지붕선이 처마일때 추녀마루가 포함될수 있기 때문에 확인하여 라인조정
if (upSideLine && upSideLine.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
const hipDegree = getDegreeByChon(upSideLine.attributes.pitch)
let minDistance = Infinity
let connectPoint
innerLines
.filter((line) => line !== joinHipLine)
.forEach((line) => {
const lineEdge = { vertex1: { x: line.x1, y: line.y1 }, vertex2: { x: line.x2, y: line.y2 } }
const intersect = edgesIntersection(upRoofEdge, lineEdge)
if (
intersect &&
isPointOnLineNew(line, intersect) &&
isPointOnLineNew({ x1: upRoofPoint[0], y1: upRoofPoint[1], x2: upRoofPoint[2], y2: upRoofPoint[3] }, intersect)
) {
const distance = Math.sqrt(Math.pow(intersect.x - upHipStartPoint.x, 2) + Math.pow(intersect.y - upHipStartPoint.y, 2))
if (distance < minDistance) {
minDistance = distance
connectPoint = intersect
}
}
})
if (connectPoint && minDistance > EPSILON) {
let upHipPoint
if (upHipStartPoint.x === upRoofLine.x1 && upHipStartPoint.y === upRoofLine.y1) {
upHipPoint = [upHipStartPoint.x, upHipStartPoint.y, connectPoint.x, connectPoint.y]
} else {
upHipPoint = [connectPoint.x, connectPoint.y, upHipStartPoint.x, upHipStartPoint.y]
}
downRoofLines.push(drawHipLine(upHipPoint, canvas, roof, textMode, hipDegree, hipDegree)) //각도 있는 처마지붕선
downRoofLines.push(drawRoofLine([connectPoint.x, connectPoint.y, intersectJoin.x, intersectJoin.y], canvas, roof, textMode)) //각도 없는 처마지붕선
} else {
downRoofLines.push(drawRoofLine([upHipStartPoint.x, upHipStartPoint.y, intersectJoin.x, intersectJoin.y], canvas, roof, textMode))
}
} else {
downRoofLines.push(drawRoofLine([upHipStartPoint.x, upHipStartPoint.y, intersectJoin.x, intersectJoin.y], canvas, roof, textMode))
}
//하단지붕선 추가.
const downHipEdge = {
vertex1: { x: downHipStartPoint.x, y: downHipStartPoint.y },
vertex2: { x: downHipStartPoint.x + upRoofVector.x, y: downHipStartPoint.y + upRoofVector.y },
}
const intersectDownJoin = edgesIntersection(downHipEdge, joinHipEdge)
//하단 지붕선에는 지붕선, 추녀마루1, 추녀마루2 가 생성되는것이 기본모양임.
if (intersectDownJoin && isPointOnLineNew(joinHipLine, intersectDownJoin)) {
//지붕선
downRoofLines.push(drawRoofLine(downRoofPoint, canvas, roof, textMode))
//지붕선에서 올라가는 추녀마루1
downRoofLines.push(
drawHipLine(
[downHipStartPoint.x, downHipStartPoint.y, intersectDownJoin.x, intersectDownJoin.y],
canvas,
roof,
textMode,
downDegree,
downDegree,
),
)
//추녀마루에서 마루로 연결되는 추녀마루2
downRoofLines.push(
drawHipLine([intersectDownJoin.x, intersectDownJoin.y, joinEndPoint.x, joinEndPoint.y], canvas, roof, textMode, downDegree, downDegree),
)
}
}
})
// canvas.renderAll()
//추가된 하단 지붕 라인 innerLines에 추가.
innerLines.push(...downRoofLines)
@ -5314,7 +5547,7 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
for (let i = 0; i < splitPoint.length; i++) {
const point = splitPoint[i].point
if (i === 0) {
innerLines.push(drawHipLine([startPoint.x, startPoint.y, point.x, point.y], canvas, roof, textMode, null, prevDegree, prevDegree))
innerLines.push(drawHipLine([startPoint.x, startPoint.y, point.x, point.y], canvas, roof, textMode, prevDegree, prevDegree))
} else {
innerLines.push(drawRoofLine([startPoint.x, startPoint.y, point.x, point.y], canvas, roof, textMode))
}
@ -5323,15 +5556,14 @@ export const drawRoofByAttribute = (roofId, canvas, textMode) => {
if (splitPoint.length === 1) {
innerLines.push(drawRoofLine([startPoint.x, startPoint.y, currentLine.x2, currentLine.y2], canvas, roof, textMode))
} else {
innerLines.push(
drawHipLine([startPoint.x, startPoint.y, currentLine.x2, currentLine.y2], canvas, roof, textMode, null, nextDegree, nextDegree),
)
innerLines.push(drawHipLine([startPoint.x, startPoint.y, currentLine.x2, currentLine.y2], canvas, roof, textMode, nextDegree, nextDegree))
}
} else {
innerLines.push(drawRoofLine([currentLine.x1, currentLine.y1, currentLine.x2, currentLine.y2], canvas, roof, textMode))
}
})
console.log('innerLines : ', innerLines)
//지붕 innerLines에 추가.
roof.innerLines = innerLines
@ -6202,7 +6434,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
prevDegree,
)
@ -6250,7 +6482,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
nextDegree,
nextDegree,
)
@ -6311,10 +6543,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
connectHipPoint = [firstHipPoint[0], firstHipPoint[1], secondHipPoint[0], secondHipPoint[1]]
firstRoofPoint = [currentRoof.x1, currentRoof.y1, firstHipPoint[0], firstHipPoint[1]]
secondRoofPoint = [currentRoof.x2, currentRoof.y2, secondHipPoint[0], secondHipPoint[1]]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, nextDegree, nextDegree)
const connectHipLine = drawRoofLine(connectHipPoint, canvas, roof, textMode)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: firstRoofLine.x1, y1: firstRoofLine.y1, x2: firstRoofLine.x2, y2: firstRoofLine.y2, line: firstRoofLine })
@ -6324,8 +6556,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
} else {
const firstHipPoint = [currentRoof.x1, currentRoof.y1, currentMidX.toNumber(), currentMidY.toNumber()]
const secondHipPoint = [currentRoof.x2, currentRoof.y2, currentMidX.toNumber(), currentMidY.toNumber()]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, nextDegree, nextDegree)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: secondHipLine.x1, y1: secondHipLine.y1, x2: secondHipLine.x2, y2: secondHipLine.y2, line: secondHipLine })
}
@ -6413,7 +6645,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
nextDegree,
afterNextDegree,
)
@ -6431,7 +6663,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
afterNextDegree,
)
@ -6586,10 +6818,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
connectHipPoint = [firstHipPoint[0], firstHipPoint[1], secondHipPoint[0], secondHipPoint[1]]
firstRoofPoint = [currentRoof.x1, currentRoof.y1, firstHipPoint[0], firstHipPoint[1]]
secondRoofPoint = [currentRoof.x2, currentRoof.y2, secondHipPoint[0], secondHipPoint[1]]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, nextDegree, nextDegree)
const connectHipLine = drawRoofLine(connectHipPoint, canvas, roof, textMode)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: firstRoofLine.x1, y1: firstRoofLine.y1, x2: firstRoofLine.x2, y2: firstRoofLine.y2, line: firstRoofLine })
@ -6599,8 +6831,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
} else {
const firstHipPoint = [currentRoof.x1, currentRoof.y1, currentMidX.toNumber(), currentMidY.toNumber()]
const secondHipPoint = [currentRoof.x2, currentRoof.y2, currentMidX.toNumber(), currentMidY.toNumber()]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, nextDegree, nextDegree)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: secondHipLine.x1, y1: secondHipLine.y1, x2: secondHipLine.x2, y2: secondHipLine.y2, line: secondHipLine })
}
@ -6915,7 +7147,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
degree,
degree,
)
@ -6978,7 +7210,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
degree,
degree,
)
@ -7116,10 +7348,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
connectHipPoint = [firstHipPoint[0], firstHipPoint[1], secondHipPoint[0], secondHipPoint[1]]
firstRoofPoint = [currentRoof.x1, currentRoof.y1, firstHipPoint[0], firstHipPoint[1]]
secondRoofPoint = [currentRoof.x2, currentRoof.y2, secondHipPoint[0], secondHipPoint[1]]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, degree, degree)
const firstRoofLine = drawHipLine(firstRoofPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, degree, degree)
const secondRoofLine = drawHipLine(secondRoofPoint, canvas, roof, textMode, nextDegree, nextDegree)
const connectHipLine = drawRoofLine(connectHipPoint, canvas, roof, textMode)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: firstRoofLine.x1, y1: firstRoofLine.y1, x2: firstRoofLine.x2, y2: firstRoofLine.y2, line: firstRoofLine })
@ -7129,8 +7361,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
} else {
const firstHipPoint = [currentRoof.x1, currentRoof.y1, currentMidX.toNumber(), currentMidY.toNumber()]
const secondHipPoint = [currentRoof.x2, currentRoof.y2, currentMidX.toNumber(), currentMidY.toNumber()]
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const firstHipLine = drawHipLine(firstHipPoint, canvas, roof, textMode, prevDegree, prevDegree)
const secondHipLine = drawHipLine(secondHipPoint, canvas, roof, textMode, nextDegree, nextDegree)
baseHipLines.push({ x1: firstHipLine.x1, y1: firstHipLine.y1, x2: firstHipLine.x2, y2: firstHipLine.y2, line: firstHipLine })
baseHipLines.push({ x1: secondHipLine.x1, y1: secondHipLine.y1, x2: secondHipLine.x2, y2: secondHipLine.y2, line: secondHipLine })
}
@ -7457,7 +7689,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
prevDegree,
)
@ -7475,7 +7707,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
nextDegree,
nextDegree,
)
@ -8259,7 +8491,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
line = drawRoofLine(points, canvas, roof, textMode)
baseGableLines.push(line)
} else {
line = drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree)
line = drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree)
baseHipLines.push({ x1: line.x1, y1: line.y1, x2: line.x2, y2: line.y2, line })
}
})
@ -8653,7 +8885,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
return
}
const hipLine = drawHipLine(points, canvas, roof, textMode, null, currentDegree, currentDegree)
const hipLine = drawHipLine(points, canvas, roof, textMode, currentDegree, currentDegree)
if (currentVectorX === 0) {
if (Math.sign(currentPoint.x - nextPoint.x) === 0) {
hipLine.attributes.actualSize = hipLine.attributes.planeSize
@ -8789,7 +9021,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
)
if (gableLines.length === 0 && hipLines.length === 0) {
const hipLine1 = drawHipLine(hipPoint1, canvas, roof, textMode, null, degree1, degree1)
const hipLine1 = drawHipLine(hipPoint1, canvas, roof, textMode, degree1, degree1)
baseHipLines.push({ x1: hipLine1.x1, y1: hipLine1.y1, x2: hipLine1.x2, y2: hipLine1.y2, line: hipLine1 })
}
}
@ -8805,7 +9037,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
(line.x2 === hipPoint2[0] && line.y2 === hipPoint2[1] && line.x1 === hipPoint2[2] && line.y1 === hipPoint2[3]),
)
if (hipLines.length === 0 && gableLines.length === 0) {
const hipLine2 = drawHipLine(hipPoint2, canvas, roof, textMode, null, degree2, degree2)
const hipLine2 = drawHipLine(hipPoint2, canvas, roof, textMode, degree2, degree2)
baseHipLines.push({ x1: hipLine2.x1, y1: hipLine2.y1, x2: hipLine2.x2, y2: hipLine2.y2, line: hipLine2 })
}
}
@ -8873,7 +9105,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
)
if (hipLines.length === 0 && gableLines.length === 0) {
const hipLine1 = drawHipLine(hipPoint1, canvas, roof, textMode, null, degree1, degree1)
const hipLine1 = drawHipLine(hipPoint1, canvas, roof, textMode, degree1, degree1)
baseHipLines.push({ x1: hipLine1.x1, y1: hipLine1.y1, x2: hipLine1.x2, y2: hipLine1.y2, line: hipLine1 })
}
}
@ -8889,7 +9121,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
(line.x2 === hipPoint2[0] && line.y2 === hipPoint2[1] && line.x1 === hipPoint2[2] && line.y1 === hipPoint2[3]),
)
if (hipLines.length === 0 && gableLines.length === 0) {
const hipLine2 = drawHipLine(hipPoint2, canvas, roof, textMode, null, degree2, degree2)
const hipLine2 = drawHipLine(hipPoint2, canvas, roof, textMode, degree2, degree2)
baseHipLines.push({ x1: hipLine2.x1, y1: hipLine2.y1, x2: hipLine2.x2, y2: hipLine2.y2, line: hipLine2 })
}
}
@ -9024,8 +9256,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
Big(currentRoof.x2).plus(Big(nextHipVector.x).times(lineWidth)).toNumber(),
Big(currentRoof.y2).plus(Big(nextHipVector.y).times(lineWidth)).toNumber(),
]
const prevHipLine = drawHipLine(prevPoint, canvas, roof, textMode, null, prevDegree, currentDegree)
const nextHipLine = drawHipLine(nextPoint, canvas, roof, textMode, null, currentDegree, nextDegree)
const prevHipLine = drawHipLine(prevPoint, canvas, roof, textMode, prevDegree, currentDegree)
const nextHipLine = drawHipLine(nextPoint, canvas, roof, textMode, currentDegree, nextDegree)
baseHipLines.push({ x1, y1, x2: prevHipLine.x1, y2: prevHipLine.y1, line: prevHipLine })
baseHipLines.push({ x1: x2, y1: y2, x2: nextHipLine.x1, y2: nextHipLine.y1, line: nextHipLine })
@ -9041,8 +9273,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const prevGablePoint = [prevHipLine.x2, prevHipLine.y2, midX, midY]
const nextGablePoint = [nextHipLine.x2, nextHipLine.y2, midX, midY]
const prevGableLine = drawHipLine(prevGablePoint, canvas, roof, textMode, null, prevDegree, currentDegree)
const nextGableLine = drawHipLine(nextGablePoint, canvas, roof, textMode, null, currentDegree, nextDegree)
const prevGableLine = drawHipLine(prevGablePoint, canvas, roof, textMode, prevDegree, currentDegree)
const nextGableLine = drawHipLine(nextGablePoint, canvas, roof, textMode, currentDegree, nextDegree)
baseHipLines.push({ x1: prevGableLine.x1, y1: prevGableLine.y1, x2: prevGableLine.x2, y2: prevGableLine.y2, line: prevGableLine })
baseHipLines.push({ x1: nextGableLine.x1, y1: nextGableLine.y1, x2: nextGableLine.x2, y2: nextGableLine.y2, line: nextGableLine })
@ -9809,8 +10041,8 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const prevHipPoint = [currentRoof.x1, currentRoof.y1, currentMidX, currentMidY]
const nextHipPoint = [currentRoof.x2, currentRoof.y2, currentMidX, currentMidY]
const prevHipLine = drawHipLine(prevHipPoint, canvas, roof, textMode, null, prevDegree, prevDegree)
const nextHipLine = drawHipLine(nextHipPoint, canvas, roof, textMode, null, nextDegree, nextDegree)
const prevHipLine = drawHipLine(prevHipPoint, canvas, roof, textMode, prevDegree, prevDegree)
const nextHipLine = drawHipLine(nextHipPoint, canvas, roof, textMode, nextDegree, nextDegree)
baseHipLines.push({ x1: prevHipLine.x1, y1: prevHipLine.y1, x2: prevHipLine.x2, y2: prevHipLine.y2, line: prevHipLine })
baseHipLines.push({ x1: nextHipLine.x1, y1: nextHipLine.y1, x2: nextHipLine.x2, y2: nextHipLine.y2, line: nextHipLine })
}
@ -10258,7 +10490,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
currentDegree,
)
@ -10402,7 +10634,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
currentDegree,
)
@ -10847,7 +11079,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
ridgeLine.x1 === firstHipLine.x1 ? firstHipLine.x2 : firstHipLine.x1,
ridgeLine.y2,
]
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, null, firstDegree, firstDegree)
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, firstDegree, firstDegree)
baseHipLines.push({
x1: oppositeRoofLine.x1,
y1: oppositeRoofLine.y1,
@ -10905,7 +11137,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const intersection = intersections[0].intersection
const intersectRidge = intersections[0].ridge
const oppositeRoofPoints = [ridgeLine.x2, ridgeLine.y2, intersection.x, intersection.y]
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, null, secondDegree, secondDegree)
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, secondDegree, secondDegree)
baseHipLines.push({
x1: oppositeLine.x1,
y1: oppositeLine.y1,
@ -10948,7 +11180,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
ridgeLine.x2,
ridgeLine.y1 === firstHipLine.y1 ? firstHipLine.y2 : firstHipLine.y1,
]
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, null, firstDegree, firstDegree)
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, firstDegree, firstDegree)
baseHipLines.push({
x1: oppositeRoofLine.x1,
y1: oppositeRoofLine.y1,
@ -11005,7 +11237,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const intersection = intersections[0].intersection
const intersectRidge = intersections[0].ridge
const oppositeRoofPoints = [ridgeLine.x2, ridgeLine.y2, intersection.x, intersection.y]
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, null, secondDegree, secondDegree)
const oppositeRoofLine = drawHipLine(oppositeRoofPoints, canvas, roof, textMode, secondDegree, secondDegree)
baseHipLines.push({
x1: oppositeLine.x1,
y1: oppositeLine.y1,
@ -11242,7 +11474,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
currentDegree,
)
@ -11384,7 +11616,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
currentDegree,
)
@ -11671,7 +11903,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
}
})
const hipLine = drawHipLine(point, canvas, roof, textMode, null, prevDegree, currentDegree)
const hipLine = drawHipLine(point, canvas, roof, textMode, prevDegree, currentDegree)
if (hipBasePoint) {
baseHipLines.push({ x1: hipBasePoint.x1, y1: hipBasePoint.y1, x2: point[2], y2: point[3], line: hipLine })
} else {
@ -11854,7 +12086,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
canvas,
roof,
textMode,
null,
prevDegree,
currentDegree,
)
@ -12158,7 +12390,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
.lt(1)
) {
// console.log('힙1')
const hipLine = drawHipLine(hipStartPoint, canvas, roof, textMode, null, prevDegree, currentDegree)
const hipLine = drawHipLine(hipStartPoint, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({
x1: hipStartPoint[0],
y1: hipStartPoint[1],
@ -12192,7 +12424,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
.abs()
.lt(1)
) {
const hipLine = drawHipLine(isStartPoint, canvas, roof, textMode, null, prevDegree, currentDegree)
const hipLine = drawHipLine(isStartPoint, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({
x1: isStartPoint[0],
y1: isStartPoint[1],
@ -12348,14 +12580,14 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
const overlapLine = overlapLineX[0]
const maxX = Math.max(overlapLine.x1, overlapLine.x2)
const point = [hipLine.x2, hipLine.y2, maxX, hipLine.y2]
const addLine = drawHipLine(point, canvas, roof, textMode, null, prevDegree, currentDegree)
const addLine = drawHipLine(point, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({ x1: point[0], y1: point[1], x2: point[2], y2: point[3], line: addLine })
}
if (overlapLineY.length > 0) {
const overlapLine = overlapLineY[0]
const maxY = Math.max(overlapLine.y1, overlapLine.y2)
const point = [hipLine.x2, hipLine.y2, hipLine.x2, maxY]
const addLine = drawHipLine(point, canvas, roof, textMode, null, prevDegree, currentDegree)
const addLine = drawHipLine(point, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({ x1: point[0], y1: point[1], x2: point[2], y2: point[3], line: addLine })
}
}
@ -12403,7 +12635,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
hipLine.x1 === horizonPoint[0] && hipLine.y1 === horizonPoint[1] && hipLine.x2 === horizonPoint[2] && hipLine.y2 === horizonPoint[3],
)
if (!alreadyHorizonLines) {
addLine = drawHipLine(horizonPoint, canvas, roof, textMode, null, prevDegree, currentDegree)
addLine = drawHipLine(horizonPoint, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({
x1: horizonPoint[0],
y1: horizonPoint[1],
@ -12426,7 +12658,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
hipLine.x1 === verticalPoint[0] && hipLine.y1 === verticalPoint[1] && hipLine.x2 === verticalPoint[2] && hipLine.y2 === verticalPoint[3],
)
if (!alreadyVerticalLine) {
addLine = drawHipLine(verticalPoint, canvas, roof, textMode, null, prevDegree, currentDegree)
addLine = drawHipLine(verticalPoint, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({
x1: verticalPoint[0],
y1: verticalPoint[1],
@ -12567,7 +12799,7 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
)
if (!baseIntersection && alreadyHips.length === 0 && otherHipInterSection.length === 0) {
const hipLine = drawHipLine(hipPoints, canvas, roof, textMode, null, prevDegree, currentDegree)
const hipLine = drawHipLine(hipPoints, canvas, roof, textMode, prevDegree, currentDegree)
baseHipLines.push({ x1: hipPoints[0], y1: hipPoints[1], x2: hipPoints[2], y2: hipPoints[3], line: hipLine })
}
}
@ -12619,11 +12851,10 @@ export const drawRidgeRoof = (roofId, canvas, textMode) => {
* @param canvas
* @param roof
* @param textMode
* @param currentRoof
* @param prevDegree
* @param currentDegree
*/
const drawHipLine = (points, canvas, roof, textMode, currentRoof, prevDegree, currentDegree) => {
const drawHipLine = (points, canvas, roof, textMode, prevDegree, currentDegree) => {
/** 대각선인 경우 경사를 조정해서 계산*/
const baseX = Big(points[0]).minus(Big(points[2])).abs()
const baseY = Big(points[1]).minus(Big(points[3])).abs()