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

Different result between old version and Clipper2 #494

Closed
F-Fede opened this issue Apr 17, 2023 · 2 comments
Closed

Different result between old version and Clipper2 #494

F-Fede opened this issue Apr 17, 2023 · 2 comments

Comments

@F-Fede
Copy link

F-Fede commented Apr 17, 2023

Hi,

I was testing Clipper2 in order to check if I can replace the old implementation with the new one, but I found a use case when I get different results from the two software versions.

In particular, it seems that some wrong small pieces are added (or misplaced) to the result; also the result seems not to be closed.
I attach a file with the code I used to replicate the issue: am I missing something?

ClipperComparison.zip

image

@AngusJohnson
Copy link
Owner

using Clipper2Lib;

namespace ClipperDemo1
{
  public class Application
  {

    public static void Main()
    {
      Paths64 subj = new Paths64(), solution = new Paths64();

      subj.Add(Clipper.MakePath(new int[] {
         154056, -98304, 147456, -93164, 145778, -91750,
         142293, -88474, 140902, -86902, 139742, -85197,
         138254, -81920, 135914, -75366, 134826, -72090,
         128940, -52429, 125640, -39322, 125319, -36045,
         125661, -32768, 128953, -19661, 134788, 0,
         135859, 3277, 138167, 9830, 139596, 13107,
         140902, 15064, 142045, 16384, 145392, 19661,
         147456, 21476, 153196, 26214, 154010, 26841,
         160563, 31381, 162758, 32768, 168456, 36045,
         170394, 37065, 176947, 40169, 180224, 41458,
         183501, 42722, 186778, 43914, 190054, 44890,
         193331, 45932, 196608, 46781, 199885, 47569,
         203162, 48281, 209715, 49428, 212992, 49826,
         219546, 50533, 226099, 50810, 229376, 50856,
         235930, 50689, 242483, 50124, 245760, 49744,
         252314, 48661, 255590, 47961, 262144, 46382,
         263785, 45875, 268698, 44307, 271974, 43144,
         275251, 41860, 278528, 40548, 285082, 37518,
         288047, 36045, 294912, 32399, 301466, 28584,
         308019, 24463, 310347, 22938, 311296, 22217,
         313804, 19661, 314573, 18597, 315813, 16384,
         322243, 3277, 328405, -9830, 335879, -26214,
         337287, -29491, 337510, -30119, 338152, -32768,
         338330, -36045, 337843, -39322, 337510, -40458,
         336648, -42598, 329168, -58982, 322961, -72090,
         321390, -75366, 316504, -85197, 314781, -88474,
         314573, -88796, 312060, -91750, 311296, -92415,
         308019, -94629, 301466, -98621, 294912, -102306,
         291635, -104006, 288358, -105669, 285082, -107260,
         278528, -110176, 271974, -112681, 268698, -113809,
         262144, -115810, 255590, -117338, 252690, -117965,
         245760, -119075, 242483, -119455, 235930, -120020,
         232653, -120143, 229376, -120216, 226099, -120186,
         219546, -119974, 212992, -119358, 209715, -119001,
         203002, -117965, 199885, -117351, 196608, -116648,
         193331, -115867, 190054, -114949, 186778, -114096,
         178843, -111411, 176947, -110670, 173670, -109293,
         170394, -107853, 163840, -104449, 160563, -102518,
         154056, -98304}));


      subj.Add(Clipper.MakePath(new int[] {
         549215, -75366, 547758, -72090, 547226, -70775,
         545367, -65536, 544436, -62259, 543717, -58982,
         542179, -52429, 541622, -49152, 540409, -36045,
         540414, -32768, 541547, -19661, 542111, -16384,
         542880, -13107, 544324, -6554, 545262, -3277,
         547226, 2252, 547645, 3277, 549112, 6554,
         551103, 9830, 553319, 13107, 556339, 16384,
         557056, 17037, 560333, 19224, 561269, 19661,
         563610, 20461, 566886, 21246, 570163, 21546,
         573440, 21184, 576717, 20111, 577642, 19661,
         579994, 18179, 582513, 16384, 583270, 15747,
         585646, 13107, 587855, 9830, 589721, 6554,
         591381, 3277, 593938, -3277, 595103, -6554,
         596378, -11638, 598122, -19661, 599279, -32768,
         599272, -36045, 598027, -49152, 596378, -56574,
         595775, -58982, 594941, -62259, 593771, -65536,
         591203, -72090, 589552, -75366, 587704, -78643,
         585531, -81920, 583270, -84455, 582396, -85197,
         579994, -86958, 577620, -88474, 576717, -88915,
         573440, -89997, 570163, -90368, 566886, -90076,
         563610, -89287, 561254, -88474, 560333, -88040,
         557056, -85840, 556353, -85197, 553779, -82383,
         553380, -81920, 551183, -78643, 549215, -75366
      }));

      solution = Clipper.InflatePaths(subj, 720896, JoinType.Round, EndType.Polygon);
      //Console.WriteLine(solution.ToString());

      SvgWriter svg = new();
      SvgUtils.AddSubject(svg, subj);
      SvgUtils.AddSolution(svg, solution, false);
      SvgUtils.SaveToFile(svg, "..\\..\\..\\tmp.svg", FillRule.EvenOdd, 420, 320, 10);
      ClipperFileIO.OpenFileWithDefaultApp("..\\..\\..\\tmp.svg");
    }

tmp

@F-Fede
Copy link
Author

F-Fede commented Apr 18, 2023

Hi Angus,

I tried the code again, then I deleted the project and download it again: now I get the expected result, I don't know what went wrong during previous downloads...

Thank you very much.

@F-Fede F-Fede closed this as completed Apr 18, 2023
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