A Polygon Clipping, Offsetting and Triangulation library (in C++, C# & Delphi)
The Clipper2 library performs intersection, union, difference and XOR boolean operations on both simple and complex polygons. It also performs polygon offsetting, and Constrained Delaunay Triangulation. This is a major update of my original Clipper library that was written over 10 years ago. That library I'm now calling Clipper1, and while it still works very well, Clipper2 is just better.
To use the library, it must be created as a submodule in git within the path of a project:
git submodule add https://github.com/SmartBuildingDesign/Clipper2.git lib/clipper2This will create the clipper2 folder inside lib. Then, within CMakeLists.txt:
import_library(lib/clipper2/CPP)
target_link_libraries(${PROJECT_NAME} Clipper2)Clipper2 can be compiled using any one of three supported programming languages: C++, or C#, or Delphi Pascal. The library can also be accessed from other languages by dynamically linking to exported functions in the C++ compiled Clipper2 library. (Since the C++ compiled code is measurably faster, even C# and Delphi developers may prefer this approach in applications where the library's performance is critical.)
| Lang. | Requirements |
|---|---|
| C++: | Requires C++17, or |
| C#: | The library uses Standard Library 2.0 but the sample code uses .NET6, or |
| Delphi: | Compiles with any version of Delphi from version 7 to current. |
Clipping
Inflating (aka Offsetting)
Constrained Delaunay Triangulation