Advertisement
Guest User

Untitled

a guest
Oct 15th, 2014
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. // ***** ===== FILE_IO::READ_GEOM_GRID() ===== *****
  2.  
  3. void File_Io::readGeomGrid(const char* filename, Geometry_3d::Table* geomTable, Grid_3d::Table* gridTable, int* withNumbers, int* withPotentials)
  4. {
  5. std::ifstream file(filename,std::ifstream::in);
  6. if (!file.good()) throw std::runtime_error("File_Io::readGeomGrid()");
  7.  
  8. // ***
  9.  
  10. std::string headerLine;
  11.  
  12. do
  13. std::getline(file,headerLine);
  14. while (headerLine.empty() || headerLine.at(0) == '#');
  15.  
  16. bool asciiMode;
  17.  
  18. if (headerLine.substr(0,5) == "ASCII")
  19. {
  20. asciiMode = true;
  21. headerLine = headerLine.substr(5,std::string::npos);
  22. }
  23. else if (headerLine.substr(0,6) == "BINARY")
  24. {
  25. asciiMode = false;
  26. headerLine = headerLine.substr(6,std::string::npos);
  27. }
  28. else
  29. throw std::runtime_error("File_Io::readGeomGrid()");
  30.  
  31. int size(0);
  32.  
  33. bool readNumbers(false);
  34. bool readPotentials(false);
  35.  
  36. {
  37. std::istringstream line(headerLine);
  38.  
  39. line >> size;
  40. if (line.fail()) throw std::runtime_error("File_Io::readGeomGrid()");
  41.  
  42. line >> std::noboolalpha >> readNumbers;
  43. if (line.fail()) throw std::runtime_error("File_Io::readGeomGrid()");
  44.  
  45. line >> std::noboolalpha >> readPotentials;
  46. if (line.fail()) throw std::runtime_error("File_Io::readGeomGrid()");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement