Menu

#194 Intersection of polygon with itself

*
open
nobody
None
1
2019-10-23
2019-10-23
Anonymous
No

Hi,

when computing the intersection of a certain polygon with itself, we get an empty list as a result (i.e., no intersection).
Coordinate list of this polygon: (1, 0), (0, 2), (0, 3)
Code to reproduce see below.
Question: did we do something wrong (e.g. wrong parameters to ClipperLib methods), or is this a bug?

Thanks in advance
Harald

#include "clipper.hpp"
#include <iostream>


int main()
{
    ClipperLib::Path poly = {{1, 0}, {0, 2}, {0, 3}}; // WRONG
    //ClipperLib::Path poly = {{1, 0}, {0, 1}, {0, 3}}; // OK

    // add the paths to Clipper
    ClipperLib::Clipper clipper;
    clipper.AddPath(poly, ClipperLib::ptClip, true);
    clipper.AddPath(poly, ClipperLib::ptSubject, true);

    // compute intersections
    ClipperLib::Paths intersections;
    bool res=clipper.Execute(ClipperLib::ctIntersection, intersections, ClipperLib::pftNonZero, ClipperLib::pftNonZero);
    std::cout << "#intersections=" << intersections.size() << "\n";

    return 0;
}

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB