So I have a set of 2D rectangles that overlap, and I want to find a polygon that represents the area they cover. It's possible for the polygon to have holes also, which would be represented by a polygon within a polygon.
So I'm guessing my output would be a tree-like structure, where a solid polygon's children are the holes, and the hole's children are island polygons within the holes(hopefully that makes sense)
A polygon would just be a list of vertices, where the last one is the same as the first
Here's a picture o开发者_运维问答f what I'm talking about:
Thanks!
I've never tried to do this but my gut reaction was to consider Sets and perhaps to find your Islands, Disjoint sets.
There probably is a better solution, but that at least might give you something to research.
Edit: there's another question that has some code that seems to solve your problem:
Algorithm to merge adjacent rectangles into polygon
精彩评论