Skip to content

Commit

Permalink
fixes index out of range error in polygonization edge tracing setup
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzWillig committed Mar 4, 2021
1 parent 6555f5b commit 7341724
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pysnic/algorithms/polygonize.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def trace_edges_unsafe(ex, ey, direction, segmentation):
queue = [starting_idx]

while len(queue) != 0:
do_break = False
while True:
# get next corner and check remaining directions
idx = queue[-1]
Expand All @@ -351,9 +352,15 @@ def trace_edges_unsafe(ex, ey, direction, segmentation):
l_dirs = len(directions)
if l_dirs <= 1:
idx = queue.pop()
if l_dirs != 0:
if len(queue) == 0:
do_break = True
break
else:
direction = directions.pop()
break

if do_break:
break

# compute starting coordinates
px = (idx % widthp) - 1
Expand Down

0 comments on commit 7341724

Please sign in to comment.