| 28 | { |
| 29 | |
| 30 | CellSet connected(const CellSet & cells) |
| 31 | { |
| 32 | CellSet res = cells; |
| 33 | CellSet addedCells = cells; |
| 34 | |
| 35 | // while some cells have been added |
| 36 | while(addedCells.size() != 0) |
| 37 | { |
| 38 | CellSet newAddedCells; |
| 39 | foreach(Cell * c, addedCells) |
| 40 | { |
| 41 | CellSet neighbourhood = c->neighbourhood(); |
| 42 | foreach(Cell * d, neighbourhood) |
| 43 | { |
| 44 | if(!res.contains(d)) |
| 45 | { |
| 46 | res << d; |
| 47 | newAddedCells << d; |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | addedCells = newAddedCells; |
| 52 | } |
| 53 | |
| 54 | return res; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | CellSet closure(Cell * c) |