#initial setup vertices = load_node(filename) min_x = min(vertices,key=lambda v: v.x).x min_y = min(vertices,key=lambda v: v.y).y max_x = max(vertices,key=lambda v: v.x).x max_y = max(vertices,key=lambda v: v.y).y dx = max_x-min_x dy = max_y-min_y v1 = Vertex(min_x-dx*100,min_y-dy*100) v2 = Vertex(min_x-dx*100,max_y+dy*200) v3 = Vertex(max_x+dx*200,min_y-dy*100) if random_order: random.shuffle(vertices) dt = Triangulation(v1,v2,v3,fast_locate=fast_locate) total = len(vertices) for index,vertex in enumerate(vertices): if index%100==0: print 100.*index/total,"% complete" dt.insert_site(vertex) print "Took",time.time()-start_time,"seconds to calculate" dt.remove_bounds() print "Took",time.time()-start_time,"seconds to generate with removed outer triangle" output_ele(basename + ".ele",dt.get_triangles()) print "Took",time.time()-start_time,"seconds to output"
#initial setup vertices = load_node("spiral.node") min_x = min(vertices,key=lambda v: v.x).x min_y = min(vertices,key=lambda v: v.y).y max_x = max(vertices,key=lambda v: v.x).x max_y = max(vertices,key=lambda v: v.y).y dx = max_x-min_x dy = max_y-min_y v1 = Vertex(min_x-dx*100,min_y-dy*100) v2 = Vertex(min_x-dx*100,max_y+dy*200) v3 = Vertex(max_x+dx*200,min_y-dy*100) dt = Triangulation(v1,v2,v3,fast_locate=True) for vertex in vertices: dt.insert_site(vertex) #dt.remove_bounds() root = tk.Tk() def draw_faces(): for face in dt.faces: if face.conflict: vis.add_drawable(Polygon2D(face.vertices(),fill="green")) def draw_skeleton(): for triangle in dt.get_triangles(): prev = None
vertices = load_node(filename) min_x = min(vertices, key=lambda v: v.x).x min_y = min(vertices, key=lambda v: v.y).y max_x = max(vertices, key=lambda v: v.x).x max_y = max(vertices, key=lambda v: v.y).y dx = max_x - min_x dy = max_y - min_y v1 = Vertex(min_x - dx * 100, min_y - dy * 100) v2 = Vertex(min_x - dx * 100, max_y + dy * 200) v3 = Vertex(max_x + dx * 200, min_y - dy * 100) if random_order: random.shuffle(vertices) dt = Triangulation(v1, v2, v3, fast_locate=fast_locate) total = len(vertices) for index, vertex in enumerate(vertices): if index % 100 == 0: print 100. * index / total, "% complete" dt.insert_site(vertex) print "Took", time.time() - start_time, "seconds to calculate" dt.remove_bounds() print "Took", time.time( ) - start_time, "seconds to generate with removed outer triangle" output_ele(basename + ".ele", dt.get_triangles()) print "Took", time.time() - start_time, "seconds to output"