333
This commit is contained in:
parent
05a3da994c
commit
e196ac961b
@ -396,7 +396,7 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
|
||||
const orderedBaseLinePoints = isClosedPolygon(baseLinePoints) ? baseLinePoints.slice(0, -1) : baseLinePoints
|
||||
|
||||
// baseLine 폴리곤의 중심 계산 (확장 방향 결정용)
|
||||
// baseLine 폴리곤의 중심 계산 (offset 방향 결정용)
|
||||
const centroid = orderedBaseLinePoints.reduce((acc, p) => {
|
||||
acc.x += p.x / orderedBaseLinePoints.length
|
||||
acc.y += p.y / orderedBaseLinePoints.length
|
||||
@ -427,7 +427,7 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
return { x: a1.x + t * (a2.x - a1.x), y: a1.y + t * (a2.y - a1.y) }
|
||||
}
|
||||
|
||||
// 각 꼭짓점에서 해당 점을 포함하는 두 baseLine을 찾아 offset 교차점으로 changRoofLinePoint 계산
|
||||
// 각 꼭짓점에서 인접 두 baseLine의 offset 교차점으로 확장 좌표 계산
|
||||
let changRoofLinePoints = orderedBaseLinePoints.map((point) => {
|
||||
const adjLines = baseLines.filter(line =>
|
||||
isSamePoint(point, line.startPoint) || isSamePoint(point, line.endPoint)
|
||||
@ -437,13 +437,12 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
return lineIntersect(oL1.sp, oL1.ep, oL2.sp, oL2.ep) || { ...point }
|
||||
})
|
||||
|
||||
// 중복 좌표 및 일직선 위의 불필요한 점 제거
|
||||
const simplifyPoints = (pts) => {
|
||||
// 중복 좌표 및 일직선 위의 불필요한 점 제거 (L자 확장 시 사각형으로 단순화)
|
||||
const simplifyPolygon = (pts) => {
|
||||
let result = [...pts]
|
||||
let changed = true
|
||||
while (changed) {
|
||||
changed = false
|
||||
// 1) 중복 좌표 제거 (인접한 동일 좌표)
|
||||
for (let i = result.length - 1; i >= 0; i--) {
|
||||
const next = result[(i + 1) % result.length]
|
||||
if (Math.abs(result[i].x - next.x) < 0.5 && Math.abs(result[i].y - next.y) < 0.5) {
|
||||
@ -451,7 +450,6 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
// 2) 일직선 위의 중간 점 제거 (cross product ≈ 0)
|
||||
for (let i = result.length - 1; i >= 0 && result.length > 3; i--) {
|
||||
const prev = result[(i - 1 + result.length) % result.length]
|
||||
const curr = result[i]
|
||||
@ -465,7 +463,7 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
|
||||
}
|
||||
return result
|
||||
}
|
||||
changRoofLinePoints = simplifyPoints(changRoofLinePoints)
|
||||
changRoofLinePoints = simplifyPolygon(changRoofLinePoints)
|
||||
|
||||
let roofLineContactPoints = [...changRoofLinePoints]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user