1

次のコードがあります。

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を統合する必要があります。これにより、小さな正方形を穴として含む大きな正方形が得られます。しかし、代わりに1つのポリゴンを取得します。これには、内側と外側のポリゴンを1つのポリゴンに接続するためのカットがあります。

期待どおりに 2 つのポリゴンを統合する方法はありますか?

グラフィック: ここに画像の説明を入力

4

1 に答える 1

1

この問題に対処し、他の多くの改善を加えた新しいバージョンの Clipper がリリースされようとしています。

Clipper バージョン 6 のプレビューは、こちらの SF トランクからダウンロードできます。

参照: これに関する SF の議論はこちら

于 2013-09-10T11:53:43.770 に答える