Clipper1 logo

Clipper1

Community
znlgis
clipper1

Use when maintaining legacy code on the Clipper 1.x API — IntPoint integer paths with a scale factor, Clipper.AddPath/Execute for ctUnion/ctIntersection/ctDifference/ctXor, ClipperOffset for jtRound/jtMiter buffering, PolyTree hole hierarchy, and the pyclipper (1.4.0) / js-clipper bindings. Clipper1 V6 (6.4.2) is frozen; new projects should use Clipper2. Also for lost hole structure in flat List<List<IntPoint>> results, self-intersections after offsetting, and scale overflow.

Overview

Publisherznlgis
Repositoryopengis-skills
Skill nameclipper1
Stars
76
Forks
12
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by znlgis on GitHub. Read the source before you install it.

Installation

Install the Clipper1 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/znlgis/opengis-skills/tree/main/cad/clipper1
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/znlgis/opengis-skills.git /tmp/opengis-skills
mkdir -p .claude/skills
cp -r /tmp/opengis-skills/cad/clipper1 .claude/skills/clipper1
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Clipper1 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Clipper1 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Clipper1 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

项目地址(V6 官方主页): https://sourceforge.net/p/polyclipping/

官方文档: https://sourceforge.net/p/polyclipping/wiki/Home/

版本: V6 末版 6.4.2(pyclipper 1.4.0 内嵌的即为该版)。原 GitHub 仓库 github.com/AngusJohnson/Clipper 已重定向到 Clipper2,V6 不再新增功能

包管理器: NuGet Clipper 6.4.0(Angus Johnson 发布)| PyPI pyclipper 1.4.0(封装 Clipper 6.4.2)| npm js-clipper 1.0.1(截至 2026-10)

许可证: Boost Software License 1.0

概述

Clipper1 主要特征:

  • 整数算法(IntPoint),通过 scale 系数模拟浮点
  • 核心 API:Clipper、ClipperOffset、ClipperBase
  • 支持:布尔运算 + 偏移 + 多边形简化
  • 多语言移植:C++(含 Header-only)、C#、Delphi/Pascal、JS、Python

新项目优先使用 Clipper2,其性能与 API 均优于 Clipper1。本 SKILL 主要用于维护遗留代码。


安装

bash
# C#(NuGet 包作者为 Angus Johnson,最新 6.4.0,略旧于 C++ V6 末版 6.4.2)
dotnet add package Clipper

# JavaScript
npm install js-clipper          # 1.0.1,或 clipper-lib

# Python
pip install pyclipper           # 1.4.0,内嵌 Clipper 6.4.2

验证:

bash
python -c "import pyclipper; print(pyclipper.__version__)"

C++ 通常直接拷贝 clipper.hpp/.cpp 到工程。


核心 API

核心数据结构

csharp
using ClipperLib;
using IntPoint = ClipperLib.IntPoint;

const long Scale = 1000000;     // 浮点 → 整数缩放因子

List<IntPoint> path = new() {
    new IntPoint(0, 0),
    new IntPoint(100 * Scale, 0),
    new IntPoint(100 * Scale, 100 * Scale),
    new IntPoint(0, 100 * Scale),
};
List<List<IntPoint>> paths = new() { path };

布尔运算

csharp
var clipper = new Clipper();
clipper.AddPath(subject, PolyType.ptSubject, true);   // true = 闭合
clipper.AddPath(clip,    PolyType.ptClip,    true);

var solution = new List<List<IntPoint>>();
clipper.Execute(ClipType.ctUnion, solution,
    PolyFillType.pftNonZero, PolyFillType.pftNonZero);

ClipType:ctIntersection、ctUnion、ctDifference、ctXor PolyFillType:pftEvenOdd、pftNonZero、pftPositive、pftNegative


多边形偏移(ClipperOffset)

csharp
var co = new ClipperOffset();
co.AddPaths(paths, JoinType.jtRound, EndType.etClosedPolygon);

var solution = new List<List<IntPoint>>();
co.Execute(ref solution, 10 * Scale);     // 正:外扩;负:内缩

JoinType:jtSquare、jtMiter、jtRound EndType:etClosedPolygon、etClosedLine、etOpenButt、etOpenSquare、etOpenRound


PolyTree(保留环层级)

csharp
var tree = new PolyTree();
clipper.Execute(ClipType.ctUnion, tree,
    PolyFillType.pftNonZero, PolyFillType.pftNonZero);

foreach (var node in tree.Childs)        // 顶层是外环
    foreach (var hole in node.Childs)    // 子节点是孔
        Console.WriteLine(hole.Contour.Count);

实用方法

csharp
double area    = Clipper.Area(path);
bool   ccw     = Clipper.Orientation(path);
var    cleaned = Clipper.CleanPolygon(path, 1.415);    // 去重/共线
var    simp    = Clipper.SimplifyPolygon(path, PolyFillType.pftNonZero);
var    reverse = Clipper.ReversePath(path);

Python(pyclipper)

python
import pyclipper

scale = 1_000_000
subj  = [[(0,0),(100,0),(100,100),(0,100)]]
clip  = [[(50,50),(150,50),(150,150),(50,150)]]

pc = pyclipper.Pyclipper()
pc.AddPaths(pyclipper.scale_to_clipper(subj, scale),
            pyclipper.PT_SUBJECT, True)
