지붕면 할당 알고리즘 수정
This commit is contained in:
parent
4684b45883
commit
59d3bd61e2
@ -1444,22 +1444,23 @@ export const usePolygon = () => {
|
||||
startLines.forEach((startLine) => {
|
||||
// 현재 남아있는 line들로 그래프 생성
|
||||
const graph = {}
|
||||
const edges = remainingLines
|
||||
.filter((line2) => line2 !== startLine)
|
||||
.map((line) => {
|
||||
return [line.startPoint, line.endPoint]
|
||||
})
|
||||
|
||||
for (const [p1, p2] of edges) {
|
||||
for (const line of remainingLines.filter((line2) => line2 !== startLine)) {
|
||||
const p1 = line.startPoint
|
||||
const p2 = line.endPoint
|
||||
const key1 = pointToKey(p1)
|
||||
const key2 = pointToKey(p2)
|
||||
const distance = calcDistance(p1, p2)
|
||||
const isStartLine = line.attributes?.isStart === true
|
||||
|
||||
if (!graph[key1]) graph[key1] = []
|
||||
if (!graph[key2]) graph[key2] = []
|
||||
|
||||
graph[key1].push({ point: p2, distance })
|
||||
graph[key2].push({ point: p1, distance })
|
||||
// isStart가 아닌 line을 우선하도록 distance 조정
|
||||
const adjustedDistance = isStartLine ? distance + 1000 : distance
|
||||
|
||||
graph[key1].push({ point: p2, distance: adjustedDistance, line })
|
||||
graph[key2].push({ point: p1, distance: adjustedDistance, line })
|
||||
}
|
||||
|
||||
const startPoint = { ...startLine.startPoint } // 시작점
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user