fix: enforce complete building and offline viewer gates

This commit is contained in:
2026-07-10 14:04:10 +08:00
parent cab4d320c0
commit a761175c09
13 changed files with 401 additions and 25 deletions

View File

@@ -568,6 +568,7 @@ def evaluate_gates(
}
)
gates.append(frame_ledger_gate(config, frames))
gates.append(vertical_storey_continuity_gate(spec))
gates.append(declared_area_gate(spec, config))
gates.append(storey_count_gate(spec, config))
return gates
@@ -681,6 +682,60 @@ def declared_area_gate(spec: dict[str, Any], config: dict[str, Any]) -> dict[str
}
def vertical_storey_continuity_gate(spec: dict[str, Any]) -> dict[str, Any]:
"""A final full-building model may not jump from F2 directly to F16.
Representative typical-floor drawings are source evidence, not permission
to leave the repeated storeys absent from the delivered building. The
repeated floors must be instantiated and labelled as derived repetitions.
"""
import re as _re
numbered: list[tuple[int, str, dict[str, Any]]] = []
for key, floor in spec.get("floors", {}).items():
match = _re.fullmatch(r"F(\d+)", str(key))
if match:
numbered.append((int(match.group(1)), str(key), floor))
numbered.sort()
if len(numbered) < 2:
return {
"name": "vertical_storey_continuity",
"status": "PASS",
"detail": f"{len(numbered)} numbered storey; no internal continuity gap to test.",
}
missing: list[str] = []
z_gaps: list[str] = []
for (left_no, left_key, left), (right_no, right_key, right) in zip(numbered, numbered[1:]):
if right_no != left_no + 1:
missing.append(f"{left_key}->{right_key}")
continue
left_z = float(left.get("z", 0.0))
right_z = float(right.get("z", 0.0))
nominal = max(float(left.get("height", 0.0)), float(right.get("height", 0.0)), 1.0)
if right_z - left_z > max(8.0, nominal * 2.0):
z_gaps.append(f"{left_key}->{right_key}={round(right_z - left_z, 2)}m")
if missing or z_gaps:
parts = []
if missing:
parts.append("missing numbered ranges " + ", ".join(missing))
if z_gaps:
parts.append("unexplained elevation gaps " + ", ".join(z_gaps))
return {
"name": "vertical_storey_continuity",
"status": "FAIL",
"detail": (
"; ".join(parts)
+ ". Instantiate source-supported repeated typical floors; do not deliver separated floor islands."
),
}
return {
"name": "vertical_storey_continuity",
"status": "PASS",
"detail": f"Numbered storeys are contiguous from {numbered[0][1]} to {numbered[-1][1]}.",
}
def storey_count_gate(spec: dict[str, Any], config: dict[str, Any]) -> dict[str, Any]:
"""Above-ground storey count must match the declared count (总图 22F 标签 / 标高梯级数).