derive: per-cluster footprint hulls — twin-tower floors no longer bridged

concave_hull over all points cannot split disconnected masses: 13号 一号楼
standard floors (A/B towers in one floor key) got ONE 135.6m hull and
use_footprint_slabs laid plates across the 36m void (user-visible as
"triangular links" between towers). Points are now union-find clustered
(footprint_cluster_linkage, 6m grid buckets; segment endpoints forced into
one cluster) and hulled per cluster — real link bridges keep clusters
merged via their walls. F4-F10 now 2x49.8m hulls matching the site-plan
OBB; 黄桥/27号 re-derived with no regression; DoD visual check extended
(look at the AIR between masses in front/side views). Regression: twintower
scenario (+3 checks).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 07:48:22 +08:00
parent c6df3f6ffb
commit 1e11d38fa9
4 changed files with 104 additions and 12 deletions

View File

@@ -887,6 +887,39 @@ def main() -> int:
ok_mx = f2 is not None and abs(f2["offset"][0]) <= 120 and abs(f2["offset"][1] - 98100.0) <= 120
check("mixed layout offset recovered", ok_mx, str(f2 and f2["offset"]))
# --- twin-tower floors must get SEPARATE footprint hulls (13号 一号楼: 凹包桥接
# 两塔, use_footprint_slabs 在 36m 空隙上生成横跨飘板) ---
tt_dir = WORK / "dxf_twintower"
tt_dir.mkdir(parents=True, exist_ok=True)
tt_doc = ezdxf.new("R2010", setup=True)
tt_doc.layers.add("I-WALL")
tt_msp = tt_doc.modelspace()
for ox in (0.0, 60000.0): # two 20m x 10m towers, 40 m of void between
for start, end in [((ox, 0), (ox + 20000, 0)), ((ox + 20000, 0), (ox + 20000, 10000)),
((ox + 20000, 10000), (ox, 10000)), ((ox, 10000), (ox, 0)),
((ox + 7000, 0), (ox + 7000, 10000)), ((ox + 13000, 0), (ox + 13000, 10000)),
((ox, 5000), (ox + 20000, 5000))]:
tt_msp.add_line(start, end, dxfattribs={"layer": "I-WALL"})
tt_doc.saveas(tt_dir / "twin.dxf")
tt_config = {
"scale": 0.001, "generate_footprints": True, "use_footprint_slabs": True,
"drawings": [{"file": "twin.dxf", "floors": [{"key": "F4", "name": "标准层", "z": 12.0, "height": 4.2}]}],
}
tt_cfg = WORK / "tt_config.json"
tt_cfg.write_text(json.dumps(tt_config, ensure_ascii=False), encoding="utf-8")
proc = run([
sys.executable, "scripts/derive_showcase_spec.py",
"--dxf-dir", str(tt_dir), "--config", str(tt_cfg),
"--out", str(WORK / "tt_spec.json"), "--vendor-dir", str(VENDOR),
])
check("derive twin-tower floor runs", proc.returncode == 0, proc.stderr[-400:])
if proc.returncode == 0:
tt_spec = json.loads((WORK / "tt_spec.json").read_text(encoding="utf-8"))
polys = tt_spec["floors"]["F4"]["footprint"]["polygons"]
spans = [max(p[0] for p in poly) - min(p[0] for p in poly) for poly in polys]
check("two separate footprint hulls", len(polys) == 2, f"n={len(polys)} spans={spans}")
check("no hull bridges the void", all(s < 25.0 for s in spans), f"spans={spans}")
# --- floor_order gaps must warn loudly, not silently drop floors (13号 b2: F11-F16 消失) ---
fo_config = {
"scale": 0.001,