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

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',
EAVES: 'eaves',
EAVE_HELP_LINE: 'eaveHelpLine',
GABLE: 'gable',
GABLE_LEFT: 'gableLeft', //케라바 왼쪽
GABLE_RIGHT: 'gableRight', //케라바 오른쪽

View File

@ -1,7 +1,13 @@
'use client'
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 { getIntersectionPoint } from '@/util/canvas-util'
import { degreesToRadians } from '@turf/turf'
@ -879,7 +885,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
}
})
// roof.fire('polygonMoved')
roof.fire('polygonMoved')
roof.fire('modified')
drawDirectionArrow(roof)
changeCorridorDimensionText()

View File

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