Drogheda/03-Architecture-Hardware/Auditoria-Final-V56-V57/scripts/render_fills.py

36 lines
2.9 KiB
Python

import sys; sys.path.insert(0,'.')
from gerb import *
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle, Circle
from shapely.ops import unary_union
INDIGO="#2C3C5B"; BOARD="#1E3A2E"
base="../in/03-Architecture-Hardware/kicad"
def fills(path, win, layer_filter=None):
objs,mac=parse(path)
regs=[g for g in geoms_of([o for o in objs if o[0]=="region"],mac,window=win)]
polys=[sh for sh,pol,net in regs if pol=="D"]
return unary_union(polys) if polys else None
fig,axs=plt.subplots(1,2,figsize=(13,4.9))
for ax,(v,b,prod,lay,ext,win,ttl) in zip(axs,[("v56","v5","HBOX_v5_Rev6_PROD","B_Cu","gbl",(136.0,111.0,154.0,121.0),"V5.6 B.Cu — zona de U7 (vía de T35) y RS1 (T34)"),
("v57","v57","HBOX_v5_Rev7_PROD","B_Cu","gbl",(136.0,108.0,154.0,118.0),"V5.7 B.Cu — zona de U7 (T36) y C129 (T37)")]):
ft=f"{base}/production/{prod}/hbox-watchdog-{b}-{lay}.{ext}"; stale=f"{base}/_to_delete/audit-20261022/{v}/gerber-cli/hbox-watchdog-{b}-{lay}.gbr"
objs,mac=parse(ft)
ax.add_patch(Rectangle((win[0],win[1]),win[2]-win[0],win[3]-win[1],facecolor=BOARD,zorder=0))
# tracks + pads from FT (same in both)
nonreg=geoms_of([o for o in objs if o[0]!="region"],mac,window=win)
draw_geoms(ax,nonreg,"#C8A05A",bg=BOARD,zorder=2)
f_ft=fills(ft,win); f_st=fills(stale,win)
both=f_ft.intersection(f_st); only_st=f_st.difference(f_ft).buffer(0); only_ft=f_ft.difference(f_st).buffer(0)
draw_geoms(ax,[(both,"D",None)],"#8E9A8E",bg=BOARD,zorder=1)
draw_geoms(ax,[(only_st,"D",None)],"#FF2D2D",bg=BOARD,zorder=3)
draw_geoms(ax,[(only_ft,"D",None)],"#51F3DA",bg=BOARD,zorder=3)
ax.set_xlim(win[0],win[2]); ax.set_ylim(win[3],win[1]); ax.set_aspect("equal"); ax.axis("off")
ax.set_title(ttl,color=INDIGO,fontsize=12,fontweight="bold",loc="left")
pass
axs[0].annotate("vía /SYS5V (138.7, 117.45) de T35:\nel relleno viejo le pasa encima (corto)",xy=(138.7,117.45),xytext=(139.5,112.2),color="white",fontsize=9,arrowprops=dict(arrowstyle="->",color="white"),bbox=dict(boxstyle="round",fc="#C0392B",ec="none"))
axs[0].annotate("RS1: vías de entrada de T34",xy=(150.8,116.3),xytext=(144.0,119.8),color="white",fontsize=9,arrowprops=dict(arrowstyle="->",color="white"),bbox=dict(boxstyle="round",fc="#C0392B",ec="none"))
axs[1].annotate("vía GND de C129 (151.25, 112.5) de T37",xy=(151.25,112.5),xytext=(139.5,109.2),color="white",fontsize=9,arrowprops=dict(arrowstyle="->",color="white"),bbox=dict(boxstyle="round",fc="#C0392B",ec="none"))
fig.suptitle("El .kicad_pcb en disco trae el relleno de zonas viejo (pasada 5); Fabrication Toolkit rellenó al exportar.\ngris = relleno igual · ROJO = cobre del relleno viejo que el Gerber NO tiene · cian = cobre nuevo del Gerber · dorado = pistas, pads y vías",color=INDIGO,fontsize=11,fontweight="bold")
fig.tight_layout(rect=(0,0,1,0.88)); fig.savefig("fig/fig-relleno-viejo.png",dpi=200,facecolor="white"); plt.close(fig)
print("ok")