Changeset 59fff1 for src/molecule.cpp
- Timestamp:
- Dec 28, 2011, 3:25:49 PM (13 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- afa9d8
- Parents:
- 30c753
- git-author:
- Frederik Heber <heber@…> (12/23/11 10:09:37)
- git-committer:
- Frederik Heber <heber@…> (12/28/11 15:25:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r30c753 r59fff1 173 173 { 174 174 size_t counter = 0; 175 for ( molecule::const_iterator iter = begin(); iter != end (); ++iter)175 for (const_iterator iter = begin(); iter != end (); ++iter) 176 176 counter++; 177 177 return counter; … … 181 181 { 182 182 OBSERVE; 183 molecule::const_iterator iter = loc;183 const_iterator iter = loc; 184 184 ++iter; 185 atom * atom = *loc;186 atomIds.erase( atom->getId() );187 formula-= atom->getType();188 atom->removeFromMolecule();185 atom * const _atom = const_cast<atom *>(*loc); 186 atomIds.erase( _atom->getId() ); 187 formula-=_atom->getType(); 188 _atom->removeFromMolecule(); 189 189 return iter; 190 190 } … … 193 193 { 194 194 OBSERVE; 195 molecule::const_iterator iter = find(key);195 const_iterator iter = find(key); 196 196 if (iter != end()){ 197 197 ++iter; … … 233 233 // iter != MyIter(atomIds.end(), FromIdToAtom()); 234 234 // ++iter) 235 for (molecule:: const_iterator iter = begin(); iter != end(); ++iter)235 for (molecule::iterator iter = begin(); iter != end(); ++iter) 236 236 vector_of_atoms.push_back(*iter); 237 237 return vector_of_atoms; … … 634 634 // copy all atoms 635 635 std::map< const atom *, atom *> FatherFinder; 636 for ( const_iterator iter = begin(); iter != end(); ++iter) {637 atom * const copy_atom = copy->AddCopyAtom(*iter);636 for (iterator iter = begin(); iter != end(); ++iter) { 637 atom * const copy_atom = copy->AddCopyAtom(*iter); 638 638 FatherFinder.insert( std::make_pair( *iter, copy_atom ) ); 639 639 } … … 649 649 // get the pendant atoms of current bond in the copy molecule 650 650 ASSERT(FatherFinder.count(Binder->leftatom), 651 "molecule::CopyMolecule() - No copy of original left atom for bond copy found"); 651 "molecule::CopyMolecule() - No copy of original left atom " 652 +toString(Binder->leftatom)+" for bond copy found"); 652 653 ASSERT(FatherFinder.count(Binder->rightatom), 653 "molecule::CopyMolecule() - No copy of original right atom for bond copy found"); 654 "molecule::CopyMolecule() - No copy of original right atom " 655 +toString(Binder->rightatom)+" for bond copy found"); 654 656 atom * const LeftAtom = FatherFinder[Binder->leftatom]; 655 657 atom * const RightAtom = FatherFinder[Binder->rightatom]; … … 674 676 { 675 677 // remove each atom from world 676 for( const_iterator AtomRunner = begin(); !empty(); AtomRunner = begin())678 for(iterator AtomRunner = begin(); !empty(); AtomRunner = begin()) 677 679 World::getInstance().destroyAtom(*AtomRunner); 678 680 }; … … 690 692 // copy all atoms 691 693 std::map< const atom *, atom *> FatherFinder; 692 for ( const_iterator iter = begin(); iter != end(); ++iter) {694 for (iterator iter = begin(); iter != end(); ++iter) { 693 695 if((*iter)->IsInShape(region)){ 694 atom * const copy_atom = copy->AddCopyAtom(*iter);696 atom * const copy_atom = copy->AddCopyAtom(*iter); 695 697 FatherFinder.insert( std::make_pair( *iter, copy_atom ) ); 696 698 } … … 739 741 740 742 // some checks to make sure we are able to create the bond 741 ASSERT(atom1, "First atom in bond-creation was an invalid pointer"); 742 ASSERT(atom2, "Second atom in bond-creation was an invalid pointer"); 743 ASSERT(FindAtom(atom1->getNr()),"First atom in bond-creation was not part of molecule"); 744 ASSERT(FindAtom(atom2->getNr()),"Second atom in bond-creation was not part of molecule"); 743 ASSERT(atom1, 744 "molecule::AddBond() - First atom "+toString(atom1) 745 +" is not a invalid pointer"); 746 ASSERT(atom2, 747 "molecule::AddBond() - Second atom "+toString(atom2) 748 +" is not a invalid pointer"); 749 ASSERT(isInMolecule(atom1), 750 "molecule::AddBond() - First atom "+toString(atom1) 751 +" is not part of molecule"); 752 ASSERT(isInMolecule(atom2), 753 "molecule::AddBond() - Second atom "+toString(atom2) 754 +" is not part of molecule"); 745 755 746 756 Binder = new bond(atom1, atom2, degree); 747 757 atom1->RegisterBond(WorldTime::getTime(), Binder); 748 758 atom2->RegisterBond(WorldTime::getTime(), Binder); 749 if ((atom1->getType() != NULL) && (atom1->getType()->getAtomicNumber() != 1) && (atom2->getType() != NULL) && (atom2->getType()->getAtomicNumber() != 1)) 759 if ((atom1->getType() != NULL) 760 && (atom1->getType()->getAtomicNumber() != 1) 761 && (atom2->getType() != NULL) 762 && (atom2->getType()->getAtomicNumber() != 1)) 750 763 NoNonBonds++; 751 764 … … 850 863 atom * molecule::FindAtom(int Nr) const 851 864 { 852 molecule:: const_iterator iter = begin();865 molecule::iterator iter = begin(); 853 866 for (; iter != end(); ++iter) 854 855 867 if ((*iter)->getNr() == Nr) 868 break; 856 869 if (iter != end()) { 857 870 //LOG(0, "Found Atom Nr. " << walker->getNr()); 858 871 return (*iter); 859 872 } else { 860 LOG(0, "Atom not found inlist.");873 ELOG(1, "Atom not found in molecule " << getName() << "'s list."); 861 874 return NULL; 862 875 } 863 }; 876 } 877 878 /** Checks whether the given atom is a member of this molecule. 879 * 880 * We make use here of molecule::atomIds to get a result on 881 * 882 * @param _atom atom to check 883 * @return true - is member, false - is not 884 */ 885 bool molecule::isInMolecule(const atom * const _atom) 886 { 887 ASSERT(_atom->getMolecule() == this, 888 "molecule::isInMolecule() - atom is not designated to be in molecule '" 889 +toString(this->getName())+"'."); 890 molecule::atomIdSet::const_iterator iter = atomIds.find(_atom->getId()); 891 return (iter != atomIds.end()); 892 } 864 893 865 894 /** Asks for atom number, and checks whether in list. … … 1002 1031 int i = 0; 1003 1032 NoNonHydrogen = 0; 1004 for (molecule:: const_iterator iter = begin(); iter != end(); ++iter) {1033 for (molecule::iterator iter = begin(); iter != end(); ++iter) { 1005 1034 (*iter)->setNr(i); // update number in molecule (for easier referencing in FragmentMolecule lateron) 1006 1035 if ((*iter)->getType()->getAtomicNumber() != 1) // count non-hydrogen atoms whilst at it
Note:
See TracChangeset
for help on using the changeset viewer.