처마 용마루 방향에 따른 타입 작업

This commit is contained in:
yjnoh 2025-03-20 17:59:58 +09:00
parent 79d873c135
commit 414d6fa0c5

View File

@ -1100,20 +1100,22 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
}
})
const maxLine = polygon.lines
.filter((line) => line[coord1] === line[coord2])
.sort(
(a, b) =>
(polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] -
(polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1],
)[0]
//직선 찾는 로직
const maxLine = polygon.lines.filter((line) => line[coord1] === line[coord2])
if (maxLine.length > 0) {
const maxLineSorted = maxLine.reduce((a, b) => {
return (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] >
(polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1]
? b
: a
})
if (maxLine) {
if (
(polygon.direction === 'south' && maxLine.direction === 'left') ||
(polygon.direction === 'north' && maxLine.direction === 'right') ||
(polygon.direction === 'east' && maxLine.direction === 'bottom') ||
(polygon.direction === 'west' && maxLine.direction === 'top')
(polygon.direction === 'south' && maxLineSorted.direction === 'left') ||
(polygon.direction === 'north' && maxLineSorted.direction === 'right') ||
(polygon.direction === 'east' && maxLineSorted.direction === 'bottom') ||
(polygon.direction === 'west' && maxLineSorted.direction === 'top')
) {
polygon.lines.forEach((line) => {
if (line.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
@ -1123,30 +1125,43 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
}
})
}
if (maxLine.length === 1) {
const maxLineCoord = polygon.lines.reduce((a, b) => {
return (polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] >
(polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1]
? b
: a
})
const isRealEavesLine = polygon.lines.find((line) => line.attributes.type === LINE_TYPE.WALLLINE.EAVES)
if (isRealEavesLine) {
if (polygon.direction === 'south' || polygon.direction === 'north') {
const targetCoord =
polygon.direction === 'south' ? Math.max(maxLineCoord.y1, maxLineCoord.y2) : Math.min(maxLineCoord.y1, maxLineCoord.y2)
const realLineCoord =
polygon.direction === 'south' ? Math.max(isRealEavesLine.y1, isRealEavesLine.y2) : Math.min(isRealEavesLine.y1, isRealEavesLine.y2)
if (targetCoord !== realLineCoord) {
isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE
}
} else if (polygon.direction === 'east' || polygon.direction === 'west') {
const targetCoord = polygon.direction === 'east' ? Math.max(maxLineCoord.x1, maxLineCoord.x2) : Math.min(maxLineCoord.x1, maxLineCoord.x2)
const realLineCoord =
polygon.direction === 'east' ? Math.max(isRealEavesLine.x1, isRealEavesLine.x2) : Math.min(isRealEavesLine.x1, isRealEavesLine.x2)
if (targetCoord !== realLineCoord) {
isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE
}
}
}
}
}
/**
* 진짜 처마 라인인지 확인하는 로직 -> 특정 모양에 따라 처마가 없는 경우가 있는데 위에 로직으로는
* 용마루도 처마로 만들어서 재보정
*/
const maxLineCoord = polygon.lines.sort(
(a, b) =>
(polygon.direction === 'south' || polygon.direction === 'east' ? b : a)[coord1] -
(polygon.direction === 'south' || polygon.direction === 'east' ? a : b)[coord1],
)[0]
const isRealEavesLine = polygon.lines.find((line) => line.attributes.type === LINE_TYPE.WALLLINE.EAVES)
if (isRealEavesLine) {
if (polygon.direction === 'south' || polygon.direction === 'north') {
if (maxLineCoord.y1 !== isRealEavesLine.y1) {
isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE
}
} else if (polygon.direction === 'east' || polygon.direction === 'west') {
if (maxLineCoord.x1 !== isRealEavesLine.x1) {
isRealEavesLine.attributes.type = LINE_TYPE.SUBLINE.RIDGE
}
}
}
}
const updateFlippedPoints = (polygon) => {