무한루프 방어코드 추가
This commit is contained in:
parent
e68e51384e
commit
85506c5a58
@ -1008,6 +1008,7 @@ export const splitPolygonWithLines = (polygon) => {
|
|||||||
routes.push(startLine.startPoint)
|
routes.push(startLine.startPoint)
|
||||||
routes.push(startLine.endPoint)
|
routes.push(startLine.endPoint)
|
||||||
//hip끼리 만나는 경우는 아무것도 안해도됨
|
//hip끼리 만나는 경우는 아무것도 안해도됨
|
||||||
|
let count = 0
|
||||||
if (!isSamePoint(startLine.endPoint, arrivalPoint)) {
|
if (!isSamePoint(startLine.endPoint, arrivalPoint)) {
|
||||||
// polygon line까지 추가
|
// polygon line까지 추가
|
||||||
const allLinesCopy = [...allLines, ...polygon.lines]
|
const allLinesCopy = [...allLines, ...polygon.lines]
|
||||||
@ -1015,7 +1016,8 @@ export const splitPolygonWithLines = (polygon) => {
|
|||||||
let currentPoint = startLine.endPoint
|
let currentPoint = startLine.endPoint
|
||||||
let currentLine = startLine
|
let currentLine = startLine
|
||||||
|
|
||||||
while (!isSamePoint(currentPoint, arrivalPoint)) {
|
while (!isSamePoint(currentPoint, arrivalPoint) && count <= polygon.points.length) {
|
||||||
|
count++
|
||||||
// startHip에서 만나는 출발선 두개. 두개의 선을 출발하여 arrivalPoint에 도착할 때 까지 count를 세고, 더 낮은 count를 가진 길을 선택한다.
|
// startHip에서 만나는 출발선 두개. 두개의 선을 출발하여 arrivalPoint에 도착할 때 까지 count를 세고, 더 낮은 count를 가진 길을 선택한다.
|
||||||
let connectedLines = allLinesCopy.filter((line) => isSamePoint(line.startPoint, currentPoint) || isSamePoint(line.endPoint, currentPoint))
|
let connectedLines = allLinesCopy.filter((line) => isSamePoint(line.startPoint, currentPoint) || isSamePoint(line.endPoint, currentPoint))
|
||||||
|
|
||||||
@ -1052,8 +1054,10 @@ export const splitPolygonWithLines = (polygon) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
routes.push(endLine.startPoint)
|
if (count <= polygon.points.length - 1) {
|
||||||
roofs.push(routes)
|
routes.push(endLine.startPoint)
|
||||||
|
roofs.push(routes)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 중복 제거
|
// 중복 제거
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user