I have a number of Objects that represent Polygons. I have a set of Pointers each to its own polygon.
Iterating through each pair of pointer I merge the polygons if they overlap into a new polygon. The two pointers in the pair I now let point to the merged polygon, in order to be able to merge it again and have the change in both pointers.
Now my problem arises pretty quickly with three objects:
- A* points to A, B* to B and C* to C as you would expect.
- I merge A* and B* and now both point to AB
- Then I merge A* and C* and now both point to ABC.
My problem is now B* does not know that AB was again merged and still points to AB, this is not what I want.
What I want is the behaviour not the pointer, so I am free for any suggestions. The only limitation is sadly that I am not allowed to use C++11 or newer.