I have rectilinear polygons present, and they are surrounded by grids(grey rectangle with dots denoting center) as shown in the diagram below.
The grids are perfectly stacked horizontally and vertically. I have with me the coordinates of the edges (x,y) and the centre points of the grids (vectorpairint,int>>). The grids may or may not intersect with the polygon edge.
I need to find all the grid points that are immediate neighbours to that edge in the respective orientation (left,top,down,bottom).
If the red polygon were not there, I could simply find the grid point closest to the edge corners and fill the rest of the matrix, but the red box messes up the continuity. The red box is also a polygon with edge coordinates known.
I would need to do this for ~120000 edges Any performant approach to solving this?