views:

79

answers:

3

I've recently encountered a need for a library or set of libraries to handle operations on 2D polygons. I need to be able to perform boolean/clipping operations (difference and union) and triangulation.

So far the libraries I've found are poly2tri, CGAL, and GPC. Poly2tri looks good for triangulation but I'm still left with boolean operations, and I'm unsure about its maturity.

CGAL and GPC are only free if my own project is free. My particular project isn't commercial, so I'm hesitant to pay or request for any licenses. But I may want to use my code for a future commercial project, so I'm hesitant about CGAL's open source licenses and GPC's freeware-only restriction. There doesn't seem to be any polygon clipping libraries with nice BSD-style licenses.

Oh, and C/C++ is preferred.

+1  A: 

Check out Liszt a Scala DSL

oluies
A: 

Clipper is an open source freeware polygon clipping library (written in Delphi and C++) that does exactly what you're asking (except for triangulation) - http://sourceforge.net/projects/polyclipping/

In my testing, Clipper is both significantly faster and far less prone to error than GPC (see more detailed comparisons here - http://www.angusj.com/delphi/clipper.php#features).

Re: Anti-grain Geometry (AGG) graphics library - it doesn't do polygon clipping, but simply uses GPC (which isn't free for commercial applications). However, Clipper does have AGG units to make clipping in AGG just as easy as GPC.

Angus Johnson
Interesting. Would you have any projects as examples that use your library. No offence if it's new, but maturity and stability is something I'm looking for.
AJM
And no offense taken :). I only finished writing the core library a few weeks ago, so I doubt that anyone has yet had time to fully evaluate and integrate it into their own code.
Angus Johnson
A: 

http://www.antigrain.com/license/index.html is the closest I can find, you may have to spend a buck if it does go commercial, but you can use it for free for now, and get consent later on.

Gnostus
Thanks, though I'm only looking for a geometry library. Anti-Grain is a full rendering library.
AJM