Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union results are unexpected. #606

Closed
BigZebra101010 opened this issue Aug 2, 2023 · 2 comments
Closed

Union results are unexpected. #606

BigZebra101010 opened this issue Aug 2, 2023 · 2 comments

Comments

@BigZebra101010
Copy link

Here is the sample code:

void TestMerge()
{
    Paths64 subject;
    Clipper2Lib::Paths64 solution;
    SvgWriter svg;
    Clipper64 c;

    c.PreserveCollinear = false;

    subject.push_back(MakePath({ 6555320,12600780 , 6553540,12600780 , 6553540,12599680 , 6553920,12599680 , 6553920,12600060 , 6552580,12600060 , 6552580,12599680 , 6552960,12599680 , 6552960,12603400 , 6551560,12603400 , 6551560,12602560 , 6551940,12602560 , 6551940,12602940 , 6550760,12602940 , 6550760,12600900 , 6551940,12600900 , 6551940,12601280 , 6551560,12601280 , 6551560,12598660 , 6555320,12598660 }));
    subject.push_back(MakePath({ 6588180,12600380 , 6587560,12600380 , 6587560,12600000 , 6587940,12600000 , 6587940,12603400 , 6586500,12603400 , 6586500,12598660 , 6588180,12598660 }));
    subject.push_back(MakePath({ 6592440,12599440 , 6592060,12599440 , 6592060,12599060 , 6593800,12599060 , 6593800,12600980 , 6593420,12600980 , 6593420,12600600 , 6594120,12600600 , 6594120,12602940 , 6593420,12602940 , 6593420,12602560 , 6593800,12602560 , 6593800,12603400 , 6592400,12603400 , 6592400,12600380 , 6592780,12600380 , 6592780,12600760 , 6591680,12600760 , 6591680,12600080 , 6592060,12600080 , 6592060,12600460 , 6589620,12600460 , 6589620,12598780 , 6592440,12598780 }));
    subject.push_back(MakePath({ 6597560,12600820 , 6596940,12600820 , 6596940,12600440 , 6597320,12600440 , 6597320,12603400 , 6595800,12603400 , 6595800,12598660 , 6597560,12598660 }));
    subject.push_back(MakePath({ 6591880,12601020 , 6591500,12601020 , 6591500,12600640 , 6592520,12600640 , 6592520,12603180 , 6590700,12603180 , 6590700,12601840 , 6591080,12601840 , 6591080,12602220 , 6589640,12602220 , 6589640,12600340 , 6591880,12600340 }));
    subject.push_back(MakePath({ 6582160,12597760 , 6581780,12597760 , 6581780,12597380 , 6602060,12597380 , 6602060,12598780 , 6581780,12598780 , 6581780,12598400 , 6582160,12598400 , 6582160,12598860 , 6545640,12598860 , 6545640,12597360 , 6582160,12597360 }));

    c.AddSubject(subject);

    c.Execute(ClipType::Union, FillRule::Positive, solution);

    SvgAddSolution(svg, solution, FillRule::NonZero, false);
    std::string filename = "my_poly.svg";
    SvgSaveToFile(svg, filename, 3000, 1000, 10);
    System(filename);
}

the two Collinear Edges are not merged.
image

@AngusJohnson
Copy link
Owner

Amend the following:

if (horz.outrec && horz.outrec != currHorzOutrec)
{
currHorzOutrec = horz.outrec;
//nb: The outrec containining the op returned by IntersectEdges
//above may no longer be associated with horzEdge.
AddTrialHorzJoin(GetLastOp(horz));
}

to:

        if (horz.outrec)
        {
          //nb: The outrec containining the op returned by IntersectEdges
          //above may no longer be associated with horzEdge.
          AddTrialHorzJoin(GetLastOp(horz));
        }

AngusJohnson added a commit that referenced this issue Aug 6, 2023
Fixed a minor bug in merging solution polygons (#606)
@AngusJohnson
Copy link
Owner

Hopefully fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants