public bool IsCross(Cell cell) { // 幅が同じ位置 if (Left == cell.Left && Right == cell.Right) { // 上辺がcell1の中 // 下辺がcell1の外 if (IsInside(cell.Left, cell.Top) && IsInside(cell.Right, cell.Top) && !IsInside(cell.Left, cell.Bottom) && !IsInside(cell.Right, cell.Bottom)) { return true; } } // 高さが同じ位置 if (Top == cell.Top && Bottom == cell.Bottom) { // 左辺がcell1の中 // 右辺がcell1の外 if (IsInside(cell.Left, cell.Top) && IsInside(cell.Left, cell.Bottom) && !IsInside(cell.Right, cell.Top) && !IsInside(cell.Right, cell.Bottom)) { return true; } } return false; }
public Cell(Cell cell) { Left = cell.Left; Right = cell.Right; Top = cell.Top; Bottom = cell.Bottom; }
public bool IsNeighbor(Cell cell) { // 高さが同じで左右で隣接している if ((Top == cell.Top && Bottom == cell.Bottom) && (Right + 1 == cell.Left || Left - 1 == cell.Right)) { return true; } // 幅が同じで上下で隣接している if ((Left == cell.Left && Right == cell.Right) && (Bottom + 1 == cell.Top || Top - 1 == cell.Bottom)) { return true; } return false; }
public Cell Join(Cell cell) { Left = Math.Min(Left, cell.Left); Right = Math.Max(Right, cell.Right); Top = Math.Min(Top, cell.Top); Bottom = Math.Max(Bottom, cell.Bottom); return this; }
public bool IsInside(Cell cell) { return IsInside(cell.Left, cell.Top) && IsInside(cell.Right, cell.Bottom); }