//For each triangle, find its neighbors, note that there are 2 types of neighbors, sharedEdge neighbors and sharedPoint neighbors. the TidyNeighbor() function would do the classification. private void CalculateTriangleNeighbor() { for (int i = 0; i < g_triangleList.Count; i++) { EPMTriangle t = g_triangleList[i]; List <EPMPoint> vertices = t.g_pointList; for (int j = 0; j < vertices.Count; j++) { List <EPMTriangle> shared = m_pointIndexToTriangleList[vertices[j].g_indexInList]; for (int k = 0; k < shared.Count; k++) { t.g_sharePointNeighbors.Add(shared[k]); } } t.TidyNeighbors(); } }