buildBondsProcessor.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: buildBondsProcessor.h,v 1.10.18.2 2007/03/29 10:34:58 bertsch Exp $
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       /*_ returns the best fitting bond order of a bond between atoms of
00199           element e1 and element e2 with a distance of length
00200       */
00201       Bond::BondOrder getNearestBondOrder_(float length, Size e1, Size e2);
00202 
00203       /*_ Returns true if the atom with atomic number an1 and atom with
00204           atomic number an2 can share a bond. If, the parameter length
00205           holds the maximal length of such a bond.
00206       */
00207       bool getMaxBondLength_(float& length, Size an1, Size an2);
00208 
00209       /*_ Returns true if the atom with atomic number an1 and atom with
00210           atomic number an2 can share a bond. If, the parameter length
00211           holds the minimal length of such a bond.
00212       */
00213       bool getMinBondLength_(float& length, Size an1, Size an2);
00214 
00216       float max_length_;
00217   };
00218 
00219 } // namespace BALL 
00220 
00221 
00222 #endif // BALL_STRUCTURE_BUILDBONDSPROCESSOR_H