/// <summary> /// Extracts the edges of a collection of cells /// </summary> /// <param name="cellularFloor">The CellularFloorBaseGeometry to which the cells belong</param> /// <param name="collection">A collection of cells IDs to find its edges</param> /// <returns>A collection of cell IDs on the edge</returns> public static HashSet <int> GetEdgeOfField(CellularFloorBaseGeometry cellularFloor, HashSet <int> collection) { HashSet <int> edge = new HashSet <int>(); foreach (var item in collection) { if (CellUtility.onEdge(item, cellularFloor, collection)) { edge.Add(item); } } return(edge); }
/// <summary> /// Extracts the edges of a collection of cells /// </summary> /// <param name="cellularFloor">The CellularFloorBaseGeometry to which the cells belong</param> /// <param name="collection">A collection of cells to find its edges</param> /// <returns>A collection of cell indices on the edge</returns> public static HashSet <Index> GetIndexEdgeOfField(CellularFloorBaseGeometry cellularFloor, HashSet <Cell> collection) { HashSet <Index> edge = new HashSet <Index>(); foreach (var item in collection) { Index index = cellularFloor.FindIndex(item); if (CellUtility.onEdge(index, cellularFloor, collection)) { edge.Add(index); } } return(edge); }
/// <summary> /// Get a list of ordered cells on the edge of a cell collection /// </summary> /// <param name="cellularFloor">The CellularFloorBaseGeometry to which the cells belong</param> /// <param name="collection">A collection of cells to find its edges</param> /// <returns>An ordered list of cells</returns> public static List <Cell> GetOrderedEdge(CellularFloorBaseGeometry cellularFloor, HashSet <Cell> collection) { HashSet <Index> edge = CellUtility.GetIndexEdgeOfField(cellularFloor, collection); IndexGraph indexGraph = new IndexGraph(edge); int zero = 0, one = 0, two = 0, three = 0, four = 0; foreach (var item in indexGraph.IndexNodeMap.Values) { switch (item.Connections.Count) { case 0: zero++; break; case 1: one++; break; case 2: two++; break; case 3: three++; break; case 4: four++; break; default: break; } } MessageBox.Show(string.Format("Zero: {0}\nOne: {1}\nTwo: {2}\nThree: {3}\nFour: {4}", zero.ToString(), one.ToString(), two.ToString(), three.ToString(), four.ToString())); return(null); }