#33 ClipperLib::ctDifference wrong result

closed
Angus Johnson
5
2013-11-19
2012-03-02
No

A situation where I get 1 polygon too much returned after a ctDifference operation.
As screenshot: http://www.michaelzeilfelder.de/Pics/Screenshots/SS-2012.03.02-20.30.59.png
Green is the ptSubject polygon.
The 2 red polygons are ptClip.
The 2 blue polygons are the results.
One of the blue polygons is now over a red one which shouldn't be if I understand ctDifference correctly (I hope so).

Code to reproduce:
ClipperLib::Clipper clipper;
ClipperLib::Polygon sub;
sub.push_back( ClipperLib::IntPoint(-102, 1061) );
sub.push_back( ClipperLib::IntPoint(-102, -1061) );
sub.push_back( ClipperLib::IntPoint(102, -1061) );
sub.push_back( ClipperLib::IntPoint(102, 1061) );
clipper.AddPolygon(sub, ClipperLib::ptSubject);

ClipperLib::Polygon clip1;
clip1.push_back( ClipperLib::IntPoint(-102, 313) );
clip1.push_back( ClipperLib::IntPoint(28, 313) );
clip1.push_back( ClipperLib::IntPoint(28, 555) );
clip1.push_back( ClipperLib::IntPoint(-102, 555) );
clipper.AddPolygon(clip1, ClipperLib::ptClip);

ClipperLib::Polygon clip2;
clip2.push_back( ClipperLib::IntPoint(-102, 313) );
clip2.push_back( ClipperLib::IntPoint(-102, -1061) );
clip2.push_back( ClipperLib::IntPoint(102, -1061) );
clip2.push_back( ClipperLib::IntPoint(102, 313) );
clipper.AddPolygon(clip2, ClipperLib::ptClip);

ClipperLib::Polygons out_polys;
clipper.Execute(ClipperLib::ctDifference, out_polys);

P.S. Thanks for the incredible quick reaction on my last bug report :-)

Discussion

  • Angus Johnson
    Angus Johnson
    2012-03-02

    Thanks. Another bug verified and the fix is about to be uploaded.
    Here's the patch in the meantime ...

    At line 374 in Orientation() Clipper.cpp ...

    outRec->bottomPt = opBottom;
    op = opBottom; //this assignment was missing!!

    P.S. Thanks for the incredible quick reaction on my last bug report :-)
    :))

     


Anonymous


Cancel   Add attachments