pc.AddPaths(pyclipper.scale_to_clipper(clip, scale),
            pyclipper.PT_CLIP, True)
sol = pc.Execute(pyclipper.CT_UNION,
                 pyclipper.PFT_NONZERO,
                 pyclipper.PFT_NONZERO)
sol = pyclipper.scale_from_clipper(sol, scale)

# 偏移
pco = pyclipper.PyclipperOffset()
pco.AddPaths(pyclipper.scale_to_clipper(subj, scale),
             pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON)
sol = pco.Execute(10 * scale)

C++ 用法

cpp
#include "clipper.hpp"
using namespace ClipperLib;

Paths subj{{ {0,0},{1000,0},{1000,1000},{0,1000} }};
Paths clip{{ {500,500},{1500,500},{1500,1500},{500,1500} }};
Clipper c;
c.AddPaths(subj, ptSubject, true);
c.AddPaths(clip, ptClip, true);
Paths solution;
c.Execute(ctUnion, solution, pftNonZero, pftNonZero);

典型工作流

工作流一:CAD/GIS 中多边形布尔运算

  1. 确定浮点精度需求,选定 scale 系数(如 1,000,000 表示微米精度)
  2. 将输入几何(Polygon/MultiLine 等)转换为 List<IntPoint> 格式,乘以 scale 取整
  3. 创建 Clipper 实例,AddPath 添加 Subject 和 Clip
  4. 调用 Execute 执行布尔运算(Union/Intersect/Difference/Xor)
  5. 将结果坐标除以 scale 还原为浮点坐标
  6. 如需保留孔洞关系,使用 PolyTree 替代 List<List<IntPoint>>

工作流二:多边形轮廓偏移(生成安全区/缓冲区)

  1. 构建多边形路径(闭合路径用 etClosedPolygon,开放用 etOpenButt 等)
  2. 创建 ClipperOffset,通过 AddPaths 添加输入
  3. 调用 Execute,正值为外扩(膨胀),负值为内缩(侵蚀)
  4. 检查结果是否自交——偏移前可先用 SimplifyPolygon 清理输入
  5. 输出偏移后的多边形用于刀路生成、安全距离计算等

与 Clipper2 主要差异

维度Clipper1Clipper2
数值类型整数 + scale整数 / 浮点双模式
性能较慢显著更快
APIClipper 类顶层 Union/Intersect/...
简化SimplifyPolygonSimplifyPaths 更准确
维护已停止新功能活跃维护

迁移要点:

  • IntPoint → Point64
  • 移除 scale,使用 PathsD 或保留 Paths64
  • API 改为静态函数

常见问题

问题解决
浮点 → 整数舍入失真增大 scale
偏移产生自相交偏移前 SimplifyPolygon
闭合 path 多余首尾点Clipper 不需要重复首点
Mac/Linux 编译失败启用 use_int32/use_xyz 对应宏
布尔结果丢了孔洞层级Execute 的出参换成 PolyTree(顶层 Childs 为外环、其子节点为孔),不要用扁平的 List<List<IntPoint>>
外扩后尖角被削平或出现毛刺按形状选 JoinType:尖角用 jtMiter(配合 MiterLimit)、圆弧用 jtRound、平角用 jtSquare;内缩毛刺先 CleanPolygon
开放线偏移结果不是预期条带EndType 必须是 etOpenButt/etOpenSquare/etOpenRound,误用 etClosedPolygon 会把线首尾闭合
面积正负号看不懂Clipper.Area 的符号就是朝向:正为外环、负为孔;需要翻转用 ReversePath,判断用 Orientation

AI 使用建议

  • 推荐工作流模式:AI 助手应将几何数据统一转换为 Clipper 的整数坐标格式(选择恰当的 scale),然后按「创建 Clipper → 添加路径 → 执行运算 → 还原坐标」的流程处理。对于带孔多边形,优先使用 PolyTree 保留层级关系。
  • 关键注意事项:① scale 选择需权衡精度与整数溢出——常用 1e6(微米级);② Clipper1 的闭合路径不需要重复首点;③ PolyFillType 需 Subject 和 Clip 各指定一次,非零环绕(NonZero)是最常用的填充规则;④ Clipper1 为非线程安全,多线程需各自持有实例。
  • 常用代码模式:new Clipper() → AddPath(subject, ptSubject, true) → AddPath(clip, ptClip, true) → Execute(ctUnion, solution, pftNonZero, pftNonZero)。

相关技能


参考资源

Frequently asked questions

What does the Clipper1 AI skill do?

Use when maintaining legacy code on the Clipper 1.x API — IntPoint integer paths with a scale factor, Clipper.AddPath/Execute for ctUnion/ctIntersection/ctDifference/ctXor, ClipperOffset for jtRound/jtMiter buffering, PolyTree hole hierarchy, and the pyclipper (1.4.0) / js-clipper bindings. Clipper1 V6 (6.4.2) is frozen; new projects should use Clipper2. Also for lost hole structure in flat List<List<IntPoint>> results, self-intersections after offsetting, and scale overflow.

Why use Clipper1 on TypingMind?

Because you install it once and use it with any model. Clipper1 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Clipper1 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/znlgis/opengis-skills/tree/main/cad/clipper1. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Clipper1?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Clipper1?

As many as you like. As long as a model supports skills, you can use Clipper1 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Clipper1 AI skill free?

Yes. It is published on GitHub by znlgis under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