I have rectilinear polygons present, and they are surrounded by grids(grey rectangle with dots denoting center) as shown in the diagram below. There are some areas where grids are not present - like the big grey and red polygons.
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 (vector<pair<int,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.
Input is the vector of grid centers : vector<pair <int,int>>
and map of vector to store the polygon coordinates: map <string,vector<pair<int,int>>
polyLst[shape1] = {x0,y0} {x1,y1} {x2,y2} {x3,y3} ,{x4,y4} ,{x5,y5} ,{x0,y0}
The polygons are closed. I have ~300 such polygons with varying edges total sum of which is ~120000. The grid is of ~600000 points.
Required output is the set of points closest to the edge (the orange ones). It should be per edge ( edge 1 (x0,y0 to x1,y1) has p1,p2,p3,... grid points as neighbour).
Any performant approach to solving this?
do this
I have an idea about what the input is for the polygons. Please add to your question: How is the grid specified? What is the required output? $\endgroup$