I'm using shapely and python to divide polygons into smaller pieces: trapezoids, parallelograms with sides parallel to x-axis and triangles with side parallel to x-axis. Initial data come from .gds file and is presented like list of tuples x,y coords. For my purpose I used difference method like described here. But I get stack when polygon has holes, for example:
from shapely.geometry import Polygon
points = [(0.0, -1.0), (0.0, 2.0), (3.0, 2.0), (3.0, 1.0), (1.0, 1.0), (1.0, 0.0), (2.0, 0.0), (2.0, 1.0), (3.0, 1.0), (3.0,-1.0)]
poly = Polygon(points)
print(poly.is_valid)
#Self-intersection at or near point 2 1
#False
So the question is what is the simpliest way how to convert this list of points into hull and holes for correct creation of polygon?
Thank you!