Menu

#206 SimplifyPolygons() shrinks triangle

*
open
nobody
None
1
2021-07-20
2021-07-20
No

Hi,

if you simplify the following (disjunct) triangles, the Y coordinate of path[0] is changed from 20164 tp 20165 in the output, see attached images.

    Path path1({ {42901,20164}, {45175,41481}, {42901,44382} });
    Path path2({ {11771,20165}, {10056,19990}, {12390,17962} });
    Paths simplifiedPaths;
    SimplifyPolygons({ path1, path2 }, simplifiedPaths, ClipperLib::pftPositive);

    cout << simplifiedPaths << endl;

Output:

(45175,41481), (42901,44382), (42901,20165)
(11771,20165), (10056,19990), (12390,17962)

The bug is located in the scanbeam processing. If the scanbeam intersects two directly connected edges, an the the resulting intersection points have an X distance <0.5, an additional vertex is inserted which should not happen.

--- a/clipper.cpp
+++ b/clipper.cpp
@@ -3054,7 +3054,8 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
       {  
         TEdge* ePrev = e->PrevInAEL;
         if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) &&

-          (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0))
+          (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0) &&
+          (ePrev->Top != e->Top) && (ePrev->Bot != e->Bot))
         {
           IntPoint pt = e->Curr;
 #ifdef use_xyz

I'm not sure if this condition ("edges may not be connected directly") fixes this problem completely.

2 Attachments

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB