"""R5 (bridge bearings + sole plates) reading of the Ungok P2 drawings -> params.sole_plates / expected.G5. D2 솔플레이트 상세 TABLE (NO., S(%), L, W, T, T1, T2) and ELEVATION TABLE (EL.'X', h3) via the app table reader. P2: h3 165 (P1 181); W 640 / 750 (NO.3, 8) = B + 100 (B 540 / 650); L 800 = A + 100. Rules reused from P1 (user 2026-10-08): bearing = (L-100) x (W-100) black box of height h3 on the pad top; slope S along the pad axis only, thick end at -Y [HITL P1, not re-confirmed for P2]. """ import json import shutil import sys import time from pathlib import Path HERE = Path(__file__).resolve().parent APP = HERE.parent / "교각모델링앱" PIER = APP / "data" / "운곡교p2" sys.path.insert(0, str(HERE)) from extract_r1 import table # noqa: E402 def main(): el, sp = table() P = json.loads((PIER / "params.json").read_text(encoding="utf-8")) E = json.loads((PIER / "expected.json").read_text(encoding="utf-8")) stamp = time.strftime("%Y%m%d_%H%M%S") for f in ("params.json", "expected.json"): shutil.copy2(PIER / f, PIER / "backup" / f"{Path(f).stem}_before_R5_{stamp}.json") h3 = {int(r["h3"]) for r in el.values()} assert len(h3) == 1, h3 h3 = h3.pop() rows, checks = [], [] for no, r in sorted(sp.items()): row = {"no": no, "S": float(r["S(%)"]), "L": int(r["L"]), "W": int(r["W"]), "T": int(r["T"]), "T1": int(r["T1"]), "T2": int(r["T2"])} rows.append(row) A, B = int(el[no]["A"]), int(el[no]["B"]) half = row["S"] / 100 * row["L"] / 2 checks.append({"no": no, "L_eq_A100": row["L"] == A + 100, "W_eq_B100": row["W"] == B + 100, "end_thick": [round(row["T"] - half, 2), round(row["T"] + half, 2)], "T1T2": [row["T1"], row["T2"]]}) s = P["sole_plates"] s.update({"table": rows, "h3": h3, "checks": checks, "bearing_height": f"h3 (D2 ELEVATION TABLE, {h3})", "src": "D2 솔플레이트 상세 TABLE (NO., S(%), L, W, T, T1, T2); ELEVATION TABLE h3; 규칙 = P1 사용자 지시(2026-10-08)"}) E["G5"] = { "el_x": {str(n): round(float(r["EL.'X'"]) * 1000) for n, r in el.items()}, "S": {str(r["no"]): r["S"] for r in rows}, "W": {str(r["no"]): r["W"] for r in rows}, "L": rows[0]["L"], "T": rows[0]["T"], "h3": h3, "bearing_shrink": 100, "colours": {"bearing": [0, 0, 0], "sole_plate": [150, 150, 150]}, "src": "D2 ELEVATION TABLE (EL.'X', h3), 솔플레이트 상세 TABLE (S, L, W, T); (L-100)x(W-100)·색 = P1 사용자 지시 준용", } assert len({r["L"] for r in rows}) == 1 and len({r["T"] for r in rows}) == 1 P["_meta"]["status"] = "R1~R5 판독 2026-10-12 (Agent 초안, 사용자 확정 전)" (PIER / "params.json").write_text(json.dumps(P, ensure_ascii=False, indent=1), encoding="utf-8") (PIER / "expected.json").write_text(json.dumps(E, ensure_ascii=False, indent=1), encoding="utf-8") print("h3", h3, "checks", [(c["no"], c["L_eq_A100"], c["W_eq_B100"], c["end_thick"]) for c in checks]) if __name__ == "__main__": main()