derive: trim segments to the frame clip (Liang-Barsky)

Membership by midpoint/endpoint kept whole segments, so long table borders
and annotation rules carried the full sheet width into a floor — 13号's 56m
frame emitted 143m of geometry and footprint hulls grew stray plates.
Segments are now clipped to the frame rect; fully-inside geometry passes
through unchanged. Regression: a 140m line crossing a 40m frame comes out
frame-wide. Dense sheet layouts hit this; 贝昂's wide frame pitch never did.

Round-3 log: tower-1 twin towers aligned and gated (union-clip standard
floors; PH centered on cores, RF parapet bbox-anchored, wing offsets
self-consistent to 50mm); podium F1-F3 zoning still open.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 22:01:20 +08:00
parent bccc9f41d6
commit 39528b38e9
3 changed files with 95 additions and 1 deletions

View File

@@ -694,6 +694,45 @@ def main() -> int:
f"glazing={len(glz_off)}",
)
# --- segments must be TRIMMED to the frame clip, not kept whole ---
# (13号: a 56m-wide frame emitted 143m of geometry because long table/
# border lines with an inside midpoint carried the full sheet width)
trim_dir = WORK / "dxf_trim"
trim_dir.mkdir(parents=True, exist_ok=True)
trim_doc = ezdxf.new("R2010", setup=True)
trim_doc.layers.add("I-WALL")
trim_msp = trim_doc.modelspace()
for start, end in [
((0, 0), (40000, 0)), ((40000, 0), (40000, 20000)),
((40000, 20000), (0, 20000)), ((0, 20000), (0, 0)),
]:
trim_msp.add_line(start, end, dxfattribs={"layer": "I-WALL"})
trim_msp.add_line((-50000, 10000), (90000, 10000), dxfattribs={"layer": "I-WALL"})
trim_doc.saveas(trim_dir / "plan.dxf")
trim_cfg = WORK / "trim_config.json"
trim_cfg.write_text(json.dumps({
"scale": 0.001, "drop_isolated_clusters": False,
"drawings": [{"file": "plan.dxf", "floors": [
{"key": "1F", "name": "首层", "z": 0.0, "height": 4.2, "clip": [-1000, -1000, 41000, 21000]},
]}],
}, ensure_ascii=False), encoding="utf-8")
trim_spec_path = WORK / "trim_spec.json"
proc = run([
sys.executable, "scripts/derive_showcase_spec.py",
"--dxf-dir", str(trim_dir), "--config", str(trim_cfg),
"--out", str(trim_spec_path), "--vendor-dir", str(VENDOR),
])
check("derive clip-trim runs", proc.returncode == 0, proc.stderr[-400:])
trim_spec = json.loads(trim_spec_path.read_text(encoding="utf-8"))
trim_walls = trim_spec["floors"]["1F"]["segments"]["walls"]
trim_max_x = max(max(s["start"][0], s["end"][0]) for s in trim_walls)
trim_min_x = min(min(s["start"][0], s["end"][0]) for s in trim_walls)
check(
"crossing line trimmed to the clip window",
len(trim_walls) == 5 and -1.5 <= trim_min_x and trim_max_x <= 42.5,
f"n={len(trim_walls)} x=[{trim_min_x:.1f},{trim_max_x:.1f}]",
)
# --- unsupported roof outlines (黄桥坡屋面: canopy with hatch-only posts) ---
uns_dir = WORK / "dxf_unsupported"
uns_dir.mkdir(parents=True, exist_ok=True)