Changeset 15392
- Timestamp:
- 10/02/17 22:59:19 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15325,15388
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.BinPacking
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.BinPacking merged: 15325,15388
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.BinPacking/3.3/3D/BinPacking3D.cs
r15278 r15392 65 65 66 66 public override void PackItem(int itemID, PackingItem item, PackingPosition position) { 67 // base call is deliberately omitted, because UpdateResidualSpace needs to be fitted in before 68 Items[itemID] = item; 69 Positions[itemID] = position; 70 ExtremePoints.Remove(position); 67 71 ResidualSpace.Remove(position); 68 base.PackItem(itemID, item, position); 72 UpdateResidualSpace(item, position); 73 foreach (int id in Items.Select(x => x.Key)) 74 GenerateNewExtremePointsForNewItem(Items[id], Positions[id]); 75 76 AddNewItemToOccupationLayers(itemID, item, position); 69 77 } 70 78 … … 237 245 if (positionFound != null) { 238 246 PackItem(itemID, item, positionFound); 239 if (Items.Count > 1)240 UpdateResidualSpace(item, positionFound);241 247 sequence.Remove(itemID); 242 248 } … … 350 356 public void UpdateResidualSpace(PackingItem item, PackingPosition pos) { 351 357 foreach (var ep in ExtremePoints) { 352 if (ep.Z >= pos.Z && ep.Z <= pos.Z + item.Depth) { 353 if (ep.X <= pos.X && ep.Y > pos.Y && ep.Y < pos.Y + item.Height) { 358 var rs = ResidualSpace[ep]; 359 var depth = pos.Rotated ? item.Width : item.Depth; 360 var width = pos.Rotated ? item.Depth : item.Width; 361 if (ep.Z >= pos.Z && ep.Z < pos.Z + depth) { 362 if (ep.X <= pos.X && ep.Y >= pos.Y && ep.Y < pos.Y + item.Height) { 354 363 var diff = pos.X - ep.X; 355 var newRSX = ResidualSpace[ep].Item1 < diff ? ResidualSpace[ep].Item1 : diff;356 ResidualSpace[ep] = Tuple.Create(newRSX, ResidualSpace[ep].Item2, ResidualSpace[ep].Item3);364 var newRSX = Math.Min(rs.Item1, diff); 365 ResidualSpace[ep] = Tuple.Create(newRSX, rs.Item2, rs.Item3); 357 366 } 358 if (ep.Y <= pos.Y && ep.X > pos.X && ep.X < pos.X + item.Width) {367 if (ep.Y <= pos.Y && ep.X >= pos.X && ep.X < pos.X + width) { 359 368 var diff = pos.Y - ep.Y; 360 var newRSY = ResidualSpace[ep].Item2 < diff ? ResidualSpace[ep].Item2 : diff;361 ResidualSpace[ep] = Tuple.Create( ResidualSpace[ep].Item1, newRSY, ResidualSpace[ep].Item3);369 var newRSY = Math.Min(rs.Item2, diff); 370 ResidualSpace[ep] = Tuple.Create(rs.Item1, newRSY, rs.Item3); 362 371 } 363 372 } 364 if (ep.Z <= pos.Z && 365 ep.Y > pos.Y && ep.Y < pos.Y + item.Height && 366 ep.X > pos.X && ep.X < pos.X + item.Width) { 367 var diff = pos.Z - ep.Z; 368 var newRSZ = ResidualSpace[ep].Item3 < diff ? ResidualSpace[ep].Item3 : diff; 369 ResidualSpace[ep] = Tuple.Create(ResidualSpace[ep].Item1, ResidualSpace[ep].Item2, newRSZ); 370 } 371 } 372 return; 373 if (ep.Z <= pos.Z && 374 ep.Y >= pos.Y && ep.Y < pos.Y + item.Height && 375 ep.X >= pos.X && ep.X < pos.X + width) { 376 var diff = pos.Z - ep.Z; 377 var newRSZ = Math.Min(rs.Item3, diff); 378 ResidualSpace[ep] = Tuple.Create(rs.Item1, rs.Item2, newRSZ); 379 } 380 } 373 381 } 374 382 }
Note: See TracChangeset
for help on using the changeset viewer.