Imagine I have two point arrays. One of them is an open polygon, which looks like this.
X
es are black dots and points ('.') - white ones.
The second point array contains a closed polygon:
I need the name of an algorithm, which allows me to determine whether a given point array is a closed polygon or an open one. I need this information to determine, whether I can flood filll it (I cannot flood fill the first example, but I can flood fill the second one).
What is the algorithm called, which allows me to distinguish between the two types of polygons?
Update 1 (10.10.2015 10:05 MSK): I need to distinguish between closed and open polygons in order to prevent flood fill errors.
A flood fill errors, is when I apply flood fill to an open polygon like
.....
..XXX
.X..X
X...X
and end up with a completely filled grid:
XXXXX
XXXXX
XXXXX
XXXXX
My original idea was to
- take the polygon,
- check, if it's open or closed and
- if it's closed, apply flood fill.
Now, I could do it differently:
- Flood fill the polygon.
- If the entire grid is filled, then it's an open one, otherwise (at least one point in the grid after flood fill is white), it's a closed one.
If there is a way to avoid doing flood fill for determining, whether a polygon is open or closed, please tell me.