#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Problems.BinPacking.Interfaces; using HeuristicLab.Problems.BinPacking.Shapes; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Common; using HeuristicLab.Data; using HeuristicLab.Problems.BinPacking.PackingBin; namespace HeuristicLab.Problems.BinPacking.PackingItem { [Item ("CuboidPackingItem", "Represents a cuboidic packing-item for bin-packing problems.")] [StorableClass] public class CuboidPackingItem : CuboidPackingShape, IPackingItem { public CuboidPackingBin TargetBin { get; set; } public double Weight { get; set; } public int Material { get; set; } public bool SupportsStacking(IPackingItem other) { return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight)); } [StorableConstructor] protected CuboidPackingItem(bool deserializing) : base(deserializing) { } protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner) : base(original, cloner) { this.Weight = original.Weight; this.Material = original.Material; } public override IDeepCloneable Clone(Cloner cloner) { return new CuboidPackingItem(this, cloner); } public CuboidPackingItem() : base() { } public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material) : this(width, height, depth, targetBin) { this.Weight = weight; this.Material = material; } public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) : base(width, height, depth) { this.TargetBin = new CuboidPackingBin(targetBin.Width, targetBin.Height, targetBin.Depth); } public void AddTargetBinMeasures(int[] targetBinMeasures) { TargetBin = new CuboidPackingBin(targetBinMeasures[0], targetBinMeasures[1], targetBinMeasures[2]); } public override string ToString() { return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight,this.Material); } } }