Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/28/16 18:32:54 (8 years ago)
Author:
gkronber
Message:

#1966: changed PackingShapes to ParameterizedItems

File:
1 edited

Legend:

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

    r13497 r13574  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using HeuristicLab.Common;
     28using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
    2830using HeuristicLab.Problems.BinPacking.PackingBin;
    2931
     
    3234  [StorableClass]
    3335  public class CuboidPackingItem : CuboidPackingShape, IPackingItem {
    34     [Storable]
    35     public CuboidPackingBin TargetBin { get; set; }
     36    public CuboidPackingBin TargetBin {
     37      get { return ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value; }
     38      set { ((IValueParameter<CuboidPackingBin>)Parameters["TargetBin"]).Value = value; }
     39    }
    3640
    37     [Storable]
    38     public double Weight { get; set; }
     41    public double Weight {
     42      get { return ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value; }
     43      set { ((IFixedValueParameter<DoubleValue>)Parameters["Weight"]).Value.Value = value; }
     44    }
    3945
    40     [Storable]
    41     public int Material { get; set; }
     46    public int Material {
     47      get { return ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value; }
     48      set { ((IFixedValueParameter<IntValue>)Parameters["Material"]).Value.Value = value; }
     49    }
    4250
    4351    public bool SupportsStacking(IPackingItem other) {
     
    4957    protected CuboidPackingItem(CuboidPackingItem original, Cloner cloner)
    5058      : base(original, cloner) {
    51       this.Weight = original.Weight;
    52       this.Material = original.Material;
    53       this.TargetBin = cloner.Clone(TargetBin);
    54     }
    55     public override IDeepCloneable Clone(Cloner cloner) {
    56       return new CuboidPackingItem(this, cloner);
    5759    }
    5860    public CuboidPackingItem()
    5961      : base() {
     62      Parameters.Add(new ValueParameter<CuboidPackingBin>("TargetBin"));
     63      Parameters.Add(new FixedValueParameter<DoubleValue>("Weight"));
     64      Parameters.Add(new FixedValueParameter<IntValue>("Material"));
    6065    }
    6166
    6267    public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin, double weight, int material)
    63       : this(width, height, depth, targetBin) {
     68      : this() {
     69      this.Width = width;
     70      this.Height = height;
     71      this.Depth = depth;
    6472      this.Weight = weight;
    6573      this.Material = material;
     74      this.TargetBin = (CuboidPackingBin)targetBin.Clone();
    6675    }
    6776
    6877    public CuboidPackingItem(int width, int height, int depth, CuboidPackingBin targetBin)
    69       : base(width, height, depth) {
     78      : this() {
     79      this.Width = width;
     80      this.Height = height;
     81      this.Depth = depth;
    7082      this.TargetBin = (CuboidPackingBin)targetBin.Clone();
     83    }
     84
     85    public override IDeepCloneable Clone(Cloner cloner) {
     86      return new CuboidPackingItem(this, cloner);
    7187    }
    7288
Note: See TracChangeset for help on using the changeset viewer.