Skip to content

Commit

Permalink
Fix '_to_contour_events' function
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed Sep 4, 2022
1 parent fdb8f99 commit 6d7d84c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions clipping/core/holey.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ def _to_contour_events(event: LeftEvent,
opposite_event_id = event.right.id
contour_start = event.start
cursor = event
visited_endpoints_ids = [event.start_id]
while cursor.end != contour_start:
previous_endpoint_position = visited_endpoints_positions[cursor.end_id]
if previous_endpoint_position == UNDEFINED_INDEX:
Expand All @@ -463,16 +464,16 @@ def _to_contour_events(event: LeftEvent,
loop_event.end_id
] = UNDEFINED_INDEX
del result[previous_endpoint_position:]
visited_endpoints_ids.append(cursor.end_id)
event_id = _to_next_event_id(opposite_event_id, are_events_processed,
connectivity)
if event_id == UNDEFINED_INDEX:
break
cursor = events[event_id]
opposite_event_id = cursor.opposite.id
result.append(cursor)
visited_endpoints_positions[event.start_id] = UNDEFINED_INDEX
for event in result:
visited_endpoints_positions[event.end_id] = UNDEFINED_INDEX
for event_id in visited_endpoints_ids:
visited_endpoints_positions[event_id] = UNDEFINED_INDEX
assert all(position == UNDEFINED_INDEX
for position in visited_endpoints_positions)
return result
Expand Down

0 comments on commit 6d7d84c

Please sign in to comment.