지붕면 이동 후 선택 제대로 안되는 현상 수정, 지붕면 할당 시 방향 화살표 전부 남쪽으로 되는 현상 수정

This commit is contained in:
hyojun.choi 2025-12-16 13:34:52 +09:00
parent 01a34fb8bc
commit b0b87bbd66
3 changed files with 46 additions and 37 deletions

View File

@ -61,6 +61,7 @@ export const LINE_TYPE = {
*/ */
DEFAULT: 'default', DEFAULT: 'default',
EAVES: 'eaves', EAVES: 'eaves',
EAVE_HELP_LINE: 'eaveHelpLine',
GABLE: 'gable', GABLE: 'gable',
GABLE_LEFT: 'gableLeft', //케라바 왼쪽 GABLE_LEFT: 'gableLeft', //케라바 왼쪽
GABLE_RIGHT: 'gableRight', //케라바 오른쪽 GABLE_RIGHT: 'gableRight', //케라바 오른쪽

View File

@ -1,7 +1,13 @@
'use client' 'use client'
import { useRecoilValue, useResetRecoilState } from 'recoil' import { useRecoilValue, useResetRecoilState } from 'recoil'
import { canvasSettingState, canvasState, currentCanvasPlanState, currentObjectState, globalPitchState } from '@/store/canvasAtom' import {
canvasSettingState,
canvasState,
currentCanvasPlanState,
currentObjectState,
globalPitchState,
} from '@/store/canvasAtom'
import { LINE_TYPE, MENU, POLYGON_TYPE } from '@/common/common' import { LINE_TYPE, MENU, POLYGON_TYPE } from '@/common/common'
import { getIntersectionPoint } from '@/util/canvas-util' import { getIntersectionPoint } from '@/util/canvas-util'
import { degreesToRadians } from '@turf/turf' import { degreesToRadians } from '@turf/turf'
@ -879,7 +885,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
} }
}) })
// roof.fire('polygonMoved') roof.fire('polygonMoved')
roof.fire('modified') roof.fire('modified')
drawDirectionArrow(roof) drawDirectionArrow(roof)
changeCorridorDimensionText() changeCorridorDimensionText()

View File

