C# 创建接头时,裁剪器不会创建孔

C# 创建接头时,裁剪器不会创建孔,c#,polygons,C#,Polygons,我有以下代码: class Program { static void Main(string[] args) { Polygon a = new Polygon(); a.Add(new IntPoint(0,0)); a.Add(new IntPoint(2,0)); a.Add(new IntPoint(2,1)); a.Add(new IntPoint(1,1)); a.Add(ne

我有以下代码:

class Program {
    static void Main(string[] args) {

        Polygon a = new Polygon();
        a.Add(new IntPoint(0,0));
        a.Add(new IntPoint(2,0));
        a.Add(new IntPoint(2,1));
        a.Add(new IntPoint(1,1));
        a.Add(new IntPoint(1,2));
        a.Add(new IntPoint(2,2));
        a.Add(new IntPoint(2,3));
        a.Add(new IntPoint(0,3));

        Polygon b = new Polygon();
        b.Add(new IntPoint(2,0));
        b.Add(new IntPoint(3,0));
        b.Add(new IntPoint(3,3));
        b.Add(new IntPoint(2,3));

        PolyTree solution = new PolyTree();

        Clipper c = new Clipper();
        c.AddPolygon(a,PolyType.ptSubject);
        c.AddPolygon(b,PolyType.ptSubject);
        c.Execute(ClipType.ctUnion,solution);


        printPolygonTree(solution);

        Console.ReadLine();
    }

    static void printPolygonTree(PolyNode tree) {
        Console.WriteLine((tree.IsHole?"Hole":"Polygon")+":");
        foreach(IntPoint point in tree.Contour) {
            Console.WriteLine(point.X+"/"+point.Y);
        }
        foreach(PolyNode node in tree.Childs) {
            printPolygonTree(node);
        }
    }
}
它应该统一多边形ab,从而形成一个大正方形,其中包含一个小正方形作为孔。但是我得到了一个多边形,它有一个切口,将内部和外部多边形连接成一个多边形

有没有办法像预期的那样统一这两个多边形

图形:

即将发布的新版本Clipper解决了这一问题,并进行了许多其他改进

您可以从SF中继下载Clipper版本6的预览:


另请参见:SF对此的讨论

即将发布的新版本Clipper解决了这个问题,并进行了许多其他改进

您可以从SF中继下载Clipper版本6的预览:

另见:SF对此的讨论