BALL  1.5.0
HMOFile.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_FORMAT_HMOFILE_H
6 #define BALL_FORMAT_HMOFILE_H
7 
9 
10 #ifndef BALL_KERNEL_ATOMCONTAINER_H
12 #endif
13 
14 #ifndef BALL_MATHS_SURFACE_H
15 # include <BALL/MATHS/surface.h>
16 #endif
17 
18 namespace BALL
19 {
33  : public LineBasedFile
34  {
35  public:
39  class HMOCharge
40  {
41  public:
43  float value;
44 
45  bool operator == (const HMOCharge& c) const
46  {
47  return ((position == c.position) && (value == c.value));
48  }
49  };
50 
52  {
53  L2 = 60, // line element with two nodes
54  L3 = 63, // line element with three nodes
55  T3 = 103, // triangular element with three nodes
56  T6 = 106, // triangular element with six nodes
57  Q4 = 104, // quadrilateral element with four nodes
58  Q8 = 108, // quadrilateral element with eight nodes
59  TH4 = 204, // tetrahedral element with four nodes
60  TH10 = 210, // tetrahedral element with ten nodes
61  P6 = 206, // pentahedral element with six nodes
62  P15 = 215, // pentahedral element with fifteen nodes
63  H8 = 208, // hexaedral element with eight nodes
64  H20 = 220 // hexaedral element with twenty nodes
65  };
67 
71 
74 
78  HMOFile(const String& filename, File::OpenMode open_mode = std::ios::in);
79 
81  virtual ~HMOFile();
82 
84 
88 
90  virtual void clear();
91 
93 
97 
99  bool operator == (const HMOFile& file);
100 
102 
106 
108  bool hasCharges() const
109  {
110  return (charges_.size() > 0);
111  }
112 
114  std::vector<HMOCharge>& getCharges()
115  {
116  return charges_;
117  }
118 
120  std::vector<HMOCharge> const& getCharges() const
121  {
122  return charges_;
123  }
124 
126  bool hasComments() const
127  {
128  return (comments_.size() > 0);
129  }
130 
132  std::vector<String>& getComments()
133  {
134  return comments_;
135  }
136 
138  std::vector<String> const& getComments() const
139  {
140  return comments_;
141  }
143 
147 
151  virtual bool open(const String& name, File::OpenMode open_mode = std::ios::in);
152 
157  virtual bool read(Surface& surface);
158 
166  virtual bool write(Surface const& surface);
167 
175  virtual bool write(Surface const& surface, AtomContainer const& ac);
176 
178 
179  protected:
180  // The vector of charge positions and magnitudes
181  std::vector<HMOCharge> charges_;
182 
183  // The comments contained in the original file
184  std::vector<String> comments_;
185 
186  // read the node data
187  void readNodeData_(Surface& surface);
188 
189  // read the element data
190  void readElementData_(Surface& surface);
191 
192  // read the charge data
194 
195  // read until a given text is found, and store all comments along the way
196  bool readUntil_(String const& pattern);
197 
198  // write the node section of the HMO file
199  void writeNodes_(Surface const& surface);
200 
201  // write the elements section of the HMO file
202  void writeElements_(Surface const& surface);
203 
204  // write the charges section of the HMO file
205  void writeCharges_(AtomContainer const& ac);
206 
207  private:
208  const HMOFile& operator = (const HMOFile& file);
209  };
210 }
211 
212 #endif // BALL_FORMAT_HMOFILE_H
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::HMOFile::HMOFile
HMOFile(const String &filename, File::OpenMode open_mode=std::ios::in)
BALL::HMOFile::ElementType
ElementType
Definition: HMOFile.h:52
BALL::HMOFile::readElementData_
void readElementData_(Surface &surface)
BALL::HMOFile::readChargeData_
void readChargeData_()
BALL::AtomContainer
Definition: atomContainer.h:32
BALL::HMOFile::open
virtual bool open(const String &name, File::OpenMode open_mode=std::ios::in)
BALL::HMOFile::HMOCharge
Definition: HMOFile.h:40
BALL::HMOFile::getCharges
std::vector< HMOCharge > const & getCharges() const
Accessor for the vector of charges, const version.
Definition: HMOFile.h:120
BALL::HMOFile::HMOCharge::value
float value
Definition: HMOFile.h:43
BALL::HMOFile::readUntil_
bool readUntil_(String const &pattern)
BALL::HMOFile::~HMOFile
virtual ~HMOFile()
Destructor.
BALL::HMOFile::hasCharges
bool hasCharges() const
Test for the presence of charges.
Definition: HMOFile.h:108
BALL::HMOFile::HMOFile
HMOFile()
Default constructor.
BALL::String
Definition: string.h:57
BALL::HMOFile::write
virtual bool write(Surface const &surface, AtomContainer const &ac)
BALL
Definition: constants.h:13
BALL::HMOFile::writeElements_
void writeElements_(Surface const &surface)
BALL::HMOFile::writeNodes_
void writeNodes_(Surface const &surface)
BALL::HMOFile::writeCharges_
void writeCharges_(AtomContainer const &ac)
BALL::HMOFile::clear
virtual void clear()
Clear method.
BALL::Constants::c
BALL_EXTERN_VARIABLE const double c
Definition: constants.h:149
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition: file.h:165
BALL::HMOFile
Definition: HMOFile.h:34
BALL::TVector3< float >
BALL::HMOFile::getComments
std::vector< String > & getComments()
Accessor for the vector of comments.
Definition: HMOFile.h:132
BALL::HMOFile::getComments
std::vector< String > const & getComments() const
Accessor for the vector of comments, const version.
Definition: HMOFile.h:138
BALL::HMOFile::comments_
std::vector< String > comments_
Definition: HMOFile.h:184
BALL::operator==
BALL_EXPORT bool operator==(const String &s1, const String &s2)
BALL::HMOFile::hasComments
bool hasComments() const
Test for the presence of comments.
Definition: HMOFile.h:126
BALL::HMOFile::read
virtual bool read(Surface &surface)
BALL::HMOFile::HMOCharge::position
Vector3 position
Definition: HMOFile.h:42
BALL::HMOFile::getCharges
std::vector< HMOCharge > & getCharges()
Accessor for the vector of charges.
Definition: HMOFile.h:114
BALL::TSurface< float >
BALL::HMOFile::charges_
std::vector< HMOCharge > charges_
Definition: HMOFile.h:181
atomContainer.h
BALL::HMOFile::readNodeData_
void readNodeData_(Surface &surface)
BALL::LineBasedFile
Definition: lineBasedFile.h:22
BALL::HMOFile::write
virtual bool write(Surface const &surface)
lineBasedFile.h
surface.h