/// <summary> /// Return gridcells group with id matched bubbles around free gridcell /// </summary> /// <param name="freeGCell"></param> /// <returns></returns> public MatchGroup GetIdArea(GridCell freeGCell, int id) { MatchGroup res = new MatchGroup(); MatchGroup equalNeigh = new MatchGroup(); MatchGroup neighTemp; if (freeGCell) { NeighBorns nCells = new NeighBorns(freeGCell, id); // res.Add(freeGCell); equalNeigh.AddRange(nCells.EqualIDCells); //equalNeigh.AddRange(gCell.EqualNeighBornCells()); while (equalNeigh.Length > 0) { res.AddRange(equalNeigh.cells); neighTemp = new MatchGroup(); foreach (var item in equalNeigh.cells) { nCells = new NeighBorns(item, id); neighTemp.AddRange(nCells.EqualIDCells); // neighTemp.AddRange(item.EqualNeighBornCells()); } equalNeigh = neighTemp; equalNeigh.Remove(res.cells); } } res.Remove(freeGCell); return(res); }
public void CreateNeighBorns() { if (gCell == null) { return; } NeighBorns nBs = new NeighBorns(gCell); // gridcell neighborns neighBorns = new List <PFCell>(nBs.Cells.Count); foreach (var n in nBs.Cells) { neighBorns.Add(n.pfCell); } Left = (nBs.Left) ? nBs.Left.pfCell : null; Right = (nBs.Right) ? nBs.Right.pfCell : null; TopLeft = (nBs.TopLeft) ? nBs.TopLeft.pfCell : null; TopRight = (nBs.TopRight) ? nBs.TopRight.pfCell : null; BottomLeft = (nBs.BottomLeft) ? nBs.BottomLeft.pfCell : null; BottomRight = (nBs.BottomRight) ? nBs.BottomRight.pfCell : null; }
/// <summary> /// Return all closed not intersected areas /// </summary> /// <returns></returns> public List <GridCell> GetDetacheCells() { CellsGroup main = new CellsGroup(); // main group from 0 row CellsGroup neigh = new CellsGroup(); CellsGroup neighTemp; main.AddRange(Rows[serviceRowsCount].GetNotEmptyCells()); // start at service rows NeighBorns nCells; for (int i = 0; i < main.Length; i++) { nCells = new NeighBorns(main.cells[i]); neigh.AddRange(nCells.NotEmptyCells);// neigh.AddRange(main.cells[i].NotEmptyNeighBornCells()); } while (neigh.Length > 0) // find and add to group not empty neighborns { main.AddRange(neigh.cells); neighTemp = new CellsGroup(); foreach (var item in neigh.cells) { nCells = new NeighBorns(item); neighTemp.AddRange(nCells.NotEmptyCells); } neigh = neighTemp; neigh.Remove(main.cells); } CellsGroup all = new CellsGroup(); all.AddRange(GetNotEmptyCells()); all.Remove(main.cells); // Debug.Log("detouched: " + all.ToString()); return(all.cells); }