dev #534
@ -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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user