private void FillLayerControls() { try { // get solution SolutionLayered solution = _analysis.SolutionLay; // packable cbLayerType.Packable = _analysis.Content; // build layers and fill CCtrl foreach (var layerEncap in solution.LayerEncaps) { if (null != layerEncap.Layer2D) { cbLayerType.Items.Add(layerEncap.Layer2D); } else if (null != layerEncap.LayerDesc) { LayerSolver solver = new LayerSolver(); Layer2DBrickImp layer = solver.BuildLayer(_analysis.ContentDimensions, _analysis.ContainerDimensions, layerEncap.LayerDesc as LayerDescBox, 0.0); cbLayerType.Items.Add(layer); } } if (cbLayerType.Items.Count > 0) { cbLayerType.SelectedIndex = 0; } } catch (Exception ex) { _log.Error(ex.Message); } }
private placement[] BuildPlacementArray(SolutionLayered sol, AnalysisLayered analysis) { List <placement> lPlacements = new List <placement>(); List <ILayer> layers = sol.Layers; foreach (ILayer layer in layers) { if (layer is Layer3DBox layerBox) { foreach (BoxPosition bPosition in layerBox) { Vector3D writtenPosition = ConvertPosition(bPosition, analysis.ContentDimensions); lPlacements.Add( new placement() { itemId = 1, x = writtenPosition.X, y = writtenPosition.Y, z = writtenPosition.Z, L = ToAxis(bPosition.DirectionLength), W = ToAxis(bPosition.DirectionWidth) } ); } } } return(lPlacements.ToArray()); }
public override void OnNext() { base.OnNext(); try { var layerEncaps = new List <LayerEncap>(); foreach (ILayer2D layer in uCtrlLayerList.Selected) { layerEncaps.Add(new LayerEncap(layer.LayerDescriptor)); } SolutionLayered.SetSolver(new LayerSolver()); if (!(_item is AnalysisCylinderCase analysis)) { _item = _document.CreateNewAnalysisCylinderCase( ItemName, ItemDescription , SelectedCylinder, SelectedCase , new List <InterlayerProperties>() , BuildConstraintSet() , layerEncaps); } else { analysis.ID.SetNameDesc(ItemName, ItemDescription); analysis.Content = SelectedCylinder; analysis.CaseProperties = SelectedCase; analysis.ConstraintSet = BuildConstraintSet(); analysis.AddSolution(layerEncaps); _document.UpdateAnalysis(analysis); } Close(); }
protected override void ExportAnalysisSpecific(Analysis analysis) { var analysisBoxCase = analysis as AnalysisBoxCase; // analysis name WSheet.Cells[RowIndex, 1] = analysisBoxCase.Name; // box if (analysisBoxCase.Content is BoxProperties boxProperties) { WSheet.Cells[RowIndex, 2] = boxProperties.Name; WSheet.Cells[RowIndex, 3] = boxProperties.Description; WSheet.Cells[RowIndex, 4] = boxProperties.Length; WSheet.Cells[RowIndex, 5] = boxProperties.Width; WSheet.Cells[RowIndex, 6] = boxProperties.Height; } // case if (analysisBoxCase.Container is BoxProperties caseProperties) { WSheet.Cells[RowIndex, 7] = caseProperties.Name; } // solution SolutionLayered sol = analysisBoxCase.SolutionLay; WSheet.Cells[RowIndex, 8] = sol.ItemCount; WSheet.Cells[RowIndex, 9] = sol.LayerCount; WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0); WSheet.Cells[RowIndex, 11] = sol.LoadWeight; WSheet.Cells[RowIndex, 12] = sol.Weight; WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency; InsertImage(analysis, 14); }
protected override void ExportAnalysisSpecific(Analysis analysis) { var analysisCylinderTruck = analysis as AnalysisCylinderTruck; // analysis name WSheet.Cells[RowIndex, 2] = analysisCylinderTruck.Name; // cylinder var cylinderProperties = analysisCylinderTruck.Content as CylinderProperties; WSheet.Cells[RowIndex, 2] = cylinderProperties.Name; WSheet.Cells[RowIndex, 3] = cylinderProperties.Description; WSheet.Cells[RowIndex, 4] = cylinderProperties.RadiusOuter * 2.0; WSheet.Cells[RowIndex, 5] = cylinderProperties.Height; // truck name var truckProperties = analysisCylinderTruck.Container as TruckProperties; WSheet.Cells[RowIndex, 6] = truckProperties.Name; // solution SolutionLayered sol = analysisCylinderTruck.SolutionLay; WSheet.Cells[RowIndex, 7] = sol.ItemCount; WSheet.Cells[RowIndex, 8] = sol.LayerCount; WSheet.Cells[RowIndex, 9] = sol.LayerBoxCount(0); WSheet.Cells[RowIndex, 10] = sol.LoadWeight; WSheet.Cells[RowIndex, 11] = sol.VolumeEfficiency; // image InsertImage(analysis, 12); }
protected override void ExportAnalysisSpecific(Analysis analysis) { // analysis name WSheet.Cells[RowIndex, 1] = analysis.Name; if (analysis is AnalysisCasePallet analysisCasePallet) { // case if (analysisCasePallet.Content is BoxProperties caseProperties) { WSheet.Cells[RowIndex, 2] = caseProperties.Name; WSheet.Cells[RowIndex, 3] = caseProperties.Description; WSheet.Cells[RowIndex, 4] = caseProperties.Length; WSheet.Cells[RowIndex, 5] = caseProperties.Width; WSheet.Cells[RowIndex, 6] = caseProperties.Height; } // constraints ConstraintSetCasePallet constraintSet = analysisCasePallet.ConstraintSet as ConstraintSetCasePallet; WSheet.Cells[RowIndex, 7] = constraintSet.OptMaxHeight.Value; // solution SolutionLayered sol = analysisCasePallet.SolutionLay; WSheet.Cells[RowIndex, 8] = sol.ItemCount; WSheet.Cells[RowIndex, 9] = sol.LayerCount; WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0); WSheet.Cells[RowIndex, 11] = sol.LoadWeight; WSheet.Cells[RowIndex, 12] = sol.Weight; WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency; } InsertImage(analysis, 14); }
public override void OnNext() { try { Layer2DBrickImp selLayer = SelectedLayer; var layerEncaps = new List<LayerEncap>() { new LayerEncap(selLayer.LayerDescriptor) }; SolutionLayered.SetSolver(new LayerSolver()); AnalysisCasePallet analysis = AnalysisCast; if (null == analysis) _item = _document.CreateNewAnalysisCasePallet( ItemName, ItemDescription , SelectedPackable, SelectedPallet , new List<InterlayerProperties>() , null, null, null , BuildConstraintSet() , layerEncaps ); else { analysis.ID.SetNameDesc(ItemName, ItemDescription); analysis.Content = SelectedPackable; analysis.PalletProperties = SelectedPallet; analysis.ConstraintSet = BuildConstraintSet(); analysis.AddSolution(layerEncaps); _document.UpdateAnalysis(analysis); } Close(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
protected override void ExportAnalysisSpecific(Analysis analysis) { var analysisCylinderPallet = analysis as AnalysisCylinderPallet; // analysis name WSheet.Cells[RowIndex, 1] = analysisCylinderPallet.Name; // cylinder var cylinderProperties = analysisCylinderPallet.Content as CylinderProperties; WSheet.Cells[RowIndex, 2] = cylinderProperties.Name; WSheet.Cells[RowIndex, 3] = cylinderProperties.Description; WSheet.Cells[RowIndex, 4] = cylinderProperties.RadiusOuter * 2.0; WSheet.Cells[RowIndex, 5] = cylinderProperties.Height; // pallet name var palletProperties = analysisCylinderPallet.Container as PalletProperties; WSheet.Cells[RowIndex, 6] = palletProperties.Name; // constraint set ConstraintSetPackablePallet constraintSet = analysisCylinderPallet.ConstraintSet as ConstraintSetPackablePallet; WSheet.Cells[RowIndex, 7] = constraintSet.OptMaxHeight.Value; // solution SolutionLayered sol = analysisCylinderPallet.SolutionLay; WSheet.Cells[RowIndex, 8] = sol.ItemCount; WSheet.Cells[RowIndex, 9] = sol.LayerCount; WSheet.Cells[RowIndex, 10] = sol.LayerBoxCount(0); WSheet.Cells[RowIndex, 11] = sol.LoadWeight; WSheet.Cells[RowIndex, 12] = sol.Weight; WSheet.Cells[RowIndex, 13] = sol.VolumeEfficiency; InsertImage(analysis, 14); }
public List <AnalysisLayered> BuildAnalyses(bool allowMultipleLayerOrientations) { var analyses = new List <AnalysisLayered>(); // get best set of layers if (allowMultipleLayerOrientations) { var listLayerEncap = new List <KeyValuePair <LayerEncap, int> >(); LayerSolver.GetBestCombination( _packable.OuterDimensions, _packable.Bulge, _caseProperties.GetStackingDimensions(ConstraintSet), ConstraintSet, ref listLayerEncap); var layerEncaps = new List <LayerEncap>(); foreach (var vp in listLayerEncap) { layerEncaps.Add(vp.Key); } var analysis = new AnalysisBoxCase(null, _packable, _caseProperties, ConstraintSet); analysis.AddSolution(layerEncaps); // only add analysis if it has a valid solution if (analysis.Solution.ItemCount > 0) { analyses.Add(analysis); } } else { // build layer list var solver = new LayerSolver(); List <Layer2DBrickImp> layers = solver.BuildLayers( _packable.OuterDimensions , _packable.Bulge , new Vector2D(_caseProperties.InsideLength, _caseProperties.InsideWidth) , 0.0 /* offsetZ */ , ConstraintSet , true ); SolutionLayered.SetSolver(solver); // loop on layers foreach (Layer2DBrickImp layer in layers) { var layerDescs = new List <LayerDesc> { layer.LayerDescriptor }; var analysis = new AnalysisBoxCase(null, _packable, _caseProperties, ConstraintSet); analysis.AddSolution(layerDescs); // only add analysis if it has a valid solution if (analysis.Solution.ItemCount > 0) { analyses.Add(analysis); } } } return(analyses); }
public override void Export(AnalysisLayered analysis, ref Stream stream) { SolutionLayered sol = analysis.SolutionLay; string nameContainer = analysis.Container.Name; string nameContent = analysis.Content.Name; // Geometry container Geometry geomContainer = new Geometry() { Uuid = Guid.NewGuid().ToString(), Type = "Geometry", Data = new Data() { Vertices = new List <double>(), Normals = new List <double>(), Uvs = new List <List <double> >(), Faces = new List <int>() } }; // Material container Material matContainer = new Material() { Uuid = Guid.NewGuid().ToString(), Type = "Material", Name = string.Format("Mat_{0}", nameContainer) }; // Geometry content Geometry geomContent = new Geometry() { }; // Material content Material matContent = new Material() { Uuid = Guid.NewGuid().ToString(), Type = "Material", Name = string.Format("Mat_{0}", nameContent) }; RootObject rootObj = new RootObject() { Geometries = new List <Geometry>() { geomContainer, geomContent }, Materials = new List <Material>() { matContainer, matContent }, Object = new Json.Object() }; string filePath = string.Empty; File.WriteAllText(filePath, JsonConvert.SerializeObject(rootObj)); }
public DockContentAnalysisPalletTruck(IDocument document, AnalysisPalletTruck analysis) : base(document) { _analysis = analysis; _analysis.AddListener(this); _solution = analysis.SolutionLay; InitializeComponent(); }
public AnalysisLayered BuildAnalysis(LayerDescBox layerDesc) { SolutionLayered.SetSolver(new LayerSolver()); AnalysisLayered analysis = new AnalysisCasePallet(Packable, PalletProperties, ConstraintSet); analysis.AddSolution(new List <LayerDesc>() { layerDesc }); return(analysis); }
public override void Export(AnalysisLayered analysis, ref Stream stream) { // number formatting NumberFormatInfo nfi = new NumberFormatInfo { NumberDecimalSeparator = ".", NumberGroupSeparator = "", NumberDecimalDigits = 1 }; // initialize csv file var csv = new StringBuilder(); SolutionLayered sol = analysis.SolutionLay; var layers = sol.Layers; foreach (ILayer layer in layers) { if (layer is Layer3DBox layerBox) { layerBox.Sort(analysis.Content, Layer3DBox.SortType.DIST_MAXCORNER); foreach (BoxPosition bPosition in layerBox) { Vector3D pos = ConvertPosition(bPosition, analysis.ContentDimensions); csv.AppendLine( $"1;" + $"{pos.X.ToString("0,0.0", nfi)};" + $"{pos.Y.ToString("0,0.0", nfi)};" + $"{pos.Z.ToString("0,0.0", nfi)};" + $"{bPosition.DirectionLength};" + $"{bPosition.DirectionWidth}"); } } else if (layer is Layer3DCyl layerCyl) { layerCyl.Sort(analysis.Content, Layer3DCyl.SortType.DIST_CENTER); foreach (Vector3D vPos in layerCyl) { csv.AppendLine( $"1;" + $"{vPos.X.ToString("0,0.0", nfi)};" + $"{vPos.Y.ToString("0,0.0", nfi)};" + $"{vPos.Z.ToString("0,0.0", nfi)};" ); } } } var writer = new StreamWriter(stream); writer.Write(csv.ToString()); writer.Flush(); stream.Position = 0; }
private void OnNext(object sender, EventArgs e) { try { Close(); var layerEncaps = new List <LayerEncap>(); foreach (ILayer2D layer2D in uCtrlLayerList.Selected) { layerEncaps.Add(new LayerEncap(layer2D.LayerDescriptor)); } string userName = string.Empty; Document doc = new Document(DocumentName, DocumentDescription, userName, DateTime.Now, null); Packable packable = doc.CreateNewPackable(BundleProp); BoxProperties caseProperties = doc.CreateNewCase( CaseName, CaseName , CaseInsideLength, CaseInsideWidth, CaseInsideHeight , CaseInsideLength, CaseInsideWidth, CaseInsideHeight , CaseWeight , new Color[] { Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate, Color.Chocolate } ); if (null == packable || null == caseProperties) { return; } SolutionLayered.SetSolver(new LayerSolver()); Analysis analysis = doc.CreateNewAnalysisBoxCase( DocumentName, DocumentDescription , packable, caseProperties , new List <InterlayerProperties>() , BuildConstraintSet() , layerEncaps); FormBrowseSolution form = new FormBrowseSolution(doc, analysis as AnalysisLayered); if (DialogResult.OK == form.ShowDialog()) { } } catch (Exception ex) { _log.Error(ex.ToString()); } }
public override void Export(AnalysisLayered analysis, ref Stream stream) { SolutionLayered sol = analysis.SolutionLay; // build orderDocument element orderDocument document = new orderDocument() { date = DateTime.Now, unit = CurrentUnit, author = analysis.ParentDocument != null ? analysis.ParentDocument.Author : string.Empty, orderType = new orderDocumentOrderType() { orderNumber = analysis.Name, orderLine = new orderLine() { itemId = 1, quantity = analysis.Solution.ItemCount }, loadSpace = BuildLoadSpace(analysis), item = BuildItem(analysis), load = new load() { loadSpaceId = 1, statistics = new statistics() { loadVolume = sol.LoadVolume, loadWeight = sol.LoadWeight, volumeUtilization = sol.VolumeEfficiency, weightUtilization = sol.WeightEfficiency.ToDouble(), cOfG = new cOfG() { x = sol.COfG.X, y = sol.COfG.Y, z = sol.COfG.Z }, loadHeight = sol.BBoxLoad.Height }, placement = BuildPlacementArray(sol, analysis) } } }; // serialization XmlSerializer serializer = new XmlSerializer(typeof(orderDocument)); serializer.Serialize(stream, document); stream.Flush(); stream.Seek(0, SeekOrigin.Begin); }
private placement[] BuildPlacementArray(SolutionLayered sol, AnalysisLayered analysis) { List <placement> lPlacements = new List <placement>(); List <ILayer> layers = sol.Layers; foreach (ILayer layer in layers) { if (layer is Layer3DBox layerBox) { layerBox.Sort(analysis.Content, Layer3DBox.SortType.DIST_MAXCORNER); foreach (BoxPosition bPosition in layerBox) { Vector3D writtenPosition = ConvertPosition(bPosition, analysis.ContentDimensions); lPlacements.Add( new placement() { itemId = 1, x = writtenPosition.X, y = writtenPosition.Y, z = writtenPosition.Z, L = ToAxis(bPosition.DirectionLength), W = ToAxis(bPosition.DirectionWidth) } ); } } else if (layer is Layer3DCyl layerCyl) { layerCyl.Sort(analysis.Content, Layer3DCyl.SortType.DIST_CENTER); foreach (Vector3D vPos in layerCyl) { lPlacements.Add( new placement() { itemId = 1, x = vPos.X, y = vPos.Y, z = vPos.Z } ); } } } return(lPlacements.ToArray()); }
public override void OnNext() { base.OnNext(); try { var layerEncaps = new List <LayerEncap>(); foreach (ILayer2D layer2D in uCtrlLayerList.Selected) { layerEncaps.Add(new LayerEncap(layer2D.LayerDescriptor)); } SolutionLayered.SetSolver(new LayerSolver()); AnalysisBoxCase analysis = AnalysisCast; if (null == analysis) { AnalysisBase = _document.CreateNewAnalysisBoxCase( ItemName, ItemDescription , SelectedBoxProperties, SelectedCase , new List <InterlayerProperties>() , BuildConstraintSet() , layerEncaps ); } else { analysis.ID.SetNameDesc(ItemName, ItemDescription); analysis.Content = SelectedBoxProperties; analysis.CaseProperties = SelectedCase; analysis.ConstraintSet = BuildConstraintSet(); analysis.AddSolution(layerEncaps); _document.UpdateAnalysis(analysis); } Close(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void UpdateControls() { try { // get solution SolutionLayered solution = _analysis.SolutionLay; int index = solution.SelectedLayerIndex; bnSymmetryX.Enabled = (index != -1); bnSymetryY.Enabled = (index != -1); cbLayerType.Enabled = (index != -1); gbLayer.Text = index != -1 ? string.Format(Resources.ID_SELECTEDLAYER, index) : Resources.ID_DOUBLECLICKALAYER; if (index != -1) { tbClickLayer.Hide(); gbLayer.Show(); // get selected solution item SolutionItem selItem = solution.SelectedSolutionItem; if (null != selItem) { // set current layer cbLayerType.SelectedIndex = selItem.IndexLayer; } } else { gbLayer.Hide(); tbClickLayer.Show(); } } catch (Exception ex) { _log.Error(ex.Message); } }
public override void OnNext() { base.OnNext(); try { var layerDescs = new List <LayerEncap>(); foreach (Layer2DBrickImp layer2D in uCtrlLayerList.Selected) { layerDescs.Add(new LayerEncap(layer2D.LayerDescriptor)); } SolutionLayered.SetSolver(new LayerSolver()); AnalysisPalletTruck analysis = AnalysisCast; if (null == analysis) { AnalysisBase = _document.CreateNewAnalysisPalletTruck( ItemName, ItemDescription , SelectedLoadedPallet, SelectedTruckProperties , BuildConstraintSet() , layerDescs); } else { analysis.ID.SetNameDesc(ItemName, ItemDescription); analysis.Content = SelectedLoadedPallet; analysis.TruckProperties = SelectedTruckProperties; analysis.ConstraintSet = BuildConstraintSet(); analysis.AddSolution(layerDescs); _document.UpdateAnalysis(analysis); } Close(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void OnNext(object sender, EventArgs e) { try { Close(); var layerEncaps = new List <LayerEncap>(); foreach (ILayer2D layer2D in uCtrlLayerList.Selected) { layerEncaps.Add(new LayerEncap(layer2D.LayerDescriptor)); } string userName = string.Empty; Document doc = new Document(DocumentName, DocumentDescription, userName, DateTime.Now, null); Packable packable = doc.CreateNewPackable(_uctrlPackable.PackableProperties); PalletProperties palletProperties = doc.CreateNewPallet(cbPallet.SelectedPallet); if (null == packable || null == palletProperties) { return; } SolutionLayered.SetSolver(new LayerSolver()); Analysis analysis = doc.CreateNewAnalysisCasePallet( DocumentName, DocumentDescription , packable, palletProperties, new List <InterlayerProperties>(), null, null, null , BuildConstraintSet() , layerEncaps); FormBrowseSolution form = new FormBrowseSolution(doc, analysis as AnalysisLayered); if (DialogResult.OK == form.ShowDialog()) { } } catch (Exception ex) { _log.Error(ex.ToString()); } }
public void ExportAnalysesToExcel() { // open excel file Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application { Visible = true, DisplayAlerts = false }; Workbooks xlWorkBooks = xlApp.Workbooks; Workbook xlWorkBook = xlWorkBooks.Add(Type.Missing); Worksheet xlWorkSheetCasePallet = xlWorkBook.Worksheets.get_Item(1); // create header xlWorkSheetCasePallet.Cells[1, 1] = "Analysis name"; xlWorkSheetCasePallet.Cells[1, 2] = "Case name"; xlWorkSheetCasePallet.Cells[1, 3] = "Case description"; xlWorkSheetCasePallet.Cells[1, 4] = "Ext. length"; xlWorkSheetCasePallet.Cells[1, 5] = "Ext. width"; xlWorkSheetCasePallet.Cells[1, 6] = "Ext. height"; xlWorkSheetCasePallet.Cells[1, 7] = "Max pallet height"; xlWorkSheetCasePallet.Cells[1, 8] = "Solution case count"; xlWorkSheetCasePallet.Cells[1, 9] = "Layers"; xlWorkSheetCasePallet.Cells[1, 10] = "Cases per layer"; xlWorkSheetCasePallet.Cells[1, 11] = "Load weight"; xlWorkSheetCasePallet.Cells[1, 12] = "Weight"; xlWorkSheetCasePallet.Cells[1, 13] = "Volume efficiency"; xlWorkSheetCasePallet.Cells[1, 14] = "Image"; Range headerRange = xlWorkSheetCasePallet.get_Range("A1", "N1"); headerRange.Font.Bold = true; xlWorkSheetCasePallet.Columns.AutoFit(); // *** get all users from Azure database and write them down int iRowCasePallet = 2; foreach (var analysis in Analyses) { try { if (analysis is AnalysisCasePallet analysisCasePallet) { // analysis name xlWorkSheetCasePallet.Cells[iRowCasePallet, 1] = analysisCasePallet.Name; // case BoxProperties caseProperties = analysisCasePallet.Content as BoxProperties; xlWorkSheetCasePallet.Cells[iRowCasePallet, 2] = caseProperties.Name; xlWorkSheetCasePallet.Cells[iRowCasePallet, 3] = caseProperties.Description; xlWorkSheetCasePallet.Cells[iRowCasePallet, 4] = caseProperties.Length; xlWorkSheetCasePallet.Cells[iRowCasePallet, 5] = caseProperties.Width; xlWorkSheetCasePallet.Cells[iRowCasePallet, 6] = caseProperties.Height; // constraints ConstraintSetCasePallet constraintSet = analysisCasePallet.ConstraintSet as ConstraintSetCasePallet; xlWorkSheetCasePallet.Cells[iRowCasePallet, 7] = constraintSet.OptMaxHeight.Value; // solution SolutionLayered sol = analysisCasePallet.SolutionLay; xlWorkSheetCasePallet.Cells[iRowCasePallet, 8] = sol.ItemCount; xlWorkSheetCasePallet.Cells[iRowCasePallet, 9] = sol.LayerCount; xlWorkSheetCasePallet.Cells[iRowCasePallet, 10] = sol.LayerBoxCount(0); xlWorkSheetCasePallet.Cells[iRowCasePallet, 11] = sol.LoadWeight; xlWorkSheetCasePallet.Cells[iRowCasePallet, 12] = sol.Weight; xlWorkSheetCasePallet.Cells[iRowCasePallet, 13] = sol.VolumeEfficiency; var stackImagePath = Path.Combine(Path.ChangeExtension(Path.GetTempFileName(), "png")); var graphics = new Graphics3DImage(new Size(768, 768)) { FontSizeRatio = 0.01f, CameraPosition = Graphics3D.Corner_0 }; using (ViewerSolution sv = new ViewerSolution(analysisCasePallet.SolutionLay)) sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); Bitmap bmp = graphics.Bitmap; bmp.Save(stackImagePath, System.Drawing.Imaging.ImageFormat.Png); Range imageCell = (Range)xlWorkSheetCasePallet.Cells[iRowCasePallet, 14]; imageCell.RowHeight = 128; imageCell.ColumnWidth = 24; xlWorkSheetCasePallet.Shapes.AddPicture(stackImagePath, LinkToFile: MsoTriState.msoFalse, SaveWithDocument: MsoTriState.msoCTrue, Left: imageCell.Left + 1, Top: imageCell.Top + 1, Width: imageCell.Width - 2, Height: imageCell.Height - 2); ++iRowCasePallet; } else if (analysis is AnalysisBoxCase analysisBoxCase) { } else if (analysis is AnalysisCaseTruck analysisCaseTruck) { } else if (analysis is AnalysisCylinderPallet analysisCylinderPallet) { } else if (analysis is AnalysisCylinderCase analysisCylinderCase) { } else if (analysis is AnalysisCylinderTruck analysisCylinderTruck) { } } catch (Exception ex) { _log.Error(ex.ToString()); } } }
public void Export(AnalysisLayered analysis, string filePath) { // solution SolutionLayered sol = analysis.SolutionLay; // scene var scene = new SceneBuilder(); if (analysis.Content is BoxProperties boxProperties) { Color[] colors = boxProperties.Colors; Color colorFilet = boxProperties.Colors[0]; Color colorTape = boxProperties.TapeColor; var meshPallet = BuildPalletMesh(analysis.Container as PalletProperties); var meshCase = BuildCaseMesh("Case", (float)boxProperties.Length, (float)boxProperties.Width, (float)boxProperties.Height, colors, 0.0f, colorFilet, boxProperties.TapeWidth.Activated ? (float)boxProperties.TapeWidth.Value : 0.0f, colorTape); var meshesInterlayer = BuildInterlayerMeshes(analysis); // add pallet mesh scene.AddRigidMesh(meshPallet, Matrix4x4.Identity); // add cases (+ interlayers) mesh List <ILayer> layers = sol.Layers; foreach (ILayer layer in layers) { if (layer is Layer3DBox layerBox) { foreach (BoxPosition bPosition in layerBox) { scene.AddRigidMesh(meshCase, BoxPositionToMatrix4x4(bPosition)); } } else if (layer is InterlayerPos interlayerPos) { InterlayerProperties interlayerProp = sol.Interlayers[interlayerPos.TypeId]; var bPosition = new BoxPosition(new Vector3D( 0.5 * (analysis.ContainerDimensions.X - interlayerProp.Length) , 0.5 * (analysis.ContainerDimensions.Y - interlayerProp.Width) , interlayerPos.ZLow), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); scene.AddRigidMesh(meshesInterlayer[interlayerPos.TypeId], BoxPositionToMatrix4x4(bPosition)); } } } // add pallet cap if any if (analysis is AnalysisCasePallet analysisCasePallet && analysisCasePallet.HasPalletCap) { PalletCapProperties capProperties = analysisCasePallet.PalletCapProperties; BoxPosition bPosition = new BoxPosition(new Vector3D( 0.5 * (analysisCasePallet.PalletProperties.Length - capProperties.Length), 0.5 * (analysisCasePallet.PalletProperties.Width - capProperties.Width), sol.BBoxLoad.PtMax.Z - capProperties.InsideHeight) , HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P ); scene.AddRigidMesh(BuildPalletCapMesh( (float)capProperties.Length, (float)capProperties.Width, (float)capProperties.Height, (float)capProperties.InsideLength, (float)capProperties.InsideWidth, (float)capProperties.InsideHeight, capProperties.Color), BoxPositionToMatrix4x4(bPosition)); } // save model var model = scene.ToGltf2(); model.Save(filePath); }
public bool OnFileNew(ref string fileName) { // INTEX data are in cms UnitsManager.CurrentUnitSystem = UnitsManager.UnitSystem.UNIT_METRIC2; string dbPath = Properties.Settings.Default.DatabasePathINTEX; if (string.IsNullOrWhiteSpace(dbPath) || !File.Exists(dbPath)) { OpenFileDialog fd = new OpenFileDialog(); fd.DefaultExt = "xls"; fd.AddExtension = false; fd.Filter = "Microsoft Excel File (*.xls)|*.xls|All files (*.*)|*.*"; fd.FilterIndex = 0; fd.RestoreDirectory = true; fd.CheckFileExists = true; if (DialogResult.OK != fd.ShowDialog()) { return(false); } dbPath = fd.FileName; Properties.Settings.Default.DatabasePathINTEX = dbPath; Properties.Settings.Default.Save(); } // load INTEX excel file List <DataItemINTEX> listItems = null; List <DataPalletINTEX> listPallets = null; List <DataCaseINTEX> listCases = null; try { // Set cursor as hourglass Cursor.Current = Cursors.WaitCursor; // load excel file if (!ExcelDataReader.ExcelDataReader.LoadIntexFile(dbPath, ref listItems, ref listPallets, ref listCases)) { Cursor.Current = Cursors.Default; string message = string.Empty; if (null == listItems || listItems.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "article", "Articles"); } else if (null == listPallets || listPallets.Count < 1) { message = string.Format(Properties.Resources.ID_ERROR_NOITEMFOUND, "palette", "Palettes"); } else { message = string.Format(Properties.Resources.ID_ERROR_INVALIDFILE, dbPath); } if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(false); } } catch (Exception ex) { MessageBox.Show( ex.Message , Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); _log.Error(ex.Message); } finally { Cursor.Current = Cursors.Default; } // do we have a valid list if (null == listItems || 0 == listItems.Count) { return(false); } // proceed : buid project file try { FormNewINTEX form = new FormNewINTEX() { ListItems = listItems, ListPallets = listPallets, ListCases = listCases }; if (DialogResult.OK != form.ShowDialog()) { return(false); } // create document DataItemINTEX item = form._currentItem; Document document = new Document(item._ref, item._description, "INTEX", DateTime.Now, null); // create box properties Color[] colorsCase = new Color[6]; for (int i = 0; i < 6; ++i) { colorsCase[i] = Color.Chocolate; } BoxProperties itemProperties = null; if (!form.UseIntermediatePacking) { itemProperties = document.CreateNewCase( item._ref , $"{item._description};EAN14 : {item._gencode};UPC : {item._UPC};PCB : {item._PCB}" , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } else { itemProperties = document.CreateNewBox( item._ref , string.Format("{0};EAN14 : {1};UPC : {2};PCB : {3}", item._description, item._gencode, item._UPC, item._PCB) , UnitsManager.ConvertLengthFrom(item._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(item._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(item._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); } itemProperties.TapeColor = Color.Beige; itemProperties.TapeWidth = new OptDouble(true, 5.0); InsertPictogram(ref itemProperties); BoxProperties currentCase = null; if (form.UseIntermediatePacking) { // create cases foreach (DataCaseINTEX dataCase in listCases) { double lengthInt = dataCase._lengthInt > 0 ? dataCase._lengthInt : dataCase._lengthExt - 2 * form.DefaultCaseThickness; double widthInt = dataCase._widthInt > 0 ? dataCase._widthInt : dataCase._widthExt - 2 * form.DefaultCaseThickness; double heightInt = dataCase._heightInt > 0 ? dataCase._heightInt : dataCase._heightExt - 2 * form.DefaultCaseThickness; BoxProperties intercaseProperties = document.CreateNewCase( dataCase._ref , string.Format("{0:0.0}*{1:0.0}*{2:0.0}", dataCase._lengthExt, dataCase._widthExt, dataCase._heightExt) , UnitsManager.ConvertLengthFrom(dataCase._lengthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._widthExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(dataCase._heightExt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(lengthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(widthInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(heightInt, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(dataCase._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , colorsCase); intercaseProperties.TapeColor = Color.Beige; intercaseProperties.TapeWidth = new OptDouble(true, 5.0); if (string.Equals(form._currentCase._ref, intercaseProperties.Name)) { currentCase = intercaseProperties; } } } // initialize Layer solver SolutionLayered.SetSolver(new LayerSolver()); if (form.UseIntermediatePacking) { // Case constraint set ConstraintSetBoxCase constraintSetBoxCase = new ConstraintSetBoxCase(currentCase); constraintSetBoxCase.AllowedOrientationsString = "1,1,1"; if (constraintSetBoxCase.Valid) { SolverBoxCase solver = new SolverBoxCase(itemProperties, currentCase); Layer2DBrickImp layer = solver.BuildBestLayer(constraintSetBoxCase); List <LayerDesc> layerDescs = new List <LayerDesc>(); if (null != layer) { layerDescs.Add(layer.LayerDescriptor); } // create case analysis AnalysisLayered analysis = document.CreateNewAnalysisBoxCase( string.Format(Properties.Resources.ID_PACKING, item._ref) , item._description , itemProperties , currentCase , null , constraintSetBoxCase , layerDescs); } } // create pallets PalletProperties currentPallet = null; foreach (DataPalletINTEX pallet in listPallets) { PalletProperties palletProperties = document.CreateNewPallet( pallet._type, pallet._type, "EUR" , UnitsManager.ConvertLengthFrom(pallet._length, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._width, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertLengthFrom(pallet._height, UnitsManager.UnitSystem.UNIT_METRIC2) , UnitsManager.ConvertMassFrom(pallet._weight, UnitsManager.UnitSystem.UNIT_METRIC2) , Color.Gold); if (string.Equals(form._currentPallet._type, pallet._type)) { currentPallet = palletProperties; } } // *** pallet analysis *** // constraint set ConstraintSetCasePallet constraintSet = new ConstraintSetCasePallet(); constraintSet.SetMaxHeight(new OptDouble(true, UnitsManager.ConvertLengthFrom(form.PalletHeight, UnitsManager.UnitSystem.UNIT_METRIC2))); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); if (constraintSet.Valid) { SolverCasePallet solver = new SolverCasePallet(form.UseIntermediatePacking ? currentCase : itemProperties, currentPallet); Layer2DBrickImp layer = solver.BuildBestLayer(constraintSet); List <LayerDesc> layerDescs = new List <LayerDesc>(); if (null != layer) { layerDescs.Add(layer.LayerDescriptor); } // create analysis AnalysisLayered palletAnalysis = document.CreateNewAnalysisCasePallet( item._ref, item.ToString() , form.UseIntermediatePacking ? currentCase : itemProperties , currentPallet, null, null, null, null, constraintSet, layerDescs); } // save document fileName = form.FilePath; document.Write(form.FilePath); if (null != OpenFile) { OpenFile(fileName); } // return true to let application open return(File.Exists(fileName)); } catch (Exception ex) { _log.Error(ex.Message); return(false); } }
public override void Draw(Graphics3D graphics, Transform3D transform) { // clear list of picking box ClearPickingBoxes(); if (null == Solution) { return; } AnalysisHomo analysis = Solution.Analysis; if (analysis is AnalysisPackablePallet analysisPackablePallet) { // ### draw pallet Pallet pallet = new Pallet(analysisPackablePallet.PalletProperties); pallet.Draw(graphics, transform); if (analysis is AnalysisCasePallet && -1 == Solution.SelectedLayerIndex) { // ### strappers SolutionLayered sol = Solution; foreach (var sd in sol.Strappers) { if (null != sd.Points && sd.Points.Count > 0) { Strapper s = new Strapper( transform.transform(IntToAxis(sd.Strapper.Axis)), sd.Strapper.Width, sd.Strapper.Color, sd.Points.ConvertAll(p => transform.transform(p)).ToList()); s.DrawBegin(graphics); } } } } else if (analysis is AnalysisPackableCase analysisPackableCase) { // ### draw case (inside) Case case_ = new Case(analysisPackableCase.CaseProperties); case_.DrawInside(graphics, transform); } else if (analysis is AnalysisPackableTruck analysisPackableTruck) { // ### draw truck Truck truck = new Truck(analysisPackableTruck.TruckProperties); truck.DrawBegin(graphics); } else if (analysis is AnalysisPalletTruck analysisPalletTruck) { // ### draw truck Truck truck = new Truck(analysisPalletTruck.TruckProperties); truck.DrawBegin(graphics); } // ### draw solution uint layerId = 0, pickId = 0; List <ILayer> layers = Solution.Layers; foreach (ILayer layer in layers) { bool aboveSelectedLayer = (Solution.SelectedLayerIndex != -1) && (layerId > Solution.SelectedLayerIndex); Transform3D upTranslation = Transform3D.Translation(new Vector3D(0.0, 0.0, aboveSelectedLayer ? DistanceAboveSelectedLayer : 0.0)); BBox3D bbox = new BBox3D(); // ### layer of boxes if (layer is Layer3DBox layerBox) { if (analysis.Content is LoadedPallet) { LoadedPallet loadedPallet = analysis.Content as LoadedPallet; BBox3D solBBox = loadedPallet.ParentAnalysis.Solution.BBoxGlobal; foreach (BoxPosition bPosition in layerBox) { var dim = solBBox.DimensionsVec; graphics.AddImage(++pickId, new SubContent(loadedPallet.ParentAnalysis as AnalysisHomo), solBBox.DimensionsVec, bPosition.Transform(transform)); // bbox used for picking bbox.Extend(new BBox3D(bPosition.Transform(transform), solBBox.DimensionsVec)); } } else if (analysis.Content is PackProperties packProperties) { foreach (BoxPosition bPosition in layerBox) { BoxPosition boxPositionModified = bPosition.Transform(transform * upTranslation); graphics.AddImage(++pickId, new SubContent(packProperties), packProperties.OuterDimensions, boxPositionModified); // bbox used for picking bbox.Extend(new BBox3D(boxPositionModified, packProperties.OuterDimensions)); } } else if (analysis.Content is BagProperties bagProperties) { foreach (BoxPosition bPosition in layerBox) { BoxPosition boxPositionModified = bPosition.Transform(transform * upTranslation); graphics.AddImage(++pickId, new SubContent(bagProperties), bagProperties.OuterDimensions, boxPositionModified); // bbox used for picking bbox.Extend(new BBox3D(boxPositionModified, bagProperties.OuterDimensions)); } } else { foreach (BoxPosition bPosition in layerBox) { BoxPosition boxPositionModified = bPosition.Transform(transform * upTranslation); BoxGeneric b; if (analysis.Content is BagProperties bagProp) { b = new BoxRounded(pickId++, bagProp.Length, bagProp.Width, bagProp.Height, bagProp.Radius, boxPositionModified) { ColorFill = bagProp.ColorFill } } ; else { b = new Box(pickId++, analysis.Content as PackableBrick, boxPositionModified); } graphics.AddBox(b); bbox.Extend(b.BBox); } } } else if (layer is Layer3DBoxIndexed layerBoxIndexed) { foreach (var bpi in layerBoxIndexed) { BoxPosition boxPositionModified = bpi.BPos.Transform(transform * upTranslation); var bProperties = analysis.Content as PackableBrick; BoxGeneric b = new Box(pickId++, analysis.Content as PackableBrick, boxPositionModified); graphics.AddBox(b); // bbox used for picking bbox.Extend(new BBox3D(boxPositionModified, bProperties.OuterDimensions)); } } else if (layer is Layer3DCyl layerCyl) { foreach (Vector3D vPos in layerCyl) { CylPosition cylPosition = new CylPosition(transform.transform(vPos), HalfAxis.HAxis.AXIS_Z_P); CylPosition cylPositionModified = cylPosition.Transform(transform * upTranslation); Cyl cyl = null; if (analysis.Content is CylinderProperties cylProp) { cyl = new Cylinder(pickId++, cylProp, cylPositionModified); } else if (analysis.Content is BottleProperties bottleProperties) { cyl = new Bottle(pickId++, bottleProperties, cylPositionModified); } graphics.AddCylinder(cyl); bbox.Extend(cyl.BBox); } } // ### interlayer else if (layer is InterlayerPos interlayerPos) { InterlayerProperties interlayerProp = Solution.Interlayers[interlayerPos.TypeId]; if (null != interlayerProp) { BoxPosition bPosition = new BoxPosition( new Vector3D( analysis.Offset.X + 0.5 * (analysis.ContainerDimensions.X - interlayerProp.Length) , analysis.Offset.Y + 0.5 * (analysis.ContainerDimensions.Y - interlayerProp.Width) , interlayerPos.ZLow ), HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P); BoxPosition boxPositionModified = bPosition.Transform(transform * upTranslation); Box box = new Box(pickId++, interlayerProp, boxPositionModified); if (analysis.Content is PackProperties) { graphics.AddImage(pickId, new SubContent(interlayerProp), interlayerProp.Dimensions, boxPositionModified); } else { graphics.AddBox(box); } bbox.Extend(box.BBox); } } if (layer is Layer3DBox || layer is Layer3DCyl) { // add layer BBox AddPickingBox(bbox, layerId); // draw bounding box around selected layer if (layerId == Solution.SelectedLayerIndex) { DrawLayerBoundingBox(graphics, bbox); } ++layerId; } } BBox3D loadBBox = Solution.BBoxLoad; BBox3D loadBBoxWDeco = Solution.BBoxLoadWDeco; if (analysis is AnalysisCasePallet analysisCasePallet) { #region Pallet corners // ### pallet corners : Begin Corner[] corners = new Corner[4]; if (analysisCasePallet.HasPalletCorners) { // positions Vector3D[] cornerPositions = { loadBBox.PtMin , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMin.Y, loadBBox.PtMin.Z) , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z) , new Vector3D(loadBBox.PtMin.X, loadBBox.PtMax.Y, loadBBox.PtMin.Z) }; // length axes HalfAxis.HAxis[] lAxes = { HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N }; // width axes HalfAxis.HAxis[] wAxes = { HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_P }; for (int i = 0; i < 4; ++i) { corners[i] = new Corner(0, analysisCasePallet.PalletCornerProperties) { Height = Math.Min(analysisCasePallet.PalletCornerProperties.Length, loadBBox.Height) }; corners[i].SetPosition( transform.transform(cornerPositions[i]) , HalfAxis.Transform(lAxes[i], transform), HalfAxis.Transform(wAxes[i], transform) ); corners[i].DrawBegin(graphics); } } #endregion #region Top corners Corner[] cornersTop = new Corner[4]; if (analysisCasePallet.HasPalletCornersTopX || analysisCasePallet.HasPalletCornersTopY) { double cornerWidth = analysisCasePallet.PalletCornerTopProperties.Width; double lengthInLDir = Math.Min(analysisCasePallet.PalletCornerTopProperties.Length, loadBBox.Length - 2.0 * cornerWidth); double widthInWDir = Math.Min(analysisCasePallet.PalletCornerTopProperties.Length, loadBBox.Width - 2.0 * cornerWidth); double offsetInLDir = 0.5 * (loadBBox.Length - lengthInLDir); double offsetInWdir = 0.5 * (loadBBox.Width - widthInWDir); Transform3D upTranslation = Transform3D.Translation(new Vector3D(0.0, 0.0, -1 != Solution.SelectedLayerIndex ? DistanceAboveSelectedLayer : 0.0)); // positions Vector3D[] cornerPositions = { new Vector3D(loadBBox.PtMin.X + offsetInLDir, loadBBox.PtMin.Y, loadBBox.PtMax.Z) , new Vector3D(loadBBox.PtMax.X - offsetInLDir, loadBBox.PtMax.Y, loadBBox.PtMax.Z) , new Vector3D(loadBBox.PtMax.X, loadBBox.PtMin.Y + offsetInWdir, loadBBox.PtMax.Z) , new Vector3D(loadBBox.PtMin.X, loadBBox.PtMax.Y - offsetInWdir, loadBBox.PtMax.Z) }; // length axes HalfAxis.HAxis[] lAxes = { HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_N, HalfAxis.HAxis.AXIS_Z_N, }; // width axes HalfAxis.HAxis[] wAxes = { HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_X_P }; for (int i = 0; i < 4; ++i) { cornersTop[i] = new Corner(0, analysisCasePallet.PalletCornerTopProperties) { Height = Math.Min(analysisCasePallet.PalletCornerTopProperties.Length, (i < 2 ? loadBBox.Length : loadBBox.Width) - 2.0 * cornerWidth) }; cornersTop[i].SetPosition( transform.transform(upTranslation.transform(cornerPositions[i])) , HalfAxis.Transform(lAxes[i], transform), HalfAxis.Transform(wAxes[i], transform) ); } // drawing if (analysisCasePallet.HasPalletCornersTopX) { for (int i = 0; i < 2; ++i) { cornersTop[i].DrawBegin(graphics); } } if (analysisCasePallet.HasPalletCornersTopY) { for (int i = 2; i < 4; ++i) { cornersTop[i].DrawBegin(graphics); } } } #endregion #region Pallet film // ### pallet film Film film = null; if (analysisCasePallet.HasPalletFilm && -1 == Solution.SelectedLayerIndex) { // instantiate film PalletFilmProperties palletFilmProperties = analysisCasePallet.PalletFilmProperties; film = new Film( palletFilmProperties.Color, palletFilmProperties.UseTransparency, palletFilmProperties.UseHatching, palletFilmProperties.HatchSpacing, palletFilmProperties.HatchAngle); film.AddRectangle(new FilmRectangle(transform.transform(loadBBoxWDeco.PtMin) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_X_P, transform), HalfAxis.Transform(HalfAxis.HAxis.AXIS_Z_P, transform) , new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), -1.0)); film.AddRectangle(new FilmRectangle(transform.transform(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_Y_P, transform), HalfAxis.Transform(HalfAxis.HAxis.AXIS_Z_P, transform) , new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), -1.0)); film.AddRectangle(new FilmRectangle(transform.transform(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis + loadBBoxWDeco.Width * Vector3D.YAxis) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_X_N, transform), HalfAxis.Transform(HalfAxis.HAxis.AXIS_Z_P, transform) , new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), -1.0)); film.AddRectangle(new FilmRectangle(transform.transform(loadBBoxWDeco.PtMin + loadBBoxWDeco.Width * Vector3D.YAxis) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_Y_N, transform), HalfAxis.Transform(HalfAxis.HAxis.AXIS_Z_P, transform) , new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), -1.0)); film.AddRectangle(new FilmRectangle(transform.transform(loadBBoxWDeco.PtMin + loadBBoxWDeco.Height * Vector3D.ZAxis) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_X_P, transform), HalfAxis.Transform(HalfAxis.HAxis.AXIS_Y_P, transform) , new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Width) , analysisCasePallet.PalletFilmTopCovering)); film.DrawBegin(graphics); } #endregion #region Pallet corners // pallet corners : End if (analysisCasePallet.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i].DrawEnd(graphics); } } if (analysisCasePallet.HasPalletCornersTopX) { for (int i = 0; i < 2; ++i) { cornersTop[i].DrawEnd(graphics); } } if (analysisCasePallet.HasPalletCornersTopY) { for (int i = 2; i < 4; ++i) { cornersTop[i].DrawEnd(graphics); } } #endregion #region Pallet sleeves // ### pallet sleeve if (analysisCasePallet.HasPalletSleeve) { var ps = new PalletSleeve(0, loadBBox, analysisCasePallet.PalletSleeveColor); ps.DrawEnd(graphics); } #endregion #region Pallet Cap // ### pallet cap if (analysisCasePallet.HasPalletCap) { PalletCapProperties capProperties = analysisCasePallet.PalletCapProperties; BoxPosition bPosition = new BoxPosition(new Vector3D( 0.5 * (analysisCasePallet.PalletProperties.Length - capProperties.Length), 0.5 * (analysisCasePallet.PalletProperties.Width - capProperties.Width), loadBBox.PtMax.Z - capProperties.InsideHeight) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_X_P, transform) , HalfAxis.Transform(HalfAxis.HAxis.AXIS_Y_P, transform) ); Transform3D upTranslation = Transform3D.Translation(new Vector3D(0.0, 0.0, -1 != Solution.SelectedLayerIndex ? DistanceAboveSelectedLayer : 0.0)); PalletCap cap = new PalletCap(0, capProperties, bPosition.Transform(upTranslation)); cap.DrawEnd(graphics); } #endregion #region Pallet labels // ### pallet labels if (null != analysisCasePallet) { foreach (var pli in analysisCasePallet.PalletLabels) { var pl = new PalletLabel(++pickId, pli.PalletLabelProperties, pli.ToBoxPosition(loadBBox)); pl.DrawEnd(graphics); } } #endregion #region Strappers // ### strappers if (-1 == Solution.SelectedLayerIndex) { foreach (var sd in Solution.Strappers) { if (null == sd.Points && sd.Points.Count > 0) { var strapper = new Strapper( transform.transform(IntToAxis(sd.Strapper.Axis)), sd.Strapper.Width, sd.Strapper.Color, sd.Points.Select(p => transform.transform(p)).ToList()); strapper.DrawEnd(graphics); } } } #endregion #region Pallet film // pallet film : End if (analysisCasePallet.HasPalletFilm && null != film) { film.DrawEnd(graphics); } #endregion } else if (analysis is AnalysisPackableTruck analysisPackableTruck2) { Truck truck = new Truck(analysisPackableTruck2.TruckProperties); truck.DrawEnd(graphics); } else if (analysis is AnalysisPalletTruck analysisPalletTruck) { Truck truck = new Truck(analysisPalletTruck.TruckProperties); truck.DrawEnd(graphics); } // ### dimensions // dimensions should only be shown when no layer is selected if (graphics.ShowDimensions && (-1 == Solution.SelectedLayerIndex)) { graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol1), Color.Black, false)); graphics.AddDimensions(new DimensionCube(BoundingBoxDim(DimCasePalletSol2), Color.Red, true)); } // ### }
private void UpdateGrid() { try { // sanity check if (gridSolution.ColumnsCount < 2) { return; } // remove all existing rows gridSolution.Rows.Clear(); // *** IViews // captionHeader SourceGrid.Cells.Views.RowHeader captionHeader = new SourceGrid.Cells.Views.RowHeader(); DevAge.Drawing.VisualElements.RowHeader veHeaderCaption = new DevAge.Drawing.VisualElements.RowHeader(); veHeaderCaption.BackColor = Color.SteelBlue; veHeaderCaption.Border = DevAge.Drawing.RectangleBorder.NoBorder; captionHeader.Background = veHeaderCaption; captionHeader.ForeColor = Color.Black; captionHeader.Font = new Font("Arial", GridFontSize, FontStyle.Bold); captionHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; // viewRowHeader SourceGrid.Cells.Views.RowHeader viewRowHeader = new SourceGrid.Cells.Views.RowHeader(); DevAge.Drawing.VisualElements.RowHeader backHeader = new DevAge.Drawing.VisualElements.RowHeader { BackColor = Color.LightGray, Border = DevAge.Drawing.RectangleBorder.NoBorder }; viewRowHeader.Background = backHeader; viewRowHeader.ForeColor = Color.Black; viewRowHeader.Font = new Font("Arial", GridFontSize, FontStyle.Regular); // viewNormal CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); // *** SolutionLayered solution = _analysis.Solution as SolutionLayered; SourceGrid.Cells.RowHeader rowHeader; int iRow = -1; // pallet caption gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_PALLET) { ColumnSpan = 2, View = captionHeader }; gridSolution[iRow, 0] = rowHeader; // layer # gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_LAYERNUMBER) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(solution.LayerCount); // interlayer # if (solution.InterlayerCount > 0) { gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_INTERLAYERNUMBER); rowHeader.View = viewRowHeader; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(solution.InterlayerCount); } // *** Item # (Recursive count) Packable content = _analysis.Content; int itemCount = solution.ItemCount; int number = 1; do { itemCount *= number; gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(string.Format("{0} #", content.DetailedName)) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(itemCount); }while (null != content && content.InnerContent(ref content, ref number)); // *** // outer dimensions BBox3D bboxGlobal = solution.BBoxGlobal; // --- gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format(Resources.ID_OUTERDIMENSIONS, Environment.NewLine, UnitsManager.LengthUnitString)) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#} x {1:0.#} x {2:0.#}", bboxGlobal.Length, bboxGlobal.Width, bboxGlobal.Height)); // load dimensions BBox3D bboxLoad = solution.BBoxLoad; // --- gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format(Resources.ID_LOADDIMENSIONS, Environment.NewLine, UnitsManager.LengthUnitString)) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#} x {1:0.#} x {2:0.#}", bboxLoad.Length, bboxLoad.Width, bboxLoad.Height)); // net weight if (solution.HasNetWeight) { gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format(Resources.ID_NETWEIGHT_WU, UnitsManager.MassUnitString)); rowHeader.View = viewRowHeader; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.NetWeight)); } // load weight gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format(Resources.ID_LOADWEIGHT_WU, UnitsManager.MassUnitString)) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LoadWeight)); // total weight gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format(Resources.ID_TOTALWEIGHT_WU, UnitsManager.MassUnitString)) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.Weight)); // volume efficiency gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(Resources.ID_VOLUMEEFFICIENCY) { View = viewRowHeader }; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.VolumeEfficiency)); int noLayerTypesUsed = solution.NoLayerTypesUsed; // ### layers : begin for (int i = 0; i < solution.Layers.Count; ++i) { List <int> layerIndexes = solution.LayerTypeUsed(i); if (0 == layerIndexes.Count) { continue; } // layer caption gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(solution.LayerCaption(i)); rowHeader.ColumnSpan = 2; rowHeader.View = captionHeader; gridSolution[iRow, 0] = rowHeader; // *** Item # (recursive count) content = _analysis.Content; itemCount = solution.LayerBoxCount(i); number = 1; do { itemCount *= number; gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader( string.Format("{0} #", content.DetailedName)); rowHeader.View = viewRowHeader; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell(itemCount); }while (null != content && content.InnerContent(ref content, ref number)); // *** // layer weight gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader(string.Format(Resources.ID_WEIGHT_WU, UnitsManager.MassUnitString)); rowHeader.View = viewRowHeader; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LayerWeight(i))); // layer space gridSolution.Rows.Insert(++iRow); rowHeader = new SourceGrid.Cells.RowHeader("Spaces"); rowHeader.View = viewRowHeader; gridSolution[iRow, 0] = rowHeader; gridSolution[iRow, 1] = new SourceGrid.Cells.Cell( string.Format(CultureInfo.InvariantCulture, "{0:0.#}", solution.LayerMaximumSpace(i))); } // ### layers : end gridSolution.AutoSizeCells(); gridSolution.Columns.StretchToFit(); gridSolution.AutoStretchColumnsToFitWidth = true; gridSolution.Invalidate(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
public static void Export( Vector3D caseDim, double caseWeight, Vector3D palletDim, double palletWeight, double maxPalletHeight, List <BoxPosition> boxPositions, bool mirrorLength, bool mirrorWidth, List <bool> interlayers, ref byte[] fileBytes) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.LightGray, TapeWidth = new OptDouble(true, 50.0) }; boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet var palletProperties = new PalletProperties(null, "EUR2", palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.SetMaxHeight(new OptDouble(true, maxPalletHeight)); // layer var layer2D = new Layer2DBrickExp(caseDim, new Vector2D(palletDim.X, palletDim.Y), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(boxPositions); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.LightYellow)); analysis.AddSolution(layer2D, mirrorLength, mirrorWidth); SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { solutionItems[i].InterlayerIndex = ((i < interlayers.Count) && interlayers[i]) ? 0 : -1; } if (iCount < interlayers.Count && interlayers[iCount]) { analysis.PalletCapProperties = new PalletCapProperties( null, "palletCap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } // export var exporter = ExporterFactory.GetExporterByName("csv (TechnologyBSA)"); exporter.PositionCoordinateMode = Exporter.CoordinateMode.CM_COG; Stream stream = new MemoryStream(); exporter.Export(analysis, ref stream); // save stream to file using (var br = new BinaryReader(stream)) fileBytes = br.ReadBytes((int)stream.Length); }
public static void GenerateExport(Vector3D caseDim, double caseWeight, Bitmap bmpTexture, int palletIndex, double palletWeight, int layerNumber, List <BoxPositionIndexed> boxPositions, bool mirrorLength, bool mirrorWidth, List <bool> interlayers, string filePath, ref int caseCount, ref int layerCount, ref double weightLoad, ref double weightTotal, ref Vector3D bbLoad, ref Vector3D bbGlob ) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.Tan, TapeWidth = new OptDouble(true, 50.0) }; if (null != bmpTexture) { double ratio = (double)bmpTexture.Height / bmpTexture.Width; boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_N, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_P, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_N, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_P, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); } boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet Vector3D palletDim = PalletIndexToDim3D(palletIndex); var palletProperties = new PalletProperties(null, PalletIndexToPalletType(palletIndex), palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.OptMaxLayerNumber = layerNumber; // layer 2D var layer2D = new Layer2DBrickExpIndexed(caseDim, new Vector2D(), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(boxPositions); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.White)); analysis.AddSolution(layer2D, mirrorLength, mirrorWidth); // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { solutionItems[i].InterlayerIndex = ((i < interlayers.Count) && interlayers[i]) ? 0 : -1; } if (iCount < interlayers.Count && interlayers[iCount]) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.White); } layerCount = analysis.SolutionLay.LayerCount; caseCount = analysis.Solution.ItemCount; weightLoad = analysis.Solution.LoadWeight; weightTotal = analysis.Solution.Weight; bbGlob = analysis.Solution.BBoxGlobal.DimensionsVec; bbLoad = analysis.Solution.BBoxLoad.DimensionsVec; // export file var exporter = new ExporterGLB(); exporter.Export(analysis, filePath); }
public ViewerSolution(SolutionLayered solution) { Solution = solution; }
public static void GetSolution( Vector3D caseDim, double caseWeight, Bitmap bmpTexture, int palletIndex, double palletWeight, double maxPalletHeight, List <BoxPositionIndexed> boxPositions, bool mirrorLength, bool mirrorWidth, List <bool> interlayers, double angle, Size sz, ref byte[] imageBytes, ref int caseCount, ref int layerCount, ref double weightLoad, ref double weightTotal, ref Vector3D bbLoad, ref Vector3D bbGlob ) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.Tan, TapeWidth = new OptDouble(true, 50.0) }; if (null != bmpTexture) { double ratio = (double)bmpTexture.Height / bmpTexture.Width; boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_N, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_X_P, TexturePosition(caseDim.Y, caseDim.Z, ratio), TextureSize(caseDim.Y, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_N, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); boxProperties.AddTexture(HalfAxis.HAxis.AXIS_Y_P, TexturePosition(caseDim.X, caseDim.Z, ratio), TextureSize(caseDim.X, caseDim.Z, ratio), 0.0, bmpTexture); } boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet Vector3D palletDim = PalletIndexToDim3D(palletIndex); var palletProperties = new PalletProperties(null, PalletIndexToPalletType(palletIndex), palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.SetMaxHeight(new OptDouble(true, maxPalletHeight)); // layer 2D var layer2D = new Layer2DBrickExpIndexed(caseDim, new Vector2D(), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(boxPositions); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.LightYellow)); analysis.AddSolution(layer2D, mirrorLength, mirrorWidth); // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { solutionItems[i].InterlayerIndex = ((i < interlayers.Count) && interlayers[i]) ? 0 : -1; } if (iCount < interlayers.Count && interlayers[iCount]) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } layerCount = analysis.SolutionLay.LayerCount; caseCount = analysis.Solution.ItemCount; weightLoad = analysis.Solution.LoadWeight; weightTotal = analysis.Solution.Weight; bbGlob = analysis.Solution.BBoxGlobal.DimensionsVec; bbLoad = analysis.Solution.BBoxLoad.DimensionsVec; // generate image path Graphics3DImage graphics = new Graphics3DImage(sz) { BackgroundColor = Color.Transparent, FontSizeRatio = ConfigSettings.FontSizeRatio, ShowDimensions = true }; graphics.SetCameraPosition(10000.0, angle, 45.0); using (ViewerSolution sv = new ViewerSolution(analysis.SolutionLay)) sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); Bitmap bmp = graphics.Bitmap; ImageConverter converter = new ImageConverter(); imageBytes = (byte[])converter.ConvertTo(bmp, typeof(byte[])); }
public static void Export( Vector3D caseDim, double caseWeight, int palletIndex, double palletWeight, int noLayers, List <BoxPositionIndexed> listBoxPositionIndexed, bool mirrorLength, bool mirrorWidth, List <bool> interlayers, ref byte[] fileBytes, System.Drawing.Imaging.ImageFormat imageFormat, ref byte[] imageFileBytes) { SolutionLayered.SetSolver(new LayerSolver()); // case var boxProperties = new BoxProperties(null, caseDim.X, caseDim.Y, caseDim.Z) { TapeColor = Color.LightGray, TapeWidth = new OptDouble(true, 50.0) }; boxProperties.SetWeight(caseWeight); boxProperties.SetAllColors(Enumerable.Repeat(Color.Beige, 6).ToArray()); // pallet Vector3D palletDim = PalletIndexToDim3D(palletIndex); var palletProperties = new PalletProperties(null, PalletIndexToPalletType(palletIndex), palletDim.X, palletDim.Y, palletDim.Z) { Weight = palletWeight, Color = Color.Yellow }; // constraint set var constraintSet = new ConstraintSetCasePallet(); constraintSet.SetAllowedOrientations(new bool[] { false, false, true }); constraintSet.OptMaxLayerNumber = noLayers; // layer var layer2D = new Layer2DBrickExpIndexed(caseDim, new Vector2D(palletDim.X, palletDim.Y), "", HalfAxis.HAxis.AXIS_Z_P); layer2D.SetPositions(listBoxPositionIndexed); // analysis var analysis = new AnalysisCasePallet(boxProperties, palletProperties, constraintSet); analysis.AddInterlayer(new InterlayerProperties(null, "interlayer", "", palletDim.X, palletDim.Y, 1.0, 0.0, Color.LightYellow)); analysis.AddSolution(layer2D, mirrorLength, mirrorWidth); SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { solutionItems[i].InterlayerIndex = ((i < interlayers.Count) && interlayers[i]) ? 0 : -1; } if (iCount < interlayers.Count && interlayers[iCount]) { analysis.PalletCapProperties = new PalletCapProperties( null, "palletCap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } // export var exporter = ExporterFactory.GetExporterByName("csv (TechnologyBSA)"); exporter.PositionCoordinateMode = Exporter.CoordinateMode.CM_COG; Stream stream = new MemoryStream(); exporter.ExportIndexed(analysis, ref stream); // save stream to file using (var br = new BinaryReader(stream)) fileBytes = br.ReadBytes((int)stream.Length); // image var graphics = new Graphics3DImage(ConfigSettings.ExportImageSize) { CameraPosition = Graphics3D.Corner_0, ShowDimensions = ConfigSettings.ExportShowDimensions }; using (ViewerSolution sv = new ViewerSolution(analysis.SolutionLay)) sv.Draw(graphics, Transform3D.Identity); graphics.Flush(); imageFileBytes = ImageToByteArray(graphics.Bitmap, imageFormat); }