The repeated segment ((0, 0), (0, 1)) in this polygon don't raise an error
>>> G = [(0,0),(2,0),(2,4),(-2,4),(-2,0),(0,0),(0,1),(-1,2),(1,2),(0,1)]
>>> isect_polygon(G)
[]
But an error occurs in this case
>>> Z = [(-1,0),(0,0),(1,1),(0,0)]
>>> isect_polygon(Z)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "isect.py", line 599, in isect_polygon
return isect_polygon_impl(segments, include_segments=False)
File "isect.py", line 591, in isect_polygon_impl
return isect_segments_impl(segments, include_segments=include_segments)
File "isect.py", line 578, in isect_segments_impl
sweep_line.handle(p, events_current)
File "isect.py", line 386, in handle
self.handle_event(e)
File "isect.py", line 393, in handle_event
self.insert(event)
File "isect.py", line 323, in insert
assert(event not in self._events_current_sweep)
AssertionError
Removal of duplicate segments after canonicalization (either in isect_segments_impl or in the __init__ of the EventQueue) solves the latter problem.
The repeated segment ((0, 0), (0, 1)) in this polygon don't raise an error
But an error occurs in this case
Removal of duplicate segments after canonicalization (either in
isect_segments_impl
or in the__init__
of theEventQueue
) solves the latter problem.