├── imgs ├── 2.png ├── 3.png └── img1.png ├── .gitignore ├── Core ├── DeepNestPort.Core │ ├── Icons │ │ ├── disk.png │ │ ├── gear.png │ │ ├── plus.png │ │ ├── arrow.png │ │ ├── color.png │ │ ├── disks.png │ │ ├── report.png │ │ ├── magnifier.png │ │ ├── control-double.png │ │ ├── cross-button.png │ │ ├── magnifier--minus.png │ │ ├── magnifier--plus.png │ │ └── folder-horizontal-open.png │ ├── Resources │ │ └── plus.png │ ├── LoadDetailSplitMode.cs │ ├── DxfSheetLoadInfo.cs │ ├── DetailLoadInfo.cs │ ├── SheetLoadInfo.cs │ ├── StaticHelpers.cs │ ├── Program.cs │ ├── AddSheetDialog.cs │ ├── RibbonMenu.Designer.cs │ ├── IDrawingContext.cs │ ├── RibbonMenu.cs │ ├── QntDialog.cs │ ├── Settings.cs │ ├── EventWrapperPictureBox.cs │ ├── DeepNestPort.Core.csproj │ ├── Settings.resx │ ├── Properties │ │ └── Resources.Designer.cs │ ├── QntDialog.Designer.cs │ ├── RibbonMenuWpf.xaml.cs │ ├── RibbonMenuWpf.xaml │ └── AddSheetDialog.Designer.cs ├── DeepNestLib.Core │ ├── Sheet.cs │ ├── PolylineExportInfo.cs │ ├── SheetPlacement.cs │ ├── PolygonBounds.cs │ ├── RectangleSheet.cs │ ├── DraftElement.cs │ ├── PlacementItem.cs │ ├── LineElement.cs │ ├── NfpKey.cs │ ├── DeepNestLib.Core.csproj │ ├── SvgPoint.cs │ ├── SvgNestConfig.cs │ ├── LocalContour.cs │ ├── PolylineElement.cs │ ├── Extensions.cs │ ├── _Clipper.cs │ ├── RawDetail.cs │ ├── D3.cs │ └── Simplify.cs ├── DeepNestConsole.Core │ ├── Properties │ │ └── launchSettings.json │ ├── task2.xml │ ├── DeepNestConsole.Core.csproj │ ├── task1.xml │ ├── Program.cs │ └── SampleProgram.cs ├── Clipper.Core │ └── Clipper.Core.csproj ├── MinkowskiWrapper.Core │ ├── MinkowskiWrapper.Core.csproj │ └── MinkowskiWrapper.cs └── README.md ├── Minkowski ├── compile.bat └── minkowski.h ├── Framework ├── DeepNestPort │ ├── app.config │ ├── settings.xml │ ├── DetailLoadInfo.cs │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── svgs │ │ ├── 17.svg │ │ ├── 16.svg │ │ ├── 13.svg │ │ ├── 11.svg │ │ ├── 6.svg │ │ ├── 2.svg │ │ ├── 15.svg │ │ ├── 4.svg │ │ ├── 1.svg │ │ ├── 9.svg │ │ └── 5.svg │ ├── SheetLoadInfo.cs │ ├── ControlExtensions.cs │ ├── Program.cs │ ├── AddSheetDialog.cs │ ├── PictureBoxProgressBar.cs │ ├── MessageFilter.cs │ ├── QntDialog.cs │ ├── QntDialog.Designer.cs │ ├── DeepNestPort.csproj │ └── AddSheetDialog.Designer.cs ├── DeepNestLib │ ├── LineElement.cs │ ├── DeepNestLib.csproj │ ├── SvgPoint.cs │ ├── SvgNestConfig.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Extensions.cs │ ├── RawDetail.cs │ ├── _Clipper.cs │ ├── D3.cs │ └── Simplify.cs ├── DeepNestConsole │ ├── App.config │ ├── task.xml │ ├── SampleProgram.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Program.cs │ └── DeepNestConsole.csproj ├── MinkowskiWrapper │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ └── Resources.resx │ ├── MinkowskiWrapper.cs │ └── MinkowskiWrapper.csproj ├── clipper_library │ ├── Properties │ │ └── AssemblyInfo.cs │ └── clipper_library.csproj └── README.md ├── Directory.Packages.props ├── LICENSE ├── README.md ├── DeepNestPort.sln └── DeepNestPort.Core.sln /imgs/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/imgs/2.png -------------------------------------------------------------------------------- /imgs/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/imgs/3.png -------------------------------------------------------------------------------- /imgs/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/imgs/img1.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.user 2 | packages/ 3 | bin/ 4 | obj/ 5 | .vs/ 6 | *.zip 7 | *.obj 8 | *.dll 9 | *.bat 10 | *.exp 11 | *.lib -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/disk.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/gear.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/plus.png -------------------------------------------------------------------------------- /Minkowski/compile.bat: -------------------------------------------------------------------------------- 1 | cl /Ox /Ob2 /Oi /Ot /Oy- /GL /GF /Gm- /MD /GS- /arch:AVX2 /fp:fast -I /LD minkowski.cc -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/arrow.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/color.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/disks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/disks.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/report.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/magnifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/magnifier.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Resources/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Resources/plus.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/control-double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/control-double.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/cross-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/cross-button.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/magnifier--minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/magnifier--minus.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/magnifier--plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/magnifier--plus.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Icons/folder-horizontal-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fel88/DeepNestPort/HEAD/Core/DeepNestPort.Core/Icons/folder-horizontal-open.png -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/LoadDetailSplitMode.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | public enum LoadDetailSplitMode 4 | { 5 | Ask, Always 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/DxfSheetLoadInfo.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | public class DxfSheetLoadInfo : SheetLoadInfo 4 | { 5 | public string Path; 6 | } 7 | } -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/Sheet.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class Sheet : NFP 4 | { 5 | public double Width; 6 | public double Height; 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "DeepNestConsole.Core": { 4 | "commandName": "Project", 5 | "commandLineArgs": "xml ../../../task1.xml" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Framework/DeepNestLib/LineElement.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DeepNestLib 4 | { 5 | public class LineElement 6 | { 7 | public PointF Start; 8 | public PointF End; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Framework/DeepNestConsole/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/PolylineExportInfo.cs: -------------------------------------------------------------------------------- 1 | using netDxf; 2 | 3 | namespace DeepNestLib 4 | { 5 | public class PolylineExportInfo 6 | { 7 | public Vector3[] Points; 8 | public bool IsClosed; 9 | } 10 | } -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/task2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Core/Clipper.Core/Clipper.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | 7 | -------------------------------------------------------------------------------- /Core/MinkowskiWrapper.Core/MinkowskiWrapper.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | 7 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/DetailLoadInfo.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort 2 | { 3 | public class DetailLoadInfo 4 | { 5 | public string Name { get; set; } 6 | public string Path { get; set; } 7 | public int Quantity { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/17.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/DetailLoadInfo.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | public class DetailLoadInfo 4 | { 5 | public string Name { get; set; } 6 | public string Path { get; set; } 7 | public int Quantity { get; set; } 8 | public bool SplitOnLoad { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/SheetLoadInfo.cs: -------------------------------------------------------------------------------- 1 | using DeepNestLib; 2 | 3 | namespace DeepNestPort 4 | { 5 | public class SheetLoadInfo 6 | { 7 | public NFP Nfp; 8 | public string Path; 9 | public string Info { get; set; } 10 | public float Width { get; set; } 11 | public float Height { get; set; } 12 | public int Quantity { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/16.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/SheetPlacement.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class SheetPlacement 4 | { 5 | public double? fitness; 6 | 7 | public float[] Rotation; 8 | public List[] placements; 9 | 10 | public NFP[] paths; 11 | public double area; 12 | public double mergedLength; 13 | internal int index; 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/DeepNestConsole.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/PolygonBounds.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class PolygonBounds 4 | { 5 | public double x; 6 | public double y; 7 | public double width; 8 | public double height; 9 | public PolygonBounds(double _x, double _y, double _w, double _h) 10 | { 11 | x = _x; 12 | y = _y; 13 | width = _w; 14 | height = _h; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/RectangleSheet.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class RectangleSheet : Sheet 4 | { 5 | public void Rebuild() 6 | { 7 | Points = new SvgPoint[] { }; 8 | AddPoint(new SvgPoint(x, y)); 9 | AddPoint(new SvgPoint(x + Width, y)); 10 | AddPoint(new SvgPoint(x + Width, y + Height)); 11 | AddPoint(new SvgPoint(x, y + Height)); 12 | } 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Core/README.md: -------------------------------------------------------------------------------- 1 | # DeepNestPort.Core 2 | 3 | Net6.0
4 | WinForm / WPF Ribbon panel 5 | 6 | :pencil2: **2D drawer:** Skia (https://github.com/mono/SkiaSharp)
7 | :warning:**Project status:** WIP :construction::construction_worker: 8 | 9 | ![image](https://user-images.githubusercontent.com/15663687/223742194-99dbba60-3bee-4e9d-9c70-39cbf60a949e.png) 10 | ![image](https://user-images.githubusercontent.com/15663687/223744108-0819e7c7-906d-464d-863f-7eb5c0b6593e.png) 11 | 12 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/DraftElement.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DeepNestLib 4 | { 5 | public abstract class DraftElement 6 | { 7 | public object Tag; 8 | public PointF Start; 9 | public PointF End; 10 | 11 | public abstract double Length { get; } 12 | 13 | public abstract void Reverse(); 14 | public abstract PointF[] GetPoints(); 15 | 16 | internal abstract void Mult(double mult); 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/PlacementItem.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class PlacementItem 4 | { 5 | public double? mergedLength; 6 | public object mergedSegments; 7 | public List> nfp; 8 | public int id; 9 | public NFP hull; 10 | public NFP hullsheet; 11 | 12 | public float rotation; 13 | public double x; 14 | public double y; 15 | public int source; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Minkowski/minkowski.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" { 5 | 6 | __declspec(dllexport) void setData(int cntA, double* pntsA, int holesCnt, int* holesSizes, double* holesPoints, int cntB, double* pntsB); 7 | __declspec(dllexport) void getSizes1(int* sizes); 8 | __declspec(dllexport) void getSizes2(int* sizes1, int* sizes2); 9 | __declspec(dllexport) void getResults(double* data, double* holesData); 10 | __declspec(dllexport) void calculateNFP(); 11 | } 12 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/SheetLoadInfo.cs: -------------------------------------------------------------------------------- 1 | using DeepNestLib; 2 | 3 | namespace DeepNestPort.Core 4 | { 5 | public class SheetLoadInfo 6 | { 7 | public NFP Nfp; 8 | 9 | public string Info { get; set; } 10 | float _width; 11 | public float Width 12 | { 13 | get => _width; set 14 | { 15 | _width = value; 16 | } 17 | } 18 | public float Height { get; set; } 19 | public int Quantity { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/StaticHelpers.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace DeepNestPort.Core 4 | { 5 | public static class StaticHelpers 6 | { 7 | public static double ToDouble(this string str) 8 | { 9 | return double.Parse(str.Replace(",", "."), CultureInfo.InvariantCulture); 10 | } 11 | 12 | public static float ToFloat(this string str) 13 | { 14 | return float.Parse(str.Replace(",", "."), CultureInfo.InvariantCulture); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/ControlExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Windows.Forms; 3 | 4 | namespace DeepNestPort 5 | { 6 | public static class ControlExtensions 7 | { 8 | public static void DoubleBuffered(this Control control, bool enable) 9 | { 10 | var doubleBufferPropertyInfo = control.GetType().GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic); 11 | doubleBufferPropertyInfo.SetValue(control, enable, null); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Program.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | internal static class Program 4 | { 5 | /// 6 | /// The main entry point for the application. 7 | /// 8 | [STAThread] 9 | static void Main() 10 | { 11 | // To customize application configuration such as set high DPI settings or default font, 12 | // see https://aka.ms/applicationconfiguration. 13 | ApplicationConfiguration.Initialize(); 14 | Application.Run(new Form1()); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace DeepNestPort 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/LineElement.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DeepNestLib 4 | { 5 | public class LineElement : DraftElement 6 | { 7 | public override PointF[] GetPoints() 8 | { 9 | return new[] { Start, End }; 10 | } 11 | public override double Length => Start.DistTo(End); 12 | public override void Reverse() 13 | { 14 | var temp = End; 15 | End = Start; 16 | Start = temp; 17 | } 18 | 19 | internal override void Mult(double mult) 20 | { 21 | Start = Start.Mult(mult); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/NfpKey.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class NfpKey : IStringify 4 | { 5 | 6 | public NFP A; 7 | public NFP B; 8 | public float ARotation { get; set; } 9 | public float BRotation { get; set; } 10 | public bool Inside { get; set; } 11 | 12 | public int AIndex { get; set; } 13 | public int BIndex { get; set; } 14 | public object Asource; 15 | public object Bsource; 16 | 17 | 18 | public string stringify() 19 | { 20 | return $"A:{AIndex} B:{BIndex} inside:{Inside} Arotation:{ARotation} Brotation:{BRotation}"; 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/AddSheetDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace DeepNestPort 5 | { 6 | public partial class AddSheetDialog : Form 7 | { 8 | public AddSheetDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | public int SheetWidth { get; set; } 14 | public int SheetHeight { get; set; } 15 | private void button1_Click(object sender, EventArgs e) 16 | { 17 | SheetWidth = (int)numericUpDown1.Value; 18 | SheetHeight = (int)numericUpDown2.Value; 19 | DialogResult = DialogResult.OK; 20 | Close(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/AddSheetDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace DeepNestPort 5 | { 6 | public partial class AddSheetDialog : Form 7 | { 8 | public AddSheetDialog() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | public int SheetWidth { get; set; } 14 | public int SheetHeight { get; set; } 15 | private void button1_Click(object sender, EventArgs e) 16 | { 17 | SheetWidth = (int)numericUpDown1.Value; 18 | SheetHeight = (int)numericUpDown2.Value; 19 | DialogResult = DialogResult.OK; 20 | Close(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/DeepNestLib.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net8.0 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/DeepNestLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | net481 7 | Library 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/SvgPoint.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class SvgPoint 4 | { 5 | public bool exact = true; 6 | public override string ToString() 7 | { 8 | return "x: " + x + "; y: " + y; 9 | } 10 | public int id; 11 | public SvgPoint(double _x, double _y) 12 | { 13 | x = _x; 14 | y = _y; 15 | } 16 | internal SvgPoint(SvgPoint point) 17 | { 18 | this.exact = point.exact; 19 | this.id = point.id; 20 | this.marked = point.marked; 21 | this.x = point.x; 22 | this.y = point.y; 23 | } 24 | public bool marked; 25 | public double x; 26 | public double y; 27 | public SvgPoint Clone() 28 | { 29 | return new SvgPoint(this); 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/SvgPoint.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class SvgPoint 4 | { 5 | public bool exact = true; 6 | public override string ToString() 7 | { 8 | return "x: " + x + "; y: " + y; 9 | } 10 | public int id; 11 | public SvgPoint(double _x, double _y) 12 | { 13 | x = _x; 14 | y = _y; 15 | } 16 | internal SvgPoint(SvgPoint point) 17 | { 18 | this.exact = point.exact; 19 | this.id = point.id; 20 | this.marked = point.marked; 21 | this.x = point.x; 22 | this.y = point.y; 23 | } 24 | public bool marked; 25 | public double x; 26 | public double y; 27 | public SvgPoint Clone() 28 | { 29 | return new SvgPoint(this); 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/SvgNestConfig.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class SvgNestConfig 4 | { 5 | public PlacementTypeEnum placementType = PlacementTypeEnum.box; 6 | public double curveTolerance = 0.72; 7 | public double scale = 25; 8 | public double clipperScale = 10000000; 9 | public bool exploreConcave = false; 10 | public int mutationRate = 10; 11 | public int populationSize = 10; 12 | public int rotations = 4; 13 | public double spacing = 10; 14 | public double sheetSpacing = 0; 15 | public bool useHoles = false; 16 | public double timeRatio = 0.5; 17 | public bool mergeLines = false; 18 | public bool simplify; 19 | 20 | #region port features (don't exist in the original DeepNest project) 21 | public bool clipByHull = false; 22 | public bool clipByRects = true; //clip by AABB + MinRect 23 | #endregion 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/SvgNestConfig.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestLib 2 | { 3 | public class SvgNestConfig 4 | { 5 | public PlacementTypeEnum placementType = PlacementTypeEnum.box; 6 | public double curveTolerance = 0.72; 7 | public double scale = 25; 8 | public double clipperScale = 10000000; 9 | public bool exploreConcave = false; 10 | public int mutationRate = 10; 11 | public int populationSize = 10; 12 | public int rotations = 4; 13 | public double spacing = 10; 14 | public double sheetSpacing = 0; 15 | public bool useHoles = false; 16 | public double timeRatio = 0.5; 17 | public bool mergeLines = false; 18 | public bool simplify; 19 | 20 | #region port features (don't exist in the original DeepNest project) 21 | public bool clipByHull = false; 22 | public bool clipByRects = true; //clip by AABB + MinRect 23 | #endregion 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Core/MinkowskiWrapper.Core/MinkowskiWrapper.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Minkowski 4 | { 5 | public class MinkowskiWrapper 6 | { 7 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 8 | public static extern void setData(int cntA, double[] pntsA, int holesCnt, int[] holesSizes, double[] holesPoints, int cntB, double[] pntsB); 9 | 10 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 11 | public static extern void calculateNFP(); 12 | 13 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 14 | public static extern void getSizes1(int[] sizes); 15 | 16 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 17 | public static extern void getSizes2(int[] sizes1, int[] sizes2); 18 | 19 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 20 | public static extern void getResults(double[] data, double[] holesData); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/MinkowskiWrapper.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Minkowski 4 | { 5 | public class MinkowskiWrapper 6 | { 7 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 8 | public static extern void setData(int cntA, double[] pntsA, int holesCnt, int[] holesSizes, double[] holesPoints, int cntB, double[] pntsB); 9 | 10 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 11 | public static extern void calculateNFP(); 12 | 13 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 14 | public static extern void getSizes1(int[] sizes); 15 | 16 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 17 | public static extern void getSizes2(int[] sizes1, int[] sizes2); 18 | 19 | [DllImport("minkowski.dll", CallingConvention = CallingConvention.Cdecl)] 20 | public static extern void getResults(double[] data, double[] holesData); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | $(NoWarn);NU1507 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 fel88 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/LocalContour.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DeepNestLib 4 | { 5 | public class LocalContour 6 | { 7 | public float Len 8 | { 9 | get 10 | { 11 | float len = 0; 12 | for (int i = 1; i <= Points.Count; i++) 13 | { 14 | var p1 = Points[i - 1]; 15 | var p2 = Points[i % Points.Count]; 16 | len += (float)Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)); 17 | } 18 | return len; 19 | } 20 | } 21 | public List Points = new List(); 22 | public bool Enable = true; 23 | public List Childrens = new List(); 24 | public LocalContour Parent; 25 | public object Tag; 26 | 27 | public void Scale(double v) 28 | { 29 | for (int i = 0; i < Points.Count; i++) 30 | { 31 | Points[i] = new PointF((float)(Points[i].X * v), (float)(Points[i].Y * v)); 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DeepNestPort.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Minkowski.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/PolylineElement.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace DeepNestLib 4 | { 5 | public class PolylineElement : DraftElement 6 | { 7 | public PointF[] Points; 8 | 9 | public override double Length 10 | { 11 | get 12 | { 13 | double len = 0; 14 | for (int i = 1; i < Points.Length; i++) 15 | { 16 | len += Points[i - 1].DistTo(Points[i]); 17 | } 18 | return len; 19 | } 20 | } 21 | 22 | public override PointF[] GetPoints() 23 | { 24 | return Points; 25 | } 26 | 27 | public override void Reverse() 28 | { 29 | Points = Points.Reverse().ToArray(); 30 | Start = Points[0]; 31 | End = Points[Points.Length - 1]; 32 | } 33 | 34 | internal override void Mult(double mult) 35 | { 36 | for (int i = 0; i < Points.Length; i++) 37 | { 38 | Points[i] = Points[i].Mult(mult); 39 | } 40 | Start = Points[0]; 41 | End = Points[Points.Length - 1]; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/PictureBoxProgressBar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | 8 | namespace DeepNestPort 9 | { 10 | public class PictureBoxProgressBar : PictureBox 11 | { 12 | public PictureBoxProgressBar() 13 | { 14 | bmp = new Bitmap(Width, Height); 15 | gr = Graphics.FromImage(bmp); 16 | SizeChanged += PictureBoxProgressBar_SizeChanged; 17 | } 18 | 19 | private void PictureBoxProgressBar_SizeChanged(object sender, EventArgs e) 20 | { 21 | bmp = new Bitmap(Width, Height); 22 | gr = Graphics.FromImage(bmp); 23 | } 24 | 25 | Bitmap bmp; 26 | Graphics gr; 27 | public float Value; 28 | public void UpdateImg() 29 | { 30 | gr.FillRectangle(Brushes.White, 0, 0, Width, Height); 31 | gr.FillRectangle(Brushes.LightGreen, 0, 0, (Value / 100.0f) * Width, Height); 32 | gr.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1); 33 | Image = bmp; 34 | 35 | //gr.DrawString((Value * 100.0f),new Font("Arial",18),); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/RibbonMenu.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | partial class RibbonMenu 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/IDrawingContext.cs: -------------------------------------------------------------------------------- 1 | using SkiaSharp; 2 | 3 | namespace DeepNestPort.Core 4 | { 5 | public interface IDrawingContext 6 | { 7 | void FillPath(Brush b, SKPath path); 8 | void DrawPath(Pen b, SKPath path); 9 | 10 | bool MiddleDrag { get; } 11 | Action PaintAction { get; set; } 12 | void SetPen(Pen pen); 13 | 14 | MouseButtons DragButton { get; set; } 15 | PointF GetCursor(); 16 | void Init(Control pb); 17 | 18 | PointF Transform(PointF p1); 19 | SKPoint TransformSK(PointF p1); 20 | PointF Transform(float x, float y); 21 | PointF Transform(double x, double y); 22 | //PointF Transform(Vector2d p1); 23 | 24 | void UpdateDrag(); 25 | Control GenerateRenderControl(); 26 | void ResetView(); 27 | void ResetMatrix(); 28 | 29 | void FitToPoints(PointF[] points, int gap = 0); 30 | void DrawLineTransformed(PointF point, PointF point2); 31 | void DrawLine(float x0, float y0, float x1, float y1); 32 | void Clear(Color white); 33 | void DrawLine(PointF pp, PointF pp2); 34 | void ZoomOut(); 35 | void ZoomIn(); 36 | void PanX(int v); 37 | void PanY(int v); 38 | } 39 | } -------------------------------------------------------------------------------- /Framework/DeepNestConsole/task.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/RibbonMenu.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls.Ribbon; 2 | using System.Windows.Forms.Integration; 3 | 4 | namespace DeepNestPort.Core 5 | { 6 | public partial class RibbonMenu : UserControl 7 | { 8 | public RibbonTab NestTab => Ribbon.nestTab; 9 | public RibbonTab GeneralTab => Ribbon.projectTab; 10 | public RibbonMenu() 11 | { 12 | InitializeComponent(); 13 | 14 | ElementHost elementHost1 = new ElementHost(); 15 | Ribbon = new RibbonMenuWpf(); 16 | Ribbon.TabChanged += Ribbon_TabChanged; 17 | 18 | //Ribbon.DataContext = Form1.Form; 19 | elementHost1.Child = Ribbon; 20 | Controls.Add(elementHost1); 21 | elementHost1.Dock = DockStyle.Fill; 22 | elementHost1.AutoSize = true; 23 | } 24 | 25 | private void Ribbon_TabChanged() 26 | { 27 | TabChanged?.Invoke(); 28 | } 29 | 30 | public event Action TabChanged; 31 | 32 | public RibbonMenuWpf Ribbon; 33 | 34 | internal void SetTab(RibbonTab tab) 35 | { 36 | tab.IsSelected = true; 37 | } 38 | 39 | internal void ApplySettings() 40 | { 41 | Ribbon.borderScroll.IsChecked = Form1.Form.BorderScrollEnabled; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/MessageFilter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Forms; 5 | 6 | namespace DeepNestPort 7 | { 8 | public class MessageFilter : IMessageFilter 9 | { 10 | private const int WM_MOUSEWHEEL = 0x020A; 11 | private const int WM_MOUSEHWHEEL = 0x020E; 12 | 13 | [DllImport("user32.dll")] 14 | static extern IntPtr WindowFromPoint(Point p); 15 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 16 | static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); 17 | 18 | public bool PreFilterMessage(ref Message m) 19 | { 20 | switch (m.Msg) 21 | { 22 | case WM_MOUSEWHEEL: 23 | case WM_MOUSEHWHEEL: 24 | IntPtr hControlUnderMouse = WindowFromPoint(new Point((int)m.LParam)); 25 | if (hControlUnderMouse == m.HWnd) 26 | { 27 | return false; 28 | } 29 | else 30 | { 31 | uint u = Convert.ToUInt32(m.Msg); 32 | SendMessage(hControlUnderMouse, u, m.WParam, m.LParam); 33 | return true; 34 | } 35 | default: 36 | return false; 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/QntDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace DeepNestPort 10 | { 11 | public partial class QntDialog : Form 12 | { 13 | public QntDialog() 14 | { 15 | InitializeComponent(); 16 | StartPosition = FormStartPosition.CenterParent; 17 | } 18 | 19 | public int Qnt=0; 20 | 21 | public void Quit() 22 | { 23 | DialogResult = DialogResult.None; 24 | try 25 | { 26 | Qnt = int.Parse(textBox1.Text); 27 | DialogResult = DialogResult.OK; 28 | Close(); 29 | } 30 | catch 31 | { 32 | textBox1.BackColor = Color.Red; 33 | textBox1.ForeColor = Color.White; 34 | } 35 | } 36 | private void button1_Click(object sender, EventArgs e) 37 | { 38 | Quit(); 39 | } 40 | 41 | private void textBox1_KeyDown(object sender, KeyEventArgs e) 42 | { 43 | if (e.KeyCode == Keys.Enter) 44 | { 45 | Quit(); 46 | } 47 | } 48 | 49 | private void textBox1_TextChanged(object sender, EventArgs e) 50 | { 51 | textBox1.BackColor = Color.White; 52 | textBox1.ForeColor = Color.Black; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/QntDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace DeepNestPort 10 | { 11 | public partial class QntDialog : Form 12 | { 13 | public QntDialog() 14 | { 15 | InitializeComponent(); 16 | StartPosition = FormStartPosition.CenterParent; 17 | } 18 | 19 | public int Qnt=0; 20 | 21 | public void Quit() 22 | { 23 | DialogResult = DialogResult.None; 24 | try 25 | { 26 | Qnt = int.Parse(textBox1.Text); 27 | DialogResult = DialogResult.OK; 28 | Close(); 29 | } 30 | catch 31 | { 32 | textBox1.BackColor = Color.Red; 33 | textBox1.ForeColor = Color.White; 34 | } 35 | } 36 | private void button1_Click(object sender, EventArgs e) 37 | { 38 | Quit(); 39 | } 40 | 41 | private void textBox1_KeyDown(object sender, KeyEventArgs e) 42 | { 43 | if (e.KeyCode == Keys.Enter) 44 | { 45 | Quit(); 46 | } 47 | } 48 | 49 | private void textBox1_TextChanged(object sender, EventArgs e) 50 | { 51 | textBox1.BackColor = Color.White; 52 | textBox1.ForeColor = Color.Black; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Framework/DeepNestConsole/SampleProgram.cs: -------------------------------------------------------------------------------- 1 | using DeepNestLib; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | 6 | namespace DeepNestConsole 7 | { 8 | public class SampleProgram 9 | { 10 | public NestingContext Context = new NestingContext(); 11 | public bool IsFinished() 12 | { 13 | //insert you code here 14 | return Context.Iterations >= 3; 15 | } 16 | 17 | public void Run() 18 | { 19 | Background.UseParallel = true; 20 | SvgNest.Config.placementType = PlacementTypeEnum.gravity; 21 | Console.WriteLine("Settings updated.."); 22 | 23 | Console.WriteLine("Start nesting.."); 24 | Console.WriteLine("Parts: " + Context.Polygons.Count()); 25 | Console.WriteLine("Sheets: " + Context.Sheets.Count()); 26 | 27 | Context.StartNest(); 28 | do 29 | { 30 | var sw = Stopwatch.StartNew(); 31 | Context.NestIterate(); 32 | sw.Stop(); 33 | Console.WriteLine("Iteration: " + Context.Iterations + "; fitness: " + Context.Current.fitness + "; nesting time: " + sw.ElapsedMilliseconds + "ms"); 34 | } while (!IsFinished()); 35 | 36 | #region convert results 37 | string path = "output.dxf"; 38 | Context.Export(path); 39 | Console.WriteLine($"Results exported in: {path}"); 40 | #endregion 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/13.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DeepNestLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DeepNestLib")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("32f6dd67-ef43-49e7-a6b3-4786344baf14")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DeepNestPort")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DeepNestPort")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c5d46522-99b3-40e7-b9a1-819761b19895")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Framework/DeepNestConsole/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DeepNestConsole")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DeepNestConsole")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c02abaed-5922-4bbf-a78c-44fcdd96d118")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("minkowskyServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("minkowskyServer")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e09e5402-28cf-4c96-9410-1af2a44833e0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Framework/clipper_library/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("clipper_library")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Angus Johnson")] 12 | [assembly: AssemblyProduct("clipper_library")] 13 | [assembly: AssemblyCopyright("Copyright © Angus Johnson 2010-14")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("51a6bdca-bc4e-4b2c-ae69-36e2497204f2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/task1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 19 | 31 | 32 | 33 | 39 | 40 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | 5 | namespace DeepNestLib 6 | { 7 | public static class Extensions 8 | { 9 | 10 | public static double DistTo(this SvgPoint p, SvgPoint p2) 11 | { 12 | return Math.Sqrt(Math.Pow(p.x - p2.x, 2) + Math.Pow(p.y - p2.y, 2)); 13 | } 14 | public static double DistTo(this PointF p, PointF p2) 15 | { 16 | return Math.Sqrt(Math.Pow(p.X - p2.X, 2) + Math.Pow(p.Y - p2.Y, 2)); 17 | } 18 | public static T[] splice(this T[] p, int a, int b) 19 | { 20 | List ret = new List(); 21 | for (int i = 0; i < p.Length; i++) 22 | { 23 | if (i >= a && i < (a + b)) continue; 24 | ret.Add(p[i]); 25 | } 26 | return ret.ToArray(); 27 | } 28 | 29 | public static List> splice(this List> p, int a, int b) 30 | { 31 | List> ret = new List>(); 32 | for (int i = a; i < (a + b); i++) 33 | { 34 | if (i >= a && i < (a + b)) continue; 35 | ret.Add(p[i]); 36 | } 37 | return ret; 38 | } 39 | 40 | public static NFP[] splice(this NFP[] p, int a, int b) 41 | { 42 | List ret = new List(); 43 | for (int i = 0; i < p.Length; i++) 44 | { 45 | if (i >= a && i < (a + b)) continue; 46 | ret.Add(p[i]); 47 | } 48 | 49 | return ret.ToArray(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/RawDetail.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | using System.Drawing.Drawing2D; 4 | using System.Linq; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class RawDetail 9 | { 10 | public List Outers = new List(); 11 | public List Holes = new List(); 12 | 13 | public RectangleF BoundingBox() 14 | { 15 | GraphicsPath gp = new GraphicsPath(); 16 | foreach (var item in Outers) 17 | { 18 | gp.AddPolygon(item.Points.ToArray()); 19 | } 20 | return gp.GetBounds(); 21 | } 22 | 23 | public string Name { get; set; } 24 | 25 | public NFP ToNfp() 26 | { 27 | 28 | NFP po = null; 29 | List nfps = new List(); 30 | foreach (var item in Outers) 31 | { 32 | var nn = new NFP(); 33 | nfps.Add(nn); 34 | foreach (var pitem in item.Points) 35 | { 36 | nn.AddPoint(new SvgPoint(pitem.X, pitem.Y)); 37 | } 38 | } 39 | 40 | if (nfps.Any()) 41 | { 42 | var tt = nfps.OrderByDescending(z => z.Area).First(); 43 | po = tt; 44 | po.Name = Name; 45 | 46 | foreach (var r in nfps) 47 | { 48 | if (r == tt) continue; 49 | if (po.children == null) 50 | { 51 | po.children = new List(); 52 | } 53 | po.children.Add(r); 54 | } 55 | 56 | 57 | 58 | } 59 | return po; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | 5 | namespace DeepNestLib 6 | { 7 | public static class Extensions 8 | { 9 | 10 | public static double DistTo(this SvgPoint p, SvgPoint p2) 11 | { 12 | return Math.Sqrt(Math.Pow(p.x - p2.x, 2) + Math.Pow(p.y - p2.y, 2)); 13 | } 14 | public static double DistTo(this PointF p, PointF p2) 15 | { 16 | return Math.Sqrt(Math.Pow(p.X - p2.X, 2) + Math.Pow(p.Y - p2.Y, 2)); 17 | } 18 | public static T[] splice(this T[] p, int a, int b) 19 | { 20 | List ret = new List(); 21 | for (int i = 0; i < p.Length; i++) 22 | { 23 | if (i >= a && i < (a + b)) continue; 24 | ret.Add(p[i]); 25 | } 26 | return ret.ToArray(); 27 | } 28 | 29 | public static List> splice(this List> p, int a, int b) 30 | { 31 | List> ret = new List>(); 32 | for (int i = a; i < (a + b); i++) 33 | { 34 | if (i >= a && i < (a + b)) continue; 35 | ret.Add(p[i]); 36 | } 37 | return ret; 38 | } 39 | 40 | public static NFP[] splice(this NFP[] p, int a, int b) 41 | { 42 | List ret = new List(); 43 | for (int i = 0; i < p.Length; i++) 44 | { 45 | if (i >= a && i < (a + b)) continue; 46 | ret.Add(p[i]); 47 | } 48 | 49 | return ret.ToArray(); 50 | } 51 | 52 | public static PointF Mult(this PointF p, double m) 53 | { 54 | return new PointF((float)(p.X * m), (float)(p.Y * m)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/11.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/6.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Framework/README.md: -------------------------------------------------------------------------------- 1 | # DeepNestPort 2 | DeepNest C# Port (https://github.com/Jack000/Deepnest) 3 | 4 | DXF Import/Export: https://github.com/IxMilia/Dxf 5 | 6 | Also take a look at the WPF Net.Core version: https://github.com/9swampy/DeepNestSharp 7 | 8 | 9 | 10 | 11 | 12 | ## Steps to build and run 13 | ``` 14 | 1. Open DeepNestPort.sln using Visual Studio 15 | 2. In visual studio press Build->Build solution, and wait until building 16 | 3. Run DeepNestPort.exe (can be found here 'DeepNestPort-master\DeepNestPort\bin\Debug\') 17 | ``` 18 | 19 | ## (Optional) Running this software using external dll 20 | Steps to generate 'minkowski.dll' file: 21 | 22 | 1.Install vs2022 and also install plugin named "Desktop development with C++" 23 | 24 | 2.Download code. 25 | 26 | 3.Download boost zip (https://www.boost.org/users/history/version_1_76_0.html) 27 | 28 | 4.Extract it somewhere and copy its location and edit it in DeepNestPort-master\Minkowski\compile.bat file like so :- 29 | cl /Ox -I "D:\boost\boost_1_76_0" /LD minkowski.cc 30 | 31 | 5.Go to Start->All Programs->(Scroll down to see Visual Studio 2022 folder)->Tools->Dev. Command Prompt 32 | Do cd to the place where DeepNestPort-master is location(u might have to do 'cd /d ' instead of 33 | normal 'cd' command to change the drive) 34 | enter 'compile.bat' in command prompt and it will automatically generate a 'minkowski.dll' file for you. 35 | 36 | Steps to generate 'DeepNestPort.exe': 37 | 38 | 1. Open vs2022 and open project in explorer(select file 'DeepNestPort.sln'). 39 | 2. In visual studio press Build->Build solution. This will take 10-20 seconds 40 | and u will obtain a 'DeepNestPort.exe' in 'DeepNestPort-master\DeepNestPort\bin\Debug\' folder. 41 | 42 | 43 | To run software just copy minkowski.dll to the folder where u have exe, and u will have this project running. 44 | Tudums! 45 | 46 | ## Contributors 47 | * https://github.com/Daniel-t-1/DeepNestPort (dxf export) 48 | * https://github.com/9swampy/DeepNestPort (simplification features) 49 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/_Clipper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class _Clipper 9 | { 10 | public static ClipperLib.IntPoint[] ScaleUpPaths(SvgPoint[] points, double scale = 1) 11 | { 12 | var result = new ClipperLib.IntPoint[points.Length]; 13 | 14 | Parallel.For(0, points.Length, i => result[i] = new ClipperLib.IntPoint((long)Math.Round((decimal)points[i].x * (decimal)scale), (long)Math.Round((decimal)points[i].y * (decimal)scale))); 15 | 16 | return result.ToArray(); 17 | } // 2 secs 18 | public static ClipperLib.IntPoint[] ScaleUpPaths(NFP p, double scale = 1) 19 | { 20 | List ret = new List(); 21 | 22 | for (int i = 0; i < p.Points.Count(); i++) 23 | { 24 | //p.Points[i] = new SvgNestPort.SvgPoint((float)Math.Round(p.Points[i].x * scale), (float)Math.Round(p.Points[i].y * scale)); 25 | ret.Add(new ClipperLib.IntPoint( 26 | (long)Math.Round((decimal)p.Points[i].x * (decimal)scale), 27 | (long)Math.Round((decimal)p.Points[i].y * (decimal)scale) 28 | )); 29 | 30 | } 31 | return ret.ToArray(); 32 | } 33 | /*public static IntPoint[] ScaleUpPath(IntPoint[] p, double scale = 1) 34 | { 35 | for (int i = 0; i < p.Length; i++) 36 | { 37 | 38 | //p[i] = new IntPoint(p[i].X * scale, p[i].Y * scale); 39 | p[i] = new IntPoint( 40 | (long)Math.Round((decimal)p[i].X * (decimal)scale), 41 | (long)Math.Round((decimal)p[i].Y * (decimal)scale)); 42 | } 43 | return p.ToArray(); 44 | } 45 | public static void ScaleUpPaths(List> p, double scale = 1) 46 | { 47 | for (int i = 0; i < p.Count; i++) 48 | { 49 | for (int j = 0; j < p[i].Count; j++) 50 | { 51 | p[i][j] = new IntPoint(p[i][j].X * scale, p[i][j].Y * scale); 52 | 53 | } 54 | } 55 | 56 | 57 | }*/ 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/_Clipper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class _Clipper 9 | { 10 | public static ClipperLib.IntPoint[] ScaleUpPaths(SvgPoint[] points, double scale = 1) 11 | { 12 | var result = new ClipperLib.IntPoint[points.Length]; 13 | 14 | Parallel.For(0, points.Length, i => result[i] = new ClipperLib.IntPoint((long)Math.Round((decimal)points[i].x * (decimal)scale), (long)Math.Round((decimal)points[i].y * (decimal)scale))); 15 | 16 | return result.ToArray(); 17 | } // 2 secs 18 | public static ClipperLib.IntPoint[] ScaleUpPaths(NFP p, double scale = 1) 19 | { 20 | List ret = new List(); 21 | 22 | for (int i = 0; i < p.Points.Count(); i++) 23 | { 24 | //p.Points[i] = new SvgNestPort.SvgPoint((float)Math.Round(p.Points[i].x * scale), (float)Math.Round(p.Points[i].y * scale)); 25 | ret.Add(new ClipperLib.IntPoint( 26 | (long)Math.Round((decimal)p.Points[i].x * (decimal)scale), 27 | (long)Math.Round((decimal)p.Points[i].y * (decimal)scale) 28 | )); 29 | 30 | } 31 | return ret.ToArray(); 32 | } 33 | /*public static IntPoint[] ScaleUpPath(IntPoint[] p, double scale = 1) 34 | { 35 | for (int i = 0; i < p.Length; i++) 36 | { 37 | 38 | //p[i] = new IntPoint(p[i].X * scale, p[i].Y * scale); 39 | p[i] = new IntPoint( 40 | (long)Math.Round((decimal)p[i].X * (decimal)scale), 41 | (long)Math.Round((decimal)p[i].Y * (decimal)scale)); 42 | } 43 | return p.ToArray(); 44 | } 45 | public static void ScaleUpPaths(List> p, double scale = 1) 46 | { 47 | for (int i = 0; i < p.Count; i++) 48 | { 49 | for (int j = 0; j < p[i].Count; j++) 50 | { 51 | p[i][j] = new IntPoint(p[i][j].X * scale, p[i][j].Y * scale); 52 | 53 | } 54 | } 55 | 56 | 57 | }*/ 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | namespace DeepNestConsole.Core 6 | { 7 | class Program 8 | { 9 | static void ShowUsage() 10 | { 11 | Console.WriteLine("deepnest console tool. usage:"); 12 | Console.WriteLine("Runing sample:"); 13 | Console.WriteLine("deepNestConsole sample"); 14 | Console.WriteLine(""); 15 | Console.WriteLine("Runing nesting from xml plan:"); 16 | Console.WriteLine("deepNestConsole xml [xml]"); 17 | } 18 | 19 | static void Main(string[] args) 20 | { 21 | if (args.Count() < 1) 22 | { 23 | ShowUsage(); 24 | return; 25 | } 26 | var type = args[0]; 27 | SampleProgram sample = new SampleProgram(); 28 | switch (type) 29 | { 30 | case "xml": 31 | { 32 | if (args.Count() < 2) 33 | { 34 | Console.WriteLine("wrong format"); 35 | return; 36 | } 37 | if (!File.Exists(args[1])) 38 | { 39 | Console.WriteLine("xml file not exist."); 40 | return; 41 | } 42 | try 43 | { 44 | sample.LoadXml(args[1]); 45 | } 46 | catch (Exception ex) 47 | { 48 | Console.WriteLine("Error loading xml file: " + ex.Message); 49 | return; 50 | } 51 | } 52 | break; 53 | case "sample": 54 | { 55 | sample.Context.LoadSampleData(); 56 | } 57 | break; 58 | default: 59 | { 60 | Console.WriteLine("wrong format"); 61 | ShowUsage(); 62 | return; 63 | } 64 | } 65 | 66 | sample.Run(); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Framework/DeepNestConsole/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | namespace DeepNestConsole 6 | { 7 | class Program 8 | { 9 | static void ShowUsage() 10 | { 11 | Console.WriteLine("deepnest console tool. usage:"); 12 | Console.WriteLine("Runing sample:"); 13 | Console.WriteLine("deepNestConsole sample"); 14 | Console.WriteLine(""); 15 | Console.WriteLine("Runing nesting from xml plan:"); 16 | Console.WriteLine("deepNestConsole xml [xml]"); 17 | } 18 | 19 | static void Main(string[] args) 20 | { 21 | if (args.Count() < 1) 22 | { 23 | ShowUsage(); 24 | return; 25 | } 26 | var type = args[0]; 27 | SampleProgram sample = new SampleProgram(); 28 | switch (type) 29 | { 30 | case "xml": 31 | { 32 | if (args.Count() < 2) 33 | { 34 | Console.WriteLine("wrong format"); 35 | return; 36 | } 37 | if (!File.Exists(args[1])) 38 | { 39 | Console.WriteLine("xml file not exist."); 40 | return; 41 | } 42 | try 43 | { 44 | sample.Context.LoadXml(args[1]); 45 | } 46 | catch (Exception ex) 47 | { 48 | Console.WriteLine("Error loading xml file: " + ex.Message); 49 | return; 50 | } 51 | } 52 | break; 53 | case "sample": 54 | { 55 | sample.Context.LoadSampleData(); 56 | } 57 | break; 58 | default: 59 | { 60 | Console.WriteLine("wrong format"); 61 | ShowUsage(); 62 | return; 63 | } 64 | } 65 | 66 | sample.Run(); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Settings.cs: -------------------------------------------------------------------------------- 1 | using DeepNestLib; 2 | 3 | namespace DeepNestPort.Core 4 | { 5 | public partial class Settings : UserControl 6 | { 7 | public Settings() 8 | { 9 | InitializeComponent(); 10 | } 11 | 12 | public void InitValues() 13 | { 14 | numericUpDown1.Value = (decimal)SvgNest.Config.spacing; 15 | numericUpDown2.Value = (decimal)SvgNest.Config.sheetSpacing; 16 | numericUpDown3.Value = Form1.Form.MaxNestSeconds; 17 | numericUpDown4.Value = SvgNest.Config.rotations; 18 | checkBox1.Checked = Form1.Form.UseNestTimeLimit; 19 | comboBox1.SelectedIndex = 0; 20 | numericUpDown3.Enabled = Form1.Form.UseNestTimeLimit; 21 | } 22 | 23 | private void numericUpDown1_ValueChanged(object sender, EventArgs e) 24 | { 25 | SvgNest.Config.spacing = (float)numericUpDown1.Value; 26 | } 27 | 28 | public event Action Close; 29 | private void button1_Click(object sender, EventArgs e) 30 | { 31 | Close?.Invoke(); 32 | } 33 | 34 | private void numericUpDown2_ValueChanged(object sender, EventArgs e) 35 | { 36 | SvgNest.Config.sheetSpacing = (double)numericUpDown2.Value; 37 | } 38 | 39 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) 40 | { 41 | if (comboBox1.SelectedIndex == 0) 42 | Form1.Form.SplitMode = LoadDetailSplitMode.Ask; 43 | if (comboBox1.SelectedIndex == 1) 44 | Form1.Form.SplitMode = LoadDetailSplitMode.Always; 45 | } 46 | 47 | private void numericUpDown3_ValueChanged(object sender, EventArgs e) 48 | { 49 | Form1.Form.MaxNestSeconds = (int)numericUpDown3.Value; 50 | } 51 | 52 | private void Settings_Load(object sender, EventArgs e) 53 | { 54 | 55 | } 56 | 57 | private void checkBox1_CheckedChanged(object sender, EventArgs e) 58 | { 59 | numericUpDown3.Enabled = checkBox1.Checked; 60 | Form1.Form.UseNestTimeLimit = checkBox1.Checked; 61 | } 62 | 63 | private void numericUpDown4_ValueChanged(object sender, EventArgs e) 64 | { 65 | SvgNest.Config.rotations = (int)numericUpDown4.Value; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/RawDetail.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | using System.Drawing.Drawing2D; 4 | using System.Linq; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class RawDetail 9 | { 10 | public List Outers = new List(); 11 | public List Holes = new List(); 12 | public object Tag; 13 | public RectangleF BoundingBox() 14 | { 15 | GraphicsPath gp = new GraphicsPath(); 16 | foreach (var item in Outers) 17 | { 18 | gp.AddPolygon(item.Points.ToArray()); 19 | } 20 | return gp.GetBounds(); 21 | } 22 | 23 | public string Name { get; set; } 24 | 25 | public NFP ToNfp() 26 | { 27 | 28 | NFP po = null; 29 | List nfps = new List(); 30 | foreach (var item in Outers) 31 | { 32 | var nn = new NFP(); 33 | nfps.Add(nn); 34 | foreach (var pitem in item.Points) 35 | { 36 | nn.AddPoint(new SvgPoint(pitem.X, pitem.Y)); 37 | } 38 | foreach (var ch in item.Childrens) 39 | { 40 | nn = new NFP(); 41 | nfps.Add(nn); 42 | foreach (var pitem in ch.Points) 43 | { 44 | nn.AddPoint(new SvgPoint(pitem.X, pitem.Y)); 45 | } 46 | } 47 | } 48 | 49 | if (nfps.Any()) 50 | { 51 | var tt = nfps.OrderByDescending(z => z.Area).First(); 52 | po = tt; 53 | po.Name = Name; 54 | 55 | foreach (var r in nfps) 56 | { 57 | if (r == tt) 58 | continue; 59 | 60 | if (po.children == null) 61 | { 62 | po.children = new List(); 63 | } 64 | po.children.Add(r); 65 | } 66 | 67 | 68 | 69 | } 70 | return po; 71 | } 72 | 73 | public void Scale(double v) 74 | { 75 | foreach (var item in Outers) 76 | { 77 | item.Scale(v); 78 | } 79 | foreach (var item in Holes) 80 | { 81 | item.Scale(v); 82 | } 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/EventWrapperPictureBox.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort.Core 2 | { 3 | public class EventWrapperPictureBox 4 | { 5 | public Control Control; 6 | public EventWrapperPictureBox(Control control) 7 | { 8 | Control = control; 9 | control.MouseUp += WrapGlControl_MouseUp; 10 | control.MouseDown += Control_MouseDown; 11 | control.KeyDown += Control_KeyDown; 12 | control.MouseMove += WrapGlControl_MouseMove; 13 | control.MouseWheel += Control_MouseWheel; 14 | control.KeyUp += Control_KeyUp; 15 | control.SizeChanged += Control_SizeChanged; 16 | } 17 | 18 | private void Control_SizeChanged(object sender, EventArgs e) 19 | { 20 | SizeChangedAction?.Invoke(sender, e); 21 | } 22 | 23 | private void Control_KeyUp(object sender, KeyEventArgs e) 24 | { 25 | KeyUpUpAction?.Invoke(sender, e); 26 | } 27 | 28 | private void Control_MouseWheel(object sender, MouseEventArgs e) 29 | { 30 | MouseWheelAction?.Invoke(sender, e); 31 | 32 | } 33 | 34 | private void Control_KeyDown(object sender, KeyEventArgs e) 35 | { 36 | KeyDownAction?.Invoke(sender, e); 37 | } 38 | 39 | private void Control_MouseDown(object sender, MouseEventArgs e) 40 | { 41 | MouseDownAction?.Invoke(sender, e); 42 | } 43 | 44 | private void WrapGlControl_MouseUp(object sender, MouseEventArgs e) 45 | { 46 | MouseUpAction?.Invoke(sender, e); 47 | 48 | } 49 | 50 | private void WrapGlControl_MouseMove(object sender, MouseEventArgs e) 51 | { 52 | MouseMoveAction?.Invoke(sender, e); 53 | 54 | } 55 | public Action SizeChangedAction; 56 | public Action MouseMoveAction; 57 | public Action MouseUpAction; 58 | public Action MouseDownAction; 59 | public Action MouseWheelAction; 60 | public Action KeyUpUpAction; 61 | public Action KeyDownAction; 62 | 63 | /*public Bitmap Image 64 | { 65 | get { return (Bitmap)Control.Image; } 66 | set { Control.Image = value; } 67 | }*/ 68 | 69 | public Point PointToClient(Point position) 70 | { 71 | return Control.PointToClient(position); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Framework/clipper_library/clipper_library.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | AnyCPU 6 | 8.0.30703 7 | 2.0 8 | {9B062971-A88E-4A3D-B3C9-12B78D15FA66} 9 | Library 10 | Properties 11 | ClipperLib 12 | clipper_library 13 | v4.8 14 | 512 15 | 16 | 17 | 18 | true 19 | full 20 | true 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DeepNestPort 2 | DeepNest C# Port (https://github.com/Jack000/Deepnest) 3 | 4 | .Net 8.0
5 | WinForm / WPF Ribbon panel 6 | 7 | :pencil2: **2D drawer:** Skia (https://github.com/mono/SkiaSharp)
8 | :warning:**Project status:** WIP :construction::construction_worker: 9 | 10 | 11 | DXF Import: https://github.com/haplokuon/netDxf
12 | DXF Export: https://github.com/IxMilia/Dxf
13 | SVG Import: https://github.com/zHaytam/SvgPathProperties 14 | 15 | Also take a look at the WPF Net.Core version: https://github.com/9swampy/DeepNestSharp 16 | ![image](https://github.com/fel88/DeepNestPort/assets/15663687/1e18868b-b05b-4f33-9cb5-43690384a664) 17 | 18 | ![image](https://user-images.githubusercontent.com/15663687/224830897-2009c0a2-e8b3-4aae-b673-2392d32b849f.png) 19 | 20 | ![image](https://user-images.githubusercontent.com/15663687/226440959-17cbc75c-dd3c-42ca-878a-39f76a959718.png) 21 | 22 | ## Steps to build and run 23 | ``` 24 | 1. Open DeepNestPort.Core.sln using Visual Studio 25 | 2. In visual studio press Build->Build solution, and wait until building 26 | 3. Run DeepNestPort.Core.exe (can be found here 'DeepNestPort-master\Core\DeepNestPort.Core\bin\Debug\') 27 | ``` 28 | 29 | ## (Optional) Running this software using external dll 30 | Steps to generate 'minkowski.dll' file: 31 | 32 | 1.Install vs2022 and also install plugin named "Desktop development with C++" 33 | 34 | 2.Download code. 35 | 36 | 3.Download boost zip (https://www.boost.org/users/history/version_1_76_0.html) 37 | 38 | 4.Extract it somewhere and copy its location and edit it in DeepNestPort-master\Minkowski\compile.bat file like so :- 39 | cl /Ox -I "D:\boost\boost_1_76_0" /LD minkowski.cc 40 | 41 | 5.Go to Start->All Programs->(Scroll down to see Visual Studio 2022 folder)->Tools->Dev. Command Prompt 42 | Do cd to the place where DeepNestPort-master is location(u might have to do 'cd /d ' instead of 43 | normal 'cd' command to change the drive) 44 | enter 'compile.bat' in command prompt and it will automatically generate a 'minkowski.dll' file for you. 45 | 46 | Steps to generate 'DeepNestPort.exe': 47 | 48 | 1. Open vs2022 and open project in explorer(select file 'DeepNestPort.sln'). 49 | 2. In visual studio press Build->Build solution. This will take 10-20 seconds 50 | and u will obtain a 'DeepNestPort.exe' in 'DeepNestPort-master\DeepNestPort\bin\Debug\' folder. 51 | 52 | 53 | To run software just copy minkowski.dll to the folder where u have exe, and u will have this project running. 54 | Tudums! 55 | 56 | ## Contributors 57 | * https://github.com/Daniel-t-1/DeepNestPort (dxf export) 58 | * https://github.com/9swampy/DeepNestPort (simplification features) 59 | 60 | 61 | Some icons by [Yusuke Kamiyamane](http://p.yusukekamiyamane.com/). Licensed under a [Creative Commons Attribution 3.0 License](http://creativecommons.org/licenses/by/3.0/) 62 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/DeepNestPort.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | net8.0-windows7.0 5 | true 6 | enable 7 | true 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | True 56 | True 57 | Resources.resx 58 | 59 | 60 | Form 61 | 62 | 63 | 64 | 65 | ResXFileCodeGenerator 66 | Resources.Designer.cs 67 | 68 | 69 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Settings.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | text/microsoft-resx 50 | 51 | 52 | 2.0 53 | 54 | 55 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 56 | 57 | 58 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 59 | 60 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DeepNestPort.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DeepNestPort.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Minkowski.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Minkowski.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DeepNestPort.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33213.308 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinkowskiWrapper", "Framework\MinkowskiWrapper\MinkowskiWrapper.csproj", "{E09E5402-28CF-4C96-9410-1AF2A44833E0}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepNestPort", "Framework\DeepNestPort\DeepNestPort.csproj", "{4EE88664-6236-46CD-868D-7D183CA38F40}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepNestLib", "Framework\DeepNestLib\DeepNestLib.csproj", "{32F6DD67-EF43-49E7-A6B3-4786344BAF14}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clipper_library", "Framework\clipper_library\clipper_library.csproj", "{9B062971-A88E-4A3D-B3C9-12B78D15FA66}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepNestConsole", "Framework\DeepNestConsole\DeepNestConsole.csproj", "{C02ABAED-5922-4BBF-A78C-44FCDD96D118}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {E09E5402-28CF-4C96-9410-1AF2A44833E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {E09E5402-28CF-4C96-9410-1AF2A44833E0}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {E09E5402-28CF-4C96-9410-1AF2A44833E0}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {E09E5402-28CF-4C96-9410-1AF2A44833E0}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {4EE88664-6236-46CD-868D-7D183CA38F40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {4EE88664-6236-46CD-868D-7D183CA38F40}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {4EE88664-6236-46CD-868D-7D183CA38F40}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {4EE88664-6236-46CD-868D-7D183CA38F40}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {32F6DD67-EF43-49E7-A6B3-4786344BAF14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {32F6DD67-EF43-49E7-A6B3-4786344BAF14}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {32F6DD67-EF43-49E7-A6B3-4786344BAF14}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {32F6DD67-EF43-49E7-A6B3-4786344BAF14}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {9B062971-A88E-4A3D-B3C9-12B78D15FA66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {9B062971-A88E-4A3D-B3C9-12B78D15FA66}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {9B062971-A88E-4A3D-B3C9-12B78D15FA66}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {9B062971-A88E-4A3D-B3C9-12B78D15FA66}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {C02ABAED-5922-4BBF-A78C-44FCDD96D118}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {C02ABAED-5922-4BBF-A78C-44FCDD96D118}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {C02ABAED-5922-4BBF-A78C-44FCDD96D118}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {C02ABAED-5922-4BBF-A78C-44FCDD96D118}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {3D2489DF-C52C-433B-9484-F94CE60173DC} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /DeepNestPort.Core.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33213.308 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeepNestPort.Core", "Core\DeepNestPort.Core\DeepNestPort.Core.csproj", "{AB881184-A938-413E-99D7-1EDC81CA5D83}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Clipper.Core", "Core\Clipper.Core\Clipper.Core.csproj", "{DB6DF9B8-736D-424C-A993-E2D02FA10844}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeepNestLib.Core", "Core\DeepNestLib.Core\DeepNestLib.Core.csproj", "{B88D05AB-04C5-45C6-A7F0-63F2ECE282B4}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinkowskiWrapper.Core", "Core\MinkowskiWrapper.Core\MinkowskiWrapper.Core.csproj", "{08B54B6F-C04B-44D3-B4D9-B7B1B1D3FD2E}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeepNestConsole.Core", "Core\DeepNestConsole.Core\DeepNestConsole.Core.csproj", "{02A02818-02F1-4AF0-9515-F0AFEBEAFD8C}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {AB881184-A938-413E-99D7-1EDC81CA5D83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {AB881184-A938-413E-99D7-1EDC81CA5D83}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {AB881184-A938-413E-99D7-1EDC81CA5D83}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {AB881184-A938-413E-99D7-1EDC81CA5D83}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {DB6DF9B8-736D-424C-A993-E2D02FA10844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {DB6DF9B8-736D-424C-A993-E2D02FA10844}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {DB6DF9B8-736D-424C-A993-E2D02FA10844}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {DB6DF9B8-736D-424C-A993-E2D02FA10844}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {B88D05AB-04C5-45C6-A7F0-63F2ECE282B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {B88D05AB-04C5-45C6-A7F0-63F2ECE282B4}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {B88D05AB-04C5-45C6-A7F0-63F2ECE282B4}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {B88D05AB-04C5-45C6-A7F0-63F2ECE282B4}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {08B54B6F-C04B-44D3-B4D9-B7B1B1D3FD2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {08B54B6F-C04B-44D3-B4D9-B7B1B1D3FD2E}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {08B54B6F-C04B-44D3-B4D9-B7B1B1D3FD2E}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {08B54B6F-C04B-44D3-B4D9-B7B1B1D3FD2E}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {02A02818-02F1-4AF0-9515-F0AFEBEAFD8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {02A02818-02F1-4AF0-9515-F0AFEBEAFD8C}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {02A02818-02F1-4AF0-9515-F0AFEBEAFD8C}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {02A02818-02F1-4AF0-9515-F0AFEBEAFD8C}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {37EFF9D2-FB46-4B87-B614-1A7A98B63FB7} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DeepNestPort.Core.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DeepNestPort.Core.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap plus { 67 | get { 68 | object obj = ResourceManager.GetObject("plus", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Framework/DeepNestConsole/DeepNestConsole.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C02ABAED-5922-4BBF-A78C-44FCDD96D118} 8 | Exe 9 | Properties 10 | DeepNestConsole 11 | DeepNestConsole 12 | v4.8 13 | 512 14 | true 15 | 16 | 17 | 18 | x86 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | false 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | false 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | {32F6DD67-EF43-49E7-A6B3-4786344BAF14} 60 | DeepNestLib 61 | 62 | 63 | 64 | 65 | PreserveNewest 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/MinkowskiWrapper.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E09E5402-28CF-4C96-9410-1AF2A44833E0} 8 | Library 9 | Properties 10 | Minkowski 11 | MinkowskiWrapper 12 | v4.8 13 | 512 14 | 15 | 16 | 17 | x86 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | false 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | ResXFileCodeGenerator 57 | Resources.Designer.cs 58 | Designer 59 | 60 | 61 | True 62 | Resources.resx 63 | True 64 | 65 | 66 | SettingsSingleFileGenerator 67 | Settings.Designer.cs 68 | 69 | 70 | True 71 | Settings.settings 72 | True 73 | 74 | 75 | 76 | 83 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/D3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class D3 9 | { 10 | 11 | // Returns the 2D cross product of AB and AC vectors, i.e., the z-component of 12 | // the 3D cross product in a quadrant I Cartesian coordinate system (+x is 13 | // right, +y is up). Returns a positive value if ABC is counter-clockwise, 14 | // negative if clockwise, and zero if the points are collinear. 15 | public static double cross(double[] a, double[] b, double[] c) 16 | { 17 | return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); 18 | } 19 | // Computes the upper convex hull per the monotone chain algorithm. 20 | // Assumes points.length >= 3, is sorted by x, unique in y. 21 | // Returns an array of indices into points in left-to-right order. 22 | public static int[] computeUpperHullIndexes(double[][] points) 23 | { 24 | Dictionary indexes = new Dictionary(); 25 | indexes.Add(0, 0); 26 | indexes.Add(1, 1); 27 | var n = points.Count(); 28 | var size = 2; 29 | 30 | for (var i = 2; i < n; ++i) 31 | { 32 | while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; 33 | 34 | if (!indexes.ContainsKey(size)) 35 | { 36 | indexes.Add(size, -1); 37 | } 38 | indexes[size++] = i; 39 | } 40 | List ret = new List(); 41 | for (int i = 0; i < size; i++) 42 | { 43 | ret.Add(indexes[i]); 44 | } 45 | return ret.ToArray(); 46 | //return indexes.slice(0, size); // remove popped points 47 | } 48 | 49 | public class HullInfoPoint 50 | { 51 | public double x; 52 | public double y; 53 | public int index; 54 | } 55 | public static double[][] polygonHull(double[][] points) 56 | { 57 | int n; 58 | n = points.Count(); 59 | if ((n) < 3) return null; 60 | 61 | 62 | 63 | HullInfoPoint[] sortedPoints = new HullInfoPoint[n]; 64 | double[][] flippedPoints = new double[n][]; 65 | 66 | 67 | 68 | for (int i = 0; i < n; ++i) sortedPoints[i] = new HullInfoPoint { x = points[i][0], y = points[i][1], index = i }; 69 | sortedPoints = sortedPoints.OrderBy(x => x.x).ThenBy(z => z.y).ToArray(); 70 | 71 | for (int i = 0; i < n; ++i) flippedPoints[i] = new double[] { sortedPoints[i].x, -sortedPoints[i].y }; 72 | 73 | var upperIndexes = computeUpperHullIndexes(sortedPoints.Select(z => new double[] { z.x, z.y, z.index }).ToArray()); 74 | var lowerIndexes = computeUpperHullIndexes(flippedPoints); 75 | 76 | 77 | // Construct the hull polygon, removing possible duplicate endpoints. 78 | var skipLeft = lowerIndexes[0] == upperIndexes[0]; 79 | var skipRight = lowerIndexes[lowerIndexes.Length - 1] == upperIndexes[upperIndexes.Length - 1]; 80 | List hull = new List(); 81 | 82 | // Add upper hull in right-to-l order. 83 | // Then add lower hull in left-to-right order. 84 | for (int i = upperIndexes.Length - 1; i >= 0; --i) 85 | hull.Add(points[sortedPoints[upperIndexes[i]].index]); 86 | //for (int i = +skipLeft; i < lowerIndexes.Length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]); 87 | for (int i = skipLeft ? 1 : 0; i < lowerIndexes.Length - (skipRight ? 1 : 0); ++i) hull.Add(points[sortedPoints[lowerIndexes[i]].index]); 88 | 89 | return hull.ToArray(); 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/D3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class D3 9 | { 10 | 11 | // Returns the 2D cross product of AB and AC vectors, i.e., the z-component of 12 | // the 3D cross product in a quadrant I Cartesian coordinate system (+x is 13 | // right, +y is up). Returns a positive value if ABC is counter-clockwise, 14 | // negative if clockwise, and zero if the points are collinear. 15 | public static double cross(double[] a, double[] b, double[] c) 16 | { 17 | return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); 18 | } 19 | // Computes the upper convex hull per the monotone chain algorithm. 20 | // Assumes points.length >= 3, is sorted by x, unique in y. 21 | // Returns an array of indices into points in left-to-right order. 22 | public static int[] computeUpperHullIndexes(double[][] points) 23 | { 24 | Dictionary indexes = new Dictionary(); 25 | indexes.Add(0, 0); 26 | indexes.Add(1, 1); 27 | var n = points.Count(); 28 | var size = 2; 29 | 30 | for (var i = 2; i < n; ++i) 31 | { 32 | while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; 33 | 34 | if (!indexes.ContainsKey(size)) 35 | { 36 | indexes.Add(size, -1); 37 | } 38 | indexes[size++] = i; 39 | } 40 | List ret = new List(); 41 | for (int i = 0; i < size; i++) 42 | { 43 | ret.Add(indexes[i]); 44 | } 45 | return ret.ToArray(); 46 | //return indexes.slice(0, size); // remove popped points 47 | } 48 | 49 | public class HullInfoPoint 50 | { 51 | public double x; 52 | public double y; 53 | public int index; 54 | } 55 | public static double[][] polygonHull(double[][] points) 56 | { 57 | int n; 58 | n = points.Count(); 59 | if ((n) < 3) return null; 60 | 61 | 62 | 63 | HullInfoPoint[] sortedPoints = new HullInfoPoint[n]; 64 | double[][] flippedPoints = new double[n][]; 65 | 66 | 67 | 68 | for (int i = 0; i < n; ++i) sortedPoints[i] = new HullInfoPoint { x = points[i][0], y = points[i][1], index = i }; 69 | sortedPoints = sortedPoints.OrderBy(x => x.x).ThenBy(z => z.y).ToArray(); 70 | 71 | for (int i = 0; i < n; ++i) flippedPoints[i] = new double[] { sortedPoints[i].x, -sortedPoints[i].y }; 72 | 73 | var upperIndexes = computeUpperHullIndexes(sortedPoints.Select(z => new double[] { z.x, z.y, z.index }).ToArray()); 74 | var lowerIndexes = computeUpperHullIndexes(flippedPoints); 75 | 76 | 77 | // Construct the hull polygon, removing possible duplicate endpoints. 78 | var skipLeft = lowerIndexes[0] == upperIndexes[0]; 79 | var skipRight = lowerIndexes[lowerIndexes.Length - 1] == upperIndexes[upperIndexes.Length - 1]; 80 | List hull = new List(); 81 | 82 | // Add upper hull in right-to-l order. 83 | // Then add lower hull in left-to-right order. 84 | for (int i = upperIndexes.Length - 1; i >= 0; --i) 85 | hull.Add(points[sortedPoints[upperIndexes[i]].index]); 86 | //for (int i = +skipLeft; i < lowerIndexes.Length - skipRight; ++i) hull.push(points[sortedPoints[lowerIndexes[i]][2]]); 87 | for (int i = skipLeft ? 1 : 0; i < lowerIndexes.Length - (skipRight ? 1 : 0); ++i) hull.Add(points[sortedPoints[lowerIndexes[i]].index]); 88 | 89 | return hull.ToArray(); 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/QntDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort 2 | { 3 | partial class QntDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.button1 = new System.Windows.Forms.Button(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.SuspendLayout(); 35 | // 36 | // textBox1 37 | // 38 | this.textBox1.Location = new System.Drawing.Point(61, 8); 39 | this.textBox1.Margin = new System.Windows.Forms.Padding(2); 40 | this.textBox1.Name = "textBox1"; 41 | this.textBox1.Size = new System.Drawing.Size(63, 20); 42 | this.textBox1.TabIndex = 0; 43 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); 44 | this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); 45 | // 46 | // button1 47 | // 48 | this.button1.Location = new System.Drawing.Point(127, 8); 49 | this.button1.Margin = new System.Windows.Forms.Padding(2); 50 | this.button1.Name = "button1"; 51 | this.button1.Size = new System.Drawing.Size(50, 20); 52 | this.button1.TabIndex = 1; 53 | this.button1.Text = "OK"; 54 | this.button1.UseVisualStyleBackColor = true; 55 | this.button1.Click += new System.EventHandler(this.button1_Click); 56 | // 57 | // label1 58 | // 59 | this.label1.AutoSize = true; 60 | this.label1.Location = new System.Drawing.Point(8, 10); 61 | this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 62 | this.label1.Name = "label1"; 63 | this.label1.Size = new System.Drawing.Size(49, 13); 64 | this.label1.TabIndex = 2; 65 | this.label1.Text = "Quantity:"; 66 | // 67 | // QntDialog 68 | // 69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 71 | this.ClientSize = new System.Drawing.Size(182, 32); 72 | this.Controls.Add(this.label1); 73 | this.Controls.Add(this.button1); 74 | this.Controls.Add(this.textBox1); 75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 76 | this.MaximizeBox = false; 77 | this.MinimizeBox = false; 78 | this.Name = "QntDialog"; 79 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 80 | this.Text = "Enter quantity"; 81 | this.ResumeLayout(false); 82 | this.PerformLayout(); 83 | 84 | } 85 | 86 | #endregion 87 | 88 | private System.Windows.Forms.TextBox textBox1; 89 | private System.Windows.Forms.Button button1; 90 | private System.Windows.Forms.Label label1; 91 | } 92 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/QntDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort 2 | { 3 | partial class QntDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textBox1 = new System.Windows.Forms.TextBox(); 32 | this.button1 = new System.Windows.Forms.Button(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.SuspendLayout(); 35 | // 36 | // textBox1 37 | // 38 | this.textBox1.Location = new System.Drawing.Point(61, 8); 39 | this.textBox1.Margin = new System.Windows.Forms.Padding(2); 40 | this.textBox1.Name = "textBox1"; 41 | this.textBox1.Size = new System.Drawing.Size(63, 20); 42 | this.textBox1.TabIndex = 0; 43 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); 44 | this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); 45 | // 46 | // button1 47 | // 48 | this.button1.Location = new System.Drawing.Point(127, 8); 49 | this.button1.Margin = new System.Windows.Forms.Padding(2); 50 | this.button1.Name = "button1"; 51 | this.button1.Size = new System.Drawing.Size(50, 20); 52 | this.button1.TabIndex = 1; 53 | this.button1.Text = "OK"; 54 | this.button1.UseVisualStyleBackColor = true; 55 | this.button1.Click += new System.EventHandler(this.button1_Click); 56 | // 57 | // label1 58 | // 59 | this.label1.AutoSize = true; 60 | this.label1.Location = new System.Drawing.Point(8, 10); 61 | this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 62 | this.label1.Name = "label1"; 63 | this.label1.Size = new System.Drawing.Size(49, 13); 64 | this.label1.TabIndex = 2; 65 | this.label1.Text = "Quantity:"; 66 | // 67 | // QntDialog 68 | // 69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 71 | this.ClientSize = new System.Drawing.Size(182, 32); 72 | this.Controls.Add(this.label1); 73 | this.Controls.Add(this.button1); 74 | this.Controls.Add(this.textBox1); 75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 76 | this.MaximizeBox = false; 77 | this.MinimizeBox = false; 78 | this.Name = "QntDialog"; 79 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 80 | this.Text = "Enter quantity"; 81 | this.ResumeLayout(false); 82 | this.PerformLayout(); 83 | 84 | } 85 | 86 | #endregion 87 | 88 | private System.Windows.Forms.TextBox textBox1; 89 | private System.Windows.Forms.Button button1; 90 | private System.Windows.Forms.Label label1; 91 | } 92 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/4.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/RibbonMenuWpf.xaml.cs: -------------------------------------------------------------------------------- 1 | using AutoDialog; 2 | using System.Text; 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Input; 6 | using System.Windows.Media; 7 | 8 | namespace DeepNestPort.Core 9 | { 10 | /// 11 | /// Interaction logic for RibbonMenuWpf.xaml 12 | /// 13 | public partial class RibbonMenuWpf : System.Windows.Controls.UserControl 14 | { 15 | public RibbonMenuWpf() 16 | { 17 | InitializeComponent(); 18 | RibbonWin.SelectionChanged += RibbonWin_SelectionChanged; 19 | RibbonWin.KeyDown += RibbonWin_KeyDown; 20 | RibbonWin.Loaded += RibbonWin_Loaded; 21 | } 22 | 23 | private void RibbonWin_Loaded(object sender, RoutedEventArgs e) 24 | { 25 | Grid child = VisualTreeHelper.GetChild((DependencyObject)sender, 0) as Grid; 26 | if (child != null) 27 | { 28 | child.RowDefinitions[0].Height = new GridLength(0); 29 | } 30 | } 31 | 32 | private void RibbonWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) 33 | { 34 | if (e.Key == Key.Tab) 35 | { 36 | if (RibbonWin.SelectedIndex != RibbonWin.Items.Count - 1) 37 | { 38 | RibbonWin.SelectedIndex++; 39 | } 40 | else 41 | { 42 | RibbonWin.SelectedIndex = 0; 43 | } 44 | } 45 | } 46 | 47 | static Form1 Form => Form1.Form; 48 | public event Action TabChanged; 49 | private void RibbonWin_SelectionChanged(object sender, SelectionChangedEventArgs e) 50 | { 51 | TabChanged?.Invoke(); 52 | } 53 | 54 | private void RibbonButton_Click(object sender, RoutedEventArgs e) 55 | { 56 | Form.AddDetailUI(); 57 | } 58 | private void Run_Click(object sender, RoutedEventArgs e) 59 | { 60 | Form.RunNest(); 61 | } 62 | 63 | private void RibbonButton_Click_1(object sender, RoutedEventArgs e) 64 | { 65 | Form.StopNesting(); 66 | } 67 | 68 | private void RibbonButton_Click_2(object sender, RoutedEventArgs e) 69 | { 70 | Form.Export(); 71 | } 72 | 73 | private void RibbonButton_Click_3(object sender, RoutedEventArgs e) 74 | { 75 | Form.ZoomIn(); 76 | } 77 | 78 | private void RibbonButton_Click_4(object sender, RoutedEventArgs e) 79 | { 80 | Form.ZoomOut(); 81 | } 82 | 83 | private void RibbonButton_Click_5(object sender, RoutedEventArgs e) 84 | { 85 | Form.FitAll(); 86 | } 87 | 88 | 89 | private void RibbonButton_Click_6(object sender, RoutedEventArgs e) 90 | { 91 | Form.FitNextSheet(); 92 | } 93 | 94 | private void RibbonButton_Click_7(object sender, RoutedEventArgs e) 95 | { 96 | Form.ExportAll(); 97 | } 98 | 99 | private void RibbonButton_Click_8(object sender, RoutedEventArgs e) 100 | { 101 | Form.SwitchSettingsPanel(); 102 | } 103 | 104 | private void RibbonToggleButton_Checked(object sender, RoutedEventArgs e) 105 | { 106 | Form.ColorsView(true); 107 | } 108 | 109 | private void colorsToggle_Unchecked(object sender, RoutedEventArgs e) 110 | { 111 | Form.ColorsView(false); 112 | } 113 | 114 | private void borderScroll_Unchecked(object sender, RoutedEventArgs e) 115 | { 116 | Form.BorderScroll(false); 117 | } 118 | 119 | private void borderScroll_Checked(object sender, RoutedEventArgs e) 120 | { 121 | Form.BorderScroll(true); 122 | } 123 | 124 | private void RibbonButton_Click_9(object sender, RoutedEventArgs e) 125 | { 126 | Form.ShowNestsList(); 127 | } 128 | 129 | private void RibbonButton_Click_10(object sender, RoutedEventArgs e) 130 | { 131 | Form.Report(); 132 | } 133 | 134 | 135 | private void Save(object sender, RoutedEventArgs e) 136 | { 137 | Form.SaveProject(); 138 | } 139 | 140 | private void Load(object sender, RoutedEventArgs e) 141 | { 142 | Form.LoadProject(); 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Core/DeepNestLib.Core/Simplify.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class Simplify 9 | { 10 | 11 | // to suit your point format, run search/replace for '.x' and '.y'; 12 | // for 3D version, see 3d branch (configurability would draw significant performance overhead) 13 | 14 | // square distance between 2 points 15 | public static double getSqDist(SvgPoint p1, SvgPoint p2) 16 | { 17 | 18 | var dx = p1.x - p2.x; 19 | var dy = p1.y - p2.y; 20 | 21 | return dx * dx + dy * dy; 22 | } 23 | 24 | // square distance from a point to a segment 25 | public static double getSqSegDist(SvgPoint p, SvgPoint p1, SvgPoint p2) 26 | { 27 | 28 | var x = p1.x; 29 | var y = p1.y; 30 | var dx = p2.x - x; 31 | var dy = p2.y - y; 32 | 33 | if (dx != 0 || dy != 0) 34 | { 35 | 36 | var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); 37 | 38 | if (t > 1) 39 | { 40 | x = p2.x; 41 | y = p2.y; 42 | 43 | } 44 | else if (t > 0) 45 | { 46 | x += dx * t; 47 | y += dy * t; 48 | } 49 | } 50 | 51 | dx = p.x - x; 52 | dy = p.y - y; 53 | 54 | return dx * dx + dy * dy; 55 | } 56 | // rest of the code doesn't care about point format 57 | 58 | // basic distance-based simplification 59 | public static NFP simplifyRadialDist(NFP points, double? sqTolerance) 60 | { 61 | 62 | var prevPoint = points[0]; 63 | var newPoints = new NFP(); 64 | newPoints.AddPoint(prevPoint); 65 | 66 | SvgPoint point = null; 67 | int i = 1; 68 | for (var len = points.length; i < len; i++) 69 | { 70 | point = points[i]; 71 | 72 | if (point.marked || getSqDist(point, prevPoint) > sqTolerance) 73 | { 74 | newPoints.AddPoint(point); 75 | prevPoint = point; 76 | } 77 | } 78 | 79 | if (prevPoint != point) newPoints.AddPoint(point); 80 | return newPoints; 81 | } 82 | 83 | 84 | public static void simplifyDPStep(NFP points, int first, int last, double? sqTolerance, NFP simplified) 85 | { 86 | var maxSqDist = sqTolerance; 87 | var index = -1; 88 | var marked = false; 89 | for (var i = first + 1; i < last; i++) 90 | { 91 | var sqDist = getSqSegDist(points[i], points[first], points[last]); 92 | 93 | if (sqDist > maxSqDist) 94 | { 95 | index = i; 96 | maxSqDist = sqDist; 97 | } 98 | /*if(points[i].marked && maxSqDist <= sqTolerance){ 99 | index = i; 100 | marked = true; 101 | }*/ 102 | } 103 | 104 | /*if(!points[index] && maxSqDist > sqTolerance){ 105 | console.log('shit shit shit'); 106 | }*/ 107 | 108 | if (maxSqDist > sqTolerance || marked) 109 | { 110 | if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified); 111 | simplified.push(points[index]); 112 | if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified); 113 | } 114 | } 115 | 116 | // simplification using Ramer-Douglas-Peucker algorithm 117 | public static NFP simplifyDouglasPeucker(NFP points, double? sqTolerance) 118 | { 119 | var last = points.length - 1; 120 | 121 | var simplified = new NFP(); 122 | simplified.AddPoint(points[0]); 123 | simplifyDPStep(points, 0, last, sqTolerance, simplified); 124 | simplified.push(points[last]); 125 | 126 | return simplified; 127 | } 128 | 129 | // both algorithms combined for awesome performance 130 | public static NFP simplify(NFP points, double? tolerance, bool highestQuality) 131 | { 132 | 133 | if (points.length <= 2) return points; 134 | 135 | var sqTolerance = (tolerance != null) ? (tolerance * tolerance) : 1; 136 | 137 | points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); 138 | points = simplifyDouglasPeucker(points, sqTolerance); 139 | 140 | return points; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Framework/DeepNestLib/Simplify.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DeepNestLib 7 | { 8 | public class Simplify 9 | { 10 | 11 | // to suit your point format, run search/replace for '.x' and '.y'; 12 | // for 3D version, see 3d branch (configurability would draw significant performance overhead) 13 | 14 | // square distance between 2 points 15 | public static double getSqDist(SvgPoint p1, SvgPoint p2) 16 | { 17 | 18 | var dx = p1.x - p2.x; 19 | var dy = p1.y - p2.y; 20 | 21 | return dx * dx + dy * dy; 22 | } 23 | 24 | // square distance from a point to a segment 25 | public static double getSqSegDist(SvgPoint p, SvgPoint p1, SvgPoint p2) 26 | { 27 | 28 | var x = p1.x; 29 | var y = p1.y; 30 | var dx = p2.x - x; 31 | var dy = p2.y - y; 32 | 33 | if (dx != 0 || dy != 0) 34 | { 35 | 36 | var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy); 37 | 38 | if (t > 1) 39 | { 40 | x = p2.x; 41 | y = p2.y; 42 | 43 | } 44 | else if (t > 0) 45 | { 46 | x += dx * t; 47 | y += dy * t; 48 | } 49 | } 50 | 51 | dx = p.x - x; 52 | dy = p.y - y; 53 | 54 | return dx * dx + dy * dy; 55 | } 56 | // rest of the code doesn't care about point format 57 | 58 | // basic distance-based simplification 59 | public static NFP simplifyRadialDist(NFP points, double? sqTolerance) 60 | { 61 | 62 | var prevPoint = points[0]; 63 | var newPoints = new NFP(); 64 | newPoints.AddPoint(prevPoint); 65 | 66 | SvgPoint point = null; 67 | int i = 1; 68 | for (var len = points.length; i < len; i++) 69 | { 70 | point = points[i]; 71 | 72 | if (point.marked || getSqDist(point, prevPoint) > sqTolerance) 73 | { 74 | newPoints.AddPoint(point); 75 | prevPoint = point; 76 | } 77 | } 78 | 79 | if (prevPoint != point) newPoints.AddPoint(point); 80 | return newPoints; 81 | } 82 | 83 | 84 | public static void simplifyDPStep(NFP points, int first, int last, double? sqTolerance, NFP simplified) 85 | { 86 | var maxSqDist = sqTolerance; 87 | var index = -1; 88 | var marked = false; 89 | for (var i = first + 1; i < last; i++) 90 | { 91 | var sqDist = getSqSegDist(points[i], points[first], points[last]); 92 | 93 | if (sqDist > maxSqDist) 94 | { 95 | index = i; 96 | maxSqDist = sqDist; 97 | } 98 | /*if(points[i].marked && maxSqDist <= sqTolerance){ 99 | index = i; 100 | marked = true; 101 | }*/ 102 | } 103 | 104 | /*if(!points[index] && maxSqDist > sqTolerance){ 105 | console.log('shit shit shit'); 106 | }*/ 107 | 108 | if (maxSqDist > sqTolerance || marked) 109 | { 110 | if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified); 111 | simplified.push(points[index]); 112 | if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified); 113 | } 114 | } 115 | 116 | // simplification using Ramer-Douglas-Peucker algorithm 117 | public static NFP simplifyDouglasPeucker(NFP points, double? sqTolerance) 118 | { 119 | var last = points.length - 1; 120 | 121 | var simplified = new NFP(); 122 | simplified.AddPoint(points[0]); 123 | simplifyDPStep(points, 0, last, sqTolerance, simplified); 124 | simplified.push(points[last]); 125 | 126 | return simplified; 127 | } 128 | 129 | // both algorithms combined for awesome performance 130 | public static NFP simplify(NFP points, double? tolerance, bool highestQuality) 131 | { 132 | 133 | if (points.length <= 2) return points; 134 | 135 | var sqTolerance = (tolerance != null) ? (tolerance * tolerance) : 1; 136 | 137 | points = highestQuality ? points : simplifyRadialDist(points, sqTolerance); 138 | points = simplifyDouglasPeucker(points, sqTolerance); 139 | 140 | return points; 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/RibbonMenuWpf.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/DeepNestPort.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | 5 | 6 | net481 7 | WinExe 8 | false 9 | true 10 | true 11 | 12 | 13 | true 14 | 15 | 16 | 17 | Component 18 | 19 | 20 | PreserveNewest 21 | 22 | 23 | PreserveNewest 24 | 25 | 26 | PreserveNewest 27 | 28 | 29 | PreserveNewest 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | PreserveNewest 36 | 37 | 38 | PreserveNewest 39 | 40 | 41 | PreserveNewest 42 | 43 | 44 | PreserveNewest 45 | 46 | 47 | PreserveNewest 48 | 49 | 50 | PreserveNewest 51 | 52 | 53 | PreserveNewest 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | PreserveNewest 64 | 65 | 66 | PreserveNewest 67 | 68 | 69 | PreserveNewest 70 | 71 | 72 | PreserveNewest 73 | 74 | 75 | PreserveNewest 76 | 77 | 78 | PreserveNewest 79 | 80 | 81 | PreserveNewest 82 | 83 | 84 | PreserveNewest 85 | 86 | 87 | PreserveNewest 88 | 89 | 90 | PreserveNewest 91 | 92 | 93 | PreserveNewest 94 | 95 | 96 | PreserveNewest 97 | 98 | 99 | PreserveNewest 100 | 101 | 102 | PreserveNewest 103 | 104 | 105 | PreserveNewest 106 | 107 | 108 | PreserveNewest 109 | 110 | 111 | PreserveNewest 112 | 113 | 114 | PreserveNewest 115 | 116 | 117 | PreserveNewest 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /Core/DeepNestConsole.Core/SampleProgram.cs: -------------------------------------------------------------------------------- 1 | using DeepNestLib; 2 | using System; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Xml.Linq; 7 | 8 | namespace DeepNestConsole.Core 9 | { 10 | public class SampleProgram 11 | { 12 | public NestingContext Context = new NestingContext(); 13 | const int NestTimeLimit = 10000; 14 | Stopwatch timer = new Stopwatch(); 15 | public bool IsFinished() 16 | { 17 | //insert you code here 18 | return timer.ElapsedMilliseconds > NestTimeLimit; 19 | } 20 | 21 | public void LoadXml(string v) 22 | { 23 | var d = XDocument.Load(v); 24 | var f = d.Descendants().First(); 25 | var gap = int.Parse(f.Attribute("gap").Value); 26 | SvgNest.Config.spacing = gap; 27 | 28 | foreach (var item in d.Descendants("sheet")) 29 | { 30 | int src = Context.GetNextSheetSource(); 31 | var cnt = int.Parse(item.Attribute("count").Value); 32 | if (item.Attribute("width") != null) 33 | { 34 | var ww = int.Parse(item.Attribute("width").Value); 35 | var hh = int.Parse(item.Attribute("height").Value); 36 | 37 | for (int i = 0; i < cnt; i++) 38 | { 39 | Context.AddSheet(ww, hh, src); 40 | } 41 | } 42 | else 43 | { 44 | var r = CsvParser.Parse(item.Value); 45 | var nfp = r[0].ToNfp(); 46 | for (int i = 0; i < cnt; i++) 47 | { 48 | Context.AddSheet(nfp, src); 49 | } 50 | 51 | } 52 | } 53 | foreach (var item in d.Descendants("part")) 54 | { 55 | var cnt = int.Parse(item.Attribute("count").Value); 56 | RawDetail[] r = null; 57 | if (item.Attribute("path") != null) 58 | { 59 | var path = item.Attribute("path").Value; 60 | 61 | if (path.ToLower().EndsWith("svg")) 62 | { 63 | r = SvgParser.LoadSvg(path); 64 | } 65 | else if (path.ToLower().EndsWith("dxf")) 66 | { 67 | r = DxfParser.LoadDxf(path); 68 | } 69 | else if (path.ToLower().EndsWith("csv")) 70 | { 71 | r = CsvParser.Load(path); 72 | } 73 | else 74 | { 75 | continue; 76 | } 77 | } 78 | else //inline mode 79 | { 80 | r = CsvParser.Parse(item.Value); 81 | r[0].Name = item.Attribute("name").Value; 82 | } 83 | 84 | 85 | var src = Context.GetNextSource(); 86 | 87 | foreach (var itemr in r) 88 | { 89 | for (int i = 0; i < cnt; i++) 90 | { 91 | Context.ImportFromRawDetail(itemr, src); 92 | } 93 | } 94 | } 95 | } 96 | 97 | public void Run() 98 | { 99 | Background.UseParallel = true; 100 | SvgNest.Config.placementType = PlacementTypeEnum.gravity; 101 | Console.WriteLine("Settings updated.."); 102 | 103 | Console.WriteLine("Start nesting.."); 104 | Console.WriteLine("Parts: " + Context.Polygons.Count()); 105 | Console.WriteLine("Sheets: " + Context.Sheets.Count()); 106 | 107 | Context.StartNest(); 108 | 109 | timer = Stopwatch.StartNew(); 110 | double bestFitness = double.MaxValue; 111 | do 112 | { 113 | var sw = Stopwatch.StartNew(); 114 | Context.NestIterate(); 115 | sw.Stop(); 116 | if (Context.Current.fitness.Value < bestFitness) 117 | { 118 | bestFitness = Context.Current.fitness.Value; 119 | Console.WriteLine($"Iteration: {Context.Iterations}; fitness: {Context.Current.fitness}; nesting time: {sw.ElapsedMilliseconds}ms"); 120 | } 121 | } while (!IsFinished()); 122 | 123 | #region convert results 124 | string path = "output.svg"; 125 | Export(path); 126 | Console.WriteLine($"Results exported in: {path}"); 127 | #endregion 128 | } 129 | 130 | public void Export(string v) 131 | { 132 | if (v.ToLower().EndsWith("svg")) 133 | SvgParser.Export(v, Context.Polygons, Context.Sheets); 134 | else if (v.ToLower().EndsWith("dxf")) 135 | DxfExporter.Export(v, Context.Polygons, Context.Sheets); 136 | else if (v.ToLower().EndsWith("jpg")) 137 | throw new NotImplementedException(); 138 | //JpgExporter.Export(v, Context.Polygons, Context.Sheets); 139 | else 140 | throw new NotImplementedException($"unknown format: {v}"); 141 | } 142 | 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/9.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Framework/MinkowskiWrapper/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Framework/DeepNestPort/svgs/5.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Core/DeepNestPort.Core/AddSheetDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort 2 | { 3 | partial class AddSheetDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); 35 | this.button1 = new System.Windows.Forms.Button(); 36 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); 37 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); 38 | this.SuspendLayout(); 39 | // 40 | // numericUpDown1 41 | // 42 | this.numericUpDown1.Location = new System.Drawing.Point(54, 12); 43 | this.numericUpDown1.Maximum = new decimal(new int[] { 44 | 10000, 45 | 0, 46 | 0, 47 | 0}); 48 | this.numericUpDown1.Minimum = new decimal(new int[] { 49 | 10, 50 | 0, 51 | 0, 52 | 0}); 53 | this.numericUpDown1.Name = "numericUpDown1"; 54 | this.numericUpDown1.Size = new System.Drawing.Size(94, 20); 55 | this.numericUpDown1.TabIndex = 0; 56 | this.numericUpDown1.Value = new decimal(new int[] { 57 | 3000, 58 | 0, 59 | 0, 60 | 0}); 61 | // 62 | // label1 63 | // 64 | this.label1.AutoSize = true; 65 | this.label1.Location = new System.Drawing.Point(12, 14); 66 | this.label1.Name = "label1"; 67 | this.label1.Size = new System.Drawing.Size(35, 13); 68 | this.label1.TabIndex = 1; 69 | this.label1.Text = "Width"; 70 | // 71 | // label2 72 | // 73 | this.label2.AutoSize = true; 74 | this.label2.Location = new System.Drawing.Point(12, 43); 75 | this.label2.Name = "label2"; 76 | this.label2.Size = new System.Drawing.Size(38, 13); 77 | this.label2.TabIndex = 2; 78 | this.label2.Text = "Height"; 79 | // 80 | // numericUpDown2 81 | // 82 | this.numericUpDown2.Location = new System.Drawing.Point(56, 41); 83 | this.numericUpDown2.Maximum = new decimal(new int[] { 84 | 10000, 85 | 0, 86 | 0, 87 | 0}); 88 | this.numericUpDown2.Minimum = new decimal(new int[] { 89 | 10, 90 | 0, 91 | 0, 92 | 0}); 93 | this.numericUpDown2.Name = "numericUpDown2"; 94 | this.numericUpDown2.Size = new System.Drawing.Size(92, 20); 95 | this.numericUpDown2.TabIndex = 3; 96 | this.numericUpDown2.Value = new decimal(new int[] { 97 | 1500, 98 | 0, 99 | 0, 100 | 0}); 101 | // 102 | // button1 103 | // 104 | this.button1.Location = new System.Drawing.Point(12, 67); 105 | this.button1.Name = "button1"; 106 | this.button1.Size = new System.Drawing.Size(136, 23); 107 | this.button1.TabIndex = 4; 108 | this.button1.Text = "Add"; 109 | this.button1.UseVisualStyleBackColor = true; 110 | this.button1.Click += new System.EventHandler(this.button1_Click); 111 | // 112 | // AddSheetDialog 113 | // 114 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 115 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 116 | this.ClientSize = new System.Drawing.Size(158, 101); 117 | this.Controls.Add(this.numericUpDown1); 118 | this.Controls.Add(this.button1); 119 | this.Controls.Add(this.numericUpDown2); 120 | this.Controls.Add(this.label2); 121 | this.Controls.Add(this.label1); 122 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 123 | this.Name = "AddSheetDialog"; 124 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 125 | this.Text = "New sheet"; 126 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); 127 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); 128 | this.ResumeLayout(false); 129 | this.PerformLayout(); 130 | 131 | } 132 | 133 | #endregion 134 | 135 | private System.Windows.Forms.NumericUpDown numericUpDown1; 136 | private System.Windows.Forms.Label label1; 137 | private System.Windows.Forms.Label label2; 138 | private System.Windows.Forms.NumericUpDown numericUpDown2; 139 | private System.Windows.Forms.Button button1; 140 | } 141 | } -------------------------------------------------------------------------------- /Framework/DeepNestPort/AddSheetDialog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace DeepNestPort 2 | { 3 | partial class AddSheetDialog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); 35 | this.button1 = new System.Windows.Forms.Button(); 36 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); 37 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); 38 | this.SuspendLayout(); 39 | // 40 | // numericUpDown1 41 | // 42 | this.numericUpDown1.Location = new System.Drawing.Point(54, 12); 43 | this.numericUpDown1.Maximum = new decimal(new int[] { 44 | 10000, 45 | 0, 46 | 0, 47 | 0}); 48 | this.numericUpDown1.Minimum = new decimal(new int[] { 49 | 10, 50 | 0, 51 | 0, 52 | 0}); 53 | this.numericUpDown1.Name = "numericUpDown1"; 54 | this.numericUpDown1.Size = new System.Drawing.Size(94, 20); 55 | this.numericUpDown1.TabIndex = 0; 56 | this.numericUpDown1.Value = new decimal(new int[] { 57 | 3000, 58 | 0, 59 | 0, 60 | 0}); 61 | // 62 | // label1 63 | // 64 | this.label1.AutoSize = true; 65 | this.label1.Location = new System.Drawing.Point(12, 14); 66 | this.label1.Name = "label1"; 67 | this.label1.Size = new System.Drawing.Size(35, 13); 68 | this.label1.TabIndex = 1; 69 | this.label1.Text = "Width"; 70 | // 71 | // label2 72 | // 73 | this.label2.AutoSize = true; 74 | this.label2.Location = new System.Drawing.Point(12, 43); 75 | this.label2.Name = "label2"; 76 | this.label2.Size = new System.Drawing.Size(38, 13); 77 | this.label2.TabIndex = 2; 78 | this.label2.Text = "Height"; 79 | // 80 | // numericUpDown2 81 | // 82 | this.numericUpDown2.Location = new System.Drawing.Point(56, 41); 83 | this.numericUpDown2.Maximum = new decimal(new int[] { 84 | 10000, 85 | 0, 86 | 0, 87 | 0}); 88 | this.numericUpDown2.Minimum = new decimal(new int[] { 89 | 10, 90 | 0, 91 | 0, 92 | 0}); 93 | this.numericUpDown2.Name = "numericUpDown2"; 94 | this.numericUpDown2.Size = new System.Drawing.Size(92, 20); 95 | this.numericUpDown2.TabIndex = 3; 96 | this.numericUpDown2.Value = new decimal(new int[] { 97 | 1500, 98 | 0, 99 | 0, 100 | 0}); 101 | // 102 | // button1 103 | // 104 | this.button1.Location = new System.Drawing.Point(12, 67); 105 | this.button1.Name = "button1"; 106 | this.button1.Size = new System.Drawing.Size(136, 23); 107 | this.button1.TabIndex = 4; 108 | this.button1.Text = "Add"; 109 | this.button1.UseVisualStyleBackColor = true; 110 | this.button1.Click += new System.EventHandler(this.button1_Click); 111 | // 112 | // AddSheetDialog 113 | // 114 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 115 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 116 | this.ClientSize = new System.Drawing.Size(158, 101); 117 | this.Controls.Add(this.numericUpDown1); 118 | this.Controls.Add(this.button1); 119 | this.Controls.Add(this.numericUpDown2); 120 | this.Controls.Add(this.label2); 121 | this.Controls.Add(this.label1); 122 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 123 | this.Name = "AddSheetDialog"; 124 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 125 | this.Text = "New sheet"; 126 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); 127 | ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); 128 | this.ResumeLayout(false); 129 | this.PerformLayout(); 130 | 131 | } 132 | 133 | #endregion 134 | 135 | private System.Windows.Forms.NumericUpDown numericUpDown1; 136 | private System.Windows.Forms.Label label1; 137 | private System.Windows.Forms.Label label2; 138 | private System.Windows.Forms.NumericUpDown numericUpDown2; 139 | private System.Windows.Forms.Button button1; 140 | } 141 | } --------------------------------------------------------------------------------