AngusJohnson / Clipper2

Polygon Clipping and Offsetting - C++, C# and Delphi
Boost Software License 1.0
1.52k stars 273 forks source link

Union of forms that share an edge #856

Closed JoseNavio closed 4 months ago

JoseNavio commented 4 months ago

Hi, I was doing some tests with the clipper2 Java port and I have the following doubt, what is the best approach to join polygons that share the same edge?, I mean adjacent forms.

I get some different behaviours:


- Using Doubles
    PathsD oneDouble = new PathsD();
    PathsD twoDouble = new PathsD();
    oneDouble.add(Clipper.MakePath(new double[]{
            0d, 1d, 1d, 1d, 1d, 0d, 0d, 0d}));
    twoDouble.add(Clipper.MakePath(new double[]{
            1d, 0d, 2d, 0d, 2d, 1d, 1d, 1d}));
    PathsD unionDouble = Clipper.Union(oneDouble, twoDouble, FillRule.NonZero, 3);
    System.out.println("Union with doubles: " + unionDouble);

    //Result:
    A = 1,000000,0,000000)  (2,000000,0,000000)  (2,000000,1,000000) (1,000000,1,000000)  (0,000000,1,000000)  (0,000000,0,000000)  

    //That would do, but my values are long too...

Thanks.