def importSVGroute(IDT_group):
IDT_group_dir = IDT_group['IDT_group_dir']
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
svg_filename = tkFileDialog.askopenfilename(title='Wafer routing filename',defaultextension = 'svg',initialdir = IDT_group_dir);
all_points = SVGT.read_colored_path_from_svg(svg_filename)
route =[[],[]]
for points in all_points['red']:
polygon = shapely_geom.Polygon(points.T)
polygon_validity = explain_validity(polygon)
if polygon_validity=='Valid Geometry':
route[0].append(polygon)
else:
tkMessageBox.showwarning('Error in svg import', polygon_validity)
for points in all_points['blue']:
polygon = shapely_geom.Polygon(points.T)
polygon_validity = explain_validity(polygon)
if polygon_validity=='Valid Geometry':
route[1].append(polygon)
else:
tkMessageBox.showwarning('Error in svg import', polygon_validity)
route[0] = shapely_geom.MultiPolygon(route[0])
route[1] = shapely_geom.MultiPolygon(route[1])
#outbox = route[0].bounds
#dx = outbox[2]-outbox[0]
#dy = outbox[3]-outbox[1]
#x0 = outbox[0]+dx/2
#y0 = outbox[1]+dy/2
x0 = 4000
y0 = 4000
factor = 1e-5;
route[0] = shapely_affinity.translate(route[0], xoff=-x0, yoff=-y0)
route[0] = shapely_affinity.scale(route[0], xfact = factor, yfact= factor, origin=(0,0,0))
route[1] = shapely_affinity.translate(route[1], xoff=-x0, yoff=-y0)
route[1] = shapely_affinity.scale(route[1], xfact = factor, yfact= factor, origin=(0,0,0))
IDT_group['route'] = route
评论列表
文章目录