fix: close remaining CAD delivery review gaps

This commit is contained in:
2026-07-11 15:26:43 +08:00
parent 6c1336fa59
commit c12d1d57cb
11 changed files with 464 additions and 93 deletions

View File

@@ -18,6 +18,20 @@ REPORT_VERSION = 1
ROOT = Path(__file__).resolve().parent.parent
SCHEMA_DIR = ROOT / "schemas"
LEGACY_CATEGORY_STYLES = {
"walls": {"label": "墙体", "color": "#d4cbb8"},
"glazing": {"label": "玻璃/幕墙", "color": "#79b8c9"},
"roof": {"label": "屋顶/屋盖", "color": "#b8ae98"},
"columns": {"label": "柱", "color": "#f58a1f"},
"beams": {"label": "梁/结构", "color": "#1f66c2"},
"railings": {"label": "栏杆/扶手", "color": "#6f746d"},
"doors": {"label": "门/开启线", "color": "#8a6a45"},
"detail_lines": {"label": "平面细节", "color": "#8c9088"},
"floor_lines": {"label": "楼面线", "color": "#18a058"},
"grid": {"label": "轴网", "color": "#20242a"},
"slab": {"label": "楼板", "color": "#c8ccc2"},
}
class ValidationFailure(ValueError):
"""Raised when a config or generated artifact violates the contract."""
@@ -87,6 +101,26 @@ def normalize_spec(spec: dict[str, Any]) -> dict[str, Any]:
units.setdefault("scale_to_meters", scale)
units.setdefault("origin_source", [0.0, 0.0])
normalized["units"] = units
raw_categories = normalized.get("categories", {})
categories = copy.deepcopy(raw_categories) if isinstance(raw_categories, dict) else {}
configured_categories = source["config"].get("categories", {})
used_categories = {
category
for floor in normalized.get("floors", {}).values()
for category, segments in floor.get("segments", {}).items()
if segments
}
if source["config"].get("use_footprint_slabs"):
used_categories.add("slab")
for category in sorted(used_categories):
if category in categories:
continue
style = dict(LEGACY_CATEGORY_STYLES.get(category, {"label": category, "color": "#8c9088"}))
override = configured_categories.get(category, {}) if isinstance(configured_categories, dict) else {}
if isinstance(override, dict):
style.update({key: override[key] for key in ("label", "color") if key in override})
categories[category] = style
normalized["categories"] = categories
for floor in normalized.get("floors", {}).values():
floor.setdefault("source_file", "unknown")
for category, segments in floor.get("segments", {}).items():