From eb3fc05cdcab1efcb1f2245730c8de7b43b25ddd Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Tue, 10 Mar 2026 23:10:51 +0100 Subject: [PATCH] fix: Box-Zone Clamping nach Box-Mitte statt Cell-Center entscheiden Euro/Badge-Zeilen hatten ihren Center innerhalb der Box-Zone, weshalb das Clamping nicht griff. Jetzt wird anhand der Box-Mitte entschieden ob eine Zelle nach oben (clamp height) oder unten (push y) gehoert. Co-Authored-By: Claude Opus 4.6 --- .../ocr-pipeline/StepReconstruction.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx b/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx index ad374bb..8bb998e 100644 --- a/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx +++ b/admin-lehrer/components/ocr-pipeline/StepReconstruction.tsx @@ -501,18 +501,18 @@ export function StepReconstruction({ sessionId, onNext }: StepReconstructionProp const cellTop = bboxPct.y const cellBottom = bboxPct.y + bboxPct.h - const cellCenter = cellTop + bboxPct.h / 2 + const boxMid = (boxZonesPct[0].topPct + boxZonesPct[0].bottomPct) / 2 for (const { topPct, bottomPct } of boxZonesPct) { - // Cell ABOVE box: clamp height so bottom doesn't exceed box top - if (cellCenter < topPct && cellBottom > topPct) { - return { ...bboxPct, h: topPct - cellTop } - } - // Cell BELOW box: push top down to box bottom - if (cellCenter > bottomPct && cellTop < bottomPct) { - const newY = bottomPct - return { ...bboxPct, y: newY, h: cellBottom - newY } + // Check if cell overlaps with box zone at all + if (cellBottom <= topPct || cellTop >= bottomPct) continue + + // Cell starts ABOVE box midpoint → belongs above, clamp bottom to box top + if (cellTop < boxMid) { + return { ...bboxPct, h: Math.max(0.5, topPct - cellTop) } } + // Cell starts AT or BELOW box midpoint → belongs below, push top to box bottom + return { ...bboxPct, y: bottomPct, h: Math.max(0.5, cellBottom - bottomPct) } } return bboxPct }