private void GetNeighbor(ITriangle tri, int i, out ITriangle neighbor, out int nid) { neighbor = tri.GetNeighbor(i); nid = neighbor == null ? -1 : neighbor.ID; }
private List <Vertex[]> GetOpenEdges(ITriangle triangle) { List <ITriangle> neighbours = new List <ITriangle>(); for (int i = 0; i < 3; i++) { if (triangle.GetNeighbor(i) != null) { neighbours.Add(triangle.GetNeighbor(i)); } } List <Vertex[]> openEdges = new List <Vertex[]>() { new Vertex[2] { triangle.GetVertex(0), triangle.GetVertex(1) }, new Vertex[2] { triangle.GetVertex(1), triangle.GetVertex(2) }, new Vertex[2] { triangle.GetVertex(2), triangle.GetVertex(0) }, }; foreach (var neighbour in neighbours) { List <Vertex[]> neighbourEdges = new List <Vertex[]>() { new Vertex[2] { neighbour.GetVertex(0), neighbour.GetVertex(1) }, new Vertex[2] { neighbour.GetVertex(1), neighbour.GetVertex(2) }, new Vertex[2] { neighbour.GetVertex(2), neighbour.GetVertex(0) }, }; List <int> edgesToRemove = new List <int>(); for (int i = 0; i < openEdges.Count; i++) { for (int j = 0; j < neighbourEdges.Count; j++) { if (openEdges[i][0] == neighbourEdges[j][0] && openEdges[i][1] == neighbourEdges[j][1] || openEdges[i][0] == neighbourEdges[j][1] && openEdges[i][1] == neighbourEdges[j][0]) { edgesToRemove.Add(i); } } } for (int i = 0; i < edgesToRemove.Count; i++) { openEdges.RemoveAt(edgesToRemove[i] - i); } } return(openEdges); }