18#ifndef __VOTCA_CSG_XYZREADER_H
19#define __VOTCA_CSG_XYZREADER_H
57 bool Open(
const std::string &file)
override;
66 throw std::runtime_error(
"Reading xyz file '" +
file_ +
"' failed");
70 void Close()
override;
75 return container.size();
80 template <
bool topology,
class T>
82 const Eigen::Vector3d &pos) {
85 typename std::iterator_traits<
decltype(container.begin())>::value_type;
87 container.push_back(atom(
id, name, pos2));
90 template <
bool topology,
class T>
92 const Eigen::Vector3d &pos) {
97 name + boost::lexical_cast<std::string>(
id),
105 template <
bool topology,
class T>
113template <
bool topology,
class T>
121 if (line1.size() != 1) {
122 throw std::runtime_error(
123 "First line of xyz file should contain number "
124 "of atoms/beads, nothing else.");
126 Index natoms = boost::lexical_cast<Index>(line1[0]);
128 throw std::runtime_error(
129 "number of beads in topology and trajectory differ");
135 for (
Index i = 0; i < natoms; ++i) {
139 throw std::runtime_error(
"unexpected end of file in xyz file");
142 std::vector<std::string> fields = tok.
ToVector();
143 if (fields.size() != 4) {
144 throw std::runtime_error(
"invalide line " +
145 boost::lexical_cast<std::string>(
line_) +
146 " in xyz file\n" + line);
148 Eigen::Vector3d pos =
149 Eigen::Vector3d(boost::lexical_cast<double>(fields[1]),
150 boost::lexical_cast<double>(fields[2]),
151 boost::lexical_cast<double>(fields[3]));
virtual void setPos(const Eigen::Vector3d &bead_position)
topology of the whole system
Bead * CreateBead(Bead::Symmetry symmetry, std::string name, std::string type, Index resnr, double m, double q)
Creates a new Bead.
Bead * getBead(const Index i)
Returns a pointer to the bead with index i.
trajectoryreader interface
class for reading xyz files
const tools::DistanceUnit distance_unit
Index getContainerSize(Topology &container)
void ReadFile(T &container)
bool Open(const std::string &file) override
open a trajectory file
void AddAtom(T &container, std::string name, Index id, const Eigen::Vector3d &pos)
bool FirstFrame(Topology &top) override
read in the first frame
bool ReadFrame(T &container)
bool NextFrame(Topology &top) override
read in the next frame
~XYZReader() override=default
bool ReadTopology(std::string file, Topology &top) override
open a topology file
void AddAtom(Topology &container, std::string name, Index id, const Eigen::Vector3d &pos)
Index getContainerSize(T &container)
base class for all analysis tools