Skip to content

my test demo #37

Description

@xuechengang
  NFP[] nfps = new NFP[13];
  nfps[0] = new NFP();
  nfps[0].AddPoint(new SvgPoint(1, 1));
  nfps[0].AddPoint(new SvgPoint(12, 12));
  nfps[0].AddPoint(new SvgPoint(1, 10));
  nfps[1] = new NFP();
  nfps[1].AddPoint(new SvgPoint(10, 10));
  nfps[1].AddPoint(new SvgPoint(22, 22));
  nfps[1].AddPoint(new SvgPoint(10, 20));
  nfps[2] = new NFP();
  nfps[2].AddPoint(new SvgPoint(20, 20));
  nfps[2].AddPoint(new SvgPoint(32, 32));
  nfps[2].AddPoint(new SvgPoint(20, 30));
  for (int i = 3; i < 13; i++)
  {
      nfps[i] = new NFP();
      nfps[i].AddPoint(new SvgPoint(10, 10));
      nfps[i].AddPoint(new SvgPoint(22, 22));
      nfps[i].AddPoint(new SvgPoint(10, 20));
  }

  StartParallel(100, 100, 20, 2, nfps);

//
// call run
//

        public List<NFP> StartParallel(double binW, double binH,
            int loopCount, double spacing, NFP[] nestPaths)
{
double newBinW = binW;
double newBinH = binH;
SvgNest.Config.spacing = spacing;
SvgNest.Config.placementType = PlacementTypeEnum.gravity;
//SvgNest.Config.rotations = isHighSpeed ? 2 : 5;
SvgNest.Config.rotations = 5;
SvgNest.Config.sheetSpacing = spacing * 0.5d;
//SvgNest.Config.useHoles = true;
DeepNestLib.Background.UseParallel = true;
NestingContext nc = new NestingContext();

nc.AddSheet((int)binW, (int)binH, 0);
nc.Polygons.AddRange(nestPaths);
nc.StartNest();
double bestFitness = double.MaxValue;
List<SheetPlacementItem>[] best_placements = null;
for (int i = 0; i < loopCount; i++)
{
    nc.NestIterate();
    if (nc.Current.fitness < bestFitness)
    {
        bestFitness = nc.Current.fitness.Value;
        best_placements = nc.Current.placements;
    }
}
SvgParser.Export("output.svg", nc.Polygons, nc.Sheets);

return nc.Polygons;
}

//output.svg

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions