00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_STRUCTURE_BUILDBONDSPROCESSOR_H
00008 #define BALL_STRUCTURE_BUILDBONDSPROCESSOR_H
00009
00010 #ifndef BALL_CONCEPT_PROCESSOR_H
00011 #include <BALL/CONCEPT/processor.h>
00012 #endif
00013
00014 #ifndef BALL_KERNEL_ATOMCONTAINER_H
00015 #include <BALL/KERNEL/atomContainer.h>
00016 #endif
00017
00018 #ifndef BALL_DATATYPE_HASHMAP_H
00019 #include <BALL/DATATYPE/hashMap.h>
00020 #endif
00021
00022 #ifndef BALL_KERNEL_BOND_H
00023 #include <BALL/KERNEL/bond.h>
00024 #endif
00025
00026 #ifndef BALL_DATATYPE_OPTIONS_H
00027 #include <BALL/DATATYPE/options.h>
00028 #endif
00029
00030
00031 #ifdef BALL_HAS_HASH_MAP
00032 namespace BALL_MAP_NAMESPACE
00033 {
00034 template<>
00035 struct hash<BALL::Bond::BondOrder>
00036 {
00037 size_t operator () (const BALL::Bond::BondOrder o) const
00038 {return (size_t)o;}
00039 };
00040 }
00041 #endif
00042
00043 namespace BALL
00044 {
00045
00049 class BALL_EXPORT BuildBondsProcessor
00050 : public UnaryProcessor<AtomContainer>
00051 {
00052
00053 public:
00054
00058
00059 struct BALL_EXPORT Option
00060 {
00064 static const char* BONDLENGTHS_FILENAME;
00065
00072 static const char* DELETE_EXISTING_BONDS;
00073
00079 static const char* REESTIMATE_BONDORDERS_RINGS;
00080
00086 static const char* DELETE_OVERESTIMATED_BONDS;
00087 };
00088
00090 struct BALL_EXPORT Default
00091 {
00093 static const char* BONDLENGTHS_FILENAME;
00094
00096 static const bool DELETE_EXISTING_BONDS;
00097
00099 static const bool REESTIMATE_BONDORDERS_RINGS;
00100
00102 static const bool DELETE_OVERESTIMATED_BONDS;
00103 };
00105
00106
00110
00111 BALL_CREATE(BuildBondsProcessor);
00112
00114 BuildBondsProcessor();
00115
00117 BuildBondsProcessor(const BuildBondsProcessor& bbp);
00118
00120 BuildBondsProcessor(const String& file_name) throw(Exception::FileNotFound);
00121
00123 virtual ~BuildBondsProcessor();
00125
00129
00131 virtual bool start();
00132
00134 virtual Processor::Result operator () (AtomContainer& ac);
00136
00140
00141 Size getNumberOfBondsBuilt();
00142
00144 void setBondLengths(const String& file_name) throw(Exception::FileNotFound);
00145
00147 HashMap<Size, HashMap<Size, HashMap<int, float> > > getBondMap() { return bond_lengths_;};
00148
00150
00154
00155 BuildBondsProcessor& operator = (const BuildBondsProcessor& bbp);
00157
00161
00162 Options options;
00163
00166 void setDefaultOptions();
00168
00169 protected:
00170
00172 Size buildBondsHashGrid3_(AtomContainer& ac);
00173
00175 void estimateBondOrders_(AtomContainer& ac);
00176
00178 void reestimateBondOrdersRings_(AtomContainer& ac);
00179
00181 void deleteOverestimatedBonds_(AtomContainer& ac);
00182
00184 void readBondLengthsFromFile_(const String& file_name = "") throw(Exception::FileNotFound);
00185
00187 Size num_bonds_;
00188
00190 HashMap<Size, HashMap<Size, HashMap<int, float> > > bond_lengths_;
00191
00193 HashMap<Size, HashMap<Size, float> > max_bond_lengths_;
00194
00196 HashMap<Size, HashMap<Size, float> > min_bond_lengths_;
00197
00198
00199
00200
00201 Bond::BondOrder getNearestBondOrder_(float length, Size e1, Size e2);
00202
00203
00204
00205
00206
00207 bool getMaxBondLength_(float& length, Size an1, Size an2);
00208
00209
00210
00211
00212
00213 bool getMinBondLength_(float& length, Size an1, Size an2);
00214
00216 float max_length_;
00217 };
00218
00219 }
00220
00221
00222 #endif // BALL_STRUCTURE_BUILDBONDSPROCESSOR_H