|  |     If there are not that many, a naive polygon clipping algorithm
    specialized for rectangles would work fine...  you could make a
    front to back pass, outputing visible fragments of each rectangle
    as clipped by polygons which have already been output.
    For many better ideas for the general case much work has been done
    because of its importance for VLSI design rule checkers.  An overall
    reference is the book 'Introduction to Computational Geometry" by
    Preparata and Shamos.
    In particular, there are multidimensional binary search trees
    and other data structures which make such clipping and interference
    detection very fast compared to simple-minded approaches.  For your
    rectangle case, an algorithm that sweeps from top to bottom, stopping
    whenever a new horizontal edge is encountered, and maintains active
    rectangle lists would do the trick.
    - Jim
 |