i try to find a way to fill a geometry with a single color that contains empty space.
I built the gray background with multiple shapes and combine them together into a single shape. However, I don’t found a solution how to fill that empty space in the center of the background.
My first approach use all the points from the shapes, and find the most outer points. I tried to do so with alpha-shape algorithm and the ConvexHull. But it didn’t work and the points are not connected correct.
Is there a simple way to do that? I can’t believe that this simple task is that hard to achieve. Are there any specific algorithms for that use-case or any helpful three geometries that I could use?
Maybe this illustration explains it better. Each closed rectangle or polygon is an indivual shape.
I basically have only the points of the corners per each shape.
I can think of one, but the implementation is up to you. Two steps:
Find one external edge
Traverse all the rest edges following the rightmost path
Here is the first step:
Pick the upper most point, it must be a point of external edge
If there are several such points, pick the rightmost one (this is X)
At X there are several edges, imagine you are at X and you look upwards and turn to the left, pick the first edge that you see - in the diagram this would be A
Here is the second step, think of vertices are crossroads (intersections) and edges are roads:
You already have road A and from point X you reach crossroad B
There are two roads going out of B, pick the rightmost one according to your direction, this is C
Following road C you reach crossroad D
From D you follow road E, because it is the rightmost according to you
Then you follow road F and so on until you return to point X
Indeed a good idea. In an un-directed graph with nodes for each corner and edges for the paths where the direction from far left to far right represents the weight. The edge weight is the smallest if the neighbor is the rightmost. After that, use any node from top or bottom corner and run Dijkstra. The algorithm will produce the right path.