main
John Lauer
Add checked thermal copper and three diode vias with recorded native edits
04a7e28
"""Compare native saved fill polygon areas; not whole-board copper union or thermal rating."""
import sys,json,hashlib
from pathlib import Path
from sexp import parse,find,first
def audit(path):
p=Path(path);b=parse(p.read_text());zones=[]
for z in find(b,'zone'):
areas={}
for poly in find(z,'filled_polygon'):
pts=[tuple(map(float,x[1:])) for x in find(first(poly,'pts'),'xy')]
area=abs(sum(x*y2-x2*y for (x,y),(x2,y2) in zip(pts,pts[1:]+pts[:1])))/2
layer=first(poly,'layer')[1];areas[layer]=areas.get(layer,0)+area
name=first(z,'name');net=first(z,'net')
zones.append({'name':name[1]if name else None,'net':net[1:]if net else None,'nativeFillPolygonAreaMm2':areas})
return {'path':str(p),'sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'zones':zones}
if __name__=='__main__':
print(json.dumps({'scope':'Saved native filled polygon area only. Not union of pads/tracks/zones; drill deductions, connectivity and thermal effectiveness require separate checks.','boards':[audit(x)for x in sys.argv[1:]]},indent=2))