24#if !defined(LOOS_DCDWRITER_HPP)
25#define LOOS_DCDWRITER_HPP
39#include <loos_defs.hpp>
41#include <AtomicGroup.hpp>
43#include <trajwriter.hpp>
51 typedef union {
unsigned int ui;
int i;
char c[4];
float f; } DataOverlay;
55 static pTrajectoryWriter create(
const std::string& s,
const bool append =
false) {
56 return(pTrajectoryWriter(
new DCDWriter(s, append)));
70 explicit DCDWriter(
const std::string& s,
const bool append =
false) :
72 _natoms(0), _nsteps(0),
73 _timestep(0.001), _current(0),
75 _header_written(false)
80 _titles.push_back(
"AUTO GENERATED BY LOOS");
84 explicit DCDWriter(std::iostream& fs,
const bool append =
false) :
86 _natoms(0), _nsteps(0), _timestep(0.001), _current(0),
87 _has_box(false), _header_written(false)
92 _titles.push_back(
"AUTO GENERATED BY LOOS");
96 DCDWriter(
const std::string& s,
const std::vector<AtomicGroup>& grps,
const bool append =
false) :
98 _natoms(grps[0].size()),
102 _has_box(grps[0].isPeriodic()),
103 _header_written(false)
108 _titles.push_back(
"AUTO GENERATED BY LOOS");
115 DCDWriter(
const std::string& s,
const std::vector<AtomicGroup>& grps,
const std::string& comment,
const bool append =
false) :
117 _natoms(grps[0].size()),
118 _nsteps(grps.size()),
121 _has_box(grps[0].isPeriodic()),
122 _header_written(false)
127 _titles.push_back(comment);
134 DCDWriter(
const std::string& s,
const std::vector<AtomicGroup>& grps,
const std::vector<std::string>& comments,
const bool append =
false) :
136 _natoms(grps[0].size()),
137 _nsteps(grps.size()),
140 _has_box(grps[0].isPeriodic()),
141 _header_written(false)
162 void setHeader(
const int na,
const int ns,
const greal ts,
const bool bf) {
164 throw(std::logic_error(
"Cannot set header after having written it"));
172 void setTitles(
const std::vector<std::string>& titles) {
174 throw(std::logic_error(
"Cannot set header after having written it"));
178 void setTitle(
const std::string& s) {
180 throw(std::logic_error(
"Cannot set header after having written it"));
181 _titles.clear(); addTitle(s);
184 void addTitle(
const std::string& s) {
186 throw(std::logic_error(
"Cannot set header after having written it"));
187 _titles.push_back(s);
190 void setComments(
const std::vector<std::string>& comments) { setTitles(comments); }
205 void writeFrames(
const std::vector<AtomicGroup>& grps);
207 void writeHeader(
void);
212 void writeF77Line(
const char*
const data,
const unsigned int len);
213 std::string fixStringSize(
const std::string& s,
const unsigned int size);
214 void writeBox(
const GCoord& box);
216 void prepareToAppend();
220 uint _natoms, _nsteps;
224 bool _header_written;
225 std::vector<std::string> _titles;
Class for handling groups of Atoms (pAtoms, actually)
Definition AtomicGroup.hpp:108
A very lightweight class for writing simple DCDs.
Definition dcdwriter.hpp:48
void writeFrames(const std::vector< AtomicGroup > &grps)
Same as writeFrame(), but writes out the vector of frames...
Definition dcdwriter.cpp:157
void setComments(const std::vector< std::string > &comments)
Set comments in metadata (not all formats support)
Definition dcdwriter.hpp:190
DCDWriter(const std::string &s, const bool append=false)
Setup for writing to a file named by s.
Definition dcdwriter.hpp:70
bool hasComments() const
Does format support comments in metadata?
Definition dcdwriter.hpp:191
void setHeader(const int na, const int ns, const greal ts, const bool bf)
Sets header parameters.
Definition dcdwriter.hpp:162
DCDWriter(const std::string &s, const std::vector< AtomicGroup > &grps, const std::vector< std::string > &comments, const bool append=false)
Writes coordinates of grps adding comments as TITLE records.
Definition dcdwriter.hpp:134
DCDWriter(const std::string &s, const std::vector< AtomicGroup > &grps, const std::string &comment, const bool append=false)
Writes coordinates of grps adding comment as a TITLE record.
Definition dcdwriter.hpp:115
DCDWriter(const std::string &s, const std::vector< AtomicGroup > &grps, const bool append=false)
Writes the coordinates of grps to file s as a DCD.
Definition dcdwriter.hpp:96
DCDWriter(std::iostream &fs, const bool append=false)
Setup for writing to a stream.
Definition dcdwriter.hpp:84
uint framesWritten(void) const
Total frames in output file.
Definition dcdwriter.hpp:209
void writeFrame(const AtomicGroup &grp)
Writes a frame to a growing DCD.
Definition dcdwriter.cpp:109
Base class for writing trajectories.
Definition trajwriter.hpp:53
Namespace for most things not already encapsulated within a class.
Definition version.cpp:3