You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB
C#

using DeepNestLib;
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Contexts;
namespace DeepNestConsole
{
public class SampleProgram
{
public NestingContext Context = new NestingContext();
public bool IsFinished()
{
//insert you code here
return Context.Iterations >= 3;
}
public void Run()
{
Background.UseParallel = true;
SvgNestConfig config = new SvgNestConfig();
Context.Config = config;
config.placementType = PlacementTypeEnum.gravity;
Console.WriteLine("Settings updated..");
Console.WriteLine("Start nesting..");
Console.WriteLine("Parts: " + Context.Polygons.Count());
Console.WriteLine("Sheets: " + Context.Sheets.Count());
Context.StartNest();
do
{
var sw = Stopwatch.StartNew();
Context.NestIterate();
sw.Stop();
Console.WriteLine("Iteration: " + Context.Iterations + "; fitness: " + Context.Current.fitness + "; nesting time: " + sw.ElapsedMilliseconds + "ms");
} while (!IsFinished());
#region convert results
string path = "output.dxf";
Context.Export(path);
Console.WriteLine($"Results exported in: {path}");
#endregion
}
}
}