"""Infer the footing rebar layers B1-B10 from the footing size (2026-10-19, read-only trial). The rules were read off the template pier (운곡교 P1): bars run (footing - 200) long; the dense layers (B2/B4, B6/B8) have the two end bars, one bar 200 (X-position axis) / 175 (Y) inside, then a 125 grid; the sparse layers (B3, B7, B1, B5) the same with a 250 grid; B9 ties sit on a 250 grid (checkerboard, half of the points); B10 hoops grow with the footing. The result is checked against (a) the template params (P1: must reproduce) and (b) the bar counts of the pier's own rebar schedule (independent evidence). usage: python tools/infer_footing_rebar.py -> prints the layers; with --check compares with that file's footing_rebar""" import json import sys import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from engine.footing_rule import dense, infer, sparse # noqa: E402,F401 if __name__ == "__main__": sx, sy = float(sys.argv[1]), float(sys.argv[2]) r = infer(sx, sy) print({k: (len(v) if isinstance(v, list) else v) for k, v in r.items()}) if "--check" in sys.argv: ref = json.load(open(sys.argv[sys.argv.index("--check") + 1], encoding="utf-8"))["footing_rebar"] for k in ("bottom_Y1", "bottom_X2", "bottom_Y3", "bottom_X4", "top_Y", "top_X"): print(k, "equal" if [round(x, 1) for x in r[k]] == [round(x, 1) for x in ref["layers"][k]["pos"]] else "DIFF")