BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_STRUCTURE_BUILDBONDSPROCESSOR_H 00006 #define BALL_STRUCTURE_BUILDBONDSPROCESSOR_H 00007 00008 #ifndef BALL_CONCEPT_PROCESSOR_H 00009 #include <BALL/CONCEPT/processor.h> 00010 #endif 00011 00012 #ifndef BALL_KERNEL_ATOMCONTAINER_H 00013 #include <BALL/KERNEL/atomContainer.h> 00014 #endif 00015 00016 #ifndef BALL_DATATYPE_HASHMAP_H 00017 #include <BALL/DATATYPE/hashMap.h> 00018 #endif 00019 00020 #ifndef BALL_KERNEL_BOND_H 00021 #include <BALL/KERNEL/bond.h> 00022 #endif 00023 00024 #ifndef BALL_DATATYPE_OPTIONS_H 00025 #include <BALL/DATATYPE/options.h> 00026 #endif 00027 00028 00029 #ifdef BALL_HAS_HASH_MAP 00030 namespace BALL_MAP_NAMESPACE 00031 { 00032 template<> 00033 struct hash<BALL::Bond::BondOrder> 00034 { 00035 size_t operator () (const BALL::Bond::BondOrder o) const 00036 {return (size_t)o;} 00037 }; 00038 } 00039 #endif 00040 00041 namespace BALL 00042 { 00043 00047 class BALL_EXPORT BuildBondsProcessor 00048 : public UnaryProcessor<AtomContainer> 00049 { 00050 00051 public: 00052 00056 00057 struct BALL_EXPORT Option 00058 { 00062 static const char* BONDLENGTHS_FILENAME; 00063 00070 static const char* DELETE_EXISTING_BONDS; 00071 00077 static const char* REESTIMATE_BONDORDERS_RINGS; 00078 00084 static const char* DELETE_OVERESTIMATED_BONDS; 00085 }; 00086 00088 struct BALL_EXPORT Default 00089 { 00091 static const char* BONDLENGTHS_FILENAME; 00092 00094 static const bool DELETE_EXISTING_BONDS; 00095 00097 static const bool REESTIMATE_BONDORDERS_RINGS; 00098 00100 static const bool DELETE_OVERESTIMATED_BONDS; 00101 }; 00103 00104 00108 00109 BALL_CREATE(BuildBondsProcessor); 00110 00112 BuildBondsProcessor(); 00113 00115 BuildBondsProcessor(const BuildBondsProcessor& bbp); 00116 00118 BuildBondsProcessor(const String& file_name) throw(Exception::FileNotFound); 00119 00121 virtual ~BuildBondsProcessor(); 00123 00127 00129 virtual bool start(); 00130 00132 virtual Processor::Result operator () (AtomContainer& ac); 00134 00138 00139 Size getNumberOfBondsBuilt(); 00140 00142 void setBondLengths(const String& file_name) throw(Exception::FileNotFound); 00143 00145 HashMap<Size, HashMap<Size, HashMap<int, float> > > getBondMap() { return bond_lengths_;}; 00146 00148 00152 00153 BuildBondsProcessor& operator = (const BuildBondsProcessor& bbp); 00155 00159 00160 Options options; 00161 00164 void setDefaultOptions(); 00166 00167 protected: 00168 00170 Size buildBondsHashGrid3_(AtomContainer& ac); 00171 00173 void estimateBondOrders_(AtomContainer& ac); 00174 00176 void reestimateBondOrdersRings_(AtomContainer& ac); 00177 00179 void deleteOverestimatedBonds_(AtomContainer& ac); 00180 00182 void readBondLengthsFromFile_(const String& file_name = "") throw(Exception::FileNotFound); 00183 00185 Size num_bonds_; 00186 00188 HashMap<Size, HashMap<Size, HashMap<int, float> > > bond_lengths_; 00189 00191 HashMap<Size, HashMap<Size, float> > max_bond_lengths_; 00192 00194 HashMap<Size, HashMap<Size, float> > min_bond_lengths_; 00195 00196 /*_ returns the best fitting bond order of a bond between atoms of 00197 element e1 and element e2 with a distance of length 00198 */ 00199 Bond::BondOrder getNearestBondOrder_(float length, Size e1, Size e2); 00200 00201 /*_ Returns true if the atom with atomic number an1 and atom with 00202 atomic number an2 can share a bond. If, the parameter length 00203 holds the maximal length of such a bond. 00204 */ 00205 bool getMaxBondLength_(float& length, Size an1, Size an2); 00206 00207 /*_ Returns true if the atom with atomic number an1 and atom with 00208 atomic number an2 can share a bond. If, the parameter length 00209 holds the minimal length of such a bond. 00210 */ 00211 bool getMinBondLength_(float& length, Size an1, Size an2); 00212 00214 float max_length_; 00215 }; 00216 00217 } // namespace BALL 00218 00219 00220 #endif // BALL_STRUCTURE_BUILDBONDSPROCESSOR_H