Ignore:
Timestamp:
Jul 24, 2015, 4:44:34 PM (10 years ago)
Author:
Frederik Heber <heber@…>
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, Candidate_v1.7.0, 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:
a58c16
Parents:
1259df
git-author:
Frederik Heber <heber@…> (06/01/15 16:57:36)
git-committer:
Frederik Heber <heber@…> (07/24/15 16:44:34)
Message:

Replaced World::getAtom() wherever possible by const version.

  • some AtomSet member functions now have const atom ptr instead of atom ptr.
  • molecule can return const and non-const AtomSet.
  • added FromIdToConstAtom to allow iterate through atoms in molecule (which are stored by id, not by ptr) in const fashion.
  • in molecule::isInMolecule() is now const, ::CopyMolecule..() is non-const (because copying involves father atom who is stored non-const).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    r1259df rf01769  
    129129  //LOG(0, "Comparing fragment no. " << *(molecule **)a << " to " << *(molecule **)b << ".");
    130130  // Yes those types are awkward... but check it for yourself it checks out this way
    131   molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
    132   molecule *mol1 = *mol1_ptr;
    133   molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
    134   molecule *mol2 = *mol2_ptr;
     131  const molecule *const *mol1_ptr= static_cast<molecule *const *>(a);
     132  const molecule *mol1 = *mol1_ptr;
     133  const molecule *const *mol2_ptr= static_cast<molecule *const *>(b);
     134  const molecule *mol2 = *mol2_ptr;
    135135  if (mol1->getAtomCount() < mol2->getAtomCount()) {
    136136    return -1;
     
    212212  else {
    213213    Origin.Zero();
    214     for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
     214    for (MoleculeList::const_iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    215215      // count atoms per element and determine size of bounding sphere
    216216      size=0.;
    217       for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     217      const molecule *MolRunner = *ListRunner;
     218      for (molecule::const_iterator iter = MolRunner->begin(); iter != MolRunner->end(); ++iter) {
    218219        counts[(*iter)->getType()->getAtomicNumber()]++;
    219220        if ((*iter)->DistanceSquared(Origin) > size)
     
    221222      }
    222223      // output Index, Name, number of atoms, chemical formula
    223       (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->getAtomCount() << "\t";
     224      (*out) << (MolRunner->ActiveFlag ? "*" : " ") << MolRunner->IndexNr << "\t" << MolRunner->name << "\t\t" << MolRunner->getAtomCount() << "\t";
    224225
    225226      std::map<atomicNumber_t,unsigned int>::reverse_iterator iter;
     
    229230      }
    230231      // Center and size
    231       Vector Center = (*ListRunner)->DetermineCenterOfAll();
     232      Vector Center = MolRunner->DetermineCenterOfAll();
    232233      (*out) << "\t" << Center << "\t" << sqrt(size) << endl;
    233234    }
     
    407408        correction[k][j] = 0.;
    408409    // 2. take every hydrogen that is a saturated one
    409     for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     410    const molecule *MolRunner = *ListRunner;
     411    for (molecule::const_iterator iter = MolRunner->begin(); iter != MolRunner->end(); ++iter) {
    410412      //LOG(1, "(*iter): " << *(*iter) << " with first bond " << *((*iter)->getListOfBonds().begin()) << ".");
    411413      if (((*iter)->getType()->getAtomicNumber() == 1) && (((*iter)->getFather() == NULL)
    412414          || ((*iter)->getFather()->getType()->getAtomicNumber() != 1))) { // if it's a hydrogen
    413         for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
     415        for (molecule::const_iterator runner = MolRunner->begin(); runner != MolRunner->end(); ++runner) {
    414416          //LOG(2, "Runner: " << *(*runner) << " with first bond " << *((*iter)->getListOfBonds().begin()) << ".");
    415417          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
     
    420422            distance = (*runner)->distance(*(*iter));
    421423            //std::stringstream output;
    422             //output << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":";
     424            //output << "Fragment " << MolRunner->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":";
    423425            for (int k = 0; k < a; k++) {
    424426              for (int j = 0; j < b; j++) {
     
    447449    line.append("/");
    448450    line += FRAGMENTPREFIX;
    449     FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), (*ListRunner)->IndexNr);
     451    FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), MolRunner->IndexNr);
    450452    line += FragmentNumber;
    451453    delete[] (FragmentNumber);
     
    506508    for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    507509      periodentafel::const_iterator elemIter;
     510      const molecule *MolRunner = *ListRunner;
    508511      for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){
    509         if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms
    510           for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){
     512        if (MolRunner->hasElement((*elemIter).first)) { // if this element got atoms
     513          for(molecule::const_iterator atomIter = MolRunner->begin(); atomIter !=MolRunner->end();++atomIter){
    511514            if ((*atomIter)->getType()->getAtomicNumber() == (*elemIter).first) {
    512515              if (((*atomIter)->GetTrueFather() != NULL) && ((*atomIter)->GetTrueFather() != (*atomIter))) {// if there is a rea
     
    557560  for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) {
    558561    // correct periodic
     562    const molecule *MolRunner = *ListRunner;
    559563    if ((*ListRunner)->ScanForPeriodicCorrection()) {
    560564      count++;
     
    565569      std::stringstream output;
    566570      output << "Contained atoms: ";
    567       for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     571      for (molecule::const_iterator iter = MolRunner->begin(); iter != MolRunner->end(); ++iter) {
    568572        output << (*iter)->getName() << " ";
    569573      }
     
    573577    {
    574578//      // center on edge
    575 //      (*ListRunner)->CenterEdge(&BoxDimension);
     579//      MolRunner->CenterEdge(&BoxDimension);
    576580//      for (int k = 0; k < NDIM; k++)  // if one edge is to small, set at least to 1 angstroem
    577581//        if (BoxDimension[k] < 1.)
     
    588592//      }
    589593//      World::getInstance().setDomain(cell_size);
    590 //      (*ListRunner)->Translate(&BoxDimension);
     594//      MolRunner->Translate(&BoxDimension);
    591595
    592596      // output file
Note: See TracChangeset for help on using the changeset viewer.