0

I'm trying to make union from the polygons in this way:

enter image description here

You can see the direction from arrows: clockwise for holes and counterclockwise for solids.

But as the result shows, it doesn't work. I tried with all GLU_TESS_WINDING_RULE combinations but couldn't make it work.

Is this possible with bare GLUtesselator, or do I need some other library for this? Can Clipper lib do it?

Rookie
  • 4,064
  • 6
  • 54
  • 86

1 Answers1

0

The General Polygon Clipper library can do boolean operations on polygons.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • Does Clipper Lib also do that? (i heard it was better). – Rookie Oct 06 '12 at 21:18
  • Had not heard of it. Looks useful. – genpfault Oct 06 '12 at 23:04
  • Yes. But the reason im trying to avoid it is because it requires the coordinate data to be in int64 format... so i need to convert back and forth, and im afraid of lost precision or calculation errors with huge numbers when i need at least 6dec and 3int precision. – Rookie Oct 07 '12 at 12:55
  • looks like everything works good now. i multiply my floats with 10 million, to ensure 6 digit precision (+1 extra digit to reduce rounding errors when converting back to floats again, i think its enough?). im not sure how large number i can use to multiply the floats and keep calculations with int64 correct... i tried very large numbers and it seems to work anyways, but if i use those other features of this library, i think it will break eventually. i looked at the lib sources, and it looks like its using int128 for calculations, so, i think its bullet-proof? – Rookie Oct 07 '12 at 16:28
  • Looks like i chose the wrong number o_O, for some reason with 10 million multiplication, it sometimes doesnt draw some triangles... (a LOT of them: 1/4) really weird. im just praying it works now as i expect :/ (with 1 million multiplication). i also tried with 16777216 but same effect came... 1000000000 seems to work too. does this make any sense to you? – Rookie Oct 07 '12 at 16:58