For polygon, the points are given in counter clock wise manner. For holes, the points are given in clock wise manner. So given a list of polygons, how to construct all the polygon with holes?
Here are a few precondition of the polygon list:
- One polygon can contain multiple holes, but a hole must be contained inside a polygon.
- A hole cannot contain one or more polygon.
- All the holes must be located inside polygon, and not outside of it
- Hole's edge can touch on polygon's.
- And all the polygons and holes must not intersect with other polygons/holes, although they can touch one another.
- The polygon/ hole can be either convex or concave.
How to devise an algorithm that construct polygons with holes?
I am looking for a general algorithm, so any code in the form of C#, C++ and matlab are welcomed.
Edit: This is my input ( in C#)
public class PolygonWithHoles
{
public List<Point> OuterBoundary;
public List<List<Point>> Holes;
}
//input: a list of point list. If the point list constructs a polygon in Counter clock wise, then it is a general polygon, else it is a holes
public List<PolygonWithHoles> ConstuctPolyHoles(List<List<Point>> Polys)
{
}