1

I am trying to perform "Union" of two polygons in Clipper Library. The problem is there is a 2mm gap between the two closest egdes of the two polygons. So the result is still two polygons. Is there a way to remove gap between polygons if it is less than, say, 5mm?

Thanks in advance.

mkierc
  • 1,193
  • 2
  • 15
  • 28
Veda
  • 243
  • 1
  • 15
  • 1
    I don't see how this is an "error" with the library as it's behaving as designed. If there's any gap between polygons there shouldn't be any union. However, to overcome this gap, you could expand (offset) your polygons using a ClipperOffset object in the same library. – Angus Johnson Jul 19 '14 at 16:50
  • If I offset them by 2 (eg.), won't it change the geometry of those polygons? – Veda Jul 21 '14 at 05:42
  • Yes, the geometries must change if you grow/expand the polygons. Nevertheless you could shrink the result by the same amount (after the union operation) to approximate starting geometries. The only other option AFAICS is to move polygons that are close together (though I don't have any suggestions as to how to accomplish that). – Angus Johnson Jul 21 '14 at 07:43
  • So I have first offset each polygon by 2, then perform union, then offset the result by -2. Is this correct? I will try this and get back. – Veda Jul 21 '14 at 09:33
  • I used offset of 5 and then -5 and it worked. Thanks a lot. – Veda Aug 14 '14 at 09:37

1 Answers1

1

Before performing Union, I offsetted all the polygons by 5 and then again by -5. After this, the Union function worked correctly, even for polygons with gaps between them. I got what I needed, but does anyone know the reason for this?

Veda
  • 243
  • 1
  • 15