2D Mesh union

I have a 2D mesh made up of many triangles and I would like to get the union of it with another 2D mesh that overlaps.

I would like to preserve as many polygons from the original meshes as possible. (Also as this is part of a realtime editor, it would be good if the technique is fast)

Is there a lightweight library, sample code or even a technique description that does what I would like to do?
I am aware of http://gts.sourceforge.net/ and http://www.cgal.org/ but they seem a bit heavy weight for what I want.

Maybe the gluTesselator can help you out…


You may want to look at GPC General Polygon Clipper library.

Wow! Thanks Nico, I had no idea that GLU could do such things. I have not done a full test yet, but my initial trials seem to indicate that it does exactly what I need. (humbled that a 10+ year old utility lib I have always had has solved a problem that has been bugging me for weeks)

@ obirsoy - That library also looks very good but it seems that GLU may do all I need.