I have one main (red) rectangle and several other rectangles, which intersect main rectangle randomly.
How can I get non-intersection area of main rectangle (red area)?
I have one main (red) rectangle and several other rectangles, which intersect main rectangle randomly.
How can I get non-intersection area of main rectangle (red area)?
This depends very much on what you mean by "have" and "get". What are the input and output formats? Do you want a sequence of points, or just the area? Is this for a general solution, or just this simplified case?
For a fast, general solution, I highly recommend the BOOST polygon library (disclosure: I was one reviewer for the BOOST conference presentation). This handles arbitrary polygons, including holes, and does a lovely job of all the basic polygon operations.
A simple polygon is a sequence of points. You can make sets of polygons. For this case, declare all of your polygons; put the red rectangle into set A, the gray ones into set B. Then A-B returns the desired displayed polygon.