- Timestamp:
- Apr 14, 2013, 6:35:27 PM (12 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:
- 78ca37
- Parents:
- 356ae4
- git-author:
- Frederik Heber <heber@…> (03/04/13 17:40:55)
- git-committer:
- Frederik Heber <heber@…> (04/14/13 18:35:27)
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r356ae4 rc6ab91 132 132 } 133 133 134 void molecule::InsertLocalToGlobalId(atom * const pointer) 135 { 136 #ifndef NDEBUG 137 std::pair< LocalToGlobalId_t::iterator, bool > inserter = 138 #endif 139 LocalToGlobalId.insert( std::make_pair(pointer->getNr(), pointer) ); 140 ASSERT( inserter.second, 141 "molecule::AddAtom() - local number "+toString(pointer->getNr())+" appears twice."); 142 } 143 134 144 bool molecule::changeAtomNr(int oldNr, int newNr, atom* target){ 135 145 OBSERVE; … … 138 148 if (oldNr != -1) // -1 is reserved and indicates no number 139 149 atomIdPool.releaseId(oldNr); 150 LocalToGlobalId.erase(oldNr); 140 151 ASSERT (target, 141 152 "molecule::changeAtomNr() - given target is NULL, cannot set Nr or name."); 142 153 target->setNr(newNr); 154 InsertLocalToGlobalId(target); 143 155 setAtomName(target); 144 156 return true; … … 202 214 NOTIFY(AtomNrChanged); 203 215 atomIdPool.releaseId(_atom->getNr()); 216 LocalToGlobalId.erase(_atom->getNr()); 204 217 _atom->setNr(-1); 205 218 } … … 220 233 NOTIFY(AtomNrChanged); 221 234 atomIdPool.releaseId(key->getNr()); 235 LocalToGlobalId.erase(key->getNr()); 222 236 key->setNr(-1); 223 237 } … … 236 250 NOTIFY(AtomNrChanged); 237 251 key->setNr(atomIdPool.getNextId()); 252 InsertLocalToGlobalId(key); 238 253 setAtomName(key); 239 254 formula+=key->getType(); … … 283 298 if (pointer != NULL) { 284 299 atom *walker = pointer->clone(); 285 walker->setName(pointer->getName()); 286 walker->setNr(last_atom++); // increase number within molecule 287 insert(walker); 288 walker->setMolecule(this); 300 AddAtom(walker); 289 301 retval=walker; 290 302 } … … 777 789 atom * molecule::FindAtom(int Nr) const 778 790 { 779 molecule::iterator iter = begin(); 780 for (; iter != end(); ++iter) 781 if ((*iter)->getNr() == Nr) 782 break; 783 if (iter != end()) { 791 LocalToGlobalId_t::const_iterator iter = LocalToGlobalId.find(Nr); 792 if (iter != LocalToGlobalId.end()) { 784 793 //LOG(0, "Found Atom Nr. " << walker->getNr()); 785 return (*iter);794 return iter->second; 786 795 } else { 787 796 ELOG(1, "Atom with Nr " << Nr << " not found in molecule " << getName() << "'s list."); -
src/molecule.hpp
r356ae4 rc6ab91 88 88 AtomIdSet atomIds; //<!set of atomic ids to check uniqueness of atoms 89 89 IdPool<atomId_t, uniqueId> atomIdPool; //!< pool of internal ids such that way may guarantee uniqueness 90 typedef std::map<atomId_t,atom *> LocalToGlobalId_t; 91 LocalToGlobalId_t LocalToGlobalId; //!< internal map to ease FindAtom 90 92 91 93 protected: … … 220 222 */ 221 223 bool changeAtomNr(int oldNr, int newNr, atom* target=0); 224 225 /** Updates the internal lookup fro local to global indices. 226 * 227 * \param pointer pointer to atom 228 */ 229 void InsertLocalToGlobalId(atom * const pointer); 222 230 223 231 /** Sets the name of the atom.
Note:
See TracChangeset
for help on using the changeset viewer.