Merge pull request 'dev' (#836) from dev into dev-deploy

Reviewed-on: #836
This commit is contained in:
ysCha 2026-05-13 14:37:25 +09:00
commit 4a4302f055
2 changed files with 222 additions and 214 deletions

View File

@ -36,6 +36,7 @@ import { calcLineActualSize2 } from '@/util/qpolygon-utils'
import { notifyLowPitchRestrictionForRoofs, isLowPitchRestricted, LOW_PITCH_RESTRICTED_ROOF_IDS } from '@/util/roof-pitch-warning' import { notifyLowPitchRestrictionForRoofs, isLowPitchRestricted, LOW_PITCH_RESTRICTED_ROOF_IDS } from '@/util/roof-pitch-warning'
// [LOW-PITCH-DIAG 2026-05-06 TEMP] 진단용 — 검증 후 import + 호출 함께 제거 // [LOW-PITCH-DIAG 2026-05-06 TEMP] 진단용 — 검증 후 import + 호출 함께 제거
import { debugCapture } from '@/util/debugCapture' import { debugCapture } from '@/util/debugCapture'
import { logger } from '@/util/logger'
export function useRoofAllocationSetting(id) { export function useRoofAllocationSetting(id) {
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
@ -217,7 +218,7 @@ export function useRoofAllocationSetting(id) {
})) }))
setCurrentRoofList(normalizedRoofs) setCurrentRoofList(normalizedRoofs)
} catch (error) { } catch (error) {
console.error('Data fetching error:', error) logger.error('Data fetching error:', error)
} }
} }
@ -521,7 +522,7 @@ export function useRoofAllocationSetting(id) {
const extLines = roofBase.lines.filter((l) => l.lineName === 'extensionLine') const extLines = roofBase.lines.filter((l) => l.lineName === 'extensionLine')
if (extLines.length === 0) { if (extLines.length === 0) {
console.log(`[INTEGRATE] roofBase.id=${roofBase.id} extensionLine 없음 → skip`) logger.log(`[INTEGRATE] roofBase.id=${roofBase.id} extensionLine 없음 → skip`)
return return
} }
@ -563,7 +564,7 @@ export function useRoofAllocationSetting(id) {
}) })
if (!sk) { if (!sk) {
console.log( logger.log(
`[INTEGRATE] ext 짝없음 ` + `[INTEGRATE] ext 짝없음 ` +
`(${extP1.x.toFixed(1)},${extP1.y.toFixed(1)})→(${extP2.x.toFixed(1)},${extP2.y.toFixed(1)})` `(${extP1.x.toFixed(1)},${extP1.y.toFixed(1)})→(${extP2.x.toFixed(1)},${extP2.y.toFixed(1)})`
) )
@ -571,8 +572,9 @@ export function useRoofAllocationSetting(id) {
} }
// [2026-04-30] sk 가 이미 SK 빌드 단계에서 연장된 경우 → merge 스킵. // [2026-04-30] sk 가 이미 SK 빌드 단계에서 연장된 경우 → merge 스킵.
if (sk.__extended) { // [save/load 보존 2026-05-13] runtime __extended 는 저장 시 사라지므로 attributes.extended 도 함께 검사.
console.log( if (sk.__extended || sk.attributes?.extended) {
logger.log(
`[INTEGRATE] sk 이미 연장됨(id=${sk.id}) → merge 스킵, ext 는 lines 에서만 제거(canvas 유지)` `[INTEGRATE] sk 이미 연장됨(id=${sk.id}) → merge 스킵, ext 는 lines 에서만 제거(canvas 유지)`
) )
extLinesOnly.push(ext) extLinesOnly.push(ext)
@ -617,7 +619,7 @@ export function useRoofAllocationSetting(id) {
}) })
mergedLine.length = totalLen mergedLine.length = totalLen
console.log( logger.log(
`[INTEGRATE] merge ` + `[INTEGRATE] merge ` +
`ext=(${extP1.x.toFixed(1)},${extP1.y.toFixed(1)})→(${extP2.x.toFixed(1)},${extP2.y.toFixed(1)}) len=${extLen.toFixed(1)} ` + `ext=(${extP1.x.toFixed(1)},${extP1.y.toFixed(1)})→(${extP2.x.toFixed(1)},${extP2.y.toFixed(1)}) len=${extLen.toFixed(1)} ` +
`sk[${sk.lineName || sk.name}]=(${skP1.x.toFixed(1)},${skP1.y.toFixed(1)})→(${skP2.x.toFixed(1)},${skP2.y.toFixed(1)}) len=${skLen.toFixed(1)} ` + `sk[${sk.lineName || sk.name}]=(${skP1.x.toFixed(1)},${skP1.y.toFixed(1)})→(${skP2.x.toFixed(1)},${skP2.y.toFixed(1)}) len=${skLen.toFixed(1)} ` +
@ -630,7 +632,7 @@ export function useRoofAllocationSetting(id) {
}) })
if (merged.length === 0 && extLinesOnly.length === 0) { if (merged.length === 0 && extLinesOnly.length === 0) {
console.log(`[INTEGRATE] 통합 대상 없음 ext=${extLines.length}`) logger.log(`[INTEGRATE] 통합 대상 없음 ext=${extLines.length}`)
return return
} }
@ -646,7 +648,7 @@ export function useRoofAllocationSetting(id) {
removedExt.forEach((l) => canvas.remove(l)) removedExt.forEach((l) => canvas.remove(l))
removedSk.forEach((l) => canvas.remove(l)) removedSk.forEach((l) => canvas.remove(l))
console.log( logger.log(
`[INTEGRATE] 완료 roofBase.id=${roofBase.id} ` + `[INTEGRATE] 완료 roofBase.id=${roofBase.id} ` +
`ext제거=${removedExt.length} sk제거=${removedSk.length} merged=${merged.length} ` + `ext제거=${removedExt.length} sk제거=${removedSk.length} merged=${merged.length} ` +
`extKeptInCanvas=${extLinesOnly.length} ` + `extKeptInCanvas=${extLinesOnly.length} ` +
@ -660,7 +662,7 @@ export function useRoofAllocationSetting(id) {
const apply = () => { const apply = () => {
const roofBases = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF && !obj.roofMaterial) const roofBases = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF && !obj.roofMaterial)
const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL) const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL)
console.log(`[ALLOC] apply() 진입. roofBases=${roofBases.length}`) logger.log(`[ALLOC] apply() 진입. roofBases=${roofBases.length}`)
roofBases.forEach((roofBase) => { roofBases.forEach((roofBase) => {
try { try {
// 지붕 할당 로직에 extensionLine 추가 // 지붕 할당 로직에 extensionLine 추가
@ -675,7 +677,7 @@ export function useRoofAllocationSetting(id) {
snapByLineName[o.lineName] = (snapByLineName[o.lineName] || 0) + 1 snapByLineName[o.lineName] = (snapByLineName[o.lineName] || 0) + 1
snapByName[o.name || '?'] = (snapByName[o.name || '?'] || 0) + 1 snapByName[o.name || '?'] = (snapByName[o.name || '?'] || 0) + 1
}) })
console.log( logger.log(
`[ALLOC-DEBUG] roofBase.id=${roofBase.id} ` + `[ALLOC-DEBUG] roofBase.id=${roofBase.id} ` +
`roofBase.lines=${roofBase.lines?.length || 0} ` + `roofBase.lines=${roofBase.lines?.length || 0} ` +
`roofBase.innerLines=${roofBase.innerLines?.length || 0} ` + `roofBase.innerLines=${roofBase.innerLines?.length || 0} ` +
@ -684,15 +686,15 @@ export function useRoofAllocationSetting(id) {
`byName=${JSON.stringify(snapByName)}` `byName=${JSON.stringify(snapByName)}`
) )
roofEaveHelpLines.forEach((o, i) => { roofEaveHelpLines.forEach((o, i) => {
console.log( logger.log(
` [ALLOC-DEBUG] picked[${i}] name=${o.name} lineName=${o.lineName} ` + ` [ALLOC-DEBUG] picked[${i}] name=${o.name} lineName=${o.lineName} ` +
`(${o.x1?.toFixed(1)},${o.y1?.toFixed(1)})→(${o.x2?.toFixed(1)},${o.y2?.toFixed(1)}) ` + `(${o.x1?.toFixed(1)},${o.y1?.toFixed(1)})→(${o.x2?.toFixed(1)},${o.y2?.toFixed(1)}) ` +
`len=${Math.hypot((o.x2 || 0) - (o.x1 || 0), (o.y2 || 0) - (o.y1 || 0)).toFixed(1)}` `len=${Math.hypot((o.x2 || 0) - (o.x1 || 0), (o.y2 || 0) - (o.y1 || 0)).toFixed(1)}`
) )
}) })
// console.log('roofBase.id:', roofBase.id) // logger.log('roofBase.id:', roofBase.id)
// console.log('roofEaveHelpLines:', roofEaveHelpLines) // logger.log('roofEaveHelpLines:', roofEaveHelpLines)
// console.log('extensionLines found:', roofEaveHelpLines.filter(l => l.lineName === 'extensionLine')) // logger.log('extensionLines found:', roofEaveHelpLines.filter(l => l.lineName === 'extensionLine'))
if (roofEaveHelpLines.length > 0) { if (roofEaveHelpLines.length > 0) {
if (roofBase.lines) { if (roofBase.lines) {
// Filter out any eaveHelpLines that are already in lines to avoid duplicates // Filter out any eaveHelpLines that are already in lines to avoid duplicates
@ -703,8 +705,8 @@ export function useRoofAllocationSetting(id) {
// extensionLine과 일반 eaveHelpLine 분리 // extensionLine과 일반 eaveHelpLine 분리
const extensionLines = newEaveLines.filter(line => line.lineName === 'extensionLine') const extensionLines = newEaveLines.filter(line => line.lineName === 'extensionLine')
const normalEaveLines = newEaveLines.filter(line => line.lineName === 'eaveHelpLine') const normalEaveLines = newEaveLines.filter(line => line.lineName === 'eaveHelpLine')
// console.log('extensionLines count:', extensionLines.length) // logger.log('extensionLines count:', extensionLines.length)
// console.log('normalEaveLines count:', normalEaveLines.length) // logger.log('normalEaveLines count:', normalEaveLines.length)
// 일반 eaveHelpLine만 Overlap 판단에 사용 // 일반 eaveHelpLine만 Overlap 판단에 사용
const linesToKeep = roofBase.lines.filter(roofLine => { const linesToKeep = roofBase.lines.filter(roofLine => {
@ -747,7 +749,7 @@ export function useRoofAllocationSetting(id) {
isPointInside(eX2, eY2, rX1, rY1, rX2, rY2); isPointInside(eX2, eY2, rX1, rY1, rX2, rY2);
if (isOverlapping) { if (isOverlapping) {
console.log('Removing overlapping line:', roofLine); logger.log('Removing overlapping line:', roofLine);
return true; // 포개지는 경우에만 삭제 return true; // 포개지는 경우에만 삭제
} }
} }
@ -759,7 +761,7 @@ export function useRoofAllocationSetting(id) {
// Combine remaining lines with newEaveLines // Combine remaining lines with newEaveLines
roofBase.lines = [...linesToKeep, ...normalEaveLines, ...extensionLines]; roofBase.lines = [...linesToKeep, ...normalEaveLines, ...extensionLines];
// [ALLOC-DEBUG] 병합 결과 breakdown // [ALLOC-DEBUG] 병합 결과 breakdown
console.log( logger.log(
`[ALLOC-DEBUG] 병합완료 roofBase.id=${roofBase.id} ` + `[ALLOC-DEBUG] 병합완료 roofBase.id=${roofBase.id} ` +
`linesToKeep=${linesToKeep.length} ` + `linesToKeep=${linesToKeep.length} ` +
`normalEave=${normalEaveLines.length} ` + `normalEave=${normalEaveLines.length} ` +
@ -767,7 +769,7 @@ export function useRoofAllocationSetting(id) {
`total=${roofBase.lines.length}` `total=${roofBase.lines.length}`
) )
roofBase.lines.forEach((ln, i) => { roofBase.lines.forEach((ln, i) => {
console.log( logger.log(
` [ALLOC-DEBUG] merged[${i}] name=${ln.name || '?'} lineName=${ln.lineName || '?'} ` + ` [ALLOC-DEBUG] merged[${i}] name=${ln.name || '?'} lineName=${ln.lineName || '?'} ` +
`(${ln.x1?.toFixed(1)},${ln.y1?.toFixed(1)})→(${ln.x2?.toFixed(1)},${ln.y2?.toFixed(1)})` `(${ln.x1?.toFixed(1)},${ln.y1?.toFixed(1)})→(${ln.x2?.toFixed(1)},${ln.y2?.toFixed(1)})`
) )
@ -812,7 +814,7 @@ export function useRoofAllocationSetting(id) {
integrateExtensionLines(roofBase) integrateExtensionLines(roofBase)
// [ALLOC-DEBUG] split 직전 최종 입력 // [ALLOC-DEBUG] split 직전 최종 입력
console.log( logger.log(
`[ALLOC-DEBUG] split 직전 roofBase.id=${roofBase.id} ` + `[ALLOC-DEBUG] split 직전 roofBase.id=${roofBase.id} ` +
`separatePolygon=${roofBase.separatePolygon?.length || 0} ` + `separatePolygon=${roofBase.separatePolygon?.length || 0} ` +
`lines=${roofBase.lines?.length || 0} ` + `lines=${roofBase.lines?.length || 0} ` +
@ -826,7 +828,7 @@ export function useRoofAllocationSetting(id) {
splitPolygonWithLines(roofBase) splitPolygonWithLines(roofBase)
} }
} catch (e) { } catch (e) {
console.log(e) logger.log(e)
canvas.discardActiveObject() canvas.discardActiveObject()
return return
} }

File diff suppressed because it is too large Load Diff