BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
73  HMOFile();
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
193  void readChargeData_();
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
std::vector< String > & getComments()
Accessor for the vector of comments.
Definition: HMOFile.h:132
std::vector< String > const & getComments() const
Accessor for the vector of comments, const version.
Definition: HMOFile.h:138
std::ios::openmode OpenMode
Definition: file.h:168
BALL_EXTERN_VARIABLE const double c
Definition: constants.h:149
std::vector< HMOCharge > const & getCharges() const
Accessor for the vector of charges, const version.
Definition: HMOFile.h:120
std::vector< String > comments_
Definition: HMOFile.h:184
std::vector< HMOCharge > charges_
Definition: HMOFile.h:181
BALL_EXPORT bool operator==(const String &s1, const String &s2)
bool hasCharges() const
Test for the presence of charges.
Definition: HMOFile.h:108
std::vector< HMOCharge > & getCharges()
Accessor for the vector of charges.
Definition: HMOFile.h:114
#define BALL_EXPORT
Definition: COMMON/global.h:50
bool hasComments() const
Test for the presence of comments.
Definition: HMOFile.h:126