suspend switch for voronoi
This commit is contained in:
parent
ab22d6dd41
commit
6bdab7d667
2 changed files with 25 additions and 7 deletions
17
run_all.py
17
run_all.py
|
|
@ -193,8 +193,7 @@ else:
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
if args.voronoi:
|
if args.voronoi:
|
||||||
# voronoi_centers = utils.load_points(args.voronoi)
|
voronoi_graph = utils.load_adjacency(args.voronoi)
|
||||||
pass
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# LOGN( "Compute the nodes of the Voronoï diagram" )
|
# LOGN( "Compute the nodes of the Voronoï diagram" )
|
||||||
|
|
@ -203,13 +202,17 @@ else:
|
||||||
voronoi_tri_centers = voronoi_tri_graph.keys()
|
voronoi_tri_centers = voronoi_tri_graph.keys()
|
||||||
|
|
||||||
voronoi_graph = voronoi.merge_enclosed( voronoi_tri_graph, penrose_segments )
|
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:
|
voronoi_edges = voronoi.edges_of( voronoi_graph )
|
||||||
# for p in voronoi_centers:
|
voronoi_centers = voronoi_graph.keys()
|
||||||
# fd.write( "%f %f\n" % (p[0],p[1]) )
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
|
||||||
15
utils.py
15
utils.py
|
|
@ -68,6 +68,21 @@ def load_matrix( filename ):
|
||||||
return matrix
|
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 ):
|
def adjacency_from_set( segments ):
|
||||||
graph = {}
|
graph = {}
|
||||||
for start,end in segments:
|
for start,end in segments:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue