When I compute the difference between two shapes which touches one another (for example a rectangle A in a bigger rectangle B with a hole at rectangle A) and a clip shape (rectangle C) the two touching shapes are merged because their share the same edges and then the clipping is executed.
Is it possible to avoid merging touching shapes when clipping?
Here is an example of the difference between two shapes (A in green and B in red) and a clip (so the operation is: A & B - Clip), it returns the blue shape:
Instead of the blue rectangle, I would like to have those two shapes:
And the intersection would give:
This would give me the four shapes I want:
I know I could perform the operations on each shape separately, but I am afraid it will be more costly.
Note
Here is the result of a XOR:
In the hand I compute the operation myself:
This is efficient enough, but I need a space-partitioning data structure to sort edges and quickly their intersections.