From 43d8957e481db3c20983689a28775f4fe3ce7d41 Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Thu, 8 Apr 2021 16:04:10 +0200 Subject: [PATCH] Add main.py to run example code --- main.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..474957a --- /dev/null +++ b/main.py @@ -0,0 +1,57 @@ +#!/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) \ No newline at end of file