I am looking for an algorithm as follows:
Given a set of possibly overlapping rectangles (All of which are "not rotated", can be uniformly represented as (left,top,right,bottom) tuplets, etc...), it returns a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area.
It seems simple enough at first glance, but prooves to be tricky (at least to be done efficiently).
Are there some known methods for this/ideas/pointers?
Methods for not necessarily minimal, but heuristicly small, sets, are interesting as well, so are methods that produce any valid output set at all.
Something based on a line-sweep algorithm would work, I think:
x
coordinates into an array, as "start-rectangle" and "end-rectangle" eventsy
-coordinates will suffice)y
-coordinates set to the part of the new rectangle that isn't already covered. I'm not completely sure this covers everything, but I think with some tweaking it should get the job done. Or at least give you some ideas... :)