"""옥성교 마크별 대조 이미지: 도면 철근상세 그림(왼쪽) ↔ 모델 형상(오른쪽) ↔ 재료표 L·모델 L. 입력: 도면_철근상세_DXF렌더.png(원본 DXF 렌더 6000x4390), jobs/c1_work/c1_shape_audit2.json. 출력: 검토파일/수정후_캡처/도면대조_옥성_<부재>.png""" import json from pathlib import Path import numpy as np import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt from matplotlib import font_manager from PIL import Image font_manager.fontManager.addfont(r"C:\Windows\Fonts\malgun.ttf") plt.rcParams["font.family"] = "Malgun Gothic" ROOT = Path(r"D:\★Pier 자료\프로그램\Pier_T") SRC = Image.open(ROOT / "검토파일" / "검토_옥성교P1" / "도면_철근상세_DXF렌더.png").convert("RGB") # 원본 DXF(옥성교P1.dxf) 렌더 6000x4390 D = json.load(open(r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_shape_audit2.json", encoding="utf-8-sig"))["옥성"] OUT = ROOT / "검토파일" / "수정후_캡처" # 도면 그림 위치 (원본 픽셀) def f(x0, y0, x1, y1): return tuple(int(v * 3) for v in (x0, y0, x1, y1)) FIG = {"ㄷj": f(350, 425, 545, 490), "C7": f(650, 275, 845, 340), "rect": f(395, 950, 510, 1020), "pent": f(960, 165, 1110, 285), "loop": f(650, 935, 835, 1020), "loopj": f(650, 1085, 835, 1170), "U": f(85, 630, 235, 685), "L": f(85, 480, 235, 535), "I": f(100, 190, 215, 225), "Bj": f(80, 1015, 235, 1075), "B9": f(400, 780, 500, 875), "B10": f(375, 1145, 515, 1268)} MAP = {"C1": "ㄷj", "C2": "ㄷj", "C3": "ㄷj", "C4": "ㄷj", "C5": "ㄷj", "C6": "ㄷj", "C7": "C7", "C8": "rect", "C10": "rect", "C12": "rect", "C9": "pent", "C11": "pent", "C13": "pent", "C14": None, "C16": None, "C15": "loop", "C17": "loopj", "C18": "U", "C19": "U", "C20": "L", "S1": "U", "S2": "U", "S5": "U", "S6": "U", "S3": "I", "S4": "I", "S7": "I", "S8": "I", "B1": "Bj", "B2": "Bj", "B3": "Bj", "B4": "Bj", "B5": "Bj", "B6": "Bj", "B7": "Bj", "B8": "Bj", "B11": "Bj", "B12": "Bj", "B9": "B9", "B10": "B10"} # 판정 (시각 대조 결과) NOTE = {"C15": ("불일치", "도면=양끝 갈고리(r80,b188,c140) / 모델=직선"), "C17": ("불일치", "도면=양끝 갈고리 + j550 / 모델=직선"), "C14": ("도면 그림 없음", "j550×4 루프 — 도면에 형상 미작도"), "C16": ("도면 그림 없음", "j550×4 루프 — 도면에 형상 미작도"), "C7": ("일치(확인)", "경사 soffit형, j1050"), "C20": ("일치", "L형"), "C9": ("확인", "오각형(경사 모따기)"), "C11": ("확인", "오각형"), "C13": ("확인", "오각형")} PARTS = {"코핑": ("P1-CP", ["C%d" % i for i in range(1, 21)] + ["S%d" % i for i in range(1, 9)]), "기초": ("P1-FT", ["B%d" % i for i in range(1, 13)])} made = [] for part, (host, marks) in PARTS.items(): its = {x["mark"]: x for x in D if x["host"] == host and x["mark"] in marks} ks = sorted(its, key=lambda m: (m[0], int(m[1:]))) rows = (len(ks) + 1) // 2 fig, axs = plt.subplots(rows, 4, figsize=(17, rows * 2.5), gridspec_kw={"width_ratios": [1, 1, 1, 1]}) axs = np.atleast_2d(axs) for ax in axs.ravel(): ax.axis("off") for i, m in enumerate(ks): x = its[m]; r, c = divmod(i, 2) a1, a2 = axs[r][c * 2], axs[r][c * 2 + 1] key = MAP.get(m) a1.axis("on"); a1.set_xticks([]); a1.set_yticks([]) if key: a1.imshow(SRC.crop(FIG[key])); a1.set_title("도면 %s" % m, fontsize=10, fontweight="bold", color="#8a5a00") else: a1.text(0.5, 0.5, "도면에 형상 그림 없음", ha="center", va="center", fontsize=10); a1.set_title("도면 %s" % m, fontsize=10, fontweight="bold") P = np.array(x["pts"]); C = P - P.mean(0) _, _, vt = np.linalg.svd(C, full_matrices=False); Q = C @ vt[:2].T a2.axis("on"); a2.set_xticks([]); a2.set_yticks([]) a2.plot(Q[:, 0], Q[:, 1], "-", color="#1f77b4", lw=2); a2.plot(*Q[0], "o", color="green", ms=5); a2.plot(*Q[-1], "s", color="red", ms=5) w, h = np.ptp(Q[:, 0]), np.ptp(Q[:, 1]) if h < 0.2 * w or w < 0.2 * h: a2.set_aspect("auto"); a2.margins(0.08) else: a2.set_aspect("equal") verdict = NOTE.get(m) a2.set_title("모델 %s %s N=%d" % (m, x["dia"], x["n_obj"]), fontsize=10, fontweight="bold", color=("#c00000" if verdict and verdict[0] == "불일치" else "black")) t = "표 L=%s / 모델 %s" % ((x["design_len"] or "-").split(".")[0], x["len"]) if verdict: t += "\n" + verdict[0] + ": " + verdict[1] a2.set_xlabel(t, fontsize=8, color=("#c00000" if verdict and verdict[0] == "불일치" else "black")) fig.suptitle("옥성교 %s 철근 — 도면 철근상세 ↔ 모델 형상 대조 (왼쪽 도면, 오른쪽 모델)" % part, fontsize=15, fontweight="bold") fig.tight_layout(rect=(0, 0, 1, 0.97)) p = OUT / ("도면대조_옥성_%s.png" % part); fig.savefig(p, dpi=75); plt.close(fig); made.append(p.name) print(made)