BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
buildBondsProcessor.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_STRUCTURE_BUILDBONDSPROCESSOR_H
6 #define BALL_STRUCTURE_BUILDBONDSPROCESSOR_H
7 
8 #ifndef BALL_CONCEPT_PROCESSOR_H
9  #include <BALL/CONCEPT/processor.h>
10 #endif
11 
12 #ifndef BALL_KERNEL_ATOMCONTAINER_H
14 #endif
15 
16 #ifndef BALL_DATATYPE_HASHMAP_H
17  #include <BALL/DATATYPE/hashMap.h>
18 #endif
19 
20 #ifndef BALL_KERNEL_BOND_H
21  #include <BALL/KERNEL/bond.h>
22 #endif
23 
24 #ifndef BALL_DATATYPE_OPTIONS_H
25  #include <BALL/DATATYPE/options.h>
26 #endif
27 
28 
29 #ifdef BALL_HAS_HASH_MAP
30 namespace BALL_MAP_NAMESPACE
31 {
32  template<>
33  struct hash<BALL::Bond::BondOrder>
34  {
35  size_t operator () (const BALL::Bond::BondOrder o) const
36  {return (size_t)o;}
37  };
38 }
39 #endif
40 
41 namespace BALL
42 {
43 
48  : public UnaryProcessor<AtomContainer>
49  {
50 
51  public:
52 
56 
58  {
62  static const char* BONDLENGTHS_FILENAME;
63 
70  static const char* DELETE_EXISTING_BONDS;
71 
77  static const char* REESTIMATE_BONDORDERS_RINGS;
78 
84  static const char* DELETE_OVERESTIMATED_BONDS;
85  };
86 
89  {
91  static const char* BONDLENGTHS_FILENAME;
92 
94  static const bool DELETE_EXISTING_BONDS;
95 
97  static const bool REESTIMATE_BONDORDERS_RINGS;
98 
100  static const bool DELETE_OVERESTIMATED_BONDS;
101  };
103 
104 
108 
110 
113 
116 
118  BuildBondsProcessor(const String& file_name) throw(Exception::FileNotFound);
119 
121  virtual ~BuildBondsProcessor();
123 
127 
129  virtual bool start();
130 
132  virtual Processor::Result operator () (AtomContainer& ac);
134 
138 
139  Size getNumberOfBondsBuilt();
140 
142  void setBondLengths(const String& file_name) throw(Exception::FileNotFound);
143 
146 
148 
152 
153  BuildBondsProcessor& operator = (const BuildBondsProcessor& bbp);
155 
159 
161 
164  void setDefaultOptions();
166 
167  protected:
168 
170  Size buildBondsHashGrid3_(AtomContainer& ac);
171 
173  void estimateBondOrders_(AtomContainer& ac);
174 
176  void reestimateBondOrdersRings_(AtomContainer& ac);
177 
179  void deleteOverestimatedBonds_(AtomContainer& ac);
180 
182  void readBondLengthsFromFile_(const String& file_name = "") throw(Exception::FileNotFound);
183 
185  Size num_bonds_;
186 
188  HashMap<Size, HashMap<Size, HashMap<int, float> > > bond_lengths_;
189 
191  HashMap<Size, HashMap<Size, float> > max_bond_lengths_;
192 
194  HashMap<Size, HashMap<Size, float> > min_bond_lengths_;
195 
196  /*_ returns the best fitting bond order of a bond between atoms of
197  element e1 and element e2 with a distance of length
198  */
199  Bond::BondOrder getNearestBondOrder_(float length, Size e1, Size e2);
200 
201  /*_ Returns true if the atom with atomic number an1 and atom with
202  atomic number an2 can share a bond. If, the parameter length
203  holds the maximal length of such a bond.
204  */
205  bool getMaxBondLength_(float& length, Size an1, Size an2);
206 
207  /*_ Returns true if the atom with atomic number an1 and atom with
208  atomic number an2 can share a bond. If, the parameter length
209  holds the minimal length of such a bond.
210  */
211  bool getMinBondLength_(float& length, Size an1, Size an2);
212 
214  float max_length_;
215  };
216 
217 } // namespace BALL
218 
219 
220 #endif // BALL_STRUCTURE_BUILDBONDSPROCESSOR_H