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

@@ -643,20 +643,70 @@ def generated_footprint(segments: dict[str, list[dict[str, Any]]], config: dict[
if len(unique_points) < 4:
return None
# Cluster points by proximity BEFORE hulling: concave_hull over all points
# can never split disconnected masses, so a twin-tower floor got ONE
# bridged hull and use_footprint_slabs laid plates across the 36 m void
# (13号 一号楼 A/B座). Per-cluster hulls keep genuinely linked wings —
# a real 连廊 contributes walls that join the clusters.
linkage = float(config.get("footprint_cluster_linkage", 6.0))
parent = list(range(len(unique_points)))
def find(a: int) -> int:
while parent[a] != a:
parent[a] = parent[parent[a]]
a = parent[a]
return a
def union(a: int, b: int) -> None:
ra, rb = find(a), find(b)
if ra != rb:
parent[rb] = ra
cell = max(linkage, 1e-6)
buckets: dict[tuple[int, int], list[int]] = {}
for idx, (px, py) in enumerate(unique_points):
buckets.setdefault((int(px // cell), int(py // cell)), []).append(idx)
for (bx, by), members in buckets.items():
for gx in (bx - 1, bx, bx + 1):
for gy in (by - 1, by, by + 1):
for other in buckets.get((gx, gy), []):
union(members[0], other)
for other in members[1:]:
union(members[0], other)
# Segments span their endpoints: both ends of one segment belong together.
seg_pt_index = {pt: i for i, pt in enumerate(unique_points)}
for category in categories:
for segment in segments.get(category, []):
start = segment.get("start")
end = segment.get("end")
if not start or not end:
continue
a = seg_pt_index.get((float(start[0]), float(start[1])))
b = seg_pt_index.get((float(end[0]), float(end[1])))
if a is not None and b is not None:
union(a, b)
clusters: dict[int, list[tuple[float, float]]] = {}
for idx, pt in enumerate(unique_points):
clusters.setdefault(find(idx), []).append(pt)
ratio = float(config.get("footprint_concave_ratio", 0.35))
simplify = float(config.get("footprint_simplify_tolerance", 0.12))
min_area = float(config.get("footprint_min_area", 8.0))
polygons = []
try:
hull = concave_hull(MultiPoint(unique_points), ratio=ratio)
if simplify > 0:
hull = hull.simplify(simplify, preserve_topology=True)
if hull.is_empty or hull.area < min_area:
return None
if hull.geom_type == "Polygon":
polygons = [hull]
elif hull.geom_type == "MultiPolygon":
polygons = list(hull.geoms)
else:
for cluster_pts in clusters.values():
if len(cluster_pts) < 4:
continue
hull = concave_hull(MultiPoint(cluster_pts), ratio=ratio)
if simplify > 0:
hull = hull.simplify(simplify, preserve_topology=True)
if hull.is_empty or hull.area < min_area:
continue
if hull.geom_type == "Polygon":
polygons.append(hull)
elif hull.geom_type == "MultiPolygon":
polygons.extend(hull.geoms)
if not polygons:
return None
except Exception:
return None