예제 #1
0
for arg in sys.argv:
    if arg == "-f":
        fast_locate = True
    if arg == "-r":
        random_order = True

if len(sys.argv)>1:
    filename = sys.argv[1]
else:
    print "Usage: python triangulate.py <filename.node>"

basename = ".".join(filename.split(".")[:-1])

#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)
예제 #2
0
파일: test.py 프로젝트: hbradlow/delaunay
from gui import Visualizer, Point2D, Line2D, Box2D, add_line, Polygon2D
import Tkinter as tk
from structures import *
from dt import Triangulation
import threading

from parse import load_node

lock = threading.Lock()


#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()
예제 #3
0
for arg in sys.argv:
    if arg == "-f":
        fast_locate = True
    if arg == "-r":
        random_order = True

if len(sys.argv) > 1:
    filename = sys.argv[1]
else:
    print "Usage: python triangulate.py <filename.node>"

basename = ".".join(filename.split(".")[:-1])

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