suspend switch for voronoi

This commit is contained in:
Johann Dreo 2014-05-21 11:25:28 +02:00
commit 6bdab7d667
2 changed files with 25 additions and 7 deletions

View file

@ -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()
########################################################################

View file

@ -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: