public Job Convert(List<CuttingScheme> schemes) { Job result = new Job(); Int32 cuttingIndex = 0; Dictionary<Sheet, LC4.Sheet> map = new Dictionary<Sheet, LC4.Sheet>(); foreach (CuttingScheme scheme in schemes) { Plan plan = new Plan(); plan.Name = (cuttingIndex + 1).ToString("00000"); plan.LaneType = LaneType.Plate; plan.Size = scheme.Height; // поперечный размер plan.Length = scheme.Width; // продольный размер plan.SizeType = SizeType.Changeable; plan.NurVonVorneAbarbeiten = true; plan.TotalAmount = scheme.Repetitions; // создаём промежуточную полосу в случае когда первый рез является продольным Lane rootLane; if (scheme.RootSection.NestedSections.First.Value.CutType == CutType.Horizontal) { rootLane = new Lane(); rootLane.Size = scheme.Width; rootLane.LaneType = LaneType.Lane; rootLane.SizeType = SizeType.Fixed; } else { rootLane = plan; } // указываем плиту на которой происходит раскрой LC4.Sheet sheet; Lage lage = new Lage(); if (!map.TryGetValue(scheme.Sheet, out sheet)) { sheet = new LC4.Sheet(); // в scheme ширина и высота указывается относительно экрана sheet.Length = scheme.Sheet.Width; sheet.Width = scheme.Sheet.Height; sheet.Thickness = scheme.Sheet.Thickness; sheet.Amount = 0; map.Add(scheme.Sheet, sheet); result.Sheets.Add(sheet); } lage.Amount = scheme.Repetitions; lage.BaseDetail = sheet; sheet.Amount += scheme.Repetitions; lage.Quality = ""; plan.Lagen.Add(lage); // добавляем вложенные полосы AddSubLanes(plan, scheme.RootSection.NestedSections); Statistics stat = scheme.CalcStatistics(); plan.Information.TotalSquare = (double)scheme.Sheet.Width * (double)scheme.Sheet.Height; plan.Information.DustSquare = stat.DustSquare; plan.Information.ScrapsSquare = stat.ScrapsSquare + stat.UndefinitesSquare; plan.Information.ScrapPercent = (plan.Information.DustSquare + plan.Information.ScrapsSquare) / plan.Information.TotalSquare * 100.0; plan.Information.DetailsCount = stat.DetailsCount; plan.Information.DetailsSquare = stat.DetailsSquare; plan.Information.RemainsCount = stat.RemainsCount; plan.Information.RemainsSquare = stat.RemainsSquare; result.Plans.Add(plan); cuttingIndex++; } return result; }
static void Test3() { Job job = new Job(); job.Name = "job"; Denisenko.Cutting.LC4.Sheet sheet = new Denisenko.Cutting.LC4.Sheet(); sheet.Amount = 1; sheet.Length = 2440; sheet.Width = 1830; sheet.Thickness = 16; job.Sheets.Add(sheet); Plan plan = new Plan(); plan.Name = "00001"; plan.LaneType = LaneType.Plate; plan.SizeType = SizeType.Changeable; plan.Copies = 1; plan.IsCopy = false; plan.Size = 1830; plan.Length = 2440; plan.TotalAmount = 50; plan.StackAmount = 1; Lage lage = new Lage(); lage.Amount = 1; lage.Postforming = false; lage.Quality = ""; lage.IsFinishPart = false; lage.BaseDetail = sheet; plan.Lagen.Add(lage); Lane cutoff1 = new Lane(); cutoff1.LaneType = LaneType.Cutoff; cutoff1.Size = 20; cutoff1.SizeType = SizeType.Automatic; plan.Add(cutoff1); Lane cut1 = new Lane(); cut1.LaneType = LaneType.Cut; cut1.Size = 4; cut1.SizeType = SizeType.Automatic; plan.Add(cut1); Lane lane1 = new Lane(); lane1.LaneType = LaneType.Lane; lane1.Size = 980; lane1.SizeType = SizeType.Changeable; plan.Add(lane1); Lane cutoff3 = new Lane(); cutoff3.LaneType = LaneType.Cutoff; cutoff3.Size = 20; cutoff3.SizeType = SizeType.Automatic; lane1.Add(cutoff3); Lane cut3 = new Lane(); cut3.LaneType = LaneType.Cut; cut3.Size = 4; cut3.SizeType = SizeType.Automatic; lane1.Add(cut3); Lane detail = new Lane(); detail.LaneType = LaneType.Detail; detail.Size = 580; detail.SizeType = SizeType.Changeable; lane1.Add(detail); Lane cut4 = new Lane(); cut4.LaneType = LaneType.Cut; cut4.Size = 4; cut4.SizeType = SizeType.Automatic; lane1.Add(cut4); Lane cutoff4 = new Lane(); cutoff4.LaneType = LaneType.Cutoff; cutoff4.Size = 1230; cutoff4.SizeType = SizeType.Automatic; lane1.Add(cutoff4); Lane cut2 = new Lane(); cut2.LaneType = LaneType.Cut; cut2.Size = 4; cut2.SizeType = SizeType.Automatic; plan.Add(cut2); Lane cutoff2 = new Lane(); cutoff2.LaneType = LaneType.Cutoff; cutoff2.Size = 1440; cutoff2.SizeType = SizeType.Automatic; plan.Add(cutoff2); job.Plans.Add(plan); job.SaveLC4("job.lc4", true); }
public Job Convert(List <CuttingScheme> schemes) { Job result = new Job(); Int32 cuttingIndex = 0; Dictionary <Sheet, LC4.Sheet> map = new Dictionary <Sheet, LC4.Sheet>(); foreach (CuttingScheme scheme in schemes) { Plan plan = new Plan(); plan.Name = (cuttingIndex + 1).ToString("00000"); plan.LaneType = LaneType.Plate; plan.Size = scheme.Height; // поперечный размер plan.Length = scheme.Width; // продольный размер plan.SizeType = SizeType.Changeable; plan.NurVonVorneAbarbeiten = true; plan.TotalAmount = scheme.Repetitions; // создаём промежуточную полосу в случае когда первый рез является продольным Lane rootLane; if (scheme.RootSection.NestedSections.First.Value.CutType == CutType.Horizontal) { rootLane = new Lane(); rootLane.Size = scheme.Width; rootLane.LaneType = LaneType.Lane; rootLane.SizeType = SizeType.Fixed; } else { rootLane = plan; } // указываем плиту на которой происходит раскрой LC4.Sheet sheet; Lage lage = new Lage(); if (!map.TryGetValue(scheme.Sheet, out sheet)) { sheet = new LC4.Sheet(); // в scheme ширина и высота указывается относительно экрана sheet.Length = scheme.Sheet.Width; sheet.Width = scheme.Sheet.Height; sheet.Thickness = scheme.Sheet.Thickness; sheet.Amount = 0; map.Add(scheme.Sheet, sheet); result.Sheets.Add(sheet); } lage.Amount = scheme.Repetitions; lage.BaseDetail = sheet; sheet.Amount += scheme.Repetitions; lage.Quality = ""; plan.Lagen.Add(lage); // добавляем вложенные полосы AddSubLanes(plan, scheme.RootSection.NestedSections); Statistics stat = scheme.CalcStatistics(); plan.Information.TotalSquare = (double)scheme.Sheet.Width * (double)scheme.Sheet.Height; plan.Information.DustSquare = stat.DustSquare; plan.Information.ScrapsSquare = stat.ScrapsSquare + stat.UndefinitesSquare; plan.Information.ScrapPercent = (plan.Information.DustSquare + plan.Information.ScrapsSquare) / plan.Information.TotalSquare * 100.0; plan.Information.DetailsCount = stat.DetailsCount; plan.Information.DetailsSquare = stat.DetailsSquare; plan.Information.RemainsCount = stat.RemainsCount; plan.Information.RemainsSquare = stat.RemainsSquare; result.Plans.Add(plan); cuttingIndex++; } return(result); }