5

以下に示すように、Clipper C++ ライブラリを使用して関数を実装しようとしていis_borderingます。

bool is_bordering(Path p1, Path p2) {

    Paths solutions;
    Clipper c;

    // execute intersection on paths
    c.AddPath(p1, ptSubject, true);
    c.AddPath(p2, ptClip, true);
    c.Execute(ctIntersection, solutions, pftNonZero);

    return (solutions.size() > 0); // the paths share edges
}


int main() {
    Path p1, p2;
    p1 << IntPoint(0,0) << IntPoint(1,0) << IntPoint(0,1) << IntPoint(0,0);
    p2 << IntPoint(1,0) << IntPoint(1,1) << IntPoint(0,1) << IntPoint(1,0);
    cout << is_bordering(p1, p2) << endl;
}

2 つの隣接するポリゴンをテストすると、結果に隣接するエッジが含まれると思いましたctIntersectionが、私にとってはこれは false を返します。上記から私が期待するのは、solutionsパスを表す緑色の次のようなものです。

この関数を (Clipper ライブラリを使用して) 機能させるにはどうすればよいですか?

4

1 に答える 1