Find the set of largest contiguous rectangles to cover multiple areas [duplicate]

I found the paper Fast Algorithms To Partition Simple Rectilinear Polygons from San-Yuan Wu and Sartaj Sahni, which could be of interest to you. In your example the region with character ‘d’ forms a rectilinear polygon, also the regions with ‘c’ and ‘.’. This paper includes algorithms for hole-free simple rectilinear polygons.

If a polygon includes holes, there are algorithms running with O(n^3/2 log n) time, as JM Keil in the paper Polygon Decomposition on page 11 states.

If minimizing the total length of the line segments introduced in the partitioning process is the other optimization criterion, the problem becomes NP-complete if the polygon contains holes (page 12). For these problems approximation algorithms exist (the paper refers to papers with such algorithms). If the polygon doesn’t contain holes there is an O(n^4) time algorithm.

Leave a Comment