Land the two deferred gaps: title-block frame clips + cross-floor datum gate

- detect_sheet_frames: title-block INSERTs (A0_V1/A0+0.5_V1/*图框*) define the
  clip window when they contain the title — pitch windows halved elongated
  sheets (13号 加长A0, one frame holding both towers); wall refine is clamped
  inside the frame rect; 13号 b1 real data: all 45 frames rect-clipped
- audit floors_aligned: cross-floor wall-profile datum check catches
  "self-consistent but misplaced" floors (13号 F3 错槽 85.8m that envelope
  centers PASSed); zero-shift guard kills the dense-podium false positive
  (27号 1#A PH matched "better" 1.5m off while already fitting in place)
- 门卫 size mismatch root-caused as representation granularity (gate compound
  vs kiosk symbol), not an extraction bug — closed in the log
- regression suite +6 checks (titleblock / crossdatum bad+good), all three
  projects re-audited with no false positives

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 08:05:57 +08:00
parent 1e11d38fa9
commit 9729857549
5 changed files with 239 additions and 13 deletions

View File

@@ -401,10 +401,68 @@ def floors_alignment_gate(spec: dict[str, Any], config: dict[str, Any]) -> dict[
"detail": worst[1] + ". Floors are not stacked — per-frame offsets are missing or wrong; "
"run detect_sheet_frames.py and use its clip/offset config.",
}
# Cross-floor datum: envelope centers are blind to "self-consistent but
# misplaced" floors (13号 F3 sat one tower-slot off — 85.8 m — and PASSed:
# the merged twin-tower envelope hid it). Correlate each floor's wall
# profile against the group's reference floor: a strong off-zero peak
# means the whole floor sits N meters from the shared wall datum.
try:
sys.path.insert(0, str(Path(__file__).resolve().parent))
from detect_sheet_frames import correlate_shift, wall_profile
except Exception:
correlate_shift = wall_profile = None # type: ignore
if correlate_shift is not None:
wall_segs: dict[str, list[tuple[float, float, float, float]]] = {}
for fk, floor in spec.get("floors", {}).items():
segs = floor.get("segments", {}).get("walls") or []
if len(segs) >= 10:
wall_segs[fk] = [(s["start"][0], s["start"][1], s["end"][0], s["end"][1]) for s in segs]
by_group: dict[str, list[str]] = defaultdict(list)
for fk in wall_segs:
by_group[derive._cap_floor_group(fk, config)].append(fk)
for grp, keys in by_group.items():
if len(keys) < 2:
continue
ref_key = max(keys, key=lambda k: sum(
math.hypot(s[2] - s[0], s[3] - s[1]) for s in wall_segs[k]))
ref_x = wall_profile(wall_segs[ref_key], 0, axis_tol=0.02, min_len=0.4)
ref_y = wall_profile(wall_segs[ref_key], 1, axis_tol=0.02, min_len=0.4)
def zero_cov(ref_prof, prof, tol: float = 0.25) -> float:
total = sum(w for _, w in prof)
if total <= 0:
return 0.0
matched = sum(w for p, w in prof
if any(abs(p - rp) <= tol for rp, _ in ref_prof))
return matched / total
for fk in keys:
if fk == ref_key:
continue
for axis, ref_prof in ((0, ref_x), (1, ref_y)):
prof = wall_profile(wall_segs[fk], axis, axis_tol=0.02, min_len=0.4)
shift, cov, ratio = correlate_shift(ref_prof, prof, coarse=0.5, fine=0.05)
# a floor already matching IN PLACE is not misplaced, however
# attractive some shifted peak looks (dense podium references
# let any small profile "match" somewhere: 27号 1#A PH)
if shift is not None and zero_cov(ref_prof, prof) >= 0.7 * cov:
continue
if (shift is not None and cov >= 0.45 and ratio >= 1.5
and abs(shift) > 1.0):
return {
"name": "floors_aligned",
"status": "FAIL",
"detail": (
f"cross_floor_datum {grp}: {fk} wall profile matches {ref_key} "
f"only when shifted {round(shift, 1)} m in {'xy'[axis]} "
f"(coverage {cov:.2f}, peak ratio {min(ratio, 99):.1f}) — the floor is "
"self-consistent but misplaced (wrong frame offset / wrong tower slot, "
"13号 F3 错槽 pattern). Re-check that frame's offset against the shared datum."
),
}
return {
"name": "floors_aligned",
"status": "PASS",
"detail": "Wall-bbox centers of same-stack floors coincide.",
"detail": "Wall-bbox centers of same-stack floors coincide; cross-floor wall-profile datum consistent.",
}