Ignore:
Timestamp:
01/12/16 10:42:58 (5 years ago)
Author:
gkronber
Message:

#1966: fixed various problems: bugs in cloning, bugs in persistence, method names, various minor improvements of source code for readability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/PackingItem/CuboidPackingItem.cs

    r13461 r13497  
    2929
    3030namespace HeuristicLab.Problems.BinPacking.PackingItem {
    31   [Item ("CuboidPackingItem", "Represents a cuboidic packing-item for bin-packing problems.")]
     31  [Item("CuboidPackingItem", "Represents a cuboidic packing-item for bin-packing problems.")]
    3232  [StorableClass]
    3333  public class CuboidPackingItem : CuboidPackingShape, IPackingItem {
     34    [Storable]
     35    public CuboidPackingBin TargetBin { get; set; }
    3436
    35     public CuboidPackingBin TargetBin { get; set; }
     37    [Storable]
    3638    public double Weight { get; set; }
     39
     40    [Storable]
    3741    public int Material { get; set; }
     42
    3843    public bool SupportsStacking(IPackingItem other) {
    3944      return ((other.Material < this.Material) || (other.Material.Equals(this.Material) && other.Weight <= this.Weight));
     
    4449    protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner)
    4550      : base(original, cloner) {
    46         this.Weight = original.Weight;
    47         this.Material = original.Material;
     51      this.Weight = original.Weight;
     52      this.Material = original.Material;
     53      this.TargetBin = cloner.Clone(TargetBin);
    4854    }
    4955    public override IDeepCloneable Clone(Cloner cloner) {
    5056      return new CuboidPackingItem(this, cloner);
    5157    }
    52     public CuboidPackingItem() : base() {
     58    public CuboidPackingItem()
     59      : base() {
    5360    }
    5461
    55     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; }
    56     public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin) : base(width, height, depth) { this.TargetBin = new CuboidPackingBin(targetBin.Width, targetBin.Height, targetBin.Depth); }
     62    public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material)
     63      : this(width, height, depth, targetBin) {
     64      this.Weight = weight;
     65      this.Material = material;
     66    }
     67
     68    public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin)
     69      : base(width, height, depth) {
     70      this.TargetBin = (CuboidPackingBin)targetBin.Clone();
     71    }
    5772
    5873    public void AddTargetBinMeasures(int[] targetBinMeasures) {
     
    6176
    6277    public override string ToString() {
    63       return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight,this.Material);
     78      return String.Format("CuboidPackingItem ({0}, {1}, {2}; w={3}, m={4})", this.Width, this.Height, this.Depth, this.Weight, this.Material);
    6479    }
    6580  }
Note: See TracChangeset for help on using the changeset viewer.