00001
00002
00003
00004
00005 #ifndef BALL_FORMAT_TRRFILE_H
00006 #define BALL_FORMAT_TRRFILE_H
00007
00008 #ifndef BALL_FORMAT_TRAJECTORYFILE_H
00009 # include <BALL/FORMAT/trajectoryFile.h>
00010 #endif
00011
00012 namespace BALL
00013 {
00024 class BALL_EXPORT TRRFile
00025 : public TrajectoryFile
00026 {
00027
00028 public:
00029
00033
00040 class BALL_EXPORT TRRHeader
00041 {
00042 public:
00043
00045 Size MAGIC;
00047 Size VERSION;
00049 Size title_string_length;
00051 String title_string;
00055 Size ir_size;
00059 Size e_size;
00060
00067 Size bounding_box_data_size;
00068
00073 Size vir_size;
00074
00079 Size pres_size;
00080
00084 Size top_size;
00085
00089 Size sym_size;
00090
00094 Size position_data_size;
00095
00100 Size velocity_data_size;
00101
00106 Size force_data_size;
00107
00110 Size number_of_atoms;
00111
00114 Size timestep_index;
00115
00119 Size nre;
00120
00123 float timestep_time;
00124
00128 float lambda;
00129
00130 TRRHeader()
00131 : MAGIC(1993),
00132 VERSION(13),
00133 title_string_length(24),
00134 title_string("Created by BALL::TRRFile"),
00135 ir_size(0),
00136 e_size(0),
00137 vir_size(0),
00138 pres_size(0),
00139 top_size(0),
00140 sym_size(0),
00141 velocity_data_size(0),
00142 force_data_size(0),
00143 timestep_index(0),
00144 nre(0),
00145 timestep_time(0.002),
00146 lambda(0)
00147 {
00148 }
00149 };
00150
00152
00156
00158 TRRFile();
00159
00161 TRRFile(const String& name, File::OpenMode open_mode = std::ios::in);
00162
00164 virtual ~TRRFile();
00166
00170
00172 virtual void clear();
00174
00178
00180 bool operator == (const TRRFile& file) const;
00182
00184
00185
00187 virtual bool init();
00188
00194 virtual bool writeNextHeader(const TRRHeader& header);
00195
00200 virtual bool readNextHeader(TRRHeader& header);
00201
00206 virtual bool append(const SnapShot& snapshot);
00207
00212 virtual bool read(SnapShot& snapshot);
00213
00215 virtual TRRFile& operator >> (SnapShotManager& ssm);
00216
00219 virtual bool flushToDisk(const std::vector<SnapShot>& buffer)
00220 throw(File::CannotWrite);
00222
00223
00226
00228 bool hasVelocities() const;
00229
00231 void setVelocityStorage(bool storage);
00232
00234 bool hasForces() const;
00235
00237 void setForceStorage(bool storage);
00238
00240 Size getPrecision() const;
00241
00243 bool setPrecision(const Size precision);
00244
00246 float getTimestep() const;
00247
00249 void setTimestep(float timestep);
00250
00252 Vector3 getBoundingBoxX() const;
00253
00255 Vector3 getBoundingBoxY() const;
00256
00258 Vector3 getBoundingBoxZ() const;
00259
00261 void setBoundingBox(const Vector3& x, const Vector3& y, const Vector3& z);
00262
00264
00265 private:
00266 const TRRFile& operator = (const TRRFile& file);
00267
00268 protected:
00269
00270
00271 TRRHeader header_;
00272
00273
00274 Size precision_;
00275
00276
00277 bool has_velocities_;
00278
00279
00280 bool has_forces_;
00281
00282
00283 Size timestep_index_;
00284
00285
00286 float timestep_;
00287
00288
00289
00290 Vector3 box1_, box2_, box3_;
00291
00292 BinaryFileAdaptor<Size> adapt_size_;
00293 BinaryFileAdaptor<char> adapt_char_;
00294 BinaryFileAdaptor<float> adapt_float_;
00295 BinaryFileAdaptor<double> adapt_double_;
00296 };
00297 }
00298
00299 #endif // BALL_FORMAT_TRRFILE_H