CGAL seems to do just about everything I need and a little more for my upcoming project. It can create polygons out of arc line segments and run boolean operations on them. It has spatial sorting packages already that would save me a lot of time regarding a few things and the whole library seems quite standardized and well planned.
There's just the issue with the license being QPL (GPL for the upcoming version 4.0) for most of the packages (except the very basic ones). I've got a meager budget and can likely not gather funds to buy the commercial licenses for those specific packages in CGAL that require it.
My specific needs of such a library would be:
- Exact precision 2D euclidean space
- Complex polygons
- Polygons able to have curved line (arc) segments
- Boolean operations on those polygons
- Polygon offsetting
- Polygon partitioning or effective triangulation
- Inscribed area and polygon fitting algorithms
- Possibly some spatial sorting structures with circular range searches
All in all, I'm looking for a well rounded 2D geometry C++ library with exact precision. Preferably with MIT, LGPL at a stretch, or a low cost one-time royalty-free license below $500.
Boost got some basic structures down, but from what I can tell they lack a lot of the higher level functionality. Any libraries that has expanded on this? I would consider doing it myself, but I lack the expertise to do it well and it'd prolong my project by quite a bit.
Just to be clear, I'm not looking for a 2D graphics library, just pure geometry structures.
Take a look at Geometric Tools for Computer Graphics.
- Refined over a decade
- Unbelievably good documentation, both in hard bound and extensively in PDF form
- Boost license
It meets all your requirements:
- Exact precision 2D euclidean space: Yes
- Complex polygons : Yes
- Polygons able to have curved line (arc) segments : Nonsensical. By definition, polygons are composed of line segments. If you are looking for splines and NURBS, the library has them.
- Boolean operations on those polygons : Yes
- Polygon offsetting : Unclear what you mean. The library certainly supports translation.
- Polygon partitioning or effective triangulation: Yes, Delaunay triangulation and Voronoi regions
- Inscribed area and polygon fitting algorithms :Yes
- Possibly some spatial sorting structures with circular range searches : Yes, spatial sorting and a whole bushel of intersection functions.
All this comes from the book Geomtric Tools for Computer Graphics by Schneider and Eberly. The book is outstanding, with clear presentation of how the algorithms work and what their limitations are. The authors have made the code available online under the Boost license and include most (all?) of the book online as a PDF to accompany each code module. They maintain an very useful website that is indexed in various ways.
I have no connection to the authors nor any monetary interest. I used their book in my thesis and it was extremely pleased with it as an easy to use reference and a powerful library.
Have you looked at Boost.Geometry library? It's nowhere near CGAL in terms of functionality, but it might help you.
You could try GeoLib www.geolib.co.uk. Not as much functionality but does offer boolean operations and is very easy to use.
来源:https://stackoverflow.com/questions/9349220/2d-geometry-library-lgpl-alternative-to-cgal