private void SetMaximumClones() { if (ObjectView.Objects3D.Count > 1) { _packModelsRequest = PackingHelper.CreatePackModelsRequest(null); _packModelsRequest.PackingType = TypeOfPacking.MaxAmountOfClones; var solutions = PackingHelper.CalculatePackingSolutions(_packModelsRequest); Dictionary <ModelFootprint, int> modelFootprints = new Dictionary <ModelFootprint, int>(); foreach (var footprint in solutions.BestSolution.Footprints) { var duplicateControl = this.spcModelControls.Panel1.Controls.OfType <DuplicateModelControl>().First(s => s.ModelFootprint.Model == footprint.Model); modelFootprints.Add(footprint, duplicateControl.TotalAmount); duplicateControl.TotalAmount = footprint.CloneCount; } var cloneModelsEventArtgs = new CloneModelsEventArgs() { PackModelsRequest = _packModelsRequest, PackagingSolutions = solutions, ModelFootprints = modelFootprints }; this.ValueChanged?.Invoke(null, cloneModelsEventArtgs); } else { this.Visible = false; } // FillBuildPlateCompleted?.Invoke(null, null); }
private void UpdateDuplicates(int previousAmount, int amount, ModelFootprint modelFootprint) { //ModelFootprint modelFootprint = this.Tag as ModelFootprint; if (modelFootprint != null) { var tmpPackModelsRequest = PackingHelper.CreatePackModelsRequest(null); foreach (var duplicateControl in this.spcModelControls.Panel1.Controls.OfType <DuplicateModelControl>()) { if (duplicateControl.ModelFootprint.Model != modelFootprint.Model) { tmpPackModelsRequest.ModelFootprints.First(s => s.Model == duplicateControl.ModelFootprint.Model).RequestedCloneCount = duplicateControl.TotalAmount; } else { tmpPackModelsRequest.ModelFootprints.First(s => s.Model == duplicateControl.ModelFootprint.Model).RequestedCloneCount = amount; } } var solutions = PackingHelper.CalculatePackingSolutions(tmpPackModelsRequest); var amountOfPackagedItems = solutions.BestSolution.PackedItems.Count(s => s.ModelFootprint.Model == modelFootprint.Model); if (amountOfPackagedItems < amount) { //workaround to fix bug somewhere in packaging logic tmpPackModelsRequest = PackingHelper.CreatePackModelsRequest(null); foreach (var duplicateControl in this.spcModelControls.Panel1.Controls.OfType <DuplicateModelControl>()) { if (duplicateControl.ModelFootprint.Model != modelFootprint.Model) { tmpPackModelsRequest.ModelFootprints.First(s => s.Model == duplicateControl.ModelFootprint.Model).RequestedCloneCount = duplicateControl.TotalAmount; } } tmpPackModelsRequest = PackingHelper.CreatePackModelsRequest(null); foreach (var duplicateControl in this.spcModelControls.Panel1.Controls.OfType <DuplicateModelControl>()) { if (duplicateControl.ModelFootprint.Model != modelFootprint.Model) { tmpPackModelsRequest.ModelFootprints.First(s => s.Model == duplicateControl.ModelFootprint.Model).RequestedCloneCount = duplicateControl.TotalAmount; } } solutions = PackingHelper.CalculatePackingSolutions(tmpPackModelsRequest); } Dictionary <ModelFootprint, int> modelFootprints = new Dictionary <ModelFootprint, int>(); modelFootprints.Add(modelFootprint, previousAmount); var cloneModelsEventArgs = new CloneModelsEventArgs() { PackModelsRequest = tmpPackModelsRequest, PackagingSolutions = solutions, ModelFootprints = modelFootprints }; this.ValueChanged?.Invoke(null, cloneModelsEventArgs); } }