Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/09/13 12:58:39 (11 years ago)
Author:
jhelm
Message:

#1966: Bugfixing; Refactoring; Performancetuning;

Location:
branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes
Files:
2 edited

Legend:

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

    r9596 r9599  
    5757
    5858    public override bool EnclosesPoint(ThreeDimensionalPacking myPosition, ThreeDimensionalPacking checkedPoint) {
    59       var c = new CuboidDiagonal(myPosition, this);
    60       return (c.x1 <= checkedPoint.X &&
    61                 c.x2 >= checkedPoint.X &&
    62                 c.y1 <= checkedPoint.Y &&
    63                 c.y2 >= checkedPoint.Y &&
    64                 c.z1 <= checkedPoint.Z &&
    65                 c.z2 >= checkedPoint.Z);
     59      return (myPosition.X <= checkedPoint.X &&
     60                (myPosition.X + (myPosition.Rotated ? Depth : Width) - 1) >= checkedPoint.X &&
     61                myPosition.Y <= checkedPoint.Y &&
     62                (myPosition.Y + Height - 1) >= checkedPoint.Y &&
     63                myPosition.Z <= checkedPoint.Z &&
     64                (myPosition.Z + (myPosition.Rotated ? Width : Depth) - 1) >= checkedPoint.Z);
    6665    }
    6766    public override bool Encloses(ThreeDimensionalPacking checkedPosition, PackingShape<ThreeDimensionalPacking> checkedShape) {
     
    8786    }
    8887    private bool Overlaps(CuboidDiagonal c1, CuboidDiagonal c2) {
    89       return !(c1.x1 >= c2.x2 ||
    90                c1.y1 >= c2.y2 || 
    91                c1.z1 >= c2.z2 ||
    92                c1.x2 <= c2.x1 ||
    93                c1.y2 <= c2.y1 ||
    94                c1.z2 <= c2.z1);
     88      return !(c1.x1 > c2.x2 ||
     89               c1.y1 > c2.y2 || 
     90               c1.z1 > c2.z2 ||
     91               c1.x2 < c2.x1 ||
     92               c1.y2 < c2.y1 ||
     93               c1.z2 < c2.z1);
    9594    }
    9695
     
    175174        y1 = myPosition.Y;
    176175        z1 = myPosition.Z;
    177         x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width);
    178         y2 = myPosition.Y + myShape.Height;
    179         z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth);
     176        x2 = myPosition.X + (myPosition.Rotated ? myShape.Depth : myShape.Width) - 1;
     177        y2 = myPosition.Y + myShape.Height - 1;
     178        z2 = myPosition.Z + (myPosition.Rotated ? myShape.Width : myShape.Depth) - 1;
    180179      }
    181180    }
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/Shapes/RectangularPackingShape.cs

    r9596 r9599  
    5252
    5353    public override bool EnclosesPoint(TwoDimensionalPacking myPosition, TwoDimensionalPacking checkedPoint) {
    54       var r = new RectangleDiagonal(myPosition, this);
    55       return (r.x1 <= checkedPoint.X &&
    56                 r.x2 >= checkedPoint.X &&
    57                 r.y1 <= checkedPoint.Y &&
    58                 r.y2 >= checkedPoint.Y);
     54      return (myPosition.X <= checkedPoint.X &&
     55                (myPosition.X + (myPosition.Rotated ? Height : Width) - 1) >= checkedPoint.X &&
     56                myPosition.Y <= checkedPoint.Y &&
     57                (myPosition.Y + (myPosition.Rotated ? Width : Height) - 1) >= checkedPoint.Y);
    5958    }
    6059    public override bool Encloses(TwoDimensionalPacking checkedPosition, PackingShape<TwoDimensionalPacking> checkedShape) {
     
    7877    }
    7978    private bool Overlaps(RectangleDiagonal r1, RectangleDiagonal r2) {
    80       return !(r1.x1 >= r2.x2 ||
    81                r1.y1 >= r2.y2 ||
    82                r1.x2 <= r2.x1 ||
    83                r1.y2 <= r2.y1);
     79      return !(r1.x1 > r2.x2 ||
     80               r1.y1 > r2.y2 ||
     81               r1.x2 < r2.x1 ||
     82               r1.y2 < r2.y1);
    8483    }
    8584
     
    150149        x1 = myPosition.X;
    151150        y1 = myPosition.Y;
    152         x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width);
    153         y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height);
     151        x2 = myPosition.X + (myPosition.Rotated ? myShape.Height : myShape.Width) - 1;
     152        y2 = myPosition.Y + (myPosition.Rotated ? myShape.Width : myShape.Height) - 1;
    154153      }
    155154    }
Note: See TracChangeset for help on using the changeset viewer.