简体   繁体   中英

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

There is an error when I am using Clipper(C#) to offset contours, Below is the paths and code:

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);

Picture is

Offset Error

Thanks a lot

Solution: Before AddPaths, ensure the contours are right, like orientation, no self-crossing... To do that, use Clipper.SimplifyPolygons.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM