当我使用 Clipper(C#) 偏移轮廓时出现错误

There is an error when I am using Clipper(C#) to offset contours

当我使用 Clipper(C#) 偏移轮廓时出现错误, 下面是路径和代码:

List<List<IntPoint>> contours = new List<List<IntPoint>>() {
    new List<IntPoint>()
    {
        new IntPoint(89081288,31121153),
        new IntPoint(79573289,41300154),
        new IntPoint(89989888,51429549)
    },
    new List<IntPoint>()
    {
        new IntPoint(103433436,22509154),
        new IntPoint(103687434,32572554),
        new IntPoint(93177234,22454711)
    }
};
List<List<IntPoint>> result = new List<List<IntPoint>>();

ClipperOffset co = new ClipperOffset();
co.AddPaths(contours, JoinType.jtMiter, EndType.etClosedPolygon);
co.Execute(ref result, 1 * 1000000);

图片是

Offset Error

非常感谢

解决方法: 在 AddPaths 之前,确保轮廓是正确的,比如方向,没有自交叉......为此,使用 Clipper.SimplifyPolygons.

co.AddPaths(Clipper.SimplifyPolygons(contours), JoinType.jtMiter, EndType.etClosedPolygon);