-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (68 loc) · 2.03 KB
/
main.py
File metadata and controls
75 lines (68 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from data_struc import Model
import sys
import json
def get_model(file_name):
f = open(file_name)
json_data = f.read()
return json.loads(json_data)
if __name__ == "__main__":
#print ("Importing model from: " + str(sys.argv[1]))
model_data = get_model(str(sys.argv[1]))
# Create A model Class
model = Model(model_data)
model.create_cells()
for i in model.cells:
model.update_cells(i.id)
"""
print -------------------------------------------------------------"
for i in model.cells:
print i.map_id, i.id
print i.boundary_defn
print i.boundary
print "-----------------------------------------------------"
print len(model.cells)
model.create_graph()
print model.graph
tmp = 0
"""
"""
while (tmp != 99):
x = int(input(">"))
if x == 99:
break
result = model.star(x)
print "------------------------------"
for i in result:
print i.id
"""
#point = [1,3,3]
#model.point_containment(point)
#model.visualize(point)
#model.teselate()
model.create_graph()
print ("Press 99 to get a list of options\n")
while(1):
x = input("-> ")
x = x.split()
x = [float(i) for i in x]
if x[0] == 1:
result = model.connected_components(x[1])
for i in result:
print (i.id)
elif x[0] == 2:
result = model.star(x[1])
for i in result:
print (i.id)
elif x[0] == 3:
point = [x[1], x[2], x[3]]
print (model.point_containment(point))
model.visualize(point)
elif x[0] == 4:
print ("Tessalation")
model.teselate()
elif x[0] == 5:
model.visualize()
elif x[0] == 0:
break
else:
print ("1: connected components\n2: Star\n3: Point Containment\n4: Tesellation\n5: Visualize")