Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/15 19:52:46 (8 years ago)
Author:
gkronber
Message:

#1966:

  • used Items instead of NamedItems and adapted views (Names/Descriptions) were not set anyway
  • fixed problems identified by Essential unit tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs

    r13032 r13461  
    3131  [StorableClass]
    3232  public abstract class CuboidPackingShape : PackingShape<ThreeDimensionalPacking>, IRegularPackingShape, IComparable<CuboidPackingShape> {
    33     #region Properties 
     33    #region Properties
    3434    /// <summary>
    3535    /// Describes the size on the X-axis
     
    6262    }
    6363    public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {
    64       return Encloses(checkedPosition, (CuboidPackingShape) checkedShape);
     64      return Encloses(checkedPosition, (CuboidPackingShape)checkedShape);
    6565    }
    6666    private bool Encloses(ThreeDimensionalPacking checkedPosition, CuboidPackingShape checkedShape) {
    6767      return Encloses(new CuboidDiagonal(this), new CuboidDiagonal(checkedPosition, checkedShape));
    68     } 
     68    }
    6969    private bool Encloses(CuboidDiagonal c1, CuboidDiagonal c2) {
    7070      return (c1.x1 <= c2.x1 &&
     
    8484    private bool Overlaps(CuboidDiagonal c1, CuboidDiagonal c2) {
    8585      return !(c1.x1 > c2.x2 ||
    86                c1.y1 > c2.y2 || 
     86               c1.y1 > c2.y2 ||
    8787               c1.z1 > c2.z2 ||
    8888               c1.x2 < c2.x1 ||
     
    9898      }
    9999    }
    100     #endregion       
     100    #endregion
    101101
    102     public CuboidPackingShape(int width, int height, int depth) : base () {
     102    protected CuboidPackingShape(int width, int height, int depth)
     103      : base() {
    103104      this.Width = width;
    104105      this.Height = height;
     
    108109    public override void InitializeFromMeasures(int[] measures) {
    109110      if (measures.Length != 3)
    110         throw new InvalidOperationException("Nr of measures does not fit shape-dimension.");       
     111        throw new InvalidOperationException("Nr of measures does not fit shape-dimension.");
    111112      this.Width = measures[0];
    112113      this.Height = measures[1];
     
    125126      this.Depth = original.Depth;
    126127    }
    127     public CuboidPackingShape() : base(){ }
     128
     129    protected CuboidPackingShape() : base() { }
    128130
    129131    public override string ToString() {
     
    136138      //Using "Clustered-Area-Height"-comparison as descr
    137139
    138       int result = (this.Width * this.Depth).CompareTo (other.Width * other.Depth);
    139    
    140     if (result == 0)
    141     result = this.MultipliedMeasures.CompareTo(other.MultipliedMeasures);
    142       //if (result == 0) {
    143       //  result = this.Depth.CompareTo(other.Depth) + this.Width.CompareTo(other.Width);
    144       //  if (result == 0) {       
    145       //    result = this.Width.CompareTo(other.Width);
    146     if (result == 0)               
    147     result = this.Height.CompareTo(other.Height);
    148       //  }
    149       //}
     140      int result = (this.Width * this.Depth).CompareTo(other.Width * other.Depth);
     141
     142      if (result == 0)
     143        result = this.MultipliedMeasures.CompareTo(other.MultipliedMeasures);
     144      if (result == 0)
     145        result = this.Height.CompareTo(other.Height);
    150146      return result;
    151     }       
     147    }
    152148
    153149    public int CompareTo(object obj) {
    154       if (obj.GetType().Equals(this.GetType()))
     150      if (obj.GetType() == this.GetType())
    155151        return this.CompareTo((CuboidPackingShape)obj);
    156152      else return 0;
    157153    }
    158154
    159     #endregion 
     155    #endregion
    160156
    161157    private struct CuboidDiagonal {
Note: See TracChangeset for help on using the changeset viewer.