//Возвращает кол-во соседей protected int FindNeiborgs(Thetra T) { //поиск соседних тетра HashSet <int> finded = new HashSet <int>(); HashSet <int> looked = new HashSet <int>(); int nT = Figures.IndexOf(T), nY; int i, j; int countSide = 0; foreach (Thetra Y in Figures) { if (T != Y) { for (j = 0; j < 4; j++) { for (i = 0; i < 4 && Y.p[i] != T.p[j]; i++) { ; } if (i != 4) { finded.Add(i); looked.Add(j); } } if (finded.Count == 3)//перезаписывается лишний раз уже известные стороны { nY = Figures.IndexOf(Y); Figures[nT].near[PositionNumerSide(looked)] = nY; Figures[nY].near[PositionNumerSide(finded)] = nT; countSide++; } finded.Clear(); looked.Clear(); } } return(countSide); }
public (Thetra[], Vector3D[]) Read() { Thetra[] resultThetras = new Thetra[1]; Vector3D[] resultVectors; string cur; string[] curNumbers; int numEntityBlocks, numNodes, numElements; int[] mesh = new int[5]; using (var file = new StreamReader(path)) { cur = file.ReadLine(); while (cur != "$Nodes") { cur = file.ReadLine(); } cur = file.ReadLine(); curNumbers = cur.Split(' '); numEntityBlocks = Int32.Parse(curNumbers[0]); numNodes = Int32.Parse(curNumbers[1]); resultVectors = new Vector3D[numNodes]; for (int i = 0, ind = 0; i < numEntityBlocks; i++) { cur = file.ReadLine(); curNumbers = cur.Split(' '); numNodes = Int32.Parse(curNumbers[3]); for (int j = 0; j < numNodes; j++) { file.ReadLine(); } for (int j = 0; j < numNodes; j++) { resultVectors[ind++] = new Vector3D(file.ReadLine()); } } while (cur != "$Elements") { cur = file.ReadLine(); } cur = file.ReadLine(); curNumbers = cur.Split(' '); numEntityBlocks = Int32.Parse(curNumbers[0]); numElements = Int32.Parse(curNumbers[1]); for (int i = 0, ind = 0; i < numEntityBlocks; i++) { cur = file.ReadLine(); curNumbers = cur.Split(' '); if (curNumbers[0] != "3") { for (int j = 0; j < Int32.Parse(curNumbers[3]); j++) { file.ReadLine(); } continue; } numNodes = Int32.Parse(curNumbers[3]); resultThetras = new Thetra[numNodes]; for (int j = 0; j < numNodes; j++) { curNumbers = file.ReadLine().Split(" "); for (int k = 0; k < 4; k++) { mesh[k] = Int32.Parse(curNumbers[k + 1]) - 1; } mesh[4] = 0; resultThetras[ind++] = new Thetra(mesh); } } } return(resultThetras, resultVectors); }