Changeset 14049 for branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PackingShape.cs
- Timestamp:
- 07/12/16 20:03:45 (8 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/PackingShape.cs
r14048 r14049 30 30 31 31 namespace HeuristicLab.Problems.BinPacking2D { 32 [Item(" RectangularPackingShape", "Represents the rectangular measures (width, height) of a two-dimensional bin-packing object.")]32 [Item("PackingShape (2d)", "Represents the rectangular measures (width, height) of a two-dimensional bin-packing object.")] 33 33 [StorableClass] 34 public class RectangularPackingShape : PackingShape<PackingPosition>, IComparable<RectangularPackingShape> {34 public class PackingShape : PackingShape<PackingPosition>, IComparable<PackingShape> { 35 35 public int Height { 36 36 get { return ((IFixedValueParameter<IntValue>)Parameters["Height"]).Value.Value; } … … 44 44 45 45 [StorableConstructor] 46 protected RectangularPackingShape(bool deserializing) : base(deserializing) { }47 protected RectangularPackingShape(RectangularPackingShape original, Cloner cloner)46 protected PackingShape(bool deserializing) : base(deserializing) { } 47 protected PackingShape(PackingShape original, Cloner cloner) 48 48 : base(original, cloner) { 49 49 } 50 public RectangularPackingShape()50 public PackingShape() 51 51 : base() { 52 52 Parameters.Add(new FixedValueParameter<IntValue>("Width")); 53 53 Parameters.Add(new FixedValueParameter<IntValue>("Height")); 54 54 } 55 public RectangularPackingShape(int width, int height)55 public PackingShape(int width, int height) 56 56 : this() { 57 57 this.Height = height; … … 60 60 61 61 public override IDeepCloneable Clone(Cloner cloner) { 62 return new RectangularPackingShape(this, cloner);62 return new PackingShape(this, cloner); 63 63 } 64 64 … … 69 69 #region IComparable<RectangularPackingShape> Members 70 70 71 public int CompareTo( RectangularPackingShape other) {71 public int CompareTo(PackingShape other) { 72 72 int result = this.Width.CompareTo(other.Width); 73 73 if (result == 0) … … 77 77 78 78 public override int CompareTo(object obj) { 79 var other = obj as RectangularPackingShape;79 var other = obj as PackingShape; 80 80 if (other != null) return CompareTo(other); 81 81 else throw new ArgumentException(string.Format("Cannot compare to object {0}", obj), "obj"); … … 96 96 } 97 97 public override bool Encloses(PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 98 return Encloses(checkedPosition, ( RectangularPackingShape)checkedShape);98 return Encloses(checkedPosition, (PackingShape)checkedShape); 99 99 } 100 private bool Encloses(PackingPosition checkedPosition, RectangularPackingShape checkedShape) {100 private bool Encloses(PackingPosition checkedPosition, PackingShape checkedShape) { 101 101 return Encloses(new RectangleDiagonal(this), new RectangleDiagonal(checkedPosition, checkedShape)); 102 102 } … … 109 109 110 110 public override bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, PackingShape<PackingPosition> checkedShape) { 111 return Overlaps(myPosition, checkedPosition, ( RectangularPackingShape)checkedShape);111 return Overlaps(myPosition, checkedPosition, (PackingShape)checkedShape); 112 112 } 113 private bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, RectangularPackingShape checkedShape) {113 private bool Overlaps(PackingPosition myPosition, PackingPosition checkedPosition, PackingShape checkedShape) { 114 114 return Overlaps(new RectangleDiagonal(myPosition, this), new RectangleDiagonal(checkedPosition, checkedShape)); 115 115 } … … 136 136 public int x2; 137 137 public int y2; 138 public RectangleDiagonal( RectangularPackingShape myShape) : this(new PackingPosition(0, 0, 0), myShape) { }139 public RectangleDiagonal(PackingPosition myPosition, RectangularPackingShape myShape) {138 public RectangleDiagonal(PackingShape myShape) : this(new PackingPosition(0, 0, 0), myShape) { } 139 public RectangleDiagonal(PackingPosition myPosition, PackingShape myShape) { 140 140 x1 = myPosition.X; 141 141 y1 = myPosition.Y;
Note: See TracChangeset
for help on using the changeset viewer.