| | |
| | | |
| | | public PlaceBlockService(ContainerSize containerSize, List<PlacedBlock>? placedBlocks = null) |
| | | { |
| | | containerSize.Length = containerSize.Length + 2 * SPACING; |
| | | containerSize.Width = containerSize.Width + 2 * SPACING; |
| | | ContainerSize = containerSize; |
| | | if (placedBlocks == null || placedBlocks.Count == 0) |
| | | { |
| | |
| | | { |
| | | PlacedBlocks = placedBlocks; |
| | | } |
| | | |
| | | |
| | | containerFloor = new PlacedBlock(new Point3D(SPACING, SPACING, 0), ContainerSize.Length - 2 * SPACING, ContainerSize.Width - 2 * SPACING, 0); |
| | | } |
| | |
| | | if (IsPositionValid(candidate, l, w, h)) |
| | | { |
| | | var placed = new PlacedBlock(candidate, l, w, h); |
| | | PlacedBlocks.Add(placed); |
| | | //PlacedBlocks.Add(placed); |
| | | return candidate; |
| | | } |
| | | } |
| | |
| | | { |
| | | var blocks = PlacedBlocks |
| | | .Where(b => b.Position.Z + b.Height == baseZ) |
| | | .OrderByDescending(b => b.Length * b.Width); |
| | | .OrderByDescending(b => b.Length * b.Width).ToList(); |
| | | |
| | | // å½baseZ=0æ¶æ·»å 容å¨åºé¨æ¯æ |
| | | if (baseZ == 0 && !blocks.Any()) |
| | | if (baseZ == 0 && blocks.Count == 0) |
| | | { |
| | | return new List<PlacedBlock> { containerFloor }; |
| | | } |