void clGeometryReader::ReadPoints(fstream &file, dMatrix &pointsX, dMatrix &pointsY, dMatrix &pointsZ) const { int EndOfBlock; int AllRead; char line[LINE_SIZE]; char *ptrLine = line; const char *tkn = " ;:"; int countData; int rmax = 0; int cmax = 0; // Read line file.getline(line, LINE_SIZE); EndOfBlock = 0; AllRead = 0; countData = 0; while(!file.eof() && file.good() && !EndOfBlock) { // Check first character in trimmed line switch(*strtrim(line)) { case '#': case '*': // Comment line, read next line file.getline(line, LINE_SIZE); break; case '&': case '$': { // Block specifier int blockCommand = GetBlockSpec(line); switch(blockCommand) { case UNKNOWN_SPEC: throw clExceptionTree("clGeometryReader", "ReadPoints", "Unknown block specifier."); break; case POINT_SPEC: throw clExceptionTree("clGeometryReader", "ReadPoints", "Unexpected start of block POINT."); break; case PATCH_SPEC: throw clExceptionTree("clGeometryReader", "ReadPoints", "Unexpected start of block PATCH."); break; case SURFACE_SPEC: throw clExceptionTree("clGeometryReader", "ReadPoints", "Unexpected start of block SURFACE."); break; case GEOMETRY_SPEC: throw clExceptionTree("clGeometryReader", "ReadPoints", "Unexpected start of block GEOMETRY."); break; case END_SPEC: EndOfBlock = 1; break; default: throw clExceptionTree("clGeometryReader", "ReadPoints", "Function GetBlockSpec returned unknown value."); break; } break; } case '/': // End of block specifier EndOfBlock = 1; break; default: if(strlen(strtrim(line)) > 0) { // Data line countData++; // Matrix specifiers if(countData==1) { // column defines constant u-values ptrLine = strtok(line, tkn); cmax = str2int(ptrLine); // row defines constant v-values ptrLine = strtok(NULL, tkn); rmax = str2int(ptrLine); // Set matrix dimensions pointsX.SetNumberRows(rmax); pointsX.SetNumberColumns(cmax); pointsY.SetNumberRows(rmax); pointsY.SetNumberColumns(cmax); pointsZ.SetNumberRows(rmax); pointsZ.SetNumberColumns(cmax); } // Specification of the x-coordinates else if(countData>=2 && countData<(2+rmax)) { int row = (countData-1); // Set first u-element in current v ptrLine = strtok(line, tkn); pointsX.SetElement(row, 1, str2double(ptrLine)); // Set following u-elements in current v for(int c=2; c<=cmax; c++) { ptrLine = strtok(0, tkn); pointsX.SetElement(row, c, str2double(ptrLine)); } } // Specification of the y-coordinates else if(countData>=(2+rmax) && countData<(2+rmax+rmax)) { int row = (countData-1-rmax); // Set first u-element in current v ptrLine = strtok(line, tkn); pointsY.SetElement(row, 1, str2double(ptrLine)); // Set following u-elements in current v for(int c=2; c<=cmax; c++) { ptrLine = strtok(0, tkn); pointsY.SetElement(row, c, str2double(ptrLine)); } } // Specification of the z-coordinates else if(countData>=(2+rmax+rmax) && countData<(2+rmax+rmax+rmax)) { int row = (countData-1-rmax-rmax); // Set first u-element in current v ptrLine = strtok(line, tkn); pointsZ.SetElement(row, 1, str2double(ptrLine)); // Set following u-elements in current v for(int c=2; c<=cmax; c++) { ptrLine = strtok(0, tkn); pointsZ.SetElement(row, c, str2double(ptrLine)); } } // Too much data else { throw clExceptionTree("clGeometryReader", "ReadPoints", "Too much data."); } if(countData==(1+rmax+rmax+rmax)) { AllRead = 1; } } file.getline(line, LINE_SIZE); break; } } if(!EndOfBlock || !AllRead) { throw clExceptionTree("clGeometryReader", "ReadPoints", "Unexpected end while reading block POINT."); } }