Changeset 13461 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
- Timestamp:
- 12/14/15 19:52:46 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/CuboidPackingShape.cs
r13032 r13461 31 31 [StorableClass] 32 32 public abstract class CuboidPackingShape : PackingShape<ThreeDimensionalPacking>, IRegularPackingShape, IComparable<CuboidPackingShape> { 33 #region Properties 33 #region Properties 34 34 /// <summary> 35 35 /// Describes the size on the X-axis … … 62 62 } 63 63 public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) { 64 return Encloses(checkedPosition, (CuboidPackingShape) 64 return Encloses(checkedPosition, (CuboidPackingShape)checkedShape); 65 65 } 66 66 private bool Encloses(ThreeDimensionalPacking checkedPosition, CuboidPackingShape checkedShape) { 67 67 return Encloses(new CuboidDiagonal(this), new CuboidDiagonal(checkedPosition, checkedShape)); 68 } 68 } 69 69 private bool Encloses(CuboidDiagonal c1, CuboidDiagonal c2) { 70 70 return (c1.x1 <= c2.x1 && … … 84 84 private bool Overlaps(CuboidDiagonal c1, CuboidDiagonal c2) { 85 85 return !(c1.x1 > c2.x2 || 86 c1.y1 > c2.y2 || 86 c1.y1 > c2.y2 || 87 87 c1.z1 > c2.z2 || 88 88 c1.x2 < c2.x1 || … … 98 98 } 99 99 } 100 #endregion 100 #endregion 101 101 102 public CuboidPackingShape(int width, int height, int depth) : base () { 102 protected CuboidPackingShape(int width, int height, int depth) 103 : base() { 103 104 this.Width = width; 104 105 this.Height = height; … … 108 109 public override void InitializeFromMeasures(int[] measures) { 109 110 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."); 111 112 this.Width = measures[0]; 112 113 this.Height = measures[1]; … … 125 126 this.Depth = original.Depth; 126 127 } 127 public CuboidPackingShape() : base(){ } 128 129 protected CuboidPackingShape() : base() { } 128 130 129 131 public override string ToString() { … … 136 138 //Using "Clustered-Area-Height"-comparison as descr 137 139 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); 150 146 return result; 151 } 147 } 152 148 153 149 public int CompareTo(object obj) { 154 if (obj.GetType() .Equals(this.GetType()))150 if (obj.GetType() == this.GetType()) 155 151 return this.CompareTo((CuboidPackingShape)obj); 156 152 else return 0; 157 153 } 158 154 159 #endregion 155 #endregion 160 156 161 157 private struct CuboidDiagonal {
Note: See TracChangeset
for help on using the changeset viewer.