I have a list of points that in pairs describe a polygon, like this:
<0,0><0,1><0,1><1,0><1,0><1,1><1,1><0,0> which is a square. Note that each pair of points describes a line so our square is made up out of the lines
<<0,0><0,1>><<0,1><1,0>><<1,0><1,1>><<1,1><0,0>>
I do however have to draw these polygons which works fine when the points in question are all properly in order and there are no holes. Unfortunatly this sometimes goes wrong when the input is like
<0,0><0,1><1,1><0,0><0,1><1,0><1,0><1,1> and the resulting polygon is weird or when there are several holes in the
<0,0><0,2><0,2><2,0><2,0><2,2><2,2><0,0><1,1><1,1.5><1,1.5><1.5,1.5><1.5,1.5><1,1>
In these situations the naitive thing of drawing these polygons with a drawpoly(points) is not going to work.
This is in c# and the input is in reality a List<GeoData>
where GeoData
contains 2 points (and some other misq data). For the output I was thinking of making a List and a List> where the first set of points are the outer line and the second list is the holes, would that work? I do need to do some extra computations with the polygons other then just drawing but I think that will be easiest with a special list of holes.
On the left is what I currently get on the right is the input.
From your example I see that you draw a single polygon. You should call the method draw polygon (
drawpoly(points)
) multiple times for each separate polygon.I think it's easier to draw the holes instead the wall, respecting the principle KISS.
To do that you can store the polygons (holes) you want to draw in a list. If we do an analysis about data, we see that bolded data show the begining and the end of an polygon.
<0,0><0,2><0,2><2,0><2,0><2,2><2,2><0,0> <1,1><1,1.5><1,1.5><1.5,1.5><1.5,1.5><1,1>
And we represent this in code, as shown below:
Usage: