"""PCB object comparison; reuses only the format-independent entity matcher.""" import math import re from collections import defaultdict from .diff import Entity, digest, match_entities TOKEN = re.compile(r'[MLAZ]|[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:[eE][-+]?\d+)?') IGNORE = {'NET_INDEX','COMPONENT_INDEX','POLYGON_INDEX','INDEX','UNIQUEID','SOURCEUNIQUEID', 'LOCKED','FLAGS_1','FLAGS_2','OUTLINE_PATH','X','Y','ROTATION','LAYER'} def number(n): return round(float(n), 7) or 0.0 def point(x, y, origin, rotation=0, mirrored=False): x,y = x-origin[0],y-origin[1] a=math.radians(rotation) x,y=x*math.cos(a)-y*math.sin(a),x*math.sin(a)+y*math.cos(a) return (number(-x if mirrored else x),number(y)) def path_signature(path, origin, rotation=0, mirrored=False): """Canonical local geometry for the M/L/A/Z vocabulary emitted by the PCB parser.""" tokens=TOKEN.findall(path); out=[]; i=0 while i