Files
Pascal Lais 43d8957e48
All checks were successful
continuous-integration/drone/push Build is passing
Add main.py to run example code
2021-04-08 16:04:10 +02:00

57 lines
1.4 KiB
Python

#!/usr/bin/python3
"""The main module is the entry point of the computational-geometry-visu application."""
from tkinter import *
import linesegment
import point
import algorithm
def update_algorithm():
if SWEEP.is_running():
SWEEP.step()
SWEEP.draw(w, canvas_width, canvas_height, 150, 70)
master.after(300, update_algorithm)
# if SWEEP.get_section() == "sweep-left-to-right" or \
# SWEEP.get_section() == "sweep-right-to-left":
# master.after(1, update_algorithm)
# else:
# master.after(1000, update_algorithm)
# SWEEP.draw(w, canvas_width, canvas_height, 150, 70)
else:
print("Finished")
SWEEP.draw(w, canvas_width, canvas_height, 150, 70)
POINT_SET = []
for _ in range(40):
POINT_SET.append(point.get_random(0, 150, 0, 70))
# POINT_SET.append(linesegment.get_random(0, 100, 0, 100))
master = Tk()
canvas_width = 1500
canvas_height = 700
w = Canvas(master,
width=canvas_width,
height=canvas_height)
w.pack()
SWEEP = algorithm.ConvexHullIncremental(POINT_SET)
# SWEEP = algorithm.NearestNeighborsSweep(POINT_SET)
SWEEP.start()
SWEEP.draw(w, canvas_width, canvas_height, 150, 70)
master.after(10, update_algorithm)
mainloop()
# print("POINT_SET = [")
# for pnt in POINT_SET:
# print(pnt.str() + ",")
# print("]")
# RESULT = SWEEP.run()
# SWEEP.get_result_string(True)