@ -856,7 +856,7 @@ export const usePolygon = () => {
if (innerLine.attributes && polygonLine.attributes.type) { if (innerLine.attributes && polygonLine.attributes.type) {
// innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경 // innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경
if (polygonLine.length < innerLine.length) { if (polygonLine.length < innerLine.length) {
if(polygonLine.lineName !== 'eaveHelpLine'){ if (polygonLine.lineName !== 'eaveHelpLine') {
polygonLine.need = false polygonLine.need = false
} }
} }
@ -867,7 +867,6 @@ export const usePolygon = () => {
// innerLine.attributes.isStart = true // innerLine.attributes.isStart = true
// innerLine.parentLine = polygonLine // innerLine.parentLine = polygonLine
// 매핑된 innerLine의 attributes를 변경 (교차점 계산 전에 적용) // 매핑된 innerLine의 attributes를 변경 (교차점 계산 전에 적용)
innerLineMapping.forEach((polygonLine, innerLine) => { innerLineMapping.forEach((polygonLine, innerLine) => {
innerLine.attributes.planeSize = innerLine.attributes.planeSize ?? polygonLine.attributes.planeSize innerLine.attributes.planeSize = innerLine.attributes.planeSize ?? polygonLine.attributes.planeSize
@ -877,7 +876,6 @@ export const usePolygon = () => {
innerLine.attributes.isStart = true innerLine.attributes.isStart = true
innerLine.parentLine = polygonLine innerLine.parentLine = polygonLine
}) })
} }
} }
}) })
@ -1387,7 +1385,7 @@ export const usePolygon = () => {
let representLine let representLine
// 지붕을 그리면서 기존 polygon의 line중 연결된 line을 찾는다. // 지붕을 그리면서 기존 polygon의 line중 연결된 line을 찾는다.
[...polygonLines, ...innerLines].forEach((line) => { ;[...polygonLines, ...innerLines].forEach((line) => {
let startFlag = false let startFlag = false
let endFlag = false let endFlag = false
const startPoint = line.startPoint const startPoint = line.startPoint
@ -1402,7 +1400,10 @@ export const usePolygon = () => {
}) })
if (startFlag && endFlag) { if (startFlag && endFlag) {
if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.EAVES) { if (
!representLines.includes(line) &&
(line.attributes.type === LINE_TYPE.WALLLINE.EAVES || line.attributes.type === LINE_TYPE.WALLLINE.EAVE_HELP_LINE)
) {
representLines.push(line) representLines.push(line)
} else if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.HIPANDGABLE) { } else if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.HIPANDGABLE) {
representLines.push(line) representLines.push(line)
@ -1630,79 +1631,80 @@ export const usePolygon = () => {
// } // }
function findShortestPath(start, end, graph, epsilon = 1) { function findShortestPath(start, end, graph, epsilon = 1) {
const startKey = pointToKey(start, epsilon); const startKey = pointToKey(start, epsilon)
const endKey = pointToKey(end, epsilon); const endKey = pointToKey(end, epsilon)
// 거리와 이전 노드 추적 // 거리와 이전 노드 추적
const distances = { [startKey]: 0 }; const distances = { [startKey]: 0 }
const previous = {}; const previous = {}
const visited = new Set(); const visited = new Set()
// 우선순위 큐 (거리가 짧은 순으로 정렬) // 우선순위 큐 (거리가 짧은 순으로 정렬)
const queue = [{ key: startKey, dist: 0 }]; const queue = [{ key: startKey, dist: 0 }]
// 모든 노드 초기화 // 모든 노드 초기화
for (const key in graph) { for (const key in graph) {
if (key !== startKey) { if (key !== startKey) {
distances[key] = Infinity; distances[key] = Infinity
} }
} }
// 우선순위 큐에서 다음 노드 선택 // 우선순위 큐에서 다음 노드 선택
const getNextNode = () => { const getNextNode = () => {
if (queue.length === 0) return null; if (queue.length === 0) return null
queue.sort((a, b) => a.dist - b.dist); queue.sort((a, b) => a.dist - b.dist)
return queue.shift(); return queue.shift()
}; }
let current; let current
while ((current = getNextNode())) { while ((current = getNextNode())) {
const currentKey = current.key; const currentKey = current.key
// 목적지에 도달하면 종료 // 목적지에 도달하면 종료
if (currentKey === endKey) break; if (currentKey === endKey) break
// 이미 방문한 노드는 건너뜀 // 이미 방문한 노드는 건너뜀
if (visited.has(currentKey)) continue; if (visited.has(currentKey)) continue
visited.add(currentKey); visited.add(currentKey)
// 인접 노드 탐색 // 인접 노드 탐색
for (const neighbor of graph[currentKey] || []) { for (const neighbor of graph[currentKey] || []) {
const neighborKey = pointToKey(neighbor.point, epsilon); const neighborKey = pointToKey(neighbor.point, epsilon)
if (visited.has(neighborKey)) continue; if (visited.has(neighborKey)) continue
const alt = distances[currentKey] + neighbor.distance; const alt = distances[currentKey] + neighbor.distance
// 더 짧은 경로를 찾은 경우 업데이트 // 더 짧은 경로를 찾은 경우 업데이트
if (alt < (distances[neighborKey] || Infinity)) { if (alt < (distances[neighborKey] || Infinity)) {
distances[neighborKey] = alt; distances[neighborKey] = alt
previous[neighborKey] = currentKey; previous[neighborKey] = currentKey
// 우선순위 큐에 추가 // 우선순위 큐에 추가
queue.push({ key: neighborKey, dist: alt }); queue.push({ key: neighborKey, dist: alt })
} }
} }
} }
// 경로 재구성 // 경로 재구성
const path = []; const path = []
let currentKey = endKey; let currentKey = endKey
// 시작점에 도달할 때까지 역추적 // 시작점에 도달할 때까지 역추적
while (previous[currentKey] !== undefined) { while (previous[currentKey] !== undefined) {
const [x, y] = currentKey.split(',').map(Number); const [x, y] = currentKey.split(',').map(Number)
path.unshift({ x, y }); path.unshift({ x, y })
currentKey = previous[currentKey]; currentKey = previous[currentKey]
} }
// 시작점 추가 // 시작점 추가
if (path.length > 0) { if (path.length > 0) {
const [sx, sy] = startKey.split(',').map(Number); const [sx, sy] = startKey.split(',').map(Number)
path.unshift({ x: sx, y: sy }); path.unshift({ x: sx, y: sy })
} }
return path.length > 0 ? path : null; return path.length > 0 ? path : null
} }
// 최종 함수 // 최종 함수
function getPath(start, end, graph, epsilon = 1) { function getPath(start, end, graph, epsilon = 1) {
// startPoint와 arrivalPoint가 될 수 있는 점은 line.attributes.type이 'default' 혹은 null이 아닌 line인 경우에만 가능 // startPoint와 arrivalPoint가 될 수 있는 점은 line.attributes.type이 'default' 혹은 null이 아닌 line인 경우에만 가능