public override void Draw(Graphics3D graphics, Transform3D transform) { // clear list of picking box ClearPickingBoxes(); if (null == _solution) { return; } Analysis analysis = _solution.Analysis; AnalysisCasePallet analysisCasePallet = analysis as AnalysisCasePallet; AnalysisBoxCase analysisBoxCase = analysis as AnalysisBoxCase; AnalysisCylinderCase analysisCylinderCase = analysis as AnalysisCylinderCase; AnalysisCylinderPallet analysisCylinderPallet = analysis as AnalysisCylinderPallet; AnalysisPalletTruck analysisPalletTruck = analysis as AnalysisPalletTruck; AnalysisCaseTruck analysisCaseTruck = analysis as AnalysisCaseTruck; if (null != analysisCasePallet) { // ### draw pallet Pallet pallet = new Pallet(analysisCasePallet.PalletProperties); pallet.Draw(graphics, transform); } else if (null != analysisBoxCase) { // draw case (inside) Case case_ = new Case(analysisBoxCase.CaseProperties); case_.DrawInside(graphics, transform); } else if (null != analysisCylinderCase) { // ### draw case (inside) Case case_ = new Case(analysisCylinderCase.CaseProperties); case_.DrawInside(graphics, transform); } else if (null != analysisCylinderPallet) { // ### draw pallet Pallet pallet = new Pallet(analysisCylinderPallet.PalletProperties); pallet.Draw(graphics, transform); } else if (null != analysisPalletTruck) { // ### draw truck Truck truck = new Truck(analysisPalletTruck.TruckProperties); truck.DrawBegin(graphics); } else if (null != analysisCaseTruck) { // ### draw truck Truck truck = new Truck(analysisCaseTruck.TruckProperties); truck.DrawBegin(graphics); } // ### draw solution uint layerId = 0, pickId = 0; List <ILayer> layers = _solution.Layers; foreach (ILayer layer in layers) { BBox3D bbox = new BBox3D(); // ### layer of boxes Layer3DBox layerBox = layer as Layer3DBox; if (null != layerBox) { if (analysis.Content is LoadedPallet) { LoadedPallet loadedPallet = analysis.Content as LoadedPallet; BBox3D solBBox = loadedPallet.ParentAnalysis.Solution.BBoxGlobal; foreach (BoxPosition bPosition in layerBox) { bool simplified = false; if (simplified) { BoxProperties bProperties = new BoxProperties(null, solBBox.Dimensions); bProperties.SetColor(Color.Chocolate); Box b = new Box(pickId++, bProperties, bPosition.Transform(transform)); graphics.AddBox(b); bbox.Extend(b.BBox); } else { graphics.AddImage(loadedPallet.ParentAnalysis, solBBox.DimensionsVec, bPosition.Transform(transform)); } } } else { bool aboveSelectedLayer = (_solution.SelectedLayerIndex != -1) && (layerId > _solution.SelectedLayerIndex); Transform3D upTranslation = Transform3D.Translation(new Vector3D(0.0, 0.0, aboveSelectedLayer ? DistanceAboveSelectedLayer : 0.0)); foreach (BoxPosition bPosition in layerBox) { BoxPosition boxPositionModified = bPosition.Transform(transform * upTranslation); Box b = null; if (analysis.Content is PackProperties) { b = new Pack(pickId++, analysis.Content as PackProperties, boxPositionModified); } else { b = new Box(pickId++, analysis.Content as PackableBrick, boxPositionModified); } graphics.AddBox(b); bbox.Extend(b.BBox); } } } Layer3DCyl layerCyl = layer as Layer3DCyl; if (null != layerCyl) { foreach (Vector3D vPos in layerCyl) { Cylinder c = new Cylinder(pickId++, analysis.Content as CylinderProperties, new CylPosition(transform.transform(vPos), HalfAxis.HAxis.AXIS_Z_P)); graphics.AddCylinder(c); bbox.Extend(c.BBox); } } if (null != layerBox || null != layerCyl) { // add layer BBox AddPickingBox(bbox, layerId); // draw bounding box around selected layer if (layerId == _solution.SelectedLayerIndex) { DrawLayerBoundingBox(graphics, bbox); } ++layerId; } // ### interlayer if (layer is InterlayerPos interlayerPos) { InterlayerProperties interlayerProp = _solution.Interlayers[interlayerPos.TypeId]; if (null != interlayerProp) { bool aboveSelectedLayer = (_solution.SelectedLayerIndex != -1) && (layerId > _solution.SelectedLayerIndex); Transform3D upTranslation = Transform3D.Translation(new Vector3D(0.0, 0.0, aboveSelectedLayer ? DistanceAboveSelectedLayer : 0.0)); 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); Box box = new Box(pickId++, interlayerProp, bPosition.Transform(transform * upTranslation)); graphics.AddBox(box); bbox.Extend(box.BBox); } } } BBox3D loadBBox = _solution.BBoxLoad; BBox3D loadBBoxWDeco = _solution.BBoxLoadWDeco; if (null != 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 }; // corners if (analysisCasePallet.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i] = new Corner(0, analysisCasePallet.PalletCornerProperties); corners[i].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 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), 0.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), 0.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), 0.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), 0.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) , UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1))); film.DrawBegin(graphics); } #endregion #region Pallet corners // pallet corners : End if (analysisCasePallet.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i].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 film // pallet film : End if (analysisCasePallet.HasPalletFilm && null != film) { film.DrawEnd(graphics); } #endregion } if (null != analysisPalletTruck) { Truck truck = new Truck(analysisPalletTruck.TruckProperties); truck.DrawEnd(graphics); } else if (null != analysisCaseTruck) { Truck truck = new Truck(analysisCaseTruck.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)); } }
public static bool GetSolutionByLayer( PackableBrick packableProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties , ConstraintSetCasePallet constraintSet , LayerDesc layerDesc , Vector3D cameraPosition, bool showCotations, float fontSizeRatio, Size sz , ref int layerCount, ref int caseCount, ref int interlayerCount , ref double weightTotal, ref double weightLoad, ref double?weightNet , ref Vector3D bbLoad, ref Vector3D bbGlob , ref double volumeEfficency, ref double?weightEfficiency , ref string palletMapPhrase , ref byte[] imageBytes , ref string[] errors ) { List <string> lErrors = new List <string>(); try { if (!packableProperties.FitsIn(palletProperties, constraintSet)) { lErrors.Add($"{packableProperties.Name} does not fit in {palletProperties.Name} with given constraint set!"); return(false); } SolutionLayered.SetSolver(new LayerSolver()); var analysis = new AnalysisCasePallet(packableProperties, palletProperties, constraintSet); analysis.AddSolution(new List <LayerDesc>() { layerDesc }); layerCount = analysis.SolutionLay.LayerCount; caseCount = analysis.Solution.ItemCount; interlayerCount = analysis.SolutionLay.LayerCount; weightLoad = analysis.Solution.LoadWeight; weightTotal = analysis.Solution.Weight; OptDouble optNetWeight = analysis.Solution.NetWeight; weightNet = optNetWeight.Activated ? optNetWeight.Value : (double?)null; bbGlob = analysis.Solution.BBoxGlobal.DimensionsVec; bbLoad = analysis.Solution.BBoxLoad.DimensionsVec; volumeEfficency = analysis.Solution.VolumeEfficiency; weightEfficiency = null; if (analysis.Solution.WeightEfficiency.Activated) { weightEfficiency = analysis.Solution.WeightEfficiency.Value; } // generate image path Graphics3DImage graphics = new Graphics3DImage(sz) { FontSizeRatio = fontSizeRatio, CameraPosition = cameraPosition, ShowDimensions = showCotations }; 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[])); // pallet phrase palletMapPhrase = BuildPalletMapPhrase(analysis.SolutionLay); } catch (Exception ex) { lErrors.Add(ex.Message); } errors = lErrors.ToArray(); return(0 == lErrors.Count); }
public override void Draw(Graphics3D graphics, bool showDimensions) { if (null == _solution) { return; } AnalysisCasePallet analysisCasePallet = _solution.Analysis as AnalysisCasePallet; // ### draw pallet Pallet pallet = new Pallet(analysisCasePallet.PalletProperties); pallet.Draw(graphics, Transform3D.Identity); // ### draw solution uint layerId = 0, pickId = 0; List <ILayer> layers = _solution.Layers; foreach (ILayer layer in layers) { // ### layer of boxes BoxLayer blayer = layer as BoxLayer; if (null != blayer) { BBox3D bbox = new BBox3D(); foreach (BoxPosition bPosition in blayer) { Box b = new Box(pickId++, analysisCasePallet.BProperties, bPosition); graphics.AddBox(b); bbox.Extend(b.BBox); } // add layer BBox AddPickingBox(bbox, layerId); // draw bounding box around selected layer if (layerId == _solution.SelectedLayerIndex) { DrawLayerBoundingBox(graphics, bbox); } ++layerId; } // ### intetrlayer InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos) { InterlayerProperties interlayerProp = _solution.Interlayers[interlayerPos.TypeId];//analysisCasePallet.Interlayer(interlayerPos.TypeId); if (null != interlayerProp) { Box box = new Box(pickId++, interlayerProp); box.Position = new Vector3D( 0.5 * (analysisCasePallet.PalletProperties.Length - interlayerProp.Length) , 0.5 * (analysisCasePallet.PalletProperties.Width - interlayerProp.Width) , interlayerPos.ZLow ); graphics.AddBox(box); } } } BBox3D loadBBox = _solution.BBoxLoad; BBox3D loadBBoxWDeco = _solution.BBoxLoadWDeco; #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 }; // corners if (analysisCasePallet.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i] = new Corner(0, analysisCasePallet.PalletCornerProperties); corners[i].Height = Math.Min(analysisCasePallet.PalletCornerProperties.Length, loadBBox.Height); corners[i].SetPosition(cornerPositions[i], lAxes[i], wAxes[i]); corners[i].DrawBegin(graphics); } } } #endregion #region Pallet cap #endregion #region Pallet film // ### pallet film Film film = null; if (analysisCasePallet.HasPalletFilm) { PalletFilmProperties palletFilmProperties = analysisCasePallet.PalletFilmProperties; film = new Film( palletFilmProperties.Color, palletFilmProperties.UseTransparency, palletFilmProperties.UseHatching, palletFilmProperties.HatchSpacing, palletFilmProperties.HatchAngle); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Length * Vector3D.XAxis + loadBBoxWDeco.Width * Vector3D.YAxis, HalfAxis.HAxis.AXIS_X_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Width * Vector3D.YAxis, HalfAxis.HAxis.AXIS_Y_N, HalfAxis.HAxis.AXIS_Z_P, new Vector2D(loadBBoxWDeco.Width, loadBBoxWDeco.Height), 0.0)); film.AddRectangle(new FilmRectangle(loadBBoxWDeco.PtMin + loadBBoxWDeco.Height * Vector3D.ZAxis, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, new Vector2D(loadBBoxWDeco.Length, loadBBoxWDeco.Width), UnitsManager.ConvertLengthFrom(200.0, UnitsManager.UnitSystem.UNIT_METRIC1))); film.DrawBegin(graphics); } #endregion // ### dimensions if (showDimensions) { graphics.AddDimensions( new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol1) , Color.Black, false)); graphics.AddDimensions( new DimensionCube(BoundingBoxDim(Properties.Settings.Default.DimCasePalletSol2) , Color.Red, true)); } #region Pallet corners // pallet corners : End if (analysisCasePallet.HasPalletCorners) { for (int i = 0; i < 4; ++i) { corners[i].DrawEnd(graphics); } } #endregion #region Pallet Cap // ### pallet cap if (analysisCasePallet.HasPalletCap) { PalletCapProperties capProperties = analysisCasePallet.PalletCapProperties; Vector3D pos = new Vector3D( 0.5 * (analysisCasePallet.PalletProperties.Length - capProperties.Length), 0.5 * (analysisCasePallet.PalletProperties.Width - capProperties.Width), loadBBox.PtMax.Z - capProperties.InsideHeight); PalletCap cap = new PalletCap(0, capProperties, pos); cap.DrawEnd(graphics); } #endregion #region Pallet film // pallet film : End if (analysisCasePallet.HasPalletFilm) { film.DrawEnd(graphics); } #endregion }
public DockContentAnalysisCasePallet(IDocument document, AnalysisCasePallet analysis) : base(document, analysis) { InitializeComponent(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // --- initialize drawing container graphCtrlSolution.Viewer = new ViewerSolution(_solution); graphCtrlSolution.Invalidate(); graphCtrlSolution.VolumeSelected += OnLayerSelected; // --- // --- initialize layer controls UpdateControls(); uCtrlMaxPalletHeight.Value = _analysis.ConstraintSet.OptMaxHeight.Value; uCtrlOptMaximumWeight.Value = _analysis.ConstraintSet.OptMaxWeight; uCtrlOptMaxNumber.Value = _analysis.ConstraintSet.OptMaxNumber; uCtrlMaxPalletHeight.ValueChanged += new UCtrlDouble.ValueChangedDelegate(OnCriterionChanged); uCtrlOptMaximumWeight.ValueChanged += new UCtrlOptDouble.ValueChangedDelegate(OnCriterionChanged); uCtrlOptMaxNumber.ValueChanged += new UCtrlOptInt.ValueChangedDelegate(OnCriterionChanged); chkbPalletCap.CheckedChanged += new EventHandler(OnCriterionChanged); chkbPalletFilm.CheckedChanged += new EventHandler(OnCriterionChanged); chkbPalletSleeve.CheckedChanged += new EventHandler(OnCriterionChanged); chkbPalletCornersTopX.CheckedChanged += new EventHandler(OnCriterionChanged); chkbPalletCornersTopY.CheckedChanged += new EventHandler(OnCriterionChanged); chkbPalletSleeve.CheckedChanged += new EventHandler(OnCriterionChanged); AnalysisCasePallet analysisCasePallet = _analysis as AnalysisCasePallet; ComboBoxHelpers.FillCombo(PalletCorners, cbPalletCorners, analysisCasePallet?.PalletCornerProperties); chkbPalletCorners.Enabled = (cbPalletCorners.Items.Count > 0); ComboBoxHelpers.FillCombo(PalletCorners, cbPalletCornersTop, analysisCasePallet?.PalletCornerTopProperties); chkbPalletCornersTopX.Enabled = (cbPalletCornersTop.Items.Count > 0); ComboBoxHelpers.FillCombo(PalletCaps, cbPalletCap, analysisCasePallet?.PalletCapProperties); chkbPalletCap.Enabled = (cbPalletCap.Items.Count > 0); ComboBoxHelpers.FillCombo(PalletFilms, cbPalletFilm, analysisCasePallet?.PalletFilmProperties); chkbPalletFilm.Enabled = (cbPalletFilm.Items.Count > 0); ComboBoxHelpers.FillCombo(PalletLabels, cbPalletLabels, null); bnAdd.Enabled = (cbPalletLabels.Items.Count > 0); chkbPalletCornersTopX.Enabled = (cbPalletCornersTop.Items.Count > 0); chkbPalletCornersTopY.Enabled = (cbPalletCornersTop.Items.Count > 0); if (null != analysisCasePallet) { chkbPalletCorners.Checked = null != analysisCasePallet.PalletCornerProperties; chkbPalletCornersTopX.Checked = null != analysisCasePallet.PalletCornerTopProperties && analysisCasePallet.PalletCornersTopX; chkbPalletCornersTopY.Checked = null != analysisCasePallet.PalletCornerTopProperties && analysisCasePallet.PalletCornersTopY; chkbPalletCap.Checked = null != analysisCasePallet.PalletCapProperties; chkbPalletFilm.Checked = null != analysisCasePallet.PalletFilmProperties; ctrlStrapperSet.StrapperSet = analysisCasePallet.StrapperSet; PalletFilmTopCovering = analysisCasePallet.PalletFilmTopCovering; HasPalletSleeve = analysisCasePallet.HasPalletSleeve; PalletSleeveColor = analysisCasePallet.PalletSleeveColor; } // --- // --- initialize grid control FillGrid(); UpdateGrid(); FillGridLabel(); // --- // handling row change in label grids _gripLabelsControllerEvent.ValueChanged += new EventHandler(OnPalletProtectionChanged); _initialized = true; }
public static void Export( Vector3D caseDim, double caseWeight, Vector3D palletDim, double palletWeight, double maxPalletHeight, List <BoxPosition> boxPositions, bool alternateLayer, bool interlayerBottom, bool interlayerIntermediate, bool interlayerTop, 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, alternateLayer); if (interlayerTop) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { bool hasInterlayer = (i == 0 && interlayerBottom) || (i != 0 && interlayerIntermediate); solutionItems[i].InterlayerIndex = hasInterlayer ? 0 : -1; } // export Exporter exporter = ExporterFactory.GetExporterByName("csv (TechnologyBSA)"); exporter.PositionCoordinateMode = Exporter.CoordinateMode.CM_COG; Stream stream = new MemoryStream(); exporter.Export(analysis, ref stream); using (BinaryReader br = new BinaryReader(stream)) fileBytes = br.ReadBytes((int)stream.Length); }
public static void GetSolution( Vector3D caseDim, double caseWeight, Vector3D palletDim, double palletWeight, double maxPalletHeight, List <BoxPosition> boxPositions, bool alternateLayer, bool interlayerBottom, bool interlayerIntermediate, bool interlayerTop, double angle, 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.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 2D var layer2D = new Layer2DBrickExp(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, alternateLayer); if (interlayerTop) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { bool hasInterlayer = (i == 0 && interlayerBottom) || (i != 0 && interlayerIntermediate); solutionItems[i].InterlayerIndex = hasInterlayer ? 0 : -1; } 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(new Size(500, 500)) { 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[])); }
private void FillGrid() { try { // remove all existing rows gridSolutions.Rows.Clear(); // *** IViews // captionHeader SourceGrid.Cells.Views.RowHeader captionHeader = new SourceGrid.Cells.Views.RowHeader(); DevAge.Drawing.VisualElements.RowHeader veHeaderCaption = new DevAge.Drawing.VisualElements.RowHeader() { BackColor = Color.SteelBlue, 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.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader(); DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader() { BackColor = Color.LightGray, Border = DevAge.Drawing.RectangleBorder.NoBorder }; viewColumnHeader.Background = backHeader; viewColumnHeader.ForeColor = Color.Black; viewColumnHeader.Font = new Font("Arial", GridFontSize, FontStyle.Regular); viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None; // viewNormal CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White); // *** // set first row gridSolutions.BorderStyle = BorderStyle.FixedSingle; gridSolutions.ColumnsCount = 7; gridSolutions.FixedRows = 1; gridSolutions.Rows.Insert(0); // header int iCol = 0; SourceGrid.Cells.ColumnHeader columnHeader; // A1xA2xA3 columnHeader = new SourceGrid.Cells.ColumnHeader("A1 x A2 x A3") { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // dimensions columnHeader = new SourceGrid.Cells.ColumnHeader( string.Format(Properties.Resources.ID_DIMENSIONS, UnitsManager.LengthUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // weight columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Properties.Resources.ID_WEIGHT_WU, UnitsManager.MassUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // #packs columnHeader = new SourceGrid.Cells.ColumnHeader("#") { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // weight columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Properties.Resources.ID_PALLETWEIGHT, UnitsManager.MassUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // efficiency columnHeader = new SourceGrid.Cells.ColumnHeader(Properties.Resources.ID_EFFICIENCYPERCENTAGE) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; // maximum space columnHeader = new SourceGrid.Cells.ColumnHeader(string.Format(Resources.ID_MAXIMUMSPACE, UnitsManager.LengthUnitString)) { AutomaticSortEnabled = false, View = viewColumnHeader }; gridSolutions[0, iCol++] = columnHeader; int iRow = 0; foreach (AnalysisLayered analysis in _analyses) { AnalysisCasePallet analysisCasePallet = analysis as AnalysisCasePallet; PackProperties pack = analysisCasePallet.Content as PackProperties; int layerCount = analysisCasePallet.SolutionLay.Layers.Count; if (layerCount < 1) { continue; } int packPerLayerCount = analysisCasePallet.SolutionLay.Layers[0].BoxCount; int itemCount = analysisCasePallet.Solution.ItemCount; double palletWeight = analysisCasePallet.Solution.Weight; double volumeEfficiency = analysisCasePallet.Solution.VolumeEfficiency; double maximumSpace = analysisCasePallet.SolutionLay.LayerCount > 0 ? analysisCasePallet.SolutionLay.LayerMaximumSpace(0) : 0; gridSolutions.Rows.Insert(++iRow); iCol = 0; gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0} x {1} x {2}", pack.Arrangement.Length, pack.Arrangement.Width, pack.Arrangement.Height)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0:0.#} x {1:0.#} x {2:0.#}", pack.OuterDimensions.X, pack.OuterDimensions.Y, pack.OuterDimensions.Z)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0:0.###}", pack.Weight)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0} = {1} x {2}", itemCount, packPerLayerCount, layerCount)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0:0.###}", palletWeight)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", volumeEfficiency)); gridSolutions[iRow, iCol++] = new SourceGrid.Cells.Cell(string.Format("{0:0.#}", maximumSpace)); } gridSolutions.AutoStretchColumnsToFitWidth = true; gridSolutions.AutoSizeCells(); gridSolutions.Columns.StretchToFit(); // select first solution if (gridSolutions.RowsCount > 1) { gridSolutions.Selection.SelectRow(1, true); } else { // grid empty -> clear drawing _selectedAnalysis = null; graphCtrlPack.Invalidate(); graphCtrlSolution.Invalidate(); } } catch (Exception ex) { _log.Error(ex.Message); } }
public static void GenerateExport(Vector3D caseDim, double caseWeight, Bitmap bmpTexture, Vector3D palletDim, double palletWeight, double maxPalletHeight, List <BoxPosition> boxPositions, bool mirrorLength, bool mirrorWidth, bool interlayerBottom, bool interlayerIntermediate, bool interlayerTop, 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 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 2D var layer2D = new Layer2DBrickExp(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); if (interlayerTop) { analysis.PalletCapProperties = new PalletCapProperties(null, "palletcap", "", palletDim.X, palletDim.Y, 1, palletDim.X, palletDim.Y, 0.0, 0.0, Color.LightYellow); } // solution SolutionLayered sol = analysis.SolutionLay; var solutionItems = sol.SolutionItems; int iCount = solutionItems.Count; for (int i = 0; i < iCount; ++i) { bool hasInterlayer = (i == 0 && interlayerBottom) || (i != 0 && interlayerIntermediate); solutionItems[i].InterlayerIndex = hasInterlayer ? 0 : -1; } 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 as AnalysisLayered, filePath); }
public List <AnalysisLayered> BuildAnalyses(bool allowMultipleLayerOrientations) { var analyses = new List <AnalysisLayered>(); var constraintSetCasePallet = ConstraintSet as ConstraintSetCasePallet; if (null == constraintSetCasePallet) { return(analyses); } Vector2D overhang = constraintSetCasePallet.Overhang; if (allowMultipleLayerOrientations) { var listLayerEncap = new List <KeyValuePair <LayerEncap, int> >(); LayerSolver.GetBestCombination( Packable.OuterDimensions, PalletProperties.GetStackingDimensions(ConstraintSet), ConstraintSet, ref listLayerEncap); SolutionLayered.SetSolver(new LayerSolver()); var analysis = new AnalysisCasePallet(Packable, PalletProperties, ConstraintSet); analysis.AddSolution(listLayerEncap); // 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 , new Vector2D(PalletProperties.Length + 2.0 * overhang.X, PalletProperties.Width + 2.0 * overhang.Y) , PalletProperties.Height , constraintSetCasePallet , true ); SolutionLayered.SetSolver(solver); // loop on layers foreach (Layer2DBrickImp layer in layers) { var layerDescs = new List <LayerDesc> { layer.LayerDescriptor }; var analysis = new AnalysisCasePallet(Packable, PalletProperties, ConstraintSet); analysis.AddSolution(layerDescs); // only add analysis if it has a valid solution if (analysis.Solution.ItemCount > 0) { analyses.Add(analysis); } } } return(analyses); }
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, int layerDesignMode, 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, layerDesignMode, 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); }
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); }
private int ToIconIndex(ItemBase item) { if (item is AnalysisCasePallet) { AnalysisCasePallet analysisCasePallet = item as AnalysisCasePallet; Packable content = analysisCasePallet.Content; if (content is BoxProperties) { return(14); } else if (content is BundleProperties) { return(15); } else if (content is PackProperties) { return(21); } else { return(0); } } else if (item is AnalysisBoxCase) { return(17); } else if (item is AnalysisPalletTruck) { return(16); } else if (item is AnalysisCaseTruck) { return(16); } else if (item is AnalysisCylinderPallet) { return(19); } else if (item is AnalysisCylinderCase) { return(17); } else if (item is HAnalysisPallet) { return(14); } else if (item is HAnalysisCase) { return(17); } else if (item is HAnalysisTruck) { return(16); } else { _log.Error("Unexpected analysis type"); return(0); } }