diff --git a/run_all.py b/run_all.py index 4f2d017..bf5bbfb 100755 --- a/run_all.py +++ b/run_all.py @@ -193,8 +193,7 @@ else: ######################################################################## if args.voronoi: - # voronoi_centers = utils.load_points(args.voronoi) - pass + voronoi_graph = utils.load_adjacency(args.voronoi) else: # LOGN( "Compute the nodes of the Voronoï diagram" ) @@ -203,13 +202,17 @@ else: voronoi_tri_centers = voronoi_tri_graph.keys() voronoi_graph = voronoi.merge_enclosed( voronoi_tri_graph, penrose_segments ) - voronoi_edges = voronoi.edges_of( voronoi_graph ) - voronoi_centers = voronoi_graph.keys() + + with open("d%i_voronoi.graph" % depth, "w") as fd: + for k in voronoi_graph: + fd.write( "%f,%f:" % (x(k),y(k)) ) + for p in voronoi_graph[k]: + fd.write( "%f,%f " % (x(p),y(p)) ) + fd.write("\n") - # with open("d%i_voronoi_centers.points" % depth, "w") as fd: - # for p in voronoi_centers: - # fd.write( "%f %f\n" % (p[0],p[1]) ) +voronoi_edges = voronoi.edges_of( voronoi_graph ) +voronoi_centers = voronoi_graph.keys() ######################################################################## diff --git a/utils.py b/utils.py index 5931577..7ee630b 100644 --- a/utils.py +++ b/utils.py @@ -68,6 +68,21 @@ def load_matrix( filename ): return matrix +def load_adjacency( filename ): + graph = {} + with open(filename) as fd: + for line in fd: + if line.strip()[0] != "#": + skey,svals = line.split(":") + key = tuple((float(i) for i in skey.split(','))) + graph[key] = [] + for sp in svals.split(): + p = tuple(float(i) for i in sp.split(",")) + assert(len(p)==2) + graph[key].append( p ) + return graph + + def adjacency_from_set( segments ): graph = {} for start,end in segments: