Utility class to read file.
More...
#include <ReadFile.h>
|
static std::vector< std::array< double, 4 > > | ReadXYZ (std::string FileName) |
| Read xyz file. More...
|
|
Utility class to read file.
Simple utility class to read in a trajectory file.
Supported file types:
Definition at line 42 of file ReadFile.h.
◆ ReadXYZ()
static std::vector<std::array<double,4> > SSAGES::ReadFile::ReadXYZ |
( |
std::string |
FileName | ) |
|
|
inlinestatic |
Read xyz file.
- Parameters
-
FileName | Name of xyz file to read in. |
- Returns
- Vector containing information stored in file.
Read in a xyz file. The information will be returned as a vector of 4-element arrays. Each array corresponds to one atom and stores the following information: atom-ID, x-coordinate, y-coordinate, z-coordinate.
Definition at line 66 of file ReadFile.h.
68 std::vector<std::array<double,4>> refcoord;
70 std::string comments =
"";
72 infile.open(FileName, std::ios::in);
75 throw std::runtime_error(
"ReadFile.h: File " + FileName +
" does not exist.");
79 std::getline(infile, line);
83 numatoms = std::stoi(line);
85 catch (
const std::invalid_argument&)
87 throw std::runtime_error(
"ReadFile.h: Invalid number of atoms defined in File.");
91 throw std::runtime_error(
"ReadFile.h: Must be more than 0 atoms defined in File.");
94 refcoord.resize(numatoms);
96 std::getline(infile, comments);
99 std::array<double,4> row;
100 while(infile >> row[0] >> row[1] >> row[2] >> row[3])
102 if(i < numatoms) refcoord[i] = row;
107 throw std::runtime_error(
108 "ReadFile: Header specified " + std::to_string(numatoms) +
109 " atoms, but read in " + std::to_string(i) +
". " +
110 "Check the format of " + FileName +
"."
Referenced by SSAGES::RMSDCV::Initialize().
The documentation for this class was generated from the following file:
- /home/michael/development/SSAGES/src/Utility/ReadFile.h