inner 1 outer 0 single line 0 1 shifted grid 0 1 pair of lines, single polygon 1 0 0 1 0 0 pair of lines, different polygons complex polygon 0 1 0 1 0 1 polygon with holes 0 1 0 1 0 1 0 1 0 1 0 1 polygons with reversed direction 0 1 0 1 0 1 0 eps for complex polygon in grid 1