| | |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_DTO.PlacedBlockDTO; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | |
| | | namespace WIDESEAWCS_BasicInfoService |
| | |
| | | |
| | | public PlaceBlockService(ContainerSize containerSize, List<PlacedBlock>? placedBlocks = null) |
| | | { |
| | | containerSize.Length = containerSize.Length + 2 * SPACING; |
| | | containerSize.Width = containerSize.Width + 2 * SPACING; |
| | | containerSize.Length = containerSize.Length; |
| | | containerSize.Width = containerSize.Width; |
| | | ContainerSize = containerSize; |
| | | if (placedBlocks == null || placedBlocks.Count == 0) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | containerFloor = new PlacedBlock(new Point3D(SPACING, SPACING, 0), ContainerSize.Length - 2 * SPACING, ContainerSize.Width - 2 * SPACING, 0); |
| | | containerFloor = new PlacedBlock(new Point3D(0, 0, 0), ContainerSize.Length, ContainerSize.Width, 0); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | xEnd = Math.Min(xEnd, ContainerSize.Length - l - SPACING); |
| | | yEnd = Math.Min(yEnd, ContainerSize.Width - w - SPACING); |
| | | |
| | | // éªè¯æ¯æé¢ç§¯ |
| | | //int supportArea = support.Length * support.Width; |
| | | //int requiredSupportArea = (int)(l * w * 0.7); // æ¯æé¢ç§¯ >= è¢«æ¯æé¢é¢ç§¯ç70% |
| | | //if (supportArea < requiredSupportArea) continue; |
| | | |
| | | if (xStart > xEnd || yStart > yEnd) continue; |
| | | |
| | | // ä¼åæç´¢ï¼ä¼å
è§è½ä½ç½® |
| | |
| | | } |
| | | |
| | | return blocks; |
| | | |
| | | |
| | | //// è·åææå¨ baseZ é«åº¦çæ¯æå |
| | | //var blocks = PlacedBlocks |
| | | // .Where(b => b.Position.Z + b.Height == baseZ) |
| | | // .ToList(); |
| | | |
| | | //// å½ baseZ=0 æ¶æ·»å 容å¨åºé¨æ¯æ |
| | | //if (baseZ == 0 && !blocks.Any()) |
| | | //{ |
| | | // return new List<PlacedBlock> { containerFloor }; |
| | | //} |
| | | |
| | | //// è®¡ç®æ´ä½å¹³é¢ |
| | | //if (blocks.Any()) |
| | | //{ |
| | | // int minX = blocks.Min(b => b.Position.X); |
| | | // int minY = blocks.Min(b => b.Position.Y); |
| | | // int maxX = blocks.Max(b => b.Position.X + b.Length); |
| | | // int maxY = blocks.Max(b => b.Position.Y + b.Width); |
| | | |
| | | // var overallSupport = new PlacedBlock( |
| | | // new Point3D(minX, minY, baseZ), |
| | | // maxX - minX, |
| | | // maxY - minY, |
| | | // 0 |
| | | // ); |
| | | |
| | | // return new List<PlacedBlock> { overallSupport }; |
| | | //} |
| | | |
| | | //return blocks; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | |
| | | return xOverlap && yOverlap && zOverlap; |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¸ç»´åæ ç»æä½ |
| | | /// è¡¨ç¤ºè´§ç©æ¾ç½®ä½ç½®çå·¦ä¸åè§åæ ï¼X,Y,Zï¼ |
| | | /// åæ ç³»è¯´æï¼ |
| | | /// - Xè½´ï¼æ²¿å®¹å¨é¿åº¦æ¹å |
| | | /// - Yè½´ï¼æ²¿å®¹å¨å®½åº¦æ¹å |
| | | /// - Zè½´ï¼åç´æ¹åï¼é«åº¦ï¼ |
| | | /// </summary> |
| | | public struct Point3D |
| | | { |
| | | /// <summary>Xè½´åæ ï¼æ¯«ç±³ï¼</summary> |
| | | public int X { get; } |
| | | |
| | | /// <summary>Yè½´åæ ï¼æ¯«ç±³ï¼</summary> |
| | | public int Y { get; } |
| | | |
| | | /// <summary>Zè½´åæ ï¼æ¯«ç±³ï¼</summary> |
| | | public int Z { get; } |
| | | |
| | | public Point3D(int x, int y, int z) |
| | | { |
| | | X = x; |
| | | Y = y; |
| | | Z = z; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å·²æ¾ç½®è´§ç©ä¿¡æ¯ç±» |
| | | /// è®°å½æ¯ä¸ªè´§ç©çä½ç½®åå°ºå¯¸ä¿¡æ¯ |
| | | /// åæ ç³»è¯´æï¼ä½ç½®ç¹ä¸ºè´§ç©çå·¦ä¸åè§åæ |
| | | /// </summary> |
| | | public class PlacedBlock |
| | | { |
| | | /// <summary>è´§ç©å·¦ä¸åè§åæ </summary> |
| | | public Point3D Position { get; } |
| | | |
| | | /// <summary>沿Xè½´æ¹åé¿åº¦ï¼æ¯«ç±³ï¼</summary> |
| | | public int Length { get; } |
| | | |
| | | /// <summary>沿Yè½´æ¹åå®½åº¦ï¼æ¯«ç±³ï¼</summary> |
| | | public int Width { get; } |
| | | |
| | | /// <summary>沿Zè½´æ¹åé«åº¦ï¼æ¯«ç±³ï¼</summary> |
| | | public int Height { get; } |
| | | |
| | | public PlacedBlock(Point3D position, int length, int width, int height) |
| | | { |
| | | Position = position; |
| | | Length = length; |
| | | Width = width; |
| | | Height = height; |
| | | } |
| | | } |
| | | |
| | | public struct ContainerSize |
| | | { |
| | | public int Length { get; set; } |
| | | public int Width { get; set; } |
| | | public int Height { get; set; } |
| | | |
| | | public ContainerSize(int length, int width, int height) |
| | | { |
| | | Length = length; |
| | | Width = width; |
| | | Height = height; |
| | | } |
| | | } |
| | | } |