AngusJohnson/Clipper2

GitHub: AngusJohnson/Clipper2

这是一个用于执行多边形布尔运算、偏移及约束三角剖分的高性能计算几何库,提供 C++、C# 和 Delphi 接口。

Stars: 2278 | Forks: 415

# Clipper2 ### 一个 Polygon ClippingOffsettingTriangulation 库(支持 C++、C# 和 Delphi)
[![GitHub Actions C++ 状态](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/009a32ce18065001.svg)](https://github.com/AngusJohnson/Clipper2/actions/workflows/actions_cpp.yml) [![C#](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/ea42e99d58065002.svg)](https://github.com/AngusJohnson/Clipper2/actions/workflows/actions_csharp.yml) [![许可证](https://img.shields.io/badge/License-Boost_1.0-lightblue.svg)](https://www.boost.org/LICENSE_1_0.txt) [![Nuget](https://img.shields.io/nuget/v/Clipper2?color=green)](https://www.nuget.org/packages/Clipper2) [![文档](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/267f87ac99065004.svg)](https://www.angusj.com/clipper2/Docs/Overview.htm) Clipper2 库对简单和复杂多边形执行 **交集**、**并集**、**差集** 和 **异或 (XOR)** 布尔运算。它还执行 **多边形偏移** 和 **约束 Delaunay 三角剖分**。这是对我在大约 15 年前编写的原始 Clipper 库的一次重大更新。我现在将那个库称为 Clipper1,虽然它仍然运行良好,但 Clipper2 只是 [更好](https://www.angusj.com/clipper2/Docs/Changes.htm)。 ### 编译器 Clipper2 可以使用三种受支持的编程语言中的任意一种进行编译:C++、C# 或 Delphi Pascal。也可以通过动态链接到 [C++ 编译的 Clipper2 库](https://github.com/AngusJohnson/Clipper2/tree/main/DLL) 中的导出函数,从其他语言访问该库。(C++ 编译的代码 [明显](https://www.angusj.com/clipper2/Docs/Changes.htm) 更快,因此在对性能要求较高的情况下,即使是 C# 和 Delphi 开发人员在应用程序开发中也可能更喜欢这种方法。) | 语言 | 要求 | | --- | --- | | [**C++:**](https://github.com/AngusJohnson/Clipper2/tree/main/CPP) | 需要 C++17,**或者** | | [**C#:**](https://github.com/AngusJohnson/Clipper2/tree/main/CSharp) | 该库使用 Standard Library 2.0,但示例代码使用 .NET6,**或者**| | [**Delphi:**](https://github.com/AngusJohnson/Clipper2/tree/main/Delphi) | 可使用从版本 7 到当前的任何版本的 Delphi 进行编译。| ### 文档 丰富的 HTML 文档

### 示例 **Clipping**
C++ https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CPP/Examples/SimpleClipping/SimpleClipping.cpp#L29-L34
C# https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CSharp/Clipper2Lib.Examples/ConsoleDemo/Main.cs#L112-L116
Delphi https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/Delphi/Examples/Example1/Example1.dpr#L21-L26
![clipperB](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/30bb71ee39065005.svg) **Inflating (亦称 Offsetting)**
C++ https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CPP/Examples/Inflate/Inflate.cpp#L36-L47
C# https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CSharp/Clipper2Lib.Examples/InflateDemo/Main.cs#L89-L100
Delphi https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/Delphi/Examples/Example2/Example2.dpr#L20-L31
![rabbit](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/354df88895065008.svg) ![rabbit_offset](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/21edb6b763065010.svg) **Constrained Delaunay Triangulation**
C++ https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CPP/Examples/Triangulation/Triangulation.cpp#L135-L138
C# https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/CSharp/Clipper2Lib.Examples/Triangulation/Main.cs#L110-L115
Delphi https://github.com/AngusJohnson/Clipper2/blob/fa7add77364eb3877dd1b8caf9b3cbd5486347f6/Delphi/Examples/Triangulation/ClipperTri.dpr#L28-L33
![coral3](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/d2b89a535d065012.svg) ![coral3t](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/32c65ad10b065014.svg)
C++ https://github.com/AngusJohnson/Clipper2/blob/2970649befb89af85e2132e5242a7d6926cbfa11/CPP/Examples/UsingZ/UsingZ.cpp#L173-L184
![coral3_t2](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/eaac6e393e065017.svg)
### 移植到其他语言 | 语言 | 链接 | | ------ | ------ | | **golang** | https://github.com/epit3d/goclipper2 | | **Haxe** | https://github.com/jeremyfa/Clipper2/tree/main/Haxe | | **Java** | https://github.com/micycle1/Clipper2-java/ | | **Kotlin** | https://github.com/Monkey-Maestro/clipper2-kotlin | | **Lua** | https://github.com/Ark223/Clipper2-Lua | | **Rust** | https://github.com/larsbrubaker/clipper2-rust | | **Swift** | https://github.com/zyunlongz/clipper2-swift | | **TypeScript** | https://github.com/countertype/clipper2-ts | | **WASM** | https://github.com/ErikSom/Clipper2-WASM/ |
标签:Boost 许可, C++, CAD, Clipper, Constrained Delaunay Triangulation, Delphi, GIS, NuGet, Polygon Offsetting, 三角剖分, 偏移计算, 几何处理, 动态链接库, 向量图形, 图形算法, 多人体追踪, 多边形裁剪, 布尔运算, 开源库, 搜索引擎爬虫, 数据擦除, 计算几何, 跨语言, 路径规划