Beispiel #1
0
 def __init__(self, points, index_main_point, delay):
     with TestProcess.lock:
         self.id = TestProcess.num_threads
         TestProcess.num_threads += 1
         self._polygon = points[:]
         ArtGalleryPainter.set_polygon(self._polygon)
         self.gallery = ArtGallery(self._polygon.pop(index_main_point))
     self.delay = delay
     self.big_delay = TestProcess._big_delay \
                      if delay < TestProcess._big_delay \
                      else delay
     self.state = TestProcess.STARTING
     threading.Thread.__init__(self)
     self.counter = 0
Beispiel #2
0
# Read the file name from command line
try:
    file_name = argv[1]
except IndexError:
    print "No input file"
    exit()

polygon = ArtGallery.load(file_name)
n_nodes = len(polygon)

# generates the network with 10 hosts
net_gen = NetworkGenerator(n_count=n_nodes-1, n_min=1, n_max=n_nodes)
net = net_gen.generate_random_network()

ArtGalleryPainter.set_polygon(polygon)

label = "Distributed Solution for Art Gallery Problem"

max_x = 0
max_y = 0
for p in polygon:
    
    # Correction on polygon draw on window
    if n_nodes < 7:
        p.x = ((p.x + 0) * 20) + 0
        p.y = ((p.y + 0) * 20) + 10

    if (p.x > max_x):
        max_x = p.x
    if (p.y > max_y):