Compare commits

..

No commits in common. "bea4d8ac3ce99e3652e7981abe343e895f2fa8e0" and "4b136ea2edbc47a397d8e2ef86f110b515fda59f" have entirely different histories.

2 changed files with 32 additions and 52 deletions

View File

@ -2677,7 +2677,7 @@ export function useModuleBasicSetting(tabNum) {
isInstall = true isInstall = true
//마지막에 설치된 모듈의 Y 좌표 //마지막에 설치된 모듈의 Y 좌표
installedLastHeightCoord = moduleY + width + heightMargin installedLastHeightCoord = moduleY + width + widthMargin
} else { } else {
//디버깅용 //디버깅용
/*tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 }) /*tempModule.set({ fill: 'transparent', stroke: 'red', strokeWidth: 1 })

View File

@ -404,25 +404,15 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
}, { x: 0, y: 0 }) }, { x: 0, y: 0 })
// baseLine을 offset만큼 바깥으로 평행이동 // baseLine을 offset만큼 바깥으로 평행이동
const offsetLine = (line, index) => { const offsetLine = (line) => {
const sp = line.startPoint, ep = line.endPoint const sp = line.startPoint, ep = line.endPoint
let offset = line.attributes?.offset ?? 0 const offset = line.attributes?.offset ?? 0
// 모든 offset이 동일할 때 수치적 안정성을 위해 약간의 변화 추가
if (baseLines.every(l => (l.attributes?.offset ?? 0) === offset)) {
offset += index * 0.01 // 각 라인에 약간의 차이 추가
}
const edx = ep.x - sp.x, edy = ep.y - sp.y const edx = ep.x - sp.x, edy = ep.y - sp.y
const len = Math.hypot(edx, edy) const len = Math.hypot(edx, edy)
if (len === 0) return { sp: { ...sp }, ep: { ...ep } } if (len === 0) return { sp: { ...sp }, ep: { ...ep } }
// 수직 벡터 계산 (항상 바깥 방향)
let nx = -edy / len, ny = edx / len let nx = -edy / len, ny = edx / len
const mid = { x: (sp.x + ep.x) / 2, y: (sp.y + ep.y) / 2 }
// 방향 결정 로직 제거 - 항상 바깥으로 확장 if (nx * (centroid.x - mid.x) + ny * (centroid.y - mid.y) > 0) { nx = -nx; ny = -ny }
// if (nx * (centroid.x - mid.x) + ny * (centroid.y - mid.y) > 0) { nx = -nx; ny = -ny }
return { return {
sp: { x: sp.x + nx * offset, y: sp.y + ny * offset }, sp: { x: sp.x + nx * offset, y: sp.y + ny * offset },
ep: { x: ep.x + nx * offset, y: ep.y + ny * offset } ep: { x: ep.x + nx * offset, y: ep.y + ny * offset }
@ -443,47 +433,37 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
isSamePoint(point, line.startPoint) || isSamePoint(point, line.endPoint) isSamePoint(point, line.startPoint) || isSamePoint(point, line.endPoint)
) )
if (adjLines.length < 2) return { ...point } if (adjLines.length < 2) return { ...point }
const idx1 = baseLines.indexOf(adjLines[0]) const oL1 = offsetLine(adjLines[0]), oL2 = offsetLine(adjLines[1])
const idx2 = baseLines.indexOf(adjLines[1])
const oL1 = offsetLine(adjLines[0], idx1), oL2 = offsetLine(adjLines[1], idx2)
return lineIntersect(oL1.sp, oL1.ep, oL2.sp, oL2.ep) || { ...point } return lineIntersect(oL1.sp, oL1.ep, oL2.sp, oL2.ep) || { ...point }
}) })
// 중복 좌표 및 일직선 위의 불필요한 점 제거 (L자 확장 시 사각형으로 단순화) // 중복 좌표 및 일직선 위의 불필요한 점 제거 (L자 확장 시 사각형으로 단순화)
// const simplifyPolygon = (pts) => { const simplifyPolygon = (pts) => {
// let result = [...pts] let result = [...pts]
let changed = true
// // 복잡한 형태 보호를 위해 최소 6개 점 유지 while (changed) {
// if (result.length <= 6) return result changed = false
for (let i = result.length - 1; i >= 0; i--) {
// let changed = true const next = result[(i + 1) % result.length]
// while (changed) { if (Math.abs(result[i].x - next.x) < 0.5 && Math.abs(result[i].y - next.y) < 0.5) {
// changed = false result.splice(i, 1)
// for (let i = result.length - 1; i >= 0; i--) { changed = true
// const next = result[(i + 1) % result.length] }
// if (Math.abs(result[i].x - next.x) < 1.0 && Math.abs(result[i].y - next.y) < 1.0) { }
// result.splice(i, 1) for (let i = result.length - 1; i >= 0 && result.length > 3; i--) {
// changed = true const prev = result[(i - 1 + result.length) % result.length]
// } const curr = result[i]
// } const next = result[(i + 1) % result.length]
// // 최소 6개 점 유지 확인 const cross = (curr.x - prev.x) * (next.y - prev.y) - (curr.y - prev.y) * (next.x - prev.x)
// if (result.length <= 6) break if (Math.abs(cross) < 1) {
result.splice(i, 1)
// for (let i = result.length - 1; i >= 0 && result.length > 3; i--) { changed = true
// const prev = result[(i - 1 + result.length) % result.length] }
// const curr = result[i] }
// const next = result[(i + 1) % result.length] }
// const cross = (curr.x - prev.x) * (next.y - prev.y) - (curr.y - prev.y) * (next.x - prev.x) return result
// // 복잡한 형태 보호를 위해 임계값 대폭 증가 }
// if (Math.abs(cross) < 50) { changRoofLinePoints = simplifyPolygon(changRoofLinePoints)
// result.splice(i, 1)
// changed = true
// }
// }
// }
// return result
// }
// changRoofLinePoints = simplifyPolygon(changRoofLinePoints)
let roofLineContactPoints = [...changRoofLinePoints] let roofLineContactPoints = [...changRoofLinePoints]