Skip to content

Commit

Permalink
Fix in visualization that showed circles on wrong locations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatoom committed Mar 20, 2021
1 parent e6b6931 commit 29a3886
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion voronoi/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def create_diagram(self, points: list):

# Pop the event queue with the highest priority
event = self.event_queue.get()
self.event = event

# Set genesis point
genesis_point = genesis_point or event.point
Expand Down Expand Up @@ -123,7 +122,11 @@ def create_diagram(self, points: list):

# Handle the event
self.handle_site_event(event)
else:
# Skip the step if circle event is no longer valid
continue

self.event = event
self.notify_observers(Message.STEP_FINISHED)

self.notify_observers(Message.DEBUG, payload="# Sweep finished")
Expand Down
1 change: 1 addition & 0 deletions voronoi/observers/voronoi_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def update(self, subject: Algorithm, message: Message, **kwargs):
vis = Visualizer(subject, canvas_offset=self.canvas_offset)
settings = dict(outgoing_edges=False)
settings.update(self.settings)
assert subject.sweep_line == subject.event.y
result = vis.plot_all(**settings)
plt.title(str(subject.event) + "\n")
elif message == Message.SWEEP_FINISHED and self.visualize_before_clipping:
Expand Down
5 changes: 3 additions & 2 deletions voronoi/visualization/visualizer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import copy
from decimal import Decimal

import numpy as np
Expand Down Expand Up @@ -195,7 +196,7 @@ def plot_sweep_line(self, sweep_line=None):
return self

def plot_events(self, triangles=False):
for event in [self.voronoi.event]: # event_queue.queue:
for event in [self.voronoi.event]: # event_queue.queue:
if isinstance(event, CircleEvent):
self._plot_circle(event, show_triangle=triangles)

Expand All @@ -218,7 +219,6 @@ def _plot_circle(self, evt, show_triangle=False):

return self


def _plot_edge(self, edge, sweep_line=None, print_name=True, color=Colors.EDGE, **kwargs):

start, end = self._origins(edge, sweep_line)
Expand Down Expand Up @@ -264,6 +264,7 @@ def _origins(self, edge, sweep_line=None):
# Get start and end of edges
start = edge.get_origin(sweep_line, max_y)
end = edge.twin.get_origin(sweep_line, max_y)
start, end = copy(start), copy(end)
start, end = self._cut_line(start, end)

return start, end
Expand Down

0 comments on commit 29a3886

Please sign in to comment.