public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) { throw new Exception("box, pallet, interlayer do not belong to the same document"); } if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) { throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); } // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) throw new Exception("box, pallet, interlayer do not belong to the same document"); if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
public PalletSolutionDesc(PalletSolutionDatabase db, CasePalletSolution sol, string friendlyName) { BoxProperties boxProperties = sol.Analysis.BProperties as BoxProperties; PalletProperties palletProperties = sol.Analysis.PalletProperties; PalletConstraintSet constraintSet = sol.Analysis.ConstraintSet; _guid = Guid.NewGuid(); _friendlyName = friendlyName; _key = new PalletSolutionKey( palletProperties.Length, palletProperties.Width, constraintSet.MaximumHeight , constraintSet.OverhangX, constraintSet.OverhangY); _caseDimensions[0] = boxProperties.Length; _caseDimensions[1] = boxProperties.Width; _caseDimensions[2] = boxProperties.Height; _insideCaseDimensions[0] = boxProperties.InsideLength; _insideCaseDimensions[1] = boxProperties.InsideWidth; _insideCaseDimensions[2] = boxProperties.InsideHeight; _caseWeight = boxProperties.Weight; _palletWeight = palletProperties.Weight; _caseOrientation = sol.CaseOrientation; _caseCount = sol.CaseCount; _parentDB = db; }
public Pallet(PalletProperties palletProperties) { _length = palletProperties.Length; _width = palletProperties.Width; _height = palletProperties.Height; _color = palletProperties.Color; _typeName = palletProperties.TypeName; }
public CaseOptimAnalysis( BProperties boxProperties , PalletProperties palletProperties , PalletConstraintSet palletConstraintSet , CaseOptimConstraintSet caseOptimConstraintSet) : base(boxProperties.ParentDocument) { }
public void ProcessAnalysis(PackPalletAnalysis analysis) { _packProperties = analysis.PackProperties; _palletProperties = analysis.PalletProperties; _interlayerProperties = analysis.InterlayerProperties; _constraintSet = analysis.ConstraintSet; analysis.Solutions = GenerateSolutions(); }
public HCylinderPalletAnalysis( CylinderProperties cylProperties, PalletProperties palletProperties, HCylinderPalletConstraintSet constraintSet) : base(cylProperties.ParentDocument) { CylinderProperties = cylProperties; PalletProperties = palletProperties; _constraintSet = constraintSet; }
public CaseOptimizer( BoxProperties boxProperties , PalletProperties palletProperties , PalletConstraintSet palletContraintSet , CaseOptimConstraintSet caseOptimConstraintSet) { _boxProperties = boxProperties; _palletProperties = palletProperties; _palletConstraintSet = palletContraintSet; _caseOptimConstraintSet = caseOptimConstraintSet; }
public void ProcessAnalysis(CylinderPalletAnalysis analysis) { _cylProperties = analysis.CylinderProperties; _palletProperties = analysis.PalletProperties; _interlayerProperties = analysis.InterlayerProperties; _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip; _constraintSet = analysis.ConstraintSet; if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); analysis.Solutions = GenerateSolutions(); }
static void Main(string[] args) { // define box properties BoxProperties boxProperties = new BoxProperties(null, 120.0, 100.0, 70.0); // define pallet properties PalletProperties palletProperties = new PalletProperties(null, "Block", 1200, 1000, 150); // define pallet constraintSet CasePalletConstraintSet constraintSet = new CasePalletConstraintSet(); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true); constraintSet.SetAllowedPattern("Column"); constraintSet.SetAllowedPattern("Diagonale"); constraintSet.SetAllowedPattern("Interlocked"); constraintSet.SetAllowedPattern("Trilock"); constraintSet.SetAllowedPattern("Spirale"); constraintSet.AllowAlignedLayers = true; constraintSet.AllowAlternateLayers = true; constraintSet.MaximumHeight = 2000; constraintSet.MaximumNumberOfItems = 2000; constraintSet.UseMaximumHeight = true; constraintSet.UseMaximumPalletWeight = false; constraintSet.UseMaximumWeightOnBox = false; Console.WriteLine("=== Constraint set ==="); Console.WriteLine(constraintSet.ToString()); // define case optim constraintSet CaseOptimConstraintSet caseOptimConstraintSet = new CaseOptimConstraintSet( new int[3]{2, 2, 4} , 4.0, 0.01 , new Vector3D(30.0, 30.0, 70.0) , new Vector3D(500.0, 500.0, 500.0) , false ); CaseOptimizer caseOptimizer = new CaseOptimizer(boxProperties, palletProperties, constraintSet, caseOptimConstraintSet); // get all valid case definitions foreach (CaseDefinition caseDefinition in caseOptimizer.CaseDefinitions(48)) Console.WriteLine(caseDefinition.ToString() + caseDefinition.OuterDimensions(boxProperties, caseOptimConstraintSet)); // build list of solutions List<CaseOptimSolution> caseOptimSolutions = caseOptimizer.CaseOptimSolutions(48); foreach (CaseOptimSolution caseOptimSolution in caseOptimSolutions) Console.WriteLine(caseOptimSolution.ToString()); }
public PackPalletAnalysis( PackProperties packProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, PackPalletConstraintSet constraintSet) : base(packProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) throw new Exception("box, pallet, interlayer do not belong to the same document"); // setting members this.PackProperties = packProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.ConstraintSet = constraintSet; }
public CylinderPalletAnalysis( CylinderProperties cylProperties , PalletProperties palletProperties , InterlayerProperties interlayerProperties , InterlayerProperties interlayerPropertiesAntiSlip , CylinderPalletConstraintSet constraintSet) : base(cylProperties.ParentDocument) { // setting members CylinderProperties = cylProperties; PalletProperties = palletProperties; InterlayerProperties = interlayerProperties; InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; _constraintSet = constraintSet; // has interlayer ? _constraintSet.HasInterlayer = null != interlayerProperties; _constraintSet.HasInterlayerAntiSlip = null != interlayerPropertiesAntiSlip; }
public PackPalletAnalysis( PackProperties packProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, PackPalletConstraintSet constraintSet) : base(packProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) { throw new Exception("box, pallet, interlayer do not belong to the same document"); } // setting members this.PackProperties = packProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.ConstraintSet = constraintSet; }
/// <summary> /// Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result) /// </summary> public static void Draw(Graphics3D graphics , CasePalletSolution solution , BoxProperties boxProperties, InterlayerProperties interlayerProperties, PalletProperties palletProperties) { // draw pallet Pallet pallet = new Pallet(palletProperties); pallet.Draw(graphics, Transform3D.Identity); // draw solution uint pickId = 0; foreach (ILayer layer in solution) { BoxLayer blayer = layer as BoxLayer; if (null != blayer) { foreach (BoxPosition bPosition in blayer) graphics.AddBox(new Box(pickId++, boxProperties, bPosition)); } InterlayerPos interlayerPos = layer as InterlayerPos; if (null != interlayerPos && null != interlayerProperties) { Box box = new Box(pickId++, interlayerProperties); // set position box.Position = new Vector3D( 0.5 * (palletProperties.Length - interlayerProperties.Length) , 0.5 * (palletProperties.Width - interlayerProperties.Width) , interlayerPos.ZLow); // draw graphics.AddBox(box); } } // always show dimensions BoxLayer bLayer = solution[solution.Count - 1] as BoxLayer; double palletHeight = solution[solution.Count - 1].ZLow + (null != bLayer ? bLayer.Thickness(boxProperties) : 0.0); // show dimensions graphics.AddDimensions(new DimensionCube(solution.BoundingBox, Color.Black, false)); graphics.AddDimensions(new DimensionCube(solution.LoadBoundingBox, Color.Red, true)); }
public FormNewPallet(Document document, PalletProperties palletProperties) { InitializeComponent(); // set unit labels UnitsManager.AdaptUnitLabels(this); // save document reference _document = document; _palletProperties = palletProperties; // initialize type combo cbType.Items.AddRange(PalletData.TypeNames); // set selected item PalletTypeName = _palletProperties.TypeName; // set caption text Text = string.Format(Resources.ID_PALLETCAPTIONEDIT, _palletProperties.Name); // initialize data tbName.Text = _palletProperties.Name; tbDescription.Text = _palletProperties.Description; PalletLength = _palletProperties.Length; PalletWidth = _palletProperties.Width; PalletHeight = _palletProperties.Height; Weight = _palletProperties.Weight; PalletColor = _palletProperties.Color; }
internal PalletProperties ToPallet(DataPallet dtPallet) { PalletProperties palletProperties = new PalletProperties(null, dtPallet.TypeName , dtPallet.Dimensions[0], dtPallet.Dimensions[1], dtPallet.Dimensions[2] ); palletProperties.Name = dtPallet.Name; palletProperties.Description = dtPallet.Description; return palletProperties; }
public PalletAnalysisCylinder(CylinderProperties cylProperties, PalletProperties palletProperties) : base(cylProperties.ParentDocument) { }
private void cbPallet_SelectedIndexChanged(object sender, EventArgs e) { if (-1 == cbPallet.SelectedIndex) return; PalletItem item = cbPallet.Items[cbPallet.SelectedIndex] as PalletItem; _palletProperties = item.Item; // update pallet image graphCtrlPallet.Invalidate(); }
private static PalletProperties LoadPalletById(Document doc, List<pallet> listPallet, string sid) { pallet palletItem = listPallet.Find(delegate(pallet p) { return p.id == sid; }); if (null == palletItem) return null; else { // dimensions double[] dimensions = palletItem.dimensions.ToArray(); // type string typeName = string.Empty; switch (palletItem.type) { case palletType.BLOCK: typeName = "BLOCK"; break; case palletType.EUR: typeName = "EUR"; break; case palletType.EUR2: typeName = "EUR2"; break; case palletType.EUR3: typeName = "EUR3"; break; case palletType.EUR6: typeName = "EUR6"; break; case palletType.GMA: typeName = "GMA"; break; case palletType.STANDARD_UK: typeName = "STANDARD_UK"; break; default: throw new Exception("Pallet with id = {0} has an unknown pallet type"); } // instantiate pallet properties PalletProperties palletProperties = new PalletProperties(doc, typeName, dimensions[0], dimensions[1], dimensions[2]); // name palletProperties.Name = palletItem.name; // description palletProperties.Description = palletItem.description; // color palletProperties.Color = System.Drawing.Color.FromArgb((int)palletItem.color[0], (int)palletItem.color[1], (int)palletItem.color[2], (int)palletItem.color[3]); // weight palletProperties.Weight = palletItem.weight; // insert in list if (null != doc) doc.AddType(palletProperties); return palletProperties; } }
public PalletItem(PalletProperties palletProperties) { _palletProperties = palletProperties; }
private Layer GenerateBestLayer( BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties, PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis) { Layer bestLayer = null; // loop through all patterns foreach (LayerPattern pattern in _patterns) { // is pattern allowed if (!_constraintSet.AllowPattern(pattern.Name)) continue; // direction 1 Layer layer1 = new Layer(bProperties, palletProperties, cornerProperties, constraintSet, hAxis); double actualLength = 0.0, actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer1, out actualLength, out actualWidth); pattern.GenerateLayer(layer1, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer1.Count) bestLayer = layer1; // direction 2 (opposite) Layer layer2 = new Layer(bProperties, palletProperties, cornerProperties, constraintSet, HalfAxis.Opposite(hAxis)); actualLength = 0.0; actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer2, out actualLength, out actualWidth); pattern.GenerateLayer(layer2, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer2.Count) bestLayer = layer2; } return bestLayer; }
public PalletProperties CreateNewPallet(PalletProperties palletProp) { PalletProperties palletPropClone = new PalletProperties(this, palletProp.TypeName, palletProp.Length, palletProp.Width, palletProp.Height); palletPropClone.Name = palletProp.Name; palletPropClone.Description = palletProp.Description; palletPropClone.Weight = palletProp.Weight; palletPropClone.Color = palletProp.Color; palletPropClone.AdmissibleLoadWeight = palletProp.AdmissibleLoadWeight; // insert in list _typeList.Add(palletPropClone); // notify listeners NotifyOnNewTypeCreated(palletPropClone); Modify(); return palletPropClone; }
public PackPalletAnalysis CreateNewPackPalletAnalysis( string name, string description , PackProperties pack, PalletProperties pallet , InterlayerProperties interlayer , PackPalletConstraintSet constraintSet , List<PackPalletSolution> solutions) { PackPalletAnalysis analysis = new PackPalletAnalysis( pack , pallet , interlayer , constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _packPalletAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewPackPalletAnalysisCreated(analysis); // set solution selected if it is unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
public PalletProperties CreateNewPallet( string name, string description , string typeName , double length, double width, double height , double weight) { PalletProperties palletProperties = new PalletProperties(this, typeName, length, width, height); palletProperties.Name = name; palletProperties.Description = description; palletProperties.Weight = weight; // insert in list _typeList.Add(palletProperties); // notify listeners NotifyOnNewTypeCreated(palletProperties); Modify(); return palletProperties; }
public PackPalletAnalysis CreateNewPackPalletAnalysis( string name, string description , PackProperties pack, PalletProperties pallet , InterlayerProperties interlayer , PackPalletConstraintSet constraintSet , IPackPalletAnalysisSolver solver) { PackPalletAnalysis analysis = new PackPalletAnalysis( pack , pallet , interlayer , constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _packPalletAnalyses.Add(analysis); // compute analysis solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _packPalletAnalyses.Remove(analysis); Modify(); return null; } // notify listeners NotifyOnNewPackPalletAnalysisCreated(analysis); Modify(); return analysis; }
/// <summary> /// Creates a new cylinder/pallet analysis without generating solutions /// </summary> /// <param name="name">Name</param> /// <param name="description">Description</param> /// <param name="cylinder">Cylinder</param> /// <param name="pallet">Pallet</param> /// <param name="interlayer">Interlayer or null</param> /// <param name="constraintSet">Cylinder/pallet analysis constraint set</param> /// <param name="solutions">Solutions</param> /// <returns>Cylinder/pallet analysis</returns> public HCylinderPalletAnalysis CreateNewHCylinderPalletAnalysis( string name, string description , CylinderProperties cylinder, PalletProperties pallet , HCylinderPalletConstraintSet constraintSet , List<HCylinderPalletSolution> solutions) { HCylinderPalletAnalysis analysis = new HCylinderPalletAnalysis(cylinder, pallet, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _hCylinderPalletAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewHCylinderPalletAnalysisCreated(analysis); // set solution selected if its unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
/// <summary> /// Creates a new analysis without generating solutions /// </summary> /// <param name="name">Name of analysis</param> /// <param name="description">Description</param> /// <param name="box">Case</param> /// <param name="pallet">Pallet</param> /// <param name="interlayer">Interlayer</param> /// <param name="constraintSet">PalletConstraintSet</param> /// <param name="solutions">Solutions</param> /// <returns>CasePalletAnalysis generated using input parameters</returns> public CasePalletAnalysis CreateNewCasePalletAnalysis( string name, string description , BProperties box, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm , PalletConstraintSet constraintSet , List<CasePalletSolution> solutions) { CasePalletAnalysis analysis = new CasePalletAnalysis( box, pallet, interlayer, interlayerAntiSlip, palletCorners, palletCap, palletFilm, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _casePalletAnalyses.Add(analysis); // set solutions analysis.Solutions = solutions; // notify listeners NotifyOnNewCasePalletAnalysisCreated(analysis); // set solution selected if it is unique if (solutions.Count == 1) analysis.SelectSolutionByIndex(0); return analysis; }
protected mesh CreatePalletMesh(PalletProperties palletProperties) { // build pallet object Pallet pallet = new Pallet(palletProperties); // build list of boxes List<Box> listBoxes = pallet.BuildListOfBoxes(); // build list of vertices / normals / UVs ulong vertexCount = 0, normalCount = 0, uvCount = 0, triangleCount = 0, boxCount = 0; string triangle_string = string.Empty; List<double> doubleArrayPosition = new List<double>(), doubleArrayNormal = new List<double>(), doubleArrayUV = new List<double>(); foreach (Box box in listBoxes) { foreach (Vector3D p in box.Points) { doubleArrayPosition.Add(p.X); doubleArrayPosition.Add(p.Y); doubleArrayPosition.Add(p.Z); ++vertexCount; } foreach (Vector3D n in box.Normals) { doubleArrayNormal.Add(n.X); doubleArrayNormal.Add(n.Y); doubleArrayNormal.Add(n.Z); ++normalCount; } foreach (Vector2D uv in box.UVs) { doubleArrayUV.Add(uv.X); doubleArrayUV.Add(uv.Y); ++uvCount; } foreach (TriangleIndices tr in box.Triangles) { triangle_string += tr.ConvertToString(boxCount); ++triangleCount; } ++boxCount; } mesh palletMesh = new mesh(); // position source source palletPositionSource = new source() { id = "pallet_position", name = "pallet_position" }; float_array farrayPosition = new float_array { id = "pallet_position_float_array", count = (ulong)doubleArrayPosition.Count, Values = doubleArrayPosition.ToArray() }; palletPositionSource.technique_common = new sourceTechnique_common() { accessor = new accessor() { stride = 3, count = vertexCount, source = "#pallet_position_float_array", param = new param[] { new param() { name = "X", type = "float" }, new param() { name = "Y", type = "float" }, new param() { name = "Z", type = "float" } } } }; palletPositionSource.Item = farrayPosition; // normal source source palletPositionNormal = new source() { id = "pallet_normal", name = "pallet_normal" }; float_array farrayNormal = new float_array { id = "pallet_normal_float_array", count = (ulong)doubleArrayNormal.Count, Values = doubleArrayNormal.ToArray() }; palletPositionNormal.technique_common = new sourceTechnique_common() { accessor = new accessor() { stride = 3, count = normalCount, source = "#pallet_normal_float_array", param = new param[] { new param() { name = "X", type = "float" }, new param() { name = "Y", type = "float" }, new param() { name = "Z", type = "float" } } } }; palletPositionNormal.Item = farrayNormal; // uv source source palletPositionUV = new source() { id = "pallet_UV", name = "pallet_UV" }; float_array farrayUV = new float_array { id = "pallet_UV_float_array", count = (ulong)doubleArrayUV.Count, Values = doubleArrayUV.ToArray() }; palletPositionUV.technique_common = new sourceTechnique_common() { accessor = new accessor() { stride = 2, count = vertexCount, source = "#pallet_UV_float_array", param = new param[] { new param() { name = "S", type = "float" }, new param() { name = "T", type = "float" } } } }; palletPositionUV.Item = farrayUV; // insert sources palletMesh.source = new source[] { palletPositionSource, palletPositionNormal, palletPositionUV }; // vertices InputLocal verticesInput = new InputLocal() { semantic = "POSITION", source = "#pallet_position" }; palletMesh.vertices = new vertices() { id = "pallet_vertex", input = new InputLocal[] { verticesInput } }; triangles trianglesPallet = new triangles() { material = "materialPallet", count = triangleCount }; trianglesPallet.input = new InputLocalOffset[] { new InputLocalOffset() { semantic="VERTEX", source="#pallet_vertex", offset=0} , new InputLocalOffset() { semantic="NORMAL", source="#pallet_normal", offset=1} , new InputLocalOffset() { semantic="TEXCOORD", source="#pallet_UV", offset=2, set=0, setSpecified=true } }; trianglesPallet.p = triangle_string; palletMesh.Items = new object[] { trianglesPallet }; return palletMesh; }
private void AppendPalletElement(PalletProperties palletProp, XmlElement elemAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; if (null == palletProp) return; // pallet XmlElement elemPallet = xmlDoc.CreateElement("pallet", ns); elemAnalysis.AppendChild(elemPallet); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = palletProp.Name; elemPallet.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = palletProp.Description; elemPallet.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemPallet, "length", UnitsManager.UnitType.UT_LENGTH, palletProp.Length); AppendElementValue(xmlDoc, elemPallet, "width", UnitsManager.UnitType.UT_LENGTH, palletProp.Width); AppendElementValue(xmlDoc, elemPallet, "height", UnitsManager.UnitType.UT_LENGTH, palletProp.Height); AppendElementValue(xmlDoc, elemPallet, "weight", UnitsManager.UnitType.UT_MASS, palletProp.Weight); AppendElementValue(xmlDoc, elemPallet, "admissibleLoad", UnitsManager.UnitType.UT_MASS, palletProp.AdmissibleLoadWeight); // type XmlElement elemType = xmlDoc.CreateElement("type", ns); elemType.InnerText = palletProp.TypeName; elemPallet.AppendChild(elemType); // --- build image Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512)); graphics.CameraPosition = Graphics3D.Corner_0; Pallet pallet = new Pallet(palletProp); pallet.Draw(graphics, Transform3D.Identity); graphics.AddDimensions(new DimensionCube(palletProp.Length, palletProp.Width, palletProp.Height)); graphics.Flush(); // --- // view_pallet_iso XmlElement elemImage = xmlDoc.CreateElement("view_pallet_iso", ns); TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap)); elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[]))); XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style"); styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4); elemImage.Attributes.Append(styleAttribute); elemPallet.AppendChild(elemImage); // save image SaveImageAs(graphics.Bitmap, "view_pallet_iso.png"); }
public List<CasePalletSolution> Process( BoxProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletConstraintSet constraintSet) { _bProperties = boxProperties; _palletProperties = palletProperties; _interlayerProperties = interlayerProperties; _interlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; _constraintSet = constraintSet; // check constraint set validity if (!_constraintSet.IsValid) throw new EngineException("Constraint set is invalid!"); // generate solutions return GenerateSolutions(); }
static int Main(string[] args) { ILog log = LogManager.GetLogger(typeof(Program)); XmlConfigurator.Configure(); try { bool useSingleColor = false; // instantiate document Document doc = new Document("Test", "Test", "fga", DateTime.Now, null); // define pallet properties PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150); Console.WriteLine("=== Pallet properties ==="); Console.WriteLine(palletProperties.ToString()); bool testCylinder = false; if (!testCylinder) { // define box properties BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250); boxProperties.Name = "Box1"; boxProperties.Weight = 3.0; if (!useSingleColor) { boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red); boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue); boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue); } else boxProperties.SetColor(Color.Chocolate); Console.WriteLine(boxProperties.ToString()); InterlayerProperties interlayerProperties = null; // define constraints CasePalletConstraintSet constraintSet = new CasePalletConstraintSet(); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true); constraintSet.SetAllowedPattern("Trilock"); constraintSet.AllowAlignedLayers = true; constraintSet.AllowAlternateLayers = false; constraintSet.MaximumPalletWeight = 2000; constraintSet.MaximumNumberOfItems = 2000; constraintSet.MaximumHeight = 2000.0; constraintSet.UseMaximumHeight = true; constraintSet.UseMaximumPalletWeight = true; constraintSet.UseMaximumWeightOnBox = false; constraintSet.AllowLastLayerOrientationChange = true; Console.WriteLine("=== Constraint set ==="); Console.WriteLine(constraintSet.ToString()); // initialize analysis CasePalletAnalysis analysis = new CasePalletAnalysis( boxProperties, palletProperties, interlayerProperties, null, null, null, null, constraintSet); // initialize solver CasePalletSolver solver = new CasePalletSolver(); solver.ProcessAnalysis(analysis); Console.WriteLine("=== Solutions ==="); int solIndex = 0; foreach (CasePalletSolution sol in analysis.Solutions) { // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000)); graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0); graphics.Target = Vector3D.Zero; graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // instantiate solution viewer CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol); sv.Draw(graphics); // save string fileName = string.Format("Pallet_{0}.bmp", solIndex++); string filePath = Path.Combine(Path.GetTempPath(), fileName); Console.WriteLine("Saving file " + filePath + "..."); graphics.SaveAs(filePath); } } else { // cylinder Console.WriteLine("=== Cylinder properties ==="); CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder", 90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue); Console.WriteLine(cylProperties.ToString()); // constraint set Console.WriteLine("=== Constraint set ==="); CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet(); constraintSet.UseMaximumPalletHeight = true; constraintSet.MaximumPalletHeight = 1200.0; constraintSet.UseMaximumPalletWeight = true; constraintSet.MaximumPalletWeight = 2000; constraintSet.UseMaximumNumberOfItems = true; constraintSet.MaximumNumberOfItems = 2000; Console.WriteLine(constraintSet.ToString()); // cylinder analysis CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet); // initialize solver CylinderSolver solver = new CylinderSolver(); solver.ProcessAnalysis(analysis); Console.WriteLine("=== Solutions ==="); int solIndex = 0; foreach (CylinderPalletSolution sol in analysis.Solutions) { // instantiate graphics Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512)); graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0); graphics.Target = Vector3D.Zero; graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f); // instantiate solution viewer CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol); sv.Draw(graphics); string fileName = string.Format("Pallet_{0}.jpg", solIndex++); string filePath = Path.Combine(Path.GetTempPath(), fileName); Console.WriteLine("Saving file " + filePath + "..."); graphics.SaveAs(filePath); } } } catch (Exception ex) { log.Error(ex.ToString()); } return 0; }
/// <summary> /// Creates a new analysis in this document + compute solutions /// </summary> /// <param name="name"></param> /// <param name="description"></param> /// <param name="box"></param> /// <param name="pallet"></param> /// <param name="interlayer"></param> /// <param name="constraintSet"></param> /// <param name="solver">Node : analysis creation requires a solver</param> /// <returns>An analysis</returns> public CasePalletAnalysis CreateNewCasePalletAnalysis( string name, string description , BProperties box, PalletProperties pallet , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm , PalletConstraintSet constraintSet , ICasePalletAnalysisSolver solver) { CasePalletAnalysis analysis = new CasePalletAnalysis( box, pallet, interlayer, interlayerAntiSlip, palletCorners, palletCap, palletFilm, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _casePalletAnalyses.Add(analysis); // compute analysis solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _casePalletAnalyses.Remove(analysis); return null; } // notify listeners NotifyOnNewCasePalletAnalysisCreated(analysis); Modify(); return analysis; }
public void Save(PalletProperties palletProperties, XmlElement parentElement, XmlDocument xmlDoc) { // create xmlPalletProperties element XmlElement xmlPalletProperties = xmlDoc.CreateElement("PalletProperties"); parentElement.AppendChild(xmlPalletProperties); // Id XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id"); guidAttribute.Value = palletProperties.Guid.ToString(); xmlPalletProperties.Attributes.Append(guidAttribute); // name XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name"); nameAttribute.Value = palletProperties.Name; xmlPalletProperties.Attributes.Append(nameAttribute); // description XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description"); descAttribute.Value = palletProperties.Description; xmlPalletProperties.Attributes.Append(descAttribute); // length XmlAttribute lengthAttribute = xmlDoc.CreateAttribute("Length"); lengthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.Length); xmlPalletProperties.Attributes.Append(lengthAttribute); // width XmlAttribute widthAttribute = xmlDoc.CreateAttribute("Width"); widthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.Width); xmlPalletProperties.Attributes.Append(widthAttribute); // height XmlAttribute heightAttribute = xmlDoc.CreateAttribute("Height"); heightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.Height); xmlPalletProperties.Attributes.Append(heightAttribute); // weight XmlAttribute weightAttribute = xmlDoc.CreateAttribute("Weight"); weightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.Weight); xmlPalletProperties.Attributes.Append(weightAttribute); // admissible load weight XmlAttribute admLoadWeightAttribute = xmlDoc.CreateAttribute("AdmissibleLoadWeight"); admLoadWeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.AdmissibleLoadWeight); xmlPalletProperties.Attributes.Append(admLoadWeightAttribute); // admissible load height XmlAttribute admLoadHeightAttribute = xmlDoc.CreateAttribute("AdmissibleLoadHeight"); admLoadHeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", palletProperties.AdmissibleLoadHeight); xmlPalletProperties.Attributes.Append(admLoadHeightAttribute); // type XmlAttribute typeAttribute = xmlDoc.CreateAttribute("Type"); typeAttribute.Value = string.Format("{0}", palletProperties.TypeName); xmlPalletProperties.Attributes.Append(typeAttribute); // color XmlAttribute colorAttribute = xmlDoc.CreateAttribute("Color"); colorAttribute.Value = string.Format("{0}", palletProperties.Color.ToArgb()); xmlPalletProperties.Attributes.Append(colorAttribute); }