Changes in src/molecule.cpp [43dad6:274d45]
- File:
-
- 1 edited
-
src/molecule.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r43dad6 r274d45 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp" 6 8 7 9 #include <cstring> … … 35 37 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 36 38 */ 37 molecule::molecule(const periodentafel * const teil) : elemente(teil),38 MDSteps(0),39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),40 ActiveFlag(false), IndexNr(-1),41 formula(this,boost::bind(&molecule::calcFormula,this) ),42 AtomCount(this,boost::bind(&molecule::doCountAtoms,this) ), last_atom(0), InternalPointer(begin())39 molecule::molecule(const periodentafel * const teil) : 40 Observable("molecule"), 41 elemente(teil), MDSteps(0), BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), 42 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1), 43 formula(this,boost::bind(&molecule::calcFormula,this),"formula"), 44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(atoms.begin()) 43 45 { 44 46 … … 143 145 molecule::const_iterator iter = loc; 144 146 iter--; 145 atoms.erase( loc ); 147 atom* atom = *loc; 148 atomIds.erase( atom->getId() ); 149 atoms.remove( atom ); 150 atom->removeFromMolecule(); 146 151 return iter; 147 152 } 148 153 149 molecule::const_iterator molecule::erase( atom * &key )154 molecule::const_iterator molecule::erase( atom * key ) 150 155 { 151 156 cout << "trying to erase atom" << endl; 152 157 molecule::const_iterator iter = find(key); 153 158 if (iter != end()){ 154 // remove this position and step forward (post-increment) 155 atoms.erase( iter++ ); 159 atomIds.erase( key->getId() ); 160 atoms.remove( key ); 161 key->removeFromMolecule(); 156 162 } 157 163 return iter; 158 164 } 159 165 160 molecule::const_iterator molecule::find ( atom *& key ) const 161 { 162 return atoms.find( key ); 166 molecule::const_iterator molecule::find ( atom * key ) const 167 { 168 molecule::const_iterator iter; 169 for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) { 170 if (*Runner == key) 171 return molecule::const_iterator(Runner); 172 } 173 return molecule::const_iterator(atoms.end()); 163 174 } 164 175 165 176 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 166 177 { 167 pair<atomSet::iterator,bool> res = atoms.insert(key); 168 return pair<iterator,bool>(iterator(res.first,this),res.second); 178 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId()); 179 if (res.second) { // push atom if went well 180 atoms.push_back(key); 181 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 182 } else { 183 return pair<iterator,bool>(molecule::iterator(end()),res.second); 184 } 185 } 186 187 bool molecule::containsAtom(atom* key){ 188 return (find(key) != end()); 169 189 } 170 190 … … 192 212 } 193 213 insert(pointer); 214 pointer->setMolecule(this); 194 215 } 195 216 return true; … … 657 678 bond * molecule::AddBond(atom *atom1, atom *atom2, int degree) 658 679 { 680 OBSERVE; 659 681 bond *Binder = NULL; 660 682 … … 780 802 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 781 803 erase(iter); 804 return empty(); 782 805 }; 783 806 … … 858 881 ElementNo[i] = current++; 859 882 } 860 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const)output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );883 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 861 884 return true; 862 885 } … … 1000 1023 configuration.MaxPsiDouble /= 2; 1001 1024 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1; 1002 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) ) {1025 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) { 1003 1026 configuration.ProcPEGamma /= 2; 1004 1027 configuration.ProcPEPsi *= 2; … … 1007 1030 configuration.ProcPEPsi = 1; 1008 1031 } 1009 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble; 1032 cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl; 1033 if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) { 1034 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown; 1035 cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl; 1036 } else { 1037 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp; 1038 cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl; 1039 } 1010 1040 }; 1011 1041
Note:
See TracChangeset
for help on using the changeset viewer.
