Changeset 9879f6 for src


Ignore:
Timestamp:
Mar 5, 2010, 10:16:47 AM (15 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, 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:
d3347e
Parents:
e87acf
git-author:
Frederik Heber <heber@…> (03/05/10 10:08:44)
git-committer:
Frederik Heber <heber@…> (03/05/10 10:16:47)
Message:

Huge Refactoring due to class molecule now being an STL container.

  • molecule::start and molecule::end were dropped. Hence, the usual construct Walker = start while (Walker->next != end) {

Walker = walker->next
...

}
was changed to
for (molecule::iterator iter = begin(); iter != end(); ++iter) {

...

}
and (*iter) used instead of Walker.

  • Two build errors remain (beside some more in folder Actions, Patterns and unittest) in molecule_pointcloud.cpp and molecule.cpp
  • lists.cpp was deleted as specialization of atom* was not needed anymore
  • link, unlink, add, remove, removewithoutcheck all are not needed for atoms anymore, just for bonds (where first, last entries remain in molecule)
  • CreateFatherLookupTable() was put back into class molecule.
  • molecule::InternalPointer is now an iterator
  • class PointCloud: GoToPrevious() and GetTerminalPoint() were dropped as not needed.
  • some new STL functions in class molecule: size(), empty(), erase(), find() and insert()
Location:
src
Files:
1 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    re87acf r9879f6  
    447447      break;
    448448    case 'b':
    449       second = mol->AskAtom("Enter number of atom as reference point: ");
    450       Log() << Verbose(0) << "Enter radius: ";
    451       cin >> tmp1;
    452       first = mol->start;
    453       second = first->next;
    454       while(second != mol->end) {
    455         first = second;
    456         second = first->next;
    457         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
    458           mol->RemoveAtom(first);
     449      {
     450        second = mol->AskAtom("Enter number of atom as reference point: ");
     451        Log() << Verbose(0) << "Enter radius: ";
     452        cin >> tmp1;
     453        molecule::iterator runner;
     454        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     455          runner = iter++;
     456          if ((*runner)->x.DistanceSquared((const Vector *)&(*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     457            mol->RemoveAtom((*runner));
     458        }
    459459      }
    460460      break;
     
    466466      Log() << Verbose(0) << "Upper boundary: ";
    467467      cin >> tmp2;
    468       first = mol->start;
    469       second = first->next;
    470       while(second != mol->end) {
    471         first = second;
    472         second = first->next;
    473         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    474           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475           mol->RemoveAtom(first);
     468      molecule::iterator runner;
     469      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     470        runner = iter++;
     471        if (((*runner)->x.x[axis] < tmp1) || ((*runner)->x.x[axis] > tmp2)) {// out of boundary ...
     472          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     473          mol->RemoveAtom((*runner));
    476474        }
    477475      }
     
    516514        min[i] = 0.;
    517515
    518       second = mol->start;
    519       while ((second->next != mol->end)) {
    520         second = second->next; // advance
    521         Z = second->type->Z;
     516      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     517        Z = (*iter)->type->Z;
    522518        tmp1 = 0.;
    523         if (first != second) {
     519        if (first != (*iter)) {
    524520          x.CopyVector((const Vector *)&first->x);
    525           x.SubtractVector((const Vector *)&second->x);
     521          x.SubtractVector((const Vector *)&(*iter)->x);
    526522          tmp1 = x.Norm();
    527523        }
    528524        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    529         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     525        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
    530526      }
    531527      for (int i=MAX_ELEMENTS;i--;)
     
    767763      vectors = new Vector *[count];
    768764      j = 0;
    769       first = mol->start;
    770       while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    771         first = first->next;
    772         Elements[j] = first->type;
    773         vectors[j] = &first->x;
     765      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     766        Elements[j] = (*iter)->type;
     767        vectors[j] = &(*iter)->x;
    774768        j++;
    775769      }
     
    10291023    return;
    10301024  }
    1031   atom *Walker = mol->start;
    10321025
    10331026  // generate some KeySets
     
    10351028  KeySet TestSets[mol->AtomCount+1];
    10361029  i=1;
    1037   while (Walker->next != mol->end) {
    1038     Walker = Walker->next;
     1030  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10391031    for (int j=0;j<i;j++) {
    1040       TestSets[j].insert(Walker->nr);
     1032      TestSets[j].insert((*iter)->nr);
    10411033    }
    10421034    i++;
     
    10441036  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10451037  KeySetTestPair test;
    1046   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1047   if (test.second) {
    1048     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1038  molecule::const_iterator iter = mol->begin();
     1039  if (iter != mol->end()) {
     1040    test = TestSets[mol->AtomCount-1].insert((*iter)->nr);
     1041    if (test.second) {
     1042      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1043    } else {
     1044      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1045    }
    10491046  } else {
    1050     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1051   }
    1052   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1053   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1047    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
     1048  }
    10541049
    10551050  // constructing Graph structure
  • src/Makefile.am

    re87acf r9879f6  
    4141                                   Descriptors/MoleculeIdDescriptor.hpp
    4242
    43 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} ${DESCRIPTORSOURCE} ${LEGACYSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp lists.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp World.cpp WorldIterators.cpp
     43SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} ${DESCRIPTORSOURCE} ${LEGACYSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp World.cpp WorldIterators.cpp
    4444HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} ${UIHEADER} ${DESCRIPTORHEADER} ${LEGACYHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp World.hpp
    4545
  • src/analysis_bonds.cpp

    re87acf r9879f6  
    2424  Mean = 0.;
    2525
    26   atom *Walker = mol->start;
    2726  int AtomCount = 0;
    28   while (Walker->next != mol->end) {
    29     Walker = Walker->next;
    30     const int count = Walker->ListOfBonds.size();
     27  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     28    const int count = (*iter)->ListOfBonds.size();
    3129    if (Max < count)
    3230      Max = count;
     
    5654
    5755  int AtomNo = 0;
    58   atom *Walker = mol->start;
    59   while (Walker->next != mol->end) {
    60     Walker = Walker->next;
    61     if (Walker->type == type1)
    62       for (BondList::const_iterator BondRunner = Walker->ListOfBonds.begin(); BondRunner != Walker->ListOfBonds.end(); BondRunner++)
    63         if ((*BondRunner)->GetOtherAtom(Walker)->type == type2) {
     56  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     57    if ((*iter)->type == type1)
     58      for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
     59        if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
    6460          const double distance = (*BondRunner)->GetDistanceSquared();
    6561          if (Min > distance)
  • src/analysis_correlation.cpp

    re87acf r9879f6  
    4141    if ((*MolWalker)->ActiveFlag) {
    4242      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    43       atom *Walker = (*MolWalker)->start;
    44       while (Walker->next != (*MolWalker)->end) {
    45         Walker = Walker->next;
    46         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    47         if ((type1 == NULL) || (Walker->type == type1)) {
     43      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     44        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     45        if ((type1 == NULL) || ((*iter)->type == type1)) {
    4846          for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++)
    4947            if ((*MolOtherWalker)->ActiveFlag) {
    5048              Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
    51               atom *OtherWalker = (*MolOtherWalker)->start;
    52               while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    53                 OtherWalker = OtherWalker->next;
    54                 Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
    55                 if (Walker->nr < OtherWalker->nr)
    56                   if ((type2 == NULL) || (OtherWalker->type == type2)) {
    57                     distance = Walker->node->PeriodicDistance(OtherWalker->node, (*MolWalker)->cell_size);
    58                     //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    59                     outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     49              for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     50                Log() << Verbose(3) << "Current otheratom is " << *(*runner) << "." << endl;
     51                if ((*iter)->nr < (*runner)->nr)
     52                  if ((type2 == NULL) || ((*runner)->type == type2)) {
     53                    distance = (*iter)->node->PeriodicDistance((*runner)->node, (*MolWalker)->cell_size);
     54                    //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     55                    outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    6056                  }
    6157              }
     
    9995      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    10096      eLog() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    101       atom *Walker = (*MolWalker)->start;
    102       while (Walker->next != (*MolWalker)->end) {
    103         Walker = Walker->next;
    104         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    105         if ((type1 == NULL) || (Walker->type == type1)) {
    106           periodicX.CopyVector(Walker->node);
     97      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     98        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     99        if ((type1 == NULL) || ((*iter)->type == type1)) {
     100          periodicX.CopyVector((*iter)->node);
    107101          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    108102          // go through every range in xyz and get distance
     
    116110                  if ((*MolOtherWalker)->ActiveFlag) {
    117111                    Log() << Verbose(2) << "Current other molecule is " << *MolOtherWalker << "." << endl;
    118                     atom *OtherWalker = (*MolOtherWalker)->start;
    119                     while (OtherWalker->next != (*MolOtherWalker)->end) { // only go up to Walker
    120                       OtherWalker = OtherWalker->next;
    121                       Log() << Verbose(3) << "Current otheratom is " << *OtherWalker << "." << endl;
    122                       if (Walker->nr < OtherWalker->nr)
    123                         if ((type2 == NULL) || (OtherWalker->type == type2)) {
    124                           periodicOtherX.CopyVector(OtherWalker->node);
     112                    for (molecule::const_iterator runner = (*MolOtherWalker)->begin(); runner != (*MolOtherWalker)->end(); ++runner) {
     113                      Log() << Verbose(3) << "Current otheratom is " << *(*runner) << "." << endl;
     114                      if ((*iter)->nr < (*runner)->nr)
     115                        if ((type2 == NULL) || ((*runner)->type == type2)) {
     116                          periodicOtherX.CopyVector((*runner)->node);
    125117                          periodicOtherX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    126118                          // go through every range in xyz and get distance
     
    132124                                checkOtherX.MatrixMultiplication(FullMatrix);
    133125                                distance = checkX.Distance(&checkOtherX);
    134                                 //Log() << Verbose(1) <<"Inserting " << *Walker << " and " << *OtherWalker << endl;
    135                                 outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> (Walker, OtherWalker) ) );
     126                                //Log() << Verbose(1) <<"Inserting " << *(*iter) << " and " << *(*runner) << endl;
     127                                outmap->insert ( pair<double, pair <atom *, atom*> > (distance, pair<atom *, atom*> ((*iter), (*runner)) ) );
    136128                              }
    137129                        }
     
    169161    if ((*MolWalker)->ActiveFlag) {
    170162      Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    171       atom *Walker = (*MolWalker)->start;
    172       while (Walker->next != (*MolWalker)->end) {
    173         Walker = Walker->next;
    174         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    175         if ((type == NULL) || (Walker->type == type)) {
    176           distance = Walker->node->PeriodicDistance(point, (*MolWalker)->cell_size);
     163      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     164        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     165        if ((type == NULL) || ((*iter)->type == type)) {
     166          distance = (*iter)->node->PeriodicDistance(point, (*MolWalker)->cell_size);
    177167          Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
    178           outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     168          outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    179169        }
    180170      }
     
    211201      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    212202      Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    213       atom *Walker = (*MolWalker)->start;
    214       while (Walker->next != (*MolWalker)->end) {
    215         Walker = Walker->next;
    216         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    217         if ((type == NULL) || (Walker->type == type)) {
    218           periodicX.CopyVector(Walker->node);
     203      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     204        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     205        if ((type == NULL) || ((*iter)->type == type)) {
     206          periodicX.CopyVector((*iter)->node);
    219207          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    220208          // go through every range in xyz and get distance
     
    227215                distance = checkX.Distance(point);
    228216                Log() << Verbose(4) << "Current distance is " << distance << "." << endl;
    229                 outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> (Walker, point) ) );
     217                outmap->insert ( pair<double, pair<atom *, const Vector*> >(distance, pair<atom *, const Vector*> ((*iter), point) ) );
    230218              }
    231219        }
     
    262250    if ((*MolWalker)->ActiveFlag) {
    263251      Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    264       atom *Walker = (*MolWalker)->start;
    265       while (Walker->next != (*MolWalker)->end) {
    266         Walker = Walker->next;
    267         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    268         if ((type == NULL) || (Walker->type == type)) {
    269           triangle = Surface->FindClosestTriangleToVector(Walker->node, LC );
     252      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     253        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     254        if ((type == NULL) || ((*iter)->type == type)) {
     255          triangle = Surface->FindClosestTriangleToVector((*iter)->node, LC );
    270256          if (triangle != NULL) {
    271             distance = DistanceToTrianglePlane(Walker->node, triangle);
    272             outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> (Walker, triangle) ) );
     257            distance = DistanceToTrianglePlane((*iter)->node, triangle);
     258            outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(distance, pair<atom *, BoundaryTriangleSet*> ((*iter), triangle) ) );
    273259          }
    274260        }
     
    315301      double * FullInverseMatrix = InverseMatrix(FullMatrix);
    316302      Log() << Verbose(2) << "Current molecule is " << *MolWalker << "." << endl;
    317       atom *Walker = (*MolWalker)->start;
    318       while (Walker->next != (*MolWalker)->end) {
    319         Walker = Walker->next;
    320         Log() << Verbose(3) << "Current atom is " << *Walker << "." << endl;
    321         if ((type == NULL) || (Walker->type == type)) {
    322           periodicX.CopyVector(Walker->node);
     303      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     304        Log() << Verbose(3) << "Current atom is " << *(*iter) << "." << endl;
     305        if ((type == NULL) || ((*iter)->type == type)) {
     306          periodicX.CopyVector((*iter)->node);
    323307          periodicX.MatrixMultiplication(FullInverseMatrix);  // x now in [0,1)^3
    324308          // go through every range in xyz and get distance
     
    339323          // insert
    340324          ShortestDistance = sqrt(ShortestDistance);
    341           outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> (Walker, ShortestTriangle) ) );
    342           //Log() << Verbose(1) << "INFO: Inserting " << Walker << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
     325          outmap->insert ( pair<double, pair<atom *, BoundaryTriangleSet*> >(ShortestDistance, pair<atom *, BoundaryTriangleSet*> ((*iter), ShortestTriangle) ) );
     326          //Log() << Verbose(1) << "INFO: Inserting " << (*iter) << " with distance " << ShortestDistance << " to " << *ShortestTriangle << "." << endl;
    343327        }
    344328      }
  • src/atom.cpp

    re87acf r9879f6  
    5959atom::~atom()
    6060{
    61   unlink(this);
    6261};
    6362
  • src/bondgraph.cpp

    re87acf r9879f6  
    8888  bool status = true;
    8989
    90   if (mol->start->next == mol->end) // only construct if molecule is not empty
     90  if (mol->empty()) // only construct if molecule is not empty
    9191    return false;
    9292
     
    121121  max_distance = 0.;
    122122
    123   atom *Runner = mol->start;
    124   while (Runner->next != mol->end) {
    125     Runner = Runner->next;
    126     if (Runner->type->CovalentRadius > max_distance)
    127       max_distance = Runner->type->CovalentRadius;
     123  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     124    if ((*iter)->type->CovalentRadius > max_distance)
     125      max_distance = (*iter)->type->CovalentRadius;
    128126  }
    129127  max_distance *= 2.;
  • src/boundary.cpp

    re87acf r9879f6  
    140140{
    141141        Info FunctionInfo(__func__);
    142   atom *Walker = NULL;
    143142  PointMap PointsOnBoundary;
    144143  LineMap LinesOnBoundary;
     
    166165
    167166    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
    168     Walker = mol->start;
    169     while (Walker->next != mol->end) {
    170       Walker = Walker->next;
    171       ProjectedVector.CopyVector(&Walker->x);
     167    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     168      ProjectedVector.CopyVector(&(*iter)->x);
    172169      ProjectedVector.SubtractVector(MolCenter);
    173170      ProjectedVector.ProjectOntoPlane(&AxisVector);
     
    184181        angle = 2. * M_PI - angle;
    185182      }
    186       Log() << Verbose(1) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
    187       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     183      Log() << Verbose(1) << "Inserting " << *(*iter) << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     184      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, (*iter))));
    188185      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    189186        Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;
    190187        Log() << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;
    191         Log() << Verbose(2) << "New vector: " << *Walker << endl;
     188        Log() << Verbose(2) << "New vector: " << *(*iter) << endl;
    192189        const double ProjectedVectorNorm = ProjectedVector.NormSquared();
    193190        if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) {
    194191          BoundaryTestPair.first->second.first = ProjectedVectorNorm;
    195           BoundaryTestPair.first->second.second = Walker;
     192          BoundaryTestPair.first->second.second = (*iter);
    196193          Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl;
    197194        } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) {
    198           helper.CopyVector(&Walker->x);
     195          helper.CopyVector(&(*iter)->x);
    199196          helper.SubtractVector(MolCenter);
    200197          const double oldhelperNorm = helper.NormSquared();
     
    202199          helper.SubtractVector(MolCenter);
    203200          if (helper.NormSquared() < oldhelperNorm) {
    204             BoundaryTestPair.first->second.second = Walker;
     201            BoundaryTestPair.first->second.second = (*iter);
    205202            Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
    206203          } else {
     
    705702  int repetition[NDIM] = { 1, 1, 1 };
    706703  int TotalNoClusters = 1;
    707   atom *Walker = NULL;
    708704  double totalmass = 0.;
    709705  double clustervolume = 0.;
     
    729725
    730726  // sum up the atomic masses
    731   Walker = mol->start;
    732   while (Walker->next != mol->end) {
    733       Walker = Walker->next;
    734       totalmass += Walker->type->mass;
     727  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     728      totalmass += (*iter)->type->mass;
    735729  }
    736730  Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl;
     
    811805  Vector FillerDistance;
    812806  double FillIt = false;
    813   atom *Walker = NULL;
    814807  bond *Binder = NULL;
    815808  int i = 0;
     
    884877
    885878          // go through all atoms
    886           Walker = filler->start;
    887           while (Walker->next != filler->end) {
    888             Walker = Walker->next;
     879          for (molecule::const_iterator iter = filler->begin(); iter != filler->end(); ++iter) {
    889880            // copy atom ...
    890             CopyAtoms[Walker->nr] = Walker->clone();
     881            CopyAtoms[(*iter)->nr] = (*iter)->clone();
    891882
    892883            // create atomic random translation vector ...
     
    913904            // ... and put at new position
    914905            if (DoRandomRotation)
    915               CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations);
    916             CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations);
    917             CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations);
    918             CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition);
     906              CopyAtoms[(*iter)->nr]->x.MatrixMultiplication(Rotations);
     907            CopyAtoms[(*iter)->nr]->x.AddVector(&AtomTranslations);
     908            CopyAtoms[(*iter)->nr]->x.AddVector(&FillerTranslations);
     909            CopyAtoms[(*iter)->nr]->x.AddVector(&CurrentPosition);
    919910
    920911            // insert into Filling
    921912
    922913            // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why???
    923             Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl;
    924             Filling->AddAtom(CopyAtoms[Walker->nr]);
     914            Log() << Verbose(4) << "Filling atom " << *(*iter) << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[(*iter)->nr]->x) << "." << endl;
     915            Filling->AddAtom(CopyAtoms[(*iter)->nr]);
    925916          }
    926917
     
    10361027//  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
    10371028//  //->InsertStraddlingPoints(mol, LCList);
    1038 //  mol->GoToFirst();
     1029//  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10391030//  class TesselPoint *Runner = NULL;
    1040 //  while (!mol->IsEnd()) {
    1041 //    Runner = mol->GetPoint();
     1031//    Runner = *iter;
    10421032//    Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
    10431033//    if (!->IsInnerPoint(Runner, LCList)) {
     
    10471037//      Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
    10481038//    }
    1049 //    mol->GoToNext();
    10501039//  }
    10511040
  • src/builder.cpp

    re87acf r9879f6  
    483483      Log() << Verbose(0) << "Enter radius: ";
    484484      cin >> tmp1;
    485       first = mol->start;
    486       second = first->next;
    487       while(second != mol->end) {
    488         first = second;
    489         second = first->next;
    490         if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
    491           mol->RemoveAtom(first);
     485      molecule::iterator runner;
     486      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     487        runner = iter++;
     488        if ((*iter)->x.DistanceSquared((const Vector *)&(*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     489          mol->RemoveAtom((*runner));
    492490      }
    493491      break;
     
    499497      Log() << Verbose(0) << "Upper boundary: ";
    500498      cin >> tmp2;
    501       first = mol->start;
    502       second = first->next;
    503       while(second != mol->end) {
    504         first = second;
    505         second = first->next;
    506         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    507           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    508           mol->RemoveAtom(first);
     499      molecule::iterator runner;
     500      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     501        runner = iter++;
     502        if (((*runner)->x.x[axis] < tmp1) || ((*runner)->x.x[axis] > tmp2)) {// out of boundary ...
     503          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     504          mol->RemoveAtom((*runner));
    509505        }
    510506      }
     
    549545        min[i] = 0.;
    550546
    551       second = mol->start;
    552       while ((second->next != mol->end)) {
    553         second = second->next; // advance
    554         Z = second->type->Z;
     547      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     548        Z = (*iter)->type->Z;
    555549        tmp1 = 0.;
    556         if (first != second) {
     550        if (first != (*iter)) {
    557551          x.CopyVector((const Vector *)&first->x);
    558           x.SubtractVector((const Vector *)&second->x);
     552          x.SubtractVector((const Vector *)&(*iter)->x);
    559553          tmp1 = x.Norm();
    560554        }
    561555        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    562         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     556        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << (*iter)->nr << ": " << tmp1 << " a.u." << endl;
    563557      }
    564558      for (int i=MAX_ELEMENTS;i--;)
     
    829823          vectors = new Vector *[count];
    830824          j = 0;
    831           first = mol->start;
    832           while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    833             first = first->next;
    834             Elements[j] = first->type;
    835             vectors[j] = &first->x;
     825          for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     826            Elements[j] = (*iter)->type;
     827            vectors[j] = &(*iter)->x;
    836828            j++;
    837829          }
     
    11841176    return;
    11851177  }
    1186   atom *Walker = mol->start;
    11871178
    11881179  // generate some KeySets
     
    11901181  KeySet TestSets[mol->AtomCount+1];
    11911182  i=1;
    1192   while (Walker->next != mol->end) {
    1193     Walker = Walker->next;
     1183  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    11941184    for (int j=0;j<i;j++) {
    1195       TestSets[j].insert(Walker->nr);
     1185      TestSets[j].insert((*iter)->nr);
    11961186    }
    11971187    i++;
     
    11991189  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    12001190  KeySetTestPair test;
    1201   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1202   if (test.second) {
    1203     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1191  molecule::const_iterator runner = mol->begin();
     1192  if (runner != mol->end()) {
     1193    test = TestSets[mol->AtomCount-1].insert((*runner)->nr);
     1194    if (test.second) {
     1195      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1196    } else {
     1197      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1198    }
    12041199  } else {
    1205     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1200    eLog() << Verbose(1) << "No atoms to test on." << endl;
    12061201  }
    1207   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1208   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
    12091202
    12101203  // constructing Graph structure
     
    18101803                double tmp1 = atof(argv[argptr+1]);
    18111804                atom *third = mol->FindAtom(atoi(argv[argptr]));
    1812                 atom *first = mol->start;
    1813                 if ((third != NULL) && (first != mol->end)) {
    1814                   atom *second = first->next;
    1815                   while(second != mol->end) {
    1816                     first = second;
    1817                     second = first->next;
    1818                     if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
    1819                       mol->RemoveAtom(first);
     1805                molecule::iterator runner;
     1806                if (third != NULL) {
     1807                  for (molecule::iterator iter = mol->begin(); iter != mol->end();) {
     1808                    runner = iter++;
     1809                    if ((*runner)->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
     1810                      mol->RemoveAtom((*runner));
    18201811                  }
    18211812                } else {
     
    20822073                    vectors = new Vector *[count];
    20832074                    j = 0;
    2084                     first = mol->start;
    2085                     while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
    2086                       first = first->next;
    2087                       Elements[j] = first->type;
    2088                       vectors[j] = &first->x;
     2075                    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     2076                      Elements[j] = (*iter)->type;
     2077                      vectors[j] = &(*iter)->x;
    20892078                      j++;
    20902079                    }
  • src/config.cpp

    re87acf r9879f6  
    15421542  int AtomNo = -1;
    15431543  int MolNo = 0;
    1544   atom *Walker = NULL;
    15451544  FILE *f = NULL;
    15461545
     
    15551554  fprintf(f, "# Created by MoleCuilder\n");
    15561555
    1557   for (MoleculeList::const_iterator Runner = MolList->ListOfMolecules.begin(); Runner != MolList->ListOfMolecules.end(); Runner++) {
    1558     Walker = (*Runner)->start;
     1556  for (MoleculeList::const_iterator MolRunner = MolList->ListOfMolecules.begin(); MolRunner != MolList->ListOfMolecules.end(); MolRunner++) {
    15591557    int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo");
    15601558    AtomNo = 0;
    1561     while (Walker->next != (*Runner)->end) {
    1562       Walker = Walker->next;
    1563       sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1564       elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1559    for (molecule::const_iterator iter = (*MolRunner)->begin(); iter != (*MolRunner)->end(); ++iter) {
     1560      sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1561      elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    15651562      fprintf(f,
    15661563             "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1567              Walker->nr,                /* atom serial number */
     1564             (*iter)->nr,                /* atom serial number */
    15681565             name,         /* atom name */
    1569              (*Runner)->name,      /* residue name */
     1566             (*MolRunner)->name,      /* residue name */
    15701567             'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    15711568             MolNo,         /* residue sequence number */
    1572              Walker->node->x[0],                 /* position X in Angstroem */
    1573              Walker->node->x[1],                 /* position Y in Angstroem */
    1574              Walker->node->x[2],                 /* position Z in Angstroem */
    1575              (double)Walker->type->Valence,         /* occupancy */
    1576              (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1569             (*iter)->node->x[0],                 /* position X in Angstroem */
     1570             (*iter)->node->x[1],                 /* position Y in Angstroem */
     1571             (*iter)->node->x[2],                 /* position Z in Angstroem */
     1572             (double)(*iter)->type->Valence,         /* occupancy */
     1573             (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    15771574             "0",            /* segment identifier */
    1578              Walker->type->symbol,    /* element symbol */
     1575             (*iter)->type->symbol,    /* element symbol */
    15791576             "0");           /* charge */
    15801577      AtomNo++;
     
    15961593{
    15971594  int AtomNo = -1;
    1598   atom *Walker = NULL;
    15991595  FILE *f = NULL;
    16001596
     
    16111607  fprintf(f, "# Created by MoleCuilder\n");
    16121608
    1613   Walker = mol->start;
    16141609  AtomNo = 0;
    1615   while (Walker->next != mol->end) {
    1616     Walker = Walker->next;
    1617     sprintf(name, "%2s%2d",Walker->type->symbol, elementNo[Walker->type->Z]);
    1618     elementNo[Walker->type->Z] = (elementNo[Walker->type->Z]+1) % 100;   // confine to two digits
     1610  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1611    sprintf(name, "%2s%2d",(*iter)->type->symbol, elementNo[(*iter)->type->Z]);
     1612    elementNo[(*iter)->type->Z] = (elementNo[(*iter)->type->Z]+1) % 100;   // confine to two digits
    16191613    fprintf(f,
    16201614           "ATOM %6u %-4s %4s%c%4u    %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s%2s\n",
    1621            Walker->nr,                /* atom serial number */
     1615           (*iter)->nr,                /* atom serial number */
    16221616           name,         /* atom name */
    16231617           mol->name,      /* residue name */
    16241618           'a'+(unsigned char)(AtomNo % 26),           /* letter for chain */
    16251619           0,         /* residue sequence number */
    1626            Walker->node->x[0],                 /* position X in Angstroem */
    1627            Walker->node->x[1],                 /* position Y in Angstroem */
    1628            Walker->node->x[2],                 /* position Z in Angstroem */
    1629            (double)Walker->type->Valence,         /* occupancy */
    1630            (double)Walker->type->NoValenceOrbitals,          /* temperature factor */
     1620           (*iter)->node->x[0],                 /* position X in Angstroem */
     1621           (*iter)->node->x[1],                 /* position Y in Angstroem */
     1622           (*iter)->node->x[2],                 /* position Z in Angstroem */
     1623           (double)(*iter)->type->Valence,         /* occupancy */
     1624           (double)(*iter)->type->NoValenceOrbitals,          /* temperature factor */
    16311625           "0",            /* segment identifier */
    1632            Walker->type->symbol,    /* element symbol */
     1626           (*iter)->type->symbol,    /* element symbol */
    16331627           "0");           /* charge */
    16341628    AtomNo++;
     
    16471641bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const
    16481642{
    1649   atom *Walker = NULL;
    16501643  ofstream *output = NULL;
    16511644  stringstream * const fname = new stringstream;
     
    16601653
    16611654  // scan maximum number of neighbours
    1662   Walker = mol->start;
    16631655  int MaxNeighbours = 0;
    1664   while (Walker->next != mol->end) {
    1665     Walker = Walker->next;
    1666     const int count = Walker->ListOfBonds.size();
     1656  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1657    const int count = (*iter)->ListOfBonds.size();
    16671658    if (MaxNeighbours < count)
    16681659      MaxNeighbours = count;
    16691660  }
    1670   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
    1671 
    1672   Walker = mol->start;
    1673   while (Walker->next != mol->end) {
    1674     Walker = Walker->next;
    1675     *output << Walker->nr << "\t";
    1676     *output << Walker->Name << "\t";
     1661  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
     1662
     1663  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1664    *output << (*iter)->nr << "\t";
     1665    *output << (*iter)->Name << "\t";
    16771666    *output << mol->name << "\t";
    16781667    *output << 0 << "\t";
    1679     *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    1680     *output << (double)Walker->type->Valence << "\t";
    1681     *output << Walker->type->symbol << "\t";
    1682     for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1683       *output << (*runner)->GetOtherAtom(Walker)->nr << "\t";
    1684     for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1668    for (int i=0;i<NDIM;i++)
     1669      *output << (*iter)->node->x[i] << "\t";
     1670    *output << (double)(*iter)->type->Valence << "\t";
     1671    *output << (*iter)->type->symbol << "\t";
     1672    for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1673      *output << (*runner)->GetOtherAtom((*iter))->nr << "\t";
     1674    for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    16851675      *output << "-\t";
    16861676    *output << endl;
     
    17011691bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const
    17021692{
    1703   atom *Walker = NULL;
    17041693  ofstream *output = NULL;
    17051694  stringstream * const fname = new stringstream;
     
    17161705  int MaxNeighbours = 0;
    17171706  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1718     Walker = (*MolWalker)->start;
    1719     while (Walker->next != (*MolWalker)->end) {
    1720       Walker = Walker->next;
    1721       const int count = Walker->ListOfBonds.size();
     1707    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
     1708      const int count = (*iter)->ListOfBonds.size();
    17221709      if (MaxNeighbours < count)
    17231710        MaxNeighbours = count;
    17241711    }
    17251712  }
    1726   *output << "# ATOMDATA Id name resName resSeq x=3 charge type neighbors=" << MaxNeighbours << endl;
     1713  *output << "# ATOMDATA Id name resName resSeq x=3 Charge type neighbors=" << MaxNeighbours << endl;
    17271714
    17281715  // create global to local id map
     
    17451732    int AtomNo = 0;
    17461733    for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    1747       Walker = (*MolWalker)->start;
    1748       while (Walker->next != (*MolWalker)->end) {
    1749         Walker = Walker->next;
     1734      for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    17501735        *output << AtomNo << "\t";
    1751         *output << Walker->Name << "\t";
     1736        *output << (*iter)->Name << "\t";
    17521737        *output << (*MolWalker)->name << "\t";
    17531738        *output << MolCounter << "\t";
    1754         *output << Walker->node->x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2] << "\t";
    1755         *output << (double)Walker->type->Valence << "\t";
    1756         *output << Walker->type->symbol << "\t";
    1757         for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++)
    1758           *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom(Walker)->nr ] << "\t";
    1759         for(int i=Walker->ListOfBonds.size(); i < MaxNeighbours; i++)
     1739        for (int i=0;i<NDIM;i++)
     1740          *output << (*iter)->node->x[i] << "\t";
     1741        *output << (double)(*iter)->type->Valence << "\t";
     1742        *output << (*iter)->type->symbol << "\t";
     1743        for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1744          *output << LocalNotoGlobalNoMap[MolCounter][ (*runner)->GetOtherAtom((*iter))->nr ] << "\t";
     1745        for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
    17601746          *output << "-\t";
    17611747        *output << endl;
  • src/helpers.hpp

    re87acf r9879f6  
    100100};
    101101
    102 /** Creates a lookup table for true father's Atom::Nr -> atom ptr.
    103  * \param *start begin of chain list
    104  * \paran *end end of chain list
    105  * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
    106  * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
    107  * \return true - success, false - failure
    108  */
    109 template <typename T> bool CreateFatherLookupTable(T *start, T *end, T **&LookupTable, int count = 0)
    110 {
    111   bool status = true;
    112   T *Walker = NULL;
    113   int AtomNo;
    114 
    115   if (LookupTable != NULL) {
    116     Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
    117     return false;
    118   }
    119 
    120   // count them
    121   if (count == 0) {
    122     Walker = start;
    123     while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
    124       Walker = Walker->next;
    125       count = (count < Walker->GetTrueFather()->nr) ? Walker->GetTrueFather()->nr : count;
    126     }
    127   }
    128   if (count <= 0) {
    129     Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
    130     return false;
    131   }
    132 
    133   // allocate and fill
    134   LookupTable = Calloc<T*>(count, "CreateFatherLookupTable - **LookupTable");
    135   if (LookupTable == NULL) {
    136     eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
    137     performCriticalExit();
    138     status = false;
    139   } else {
    140     Walker = start;
    141     while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
    142       Walker = Walker->next;
    143       AtomNo = Walker->GetTrueFather()->nr;
    144       if ((AtomNo >= 0) && (AtomNo < count)) {
    145         //*out << "Setting LookupTable[" << AtomNo << "] to " << *Walker << endl;
    146         LookupTable[AtomNo] = Walker;
    147       } else {
    148         Log() << Verbose(0) << "Walker " << *Walker << " exceeded range of nuclear ids [0, " << count << ")." << endl;
    149         status = false;
    150         break;
    151       }
    152     }
    153   }
    154 
    155   return status;
    156 };
    157 
    158102/** Frees a two-dimensional array.
    159103 * \param *ptr pointer to array
  • src/lists.hpp

    re87acf r9879f6  
    88#ifndef LISTS_HPP_
    99#define LISTS_HPP_
    10 
    11 class atom;
    1210
    1311/******************************** Some templates for list management ***********************************/
     
    134132};
    135133
    136 /** Returns the first marker in a chain list.
    137  * \param *me one arbitrary item in chain list
    138  * \return poiner to first marker
    139  */
    140 template <typename X> X *GetFirst(X *me)
    141 {
    142   X *Binder = me;
    143   while(Binder->previous != 0)
    144     Binder = Binder->previous;
    145   return Binder;
    146 };
    147 
    148 /** Returns the last marker in a chain list.
    149  * \param *me one arbitrary item in chain list
    150  * \return poiner to last marker
    151  */
    152 template <typename X> X *GetLast(X *me)
    153 {
    154   X *Binder = me;
    155   while(Binder->next != 0)
    156     Binder = Binder->next;
    157   return Binder;
    158 };
    159 
    160134#endif /* LISTS_HPP_ */
  • src/molecule.cpp

    re87acf r9879f6  
    3737  formula(this,boost::bind(&molecule::calcFormula,this)),
    3838  last_atom(0),
    39   InternalPointer(start)
    40 {
    41   // init atom chain list
    42   //start->father = NULL;
    43   //end->father = NULL;
    44   //link(start,end);
    45 
     39  InternalPointer(begin())
     40{
    4641  // init bond chain list
    4742  link(first,last);
     
    6762  delete(first);
    6863  delete(last);
    69   end->getWorld()->destroyAtom(end);
    70   start->getWorld()->destroyAtom(start);
    7164};
    7265
     
    10396  for (int j = 0; j<MAX_ELEMENTS;j++)
    10497    Counts[j] = 0;
    105   for(atom *Walker = start; Walker != end; Walker = Walker->next) {
    106     Counts[Walker->type->Z]++;
     98  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     99    Counts[(*iter)->type->Z]++;
    107100  }
    108101  for(element* Elemental = elemente->end; Elemental != elemente->start; Elemental = Elemental->previous) {
     
    124117}
    125118
    126 molecule::iterator molecule::ende(){
     119molecule::iterator molecule::end(){
    127120  return molecule::iterator(atoms.end(),this);
    128121}
    129122
    130 molecule::const_iterator molecule::ende() const{
     123molecule::const_iterator molecule::end() const{
    131124  return atoms.end();
     125}
     126
     127bool molecule::empty() const
     128{
     129  return (begin() == end());
     130}
     131
     132size_t molecule::size() const
     133{
     134  size_t counter = 0;
     135  for (molecule::const_iterator iter = begin(); iter != end (); ++iter)
     136    counter++;
     137  return counter;
     138}
     139
     140molecule::const_iterator molecule::erase( const_iterator loc )
     141{
     142  molecule::const_iterator iter = loc;
     143  iter--;
     144  atoms.erase( loc );
     145  return iter;
     146}
     147
     148molecule::const_iterator molecule::erase( atom *& key )
     149{
     150  molecule::const_iterator iter = find(key);
     151  molecule::const_iterator runner = iter;
     152  if (runner != begin()) {
     153    runner--;
     154    if (iter != end())
     155      atoms.erase( key );
     156    return runner;
     157  } else
     158    return end();
     159}
     160
     161molecule::const_iterator molecule::find ( atom *& key ) const
     162{
     163  return atoms.find( key );
     164}
     165
     166pair<molecule::iterator,bool> molecule::insert ( atom * const key )
     167{
     168  return atoms.insert(key);
    132169}
    133170
     
    139176bool molecule::AddAtom(atom *pointer)
    140177{
    141   bool retval = false;
    142178  OBSERVE;
    143179  if (pointer != NULL) {
    144180    pointer->sort = &pointer->nr;
    145     pointer->nr = last_atom++;  // increase number within molecule
    146181    AtomCount++;
    147182    if (pointer->type != NULL) {
     
    157192      }
    158193    }
    159     retval = add(pointer, end);
    160   }
    161   return retval;
     194    insert(pointer);
     195  }
     196  return true;
    162197};
    163198
     
    175210    walker->Name = Malloc<char>(strlen(pointer->Name) + 1, "atom::atom: *Name");
    176211    strcpy (walker->Name, pointer->Name);
    177     walker->nr = last_atom++;  // increase number within molecule
    178     add(walker, end);
     212    insert(walker);
    179213    if ((pointer->type != NULL) && (pointer->type->Z != 1))
    180214      NoNonHydrogen++;
     
    701735    ElementCount--;
    702736  RemoveBonds(pointer);
    703   return remove(pointer, start, end);
     737  erase(pointer);
     738  return true;
    704739};
    705740
     
    718753  if (ElementsInMolecule[pointer->type->Z] == 0)  // was last atom of this element?
    719754    ElementCount--;
    720   unlink(pointer);
     755  erase(pointer);
    721756  return true;
    722757};
     
    727762bool molecule::CleanupMolecule()
    728763{
    729   return (cleanup(first,last) && cleanup(start,end));
     764  for (molecule::iterator iter = begin(); !empty(); iter = begin())
     765      erase(iter);
     766  return (cleanup(first,last));
    730767};
    731768
     
    734771 * \return pointer to atom or NULL
    735772 */
    736 atom * molecule::FindAtom(int Nr)  const{
    737   atom * walker = find(&Nr, start,end);
    738   if (walker != NULL) {
     773atom * molecule::FindAtom(int Nr)  const
     774{
     775  molecule::const_iterator iter = begin();
     776  for (; iter != end(); ++iter)
     777    if ((*iter)->nr == Nr)
     778      break;
     779  if (iter != end()) {
    739780    //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl;
    740     return walker;
     781    return (*iter);
    741782  } else {
    742783    Log() << Verbose(0) << "Atom not found in list." << endl;
     
    896937void molecule::CountAtoms()
    897938{
    898   int i = 0;
    899   atom *Walker = start;
    900   while (Walker->next != end) {
    901     Walker = Walker->next;
    902     i++;
    903   }
     939  int i = size();
    904940  if ((AtomCount == 0) || (i != AtomCount)) {
    905941    Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
     
    910946      i=0;
    911947      NoNonHydrogen = 0;
    912       Walker = start;
    913       while (Walker->next != end) {
    914         Walker = Walker->next;
    915         Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    916         if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
     948      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     949        (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
     950        if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
    917951          NoNonHydrogen++;
    918         Free(&Walker->Name);
    919         Walker->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
    920         sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    921         Log() << Verbose(3) << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
     952        Free(&(*iter)->Name);
     953        (*iter)->Name = Malloc<char>(6, "molecule::CountAtoms: *walker->Name");
     954        sprintf((*iter)->Name, "%2s%02d", (*iter)->type->symbol, (*iter)->nr+1);
     955        Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->Name << "." << endl;
    922956        i++;
    923957      }
     
    10921126int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule)
    10931127{
    1094   atom *Walker = NULL, *OtherWalker = NULL;
    10951128  Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl;
    10961129  int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap");
     
    11031136  } else {
    11041137    Log() << Verbose(4) << "Map is ";
    1105     Walker = start;
    1106     while (Walker->next != end) {
    1107       Walker = Walker->next;
    1108       if (Walker->father == NULL) {
    1109         AtomicMap[Walker->nr] = -2;
     1138    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1139      if ((*iter)->father == NULL) {
     1140        AtomicMap[(*iter)->nr] = -2;
    11101141      } else {
    1111         OtherWalker = OtherMolecule->start;
    1112         while (OtherWalker->next != OtherMolecule->end) {
    1113           OtherWalker = OtherWalker->next;
     1142        for (molecule::const_iterator runner = OtherMolecule->begin(); runner != OtherMolecule->end(); ++runner) {
    11141143      //for (int i=0;i<AtomCount;i++) { // search atom
    11151144        //for (int j=0;j<OtherMolecule->AtomCount;j++) {
    1116           //Log() << Verbose(4) << "Comparing father " << Walker->father << " with the other one " << OtherWalker->father << "." << endl;
    1117           if (Walker->father == OtherWalker)
    1118             AtomicMap[Walker->nr] = OtherWalker->nr;
     1145          //Log() << Verbose(4) << "Comparing father " << (*iter)->father << " with the other one " << (*runner)->father << "." << endl;
     1146          if ((*iter)->father == (*runner))
     1147            AtomicMap[(*iter)->nr] = (*runner)->nr;
    11191148        }
    11201149      }
    1121       Log() << Verbose(0) << AtomicMap[Walker->nr] << "\t";
     1150      Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t";
    11221151    }
    11231152    Log() << Verbose(0) << endl;
     
    11531182void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const
    11541183{
    1155   atom *Walker = start;
    1156   while (Walker->next != end) {
    1157     Walker = Walker->next;
    1158     array[(Walker->*index)] = Walker;
     1184  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1185    array[((*iter)->*index)] = (*iter);
    11591186  }
    11601187};
  • src/molecule.hpp

    re87acf r9879f6  
    137137  iterator end();
    138138  const_iterator end() const;
     139  bool empty() const;
     140  size_t size() const;
     141  const_iterator erase( const_iterator loc );
     142  const_iterator erase( atom *& key );
     143  const_iterator find (  atom *& key ) const;
     144  pair<iterator,bool> insert ( atom * const key );
    139145
    140146
     
    143149  Vector *GetCenter() const ;
    144150  TesselPoint *GetPoint() const ;
    145   TesselPoint *GetTerminalPoint() const ;
    146151  int GetMaxId() const;
    147152  void GoToNext() const ;
    148   void GoToPrevious() const ;
    149153  void GoToFirst() const ;
    150   void GoToLast() const ;
    151154  bool IsEmpty() const ;
    152155  bool IsEnd() const ;
     
    310313  bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex);
    311314  bool CreateMappingLabelsToConfigSequence(int *&SortIndex);
     315  bool CreateFatherLookupTable(atom **&LookupTable, int count = 0);
    312316  void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem);
    313317  /// -# BOSSANOVA
     
    338342  private:
    339343  int last_atom;      //!< number given to last atom
    340   mutable atom *InternalPointer;  //!< internal pointer for PointCloud
     344  mutable iterator InternalPointer;  //!< internal pointer for PointCloud
    341345};
    342346
  • src/molecule_dynamics.cpp

    re87acf r9879f6  
    2727  gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM);
    2828  gsl_vector *x = gsl_vector_alloc(NDIM);
    29   atom * Runner = mol->start;
    3029  atom *Sprinter = NULL;
    3130  Vector trajectory1, trajectory2, normal, TestVector;
    3231  double Norm1, Norm2, tmp, result = 0.;
    3332
    34   while (Runner->next != mol->end) {
    35     Runner = Runner->next;
    36     if (Runner == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
     33  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     34    if ((*iter) == Walker) // hence, we only go up to the Walker, not beyond (similar to i=0; i<j; i++)
    3735      break;
    3836    // determine normalized trajectories direction vector (n1, n2)
     
    4240    trajectory1.Normalize();
    4341    Norm1 = trajectory1.Norm();
    44     Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     42    Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    4543    trajectory2.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));
    46     trajectory2.SubtractVector(&Runner->Trajectory.R.at(Params.startstep));
     44    trajectory2.SubtractVector(&(*iter)->Trajectory.R.at(Params.startstep));
    4745    trajectory2.Normalize();
    4846    Norm2 = trajectory1.Norm();
    4947    // check whether either is zero()
    5048    if ((Norm1 < MYEPSILON) && (Norm2 < MYEPSILON)) {
    51       tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.startstep));
     49      tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&(*iter)->Trajectory.R.at(Params.startstep));
    5250    } else if (Norm1 < MYEPSILON) {
    5351      Sprinter = Params.PermutationMap[Walker->nr];   // find first target point
    5452      trajectory1.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));  // copy first offset
    55       trajectory1.SubtractVector(&Runner->Trajectory.R.at(Params.startstep));  // subtract second offset
     53      trajectory1.SubtractVector(&(*iter)->Trajectory.R.at(Params.startstep));  // subtract second offset
    5654      trajectory2.Scale( trajectory1.ScalarProduct(&trajectory2) ); // trajectory2 is scaled to unity, hence we don't need to divide by anything
    5755      trajectory1.SubtractVector(&trajectory2);   // project the part in norm direction away
    5856      tmp = trajectory1.Norm();  // remaining norm is distance
    5957    } else if (Norm2 < MYEPSILON) {
    60       Sprinter = Params.PermutationMap[Runner->nr];   // find second target point
     58      Sprinter = Params.PermutationMap[(*iter)->nr];   // find second target point
    6159      trajectory2.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep));  // copy second offset
    6260      trajectory2.SubtractVector(&Walker->Trajectory.R.at(Params.startstep));  // subtract first offset
     
    6563      tmp = trajectory2.Norm();  // remaining norm is distance
    6664    } else if ((fabs(trajectory1.ScalarProduct(&trajectory2)/Norm1/Norm2) - 1.) < MYEPSILON) { // check whether they're linear dependent
    67   //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear dependent: ";
     65  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear dependent: ";
    6866  //        Log() << Verbose(0) << trajectory1;
    6967  //        Log() << Verbose(0) << " and ";
    7068  //        Log() << Verbose(0) << trajectory2;
    71       tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.startstep));
     69      tmp = Walker->Trajectory.R.at(Params.startstep).Distance(&(*iter)->Trajectory.R.at(Params.startstep));
    7270  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    7371    } else { // determine distance by finding minimum distance
    74   //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *Runner << " are linear independent ";
     72  //        Log() << Verbose(3) << "Both trajectories of " << *Walker << " and " << *(*iter) << " are linear independent ";
    7573  //        Log() << Verbose(0) << endl;
    7674  //        Log() << Verbose(0) << "First Trajectory: ";
     
    8886        gsl_matrix_set(A, 1, i, trajectory2.x[i]);
    8987        gsl_matrix_set(A, 2, i, normal.x[i]);
    90         gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep).x[i] - Runner->Trajectory.R.at(Params.startstep).x[i]));
     88        gsl_vector_set(x,i, (Walker->Trajectory.R.at(Params.startstep).x[i] - (*iter)->Trajectory.R.at(Params.startstep).x[i]));
    9189      }
    9290      // solve the linear system by Householder transformations
     
    9694  //        Log() << Verbose(0) << " with distance " << tmp << "." << endl;
    9795      // test whether we really have the intersection (by checking on c_1 and c_2)
    98       TestVector.CopyVector(&Runner->Trajectory.R.at(Params.startstep));
     96      TestVector.CopyVector(&(*iter)->Trajectory.R.at(Params.startstep));
    9997      trajectory2.Scale(gsl_vector_get(x,1));
    10098      TestVector.AddVector(&trajectory2);
     
    131129{
    132130  double result = 0.;
    133   atom * Runner = mol->start;
    134   while (Runner->next != mol->end) {
    135     Runner = Runner->next;
    136     if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[Runner->nr]) && (Walker->nr < Runner->nr)) {
     131  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     132    if ((Params.PermutationMap[Walker->nr] == Params.PermutationMap[(*iter)->nr]) && (Walker->nr < (*iter)->nr)) {
    137133  //    atom *Sprinter = PermutationMap[Walker->nr];
    138   //        Log() << Verbose(0) << *Walker << " and " << *Runner << " are heading to the same target at ";
     134  //        Log() << Verbose(0) << *Walker << " and " << *(*iter) << " are heading to the same target at ";
    139135  //        Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep);
    140136  //        Log() << Verbose(0) << ", penalting." << endl;
     
    167163  // go through every atom
    168164  atom *Runner = NULL;
    169   atom *Walker = start;
    170   while (Walker->next != end) {
    171     Walker = Walker->next;
     165  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    172166    // first term: distance to target
    173     Runner = Params.PermutationMap[Walker->nr];   // find target point
    174     tmp = (Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.endstep)));
     167    Runner = Params.PermutationMap[(*iter)->nr];   // find target point
     168    tmp = ((*iter)->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.endstep)));
    175169    tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem;
    176170    result += Params.PenaltyConstants[0] * tmp;
     
    178172
    179173    // second term: sum of distances to other trajectories
    180     result += SumDistanceOfTrajectories(Walker, this, Params);
     174    result += SumDistanceOfTrajectories((*iter), this, Params);
    181175
    182176    // third term: penalty for equal targets
    183     result += PenalizeEqualTargets(Walker, this, Params);
     177    result += PenalizeEqualTargets((*iter), this, Params);
    184178  }
    185179
     
    224218  }
    225219
    226   atom *Runner = NULL;
    227   atom *Walker = mol->start;
    228   while (Walker->next != mol->end) {
    229     Walker = Walker->next;
    230     Runner = mol->start;
    231     while(Runner->next != mol->end) {
    232       Runner = Runner->next;
    233       Params.DistanceList[Walker->nr]->insert( DistancePair(Walker->Trajectory.R.at(Params.startstep).Distance(&Runner->Trajectory.R.at(Params.endstep)), Runner) );
     220  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     221    for (molecule::const_iterator runner = mol->begin(); runner != mol->end(); ++runner) {
     222      Params.DistanceList[(*iter)->nr]->insert( DistancePair((*iter)->Trajectory.R.at(Params.startstep).Distance(&(*runner)->Trajectory.R.at(Params.endstep)), (*runner)) );
    234223    }
    235224  }
     
    243232void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params)
    244233{
    245   atom *Walker = mol->start;
    246   while (Walker->next != mol->end) {
    247     Walker = Walker->next;
    248     Params.StepList[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // stores the step to the next iterator that could be a possible next target
    249     Params.PermutationMap[Walker->nr] = Params.DistanceList[Walker->nr]->begin()->second;   // always pick target with the smallest distance
    250     Params.DoubleList[Params.DistanceList[Walker->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
    251     Params.DistanceIterators[Walker->nr] = Params.DistanceList[Walker->nr]->begin();    // and remember which one we picked
    252     Log() << Verbose(2) << *Walker << " starts with distance " << Params.DistanceList[Walker->nr]->begin()->first << "." << endl;
     234  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     235    Params.StepList[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // stores the step to the next iterator that could be a possible next target
     236    Params.PermutationMap[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin()->second;   // always pick target with the smallest distance
     237    Params.DoubleList[Params.DistanceList[(*iter)->nr]->begin()->second->nr]++;            // increase this target's source count (>1? not injective)
     238    Params.DistanceIterators[(*iter)->nr] = Params.DistanceList[(*iter)->nr]->begin();    // and remember which one we picked
     239    Log() << Verbose(2) << *(*iter) << " starts with distance " << Params.DistanceList[(*iter)->nr]->begin()->first << "." << endl;
    253240  }
    254241};
     
    291278void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params)
    292279{
    293   atom *Walker = mol->start;
     280  molecule::const_iterator iter = mol->begin();
    294281  DistanceMap::iterator NewBase;
    295282  double Potential = fabs(mol->ConstrainedPotential(Params));
    296283
     284  if (mol->empty()) {
     285    eLog() << Verbose(1) << "Molecule is empty." << endl;
     286    return;
     287  }
    297288  while ((Potential) > Params.PenaltyConstants[2]) {
    298289    PrintPermutationMap(mol->AtomCount, Params);
    299     Walker = Walker->next;
    300     if (Walker == mol->end) // round-robin at the end
    301       Walker = mol->start->next;
    302     if (Params.DoubleList[Params.DistanceIterators[Walker->nr]->second->nr] <= 1)  // no need to make those injective that aren't
     290    iter++;
     291    if (iter == mol->end()) // round-robin at the end
     292      iter = mol->begin();
     293    if (Params.DoubleList[Params.DistanceIterators[(*iter)->nr]->second->nr] <= 1)  // no need to make those injective that aren't
    303294      continue;
    304295    // now, try finding a new one
    305     Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);
     296    Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params);
    306297  }
    307298  for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1
     
    350341  Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList");
    351342  int round;
    352   atom *Walker = NULL, *Runner = NULL, *Sprinter = NULL;
     343  atom *Sprinter = NULL;
    353344  DistanceMap::iterator Rider, Strider;
    354345
     
    377368    Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl;
    378369    OlderPotential = OldPotential;
     370    molecule::const_iterator iter;
    379371    do {
    380       Walker = start;
    381       while (Walker->next != end) { // pick one
    382         Walker = Walker->next;
     372      iter = begin();
     373      for (; iter != end(); ++iter) {
    383374        PrintPermutationMap(AtomCount, Params);
    384         Sprinter = Params.DistanceIterators[Walker->nr]->second;   // store initial partner
    385         Strider = Params.DistanceIterators[Walker->nr];  //remember old iterator
    386         Params.DistanceIterators[Walker->nr] = Params.StepList[Walker->nr];
    387         if (Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->end()) {// stop, before we run through the list and still on
    388           Params.DistanceIterators[Walker->nr] == Params.DistanceList[Walker->nr]->begin();
     375        Sprinter = Params.DistanceIterators[(*iter)->nr]->second;   // store initial partner
     376        Strider = Params.DistanceIterators[(*iter)->nr];  //remember old iterator
     377        Params.DistanceIterators[(*iter)->nr] = Params.StepList[(*iter)->nr];
     378        if (Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->end()) {// stop, before we run through the list and still on
     379          Params.DistanceIterators[(*iter)->nr] == Params.DistanceList[(*iter)->nr]->begin();
    389380          break;
    390381        }
    391         //Log() << Verbose(2) << "Current Walker: " << *Walker << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[Walker->nr]->second << "." << endl;
     382        //Log() << Verbose(2) << "Current Walker: " << *(*iter) << " with old/next candidate " << *Sprinter << "/" << *DistanceIterators[(*iter)->nr]->second << "." << endl;
    392383        // find source of the new target
    393         Runner = start->next;
    394         while(Runner != end) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
    395           if (Params.PermutationMap[Runner->nr] == Params.DistanceIterators[Walker->nr]->second) {
    396             //Log() << Verbose(2) << "Found the corresponding owner " << *Runner << " to " << *PermutationMap[Runner->nr] << "." << endl;
     384        molecule::const_iterator runner = begin();
     385        for (; runner != end(); ++runner) { // find the source whose toes we might be stepping on (Walker's new target should be in use by another already)
     386          if (Params.PermutationMap[(*runner)->nr] == Params.DistanceIterators[(*iter)->nr]->second) {
     387            //Log() << Verbose(2) << "Found the corresponding owner " << *(*runner) << " to " << *PermutationMap[(*runner)->nr] << "." << endl;
    397388            break;
    398389          }
    399           Runner = Runner->next;
    400390        }
    401         if (Runner != end) { // we found the other source
     391        if (runner != end()) { // we found the other source
    402392          // then look in its distance list for Sprinter
    403           Rider = Params.DistanceList[Runner->nr]->begin();
    404           for (; Rider != Params.DistanceList[Runner->nr]->end(); Rider++)
     393          Rider = Params.DistanceList[(*runner)->nr]->begin();
     394          for (; Rider != Params.DistanceList[(*runner)->nr]->end(); Rider++)
    405395            if (Rider->second == Sprinter)
    406396              break;
    407           if (Rider != Params.DistanceList[Runner->nr]->end()) { // if we have found one
    408             //Log() << Verbose(2) << "Current Other: " << *Runner << " with old/next candidate " << *PermutationMap[Runner->nr] << "/" << *Rider->second << "." << endl;
     397          if (Rider != Params.DistanceList[(*runner)->nr]->end()) { // if we have found one
     398            //Log() << Verbose(2) << "Current Other: " << *(*runner) << " with old/next candidate " << *PermutationMap[(*runner)->nr] << "/" << *Rider->second << "." << endl;
    409399            // exchange both
    410             Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap
    411             Params.PermutationMap[Runner->nr] = Sprinter;  // and hand the old target to its respective owner
     400            Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // put next farther distance into PermutationMap
     401            Params.PermutationMap[(*runner)->nr] = Sprinter;  // and hand the old target to its respective owner
    412402            PrintPermutationMap(AtomCount, Params);
    413403            // calculate the new potential
     
    416406            if (Potential > OldPotential) { // we made everything worse! Undo ...
    417407              //Log() << Verbose(3) << "Nay, made the potential worse: " << Potential << " vs. " << OldPotential << "!" << endl;
    418               //Log() << Verbose(3) << "Setting " << *Runner << "'s source to " << *Params.DistanceIterators[Runner->nr]->second << "." << endl;
     408              //Log() << Verbose(3) << "Setting " << *(*runner) << "'s source to " << *Params.DistanceIterators[(*runner)->nr]->second << "." << endl;
    419409              // Undo for Runner (note, we haven't moved the iteration yet, we may use this)
    420               Params.PermutationMap[Runner->nr] = Params.DistanceIterators[Runner->nr]->second;
     410              Params.PermutationMap[(*runner)->nr] = Params.DistanceIterators[(*runner)->nr]->second;
    421411              // Undo for Walker
    422               Params.DistanceIterators[Walker->nr] = Strider;  // take next farther distance target
    423               //Log() << Verbose(3) << "Setting " << *Walker << "'s source to " << *Params.DistanceIterators[Walker->nr]->second << "." << endl;
    424               Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second;
     412              Params.DistanceIterators[(*iter)->nr] = Strider;  // take next farther distance target
     413              //Log() << Verbose(3) << "Setting " << *(*iter) << "'s source to " << *Params.DistanceIterators[(*iter)->nr]->second << "." << endl;
     414              Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second;
    425415            } else {
    426               Params.DistanceIterators[Runner->nr] = Rider;  // if successful also move the pointer in the iterator list
     416              Params.DistanceIterators[(*runner)->nr] = Rider;  // if successful also move the pointer in the iterator list
    427417              Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl;
    428418              OldPotential = Potential;
     
    434424            //Log() << Verbose(0) << endl;
    435425          } else {
    436             eLog() << Verbose(1) << *Runner << " was not the owner of " << *Sprinter << "!" << endl;
     426            eLog() << Verbose(1) << *(*runner) << " was not the owner of " << *Sprinter << "!" << endl;
    437427            exit(255);
    438428          }
    439429        } else {
    440           Params.PermutationMap[Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // new target has no source!
     430          Params.PermutationMap[(*iter)->nr] = Params.DistanceIterators[(*iter)->nr]->second; // new target has no source!
    441431        }
    442         Params.StepList[Walker->nr]++; // take next farther distance target
     432        Params.StepList[(*iter)->nr]++; // take next farther distance target
    443433      }
    444     } while (Walker->next != end);
     434    } while (++iter != end());
    445435  } while ((OlderPotential - OldPotential) > 1e-3);
    446436  Log() << Verbose(1) << "done." << endl;
     
    489479  // Get the Permutation Map by MinimiseConstrainedPotential
    490480  atom **PermutationMap = NULL;
    491   atom *Walker = NULL, *Sprinter = NULL;
     481  atom *Sprinter = NULL;
    492482  if (!MapByIdentity)
    493483    MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem());
     
    508498    mol = World::get()->createMolecule();
    509499    MoleculePerStep->insert(mol);
    510     Walker = start;
    511     while (Walker->next != end) {
    512       Walker = Walker->next;
     500    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    513501      // add to molecule list
    514       Sprinter = mol->AddCopyAtom(Walker);
     502      Sprinter = mol->AddCopyAtom((*iter));
    515503      for (int n=NDIM;n--;) {
    516         Sprinter->x.x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
     504        Sprinter->x.x[n] = (*iter)->Trajectory.R.at(startstep).x[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep).x[n] - (*iter)->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
    517505        // add to Trajectories
    518506        //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl;
    519507        if (step < MaxSteps) {
    520           Walker->Trajectory.R.at(step).x[n] = Walker->Trajectory.R.at(startstep).x[n] + (PermutationMap[Walker->nr]->Trajectory.R.at(endstep).x[n] - Walker->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
    521           Walker->Trajectory.U.at(step).x[n] = 0.;
    522           Walker->Trajectory.F.at(step).x[n] = 0.;
     508          (*iter)->Trajectory.R.at(step).x[n] = (*iter)->Trajectory.R.at(startstep).x[n] + (PermutationMap[(*iter)->nr]->Trajectory.R.at(endstep).x[n] - (*iter)->Trajectory.R.at(startstep).x[n])*((double)step/(double)MaxSteps);
     509          (*iter)->Trajectory.U.at(step).x[n] = 0.;
     510          (*iter)->Trajectory.F.at(step).x[n] = 0.;
    523511        }
    524512      }
  • src/molecule_fragmentation.cpp

    re87acf r9879f6  
    3838  int FragmentCount;
    3939  // get maximum bond degree
    40   atom *Walker = start;
    41   while (Walker->next != end) {
    42     Walker = Walker->next;
    43     c = (Walker->ListOfBonds.size() > c) ? Walker->ListOfBonds.size() : c;
     40  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     41    c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
    4442  }
    4543  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    358356map<double, pair<int,int> >  * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol)
    359357{
    360   atom *Walker = mol->start;
     358  atom *Walker = NULL;
    361359  map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ;
    362360  Log() << Verbose(1) << "Root candidate list is: " << endl;
     
    390388bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol)
    391389{
    392   atom *Walker = mol->start;
     390  atom *Walker = NULL;
    393391  int No = -1;
    394392  bool status = false;
     
    434432bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path)
    435433{
    436   atom *Walker = start;
    437434  bool status = false;
    438435
     
    456453    if (AdaptiveCriteriaList->empty()) {
    457454      eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl;
    458       while (Walker->next != end) {
    459         Walker = Walker->next;
     455      for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    460456    #ifdef ADDHYDROGEN
    461         if (Walker->type->Z != 1) // skip hydrogen
     457        if ((*iter)->type->Z != 1) // skip hydrogen
    462458    #endif
    463459        {
    464           AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
     460          AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
    465461          status = true;
    466462        }
     
    477473    Free(&FinalRootCandidates);
    478474  } else { // global increase of Bond Order
    479     while (Walker->next != end) {
    480       Walker = Walker->next;
     475    for(molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    481476  #ifdef ADDHYDROGEN
    482       if (Walker->type->Z != 1) // skip hydrogen
     477      if ((*iter)->type->Z != 1) // skip hydrogen
    483478  #endif
    484479      {
    485         AtomMask[Walker->nr] = true;  // include all (non-hydrogen) atoms
    486         if ((Order != 0) && (Walker->AdaptiveOrder < Order)) // && (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]))
     480        AtomMask[(*iter)->nr] = true;  // include all (non-hydrogen) atoms
     481        if ((Order != 0) && ((*iter)->AdaptiveOrder < Order)) // && ((*iter)->AdaptiveOrder < MinimumRingSize[(*iter)->nr]))
    487482          status = true;
    488483      }
     
    523518
    524519  return true;
     520};
     521
     522
     523
     524/** Creates a lookup table for true father's Atom::Nr -> atom ptr.
     525 * \param *start begin of list (STL iterator, i.e. first item)
     526 * \paran *end end of list (STL iterator, i.e. one past last item)
     527 * \param **Lookuptable pointer to return allocated lookup table (should be NULL on start)
     528 * \param count optional predetermined size for table (otherwise we set the count to highest true father id)
     529 * \return true - success, false - failure
     530 */
     531bool molecule::CreateFatherLookupTable(atom **&LookupTable, int count)
     532{
     533  bool status = true;
     534  int AtomNo;
     535
     536  if (LookupTable != NULL) {
     537    Log() << Verbose(0) << "Pointer for Lookup table is not NULL! Aborting ..." <<endl;
     538    return false;
     539  }
     540
     541  // count them
     542  if (count == 0) {
     543    for (molecule::iterator iter = begin(); iter != end(); ++iter) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron
     544      count = (count < (*iter)->GetTrueFather()->nr) ? (*iter)->GetTrueFather()->nr : count;
     545    }
     546  }
     547  if (count <= 0) {
     548    Log() << Verbose(0) << "Count of lookup list is 0 or less." << endl;
     549    return false;
     550  }
     551
     552  // allocate and fill
     553  LookupTable = Calloc<atom *>(count, "CreateFatherLookupTable - **LookupTable");
     554  if (LookupTable == NULL) {
     555    eLog() << Verbose(0) << "LookupTable memory allocation failed!" << endl;
     556    performCriticalExit();
     557    status = false;
     558  } else {
     559    for (molecule::iterator iter = begin(); iter != end(); ++iter) {
     560      AtomNo = (*iter)->GetTrueFather()->nr;
     561      if ((AtomNo >= 0) && (AtomNo < count)) {
     562        //*out << "Setting LookupTable[" << AtomNo << "] to " << *(*iter) << endl;
     563        LookupTable[AtomNo] = (*iter);
     564      } else {
     565        Log() << Verbose(0) << "Walker " << *(*iter) << " exceeded range of nuclear ids [0, " << count << ")." << endl;
     566        status = false;
     567        break;
     568      }
     569    }
     570  }
     571
     572  return status;
    525573};
    526574
     
    575623
    576624  // create lookup table for Atom::nr
    577   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(start, end, ListOfAtoms, AtomCount);
     625  FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, AtomCount);
    578626
    579627  // === compare it with adjacency file ===
     
    871919  Leaf->CountAtoms();
    872920
    873   atom *Runner = Leaf->start;
    874   while (Runner->next != Leaf->end) {
    875     Runner = Runner->next;
     921#ifdef ADDHYDROGEN
     922  molecule::const_iterator runner;
     923#endif
     924  for (molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ) {
    876925    LonelyFlag = true;
    877     FatherOfRunner = Runner->father;
     926    FatherOfRunner = (*iter)->father;
    878927    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    879928      // create all bonds
     
    886935//            Log() << Verbose(3) << "Adding Bond: ";
    887936//            Log() << Verbose(0) <<
    888             Leaf->AddBond(Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);
     937            Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree);
    889938//            Log() << Verbose(0) << "." << endl;
    890             //NumBonds[Runner->nr]++;
     939            //NumBonds[(*iter)->nr]++;
    891940          } else {
    892941//            Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl;
     
    896945//          Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl;
    897946#ifdef ADDHYDROGEN
    898           //Log() << Verbose(3) << "Adding Hydrogen to " << Runner->Name << " and a bond in between." << endl;
    899           if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), Runner, FatherOfRunner, OtherFather, IsAngstroem))
     947          //Log() << Verbose(3) << "Adding Hydrogen to " << (*iter)->Name << " and a bond in between." << endl;
     948          if(!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))
    900949            exit(1);
    901950#endif
    902           //NumBonds[Runner->nr] += Binder->BondDegree;
     951          //NumBonds[(*iter)->nr] += Binder->BondDegree;
    903952        }
    904953      }
    905954    } else {
    906       eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;
     955      eLog() << Verbose(1) << "Son " << (*iter)->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl;
    907956    }
    908957    if ((LonelyFlag) && (Leaf->AtomCount > 1)) {
    909       Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl;
     958      Log() << Verbose(0) << *(*iter) << "has got bonds only to hydrogens!" << endl;
    910959    }
    911960#ifdef ADDHYDROGEN
    912     while ((Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen
    913       Runner = Runner->next;
     961    while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)) // skip added hydrogen
     962      iter++;
    914963#endif
    915964  }
     
    15591608
    15601609  // Construct the complete KeySet which we need for topmost level only (but for all Roots)
    1561   atom *Walker = start;
    15621610  KeySet CompleteMolecule;
    1563   while (Walker->next != end) {
    1564     Walker = Walker->next;
    1565     CompleteMolecule.insert(Walker->GetTrueFather()->nr);
     1611  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     1612    CompleteMolecule.insert((*iter)->GetTrueFather()->nr);
    15661613  }
    15671614
     
    15741621    RootKeyNr = RootStack.front();
    15751622    RootStack.pop_front();
    1576     Walker = FindAtom(RootKeyNr);
     1623    atom *Walker = FindAtom(RootKeyNr);
    15771624    // check cyclic lengths
    15781625    //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) {
  • src/molecule_geometry.cpp

    re87acf r9879f6  
    6666
    6767//  Log() << Verbose(3) << "Begin of CenterEdge." << endl;
    68   atom *ptr = start->next;  // start at first in list
    69   if (ptr != end) {  //list not empty?
     68  molecule::const_iterator iter = begin();  // start at first in list
     69  if (iter != end()) { //list not empty?
    7070    for (int i=NDIM;i--;) {
    71       max->x[i] = ptr->x.x[i];
    72       min->x[i] = ptr->x.x[i];
    73     }
    74     while (ptr->next != end) {  // continue with second if present
    75       ptr = ptr->next;
    76       //ptr->Output(1,1,out);
     71      max->x[i] = (*iter)->x.x[i];
     72      min->x[i] = (*iter)->x.x[i];
     73    }
     74    for (; iter != end(); ++iter) {// continue with second if present
     75      //(*iter)->Output(1,1,out);
    7776      for (int i=NDIM;i--;) {
    78         max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i];
    79         min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i];
     77        max->x[i] = (max->x[i] < (*iter)->x.x[i]) ? (*iter)->x.x[i] : max->x[i];
     78        min->x[i] = (min->x[i] > (*iter)->x.x[i]) ? (*iter)->x.x[i] : min->x[i];
    8079      }
    8180    }
     
    101100{
    102101  int Num = 0;
    103   atom *ptr = start;  // start at first in list
     102  molecule::const_iterator iter = begin();  // start at first in list
    104103
    105104  Center.Zero();
    106105
    107   if (ptr->next != end) {   //list not empty?
    108     while (ptr->next != end) {  // continue with second if present
    109       ptr = ptr->next;
     106  if (iter != end()) {   //list not empty?
     107    for (; iter != end(); ++iter) {  // continue with second if present
    110108      Num++;
    111       Center.AddVector(&ptr->x);
     109      Center.AddVector(&(*iter)->x);
    112110    }
    113111    Center.Scale(-1./Num); // divide through total number (and sign for direction)
     
    122120Vector * molecule::DetermineCenterOfAll() const
    123121{
    124   atom *ptr = start->next;  // start at first in list
     122  molecule::const_iterator iter = begin();  // start at first in list
    125123  Vector *a = new Vector();
    126124  Vector tmp;
     
    129127  a->Zero();
    130128
    131   if (ptr != end) {   //list not empty?
    132     while (ptr->next != end) {  // continue with second if present
    133       ptr = ptr->next;
     129  if (iter != end()) {   //list not empty?
     130    for (; iter != end(); ++iter) {  // continue with second if present
    134131      Num += 1.;
    135       tmp.CopyVector(&ptr->x);
     132      tmp.CopyVector(&(*iter)->x);
    136133      a->AddVector(&tmp);
    137134    }
     
    147144Vector * molecule::DetermineCenterOfGravity()
    148145{
    149   atom *ptr = start->next;  // start at first in list
     146  molecule::const_iterator iter = begin();  // start at first in list
    150147  Vector *a = new Vector();
    151148  Vector tmp;
     
    154151  a->Zero();
    155152
    156   if (ptr != end) {   //list not empty?
    157     while (ptr->next != end) {  // continue with second if present
    158       ptr = ptr->next;
    159       Num += ptr->type->mass;
    160       tmp.CopyVector(&ptr->x);
    161       tmp.Scale(ptr->type->mass);  // scale by mass
     153  if (iter != end()) {   //list not empty?
     154    for (; iter != end(); ++iter) {  // continue with second if present
     155      Num += (*iter)->type->mass;
     156      tmp.CopyVector(&(*iter)->x);
     157      tmp.Scale((*iter)->type->mass);  // scale by mass
    162158      a->AddVector(&tmp);
    163159    }
     
    195191void molecule::Scale(const double ** const factor)
    196192{
    197   atom *ptr = start;
    198 
    199   while (ptr->next != end) {
    200     ptr = ptr->next;
     193  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    201194    for (int j=0;j<MDSteps;j++)
    202       ptr->Trajectory.R.at(j).Scale(factor);
    203     ptr->x.Scale(factor);
     195      (*iter)->Trajectory.R.at(j).Scale(factor);
     196    (*iter)->x.Scale(factor);
    204197  }
    205198};
     
    210203void molecule::Translate(const Vector *trans)
    211204{
    212   atom *ptr = start;
    213 
    214   while (ptr->next != end) {
    215     ptr = ptr->next;
     205  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    216206    for (int j=0;j<MDSteps;j++)
    217       ptr->Trajectory.R.at(j).Translate(trans);
    218     ptr->x.Translate(trans);
     207      (*iter)->Trajectory.R.at(j).Translate(trans);
     208    (*iter)->x.Translate(trans);
    219209  }
    220210};
     
    251241void molecule::DeterminePeriodicCenter(Vector &center)
    252242{
    253   atom *Walker = start;
    254243  double *matrix = ReturnFullMatrixforSymmetric(cell_size);
    255244  double *inversematrix = InverseMatrix(cell_size);
     
    261250    Center.Zero();
    262251    flag = true;
    263     while (Walker->next != end) {
    264       Walker = Walker->next;
     252    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    265253#ifdef ADDHYDROGEN
    266       if (Walker->type->Z != 1) {
     254      if ((*iter)->type->Z != 1) {
    267255#endif
    268         Testvector.CopyVector(&Walker->x);
     256        Testvector.CopyVector(&(*iter)->x);
    269257        Testvector.MatrixMultiplication(inversematrix);
    270258        Translationvector.Zero();
    271         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    272          if (Walker->nr < (*Runner)->GetOtherAtom(Walker)->nr) // otherwise we shift one to, the other fro and gain nothing
     259        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     260         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    273261            for (int j=0;j<NDIM;j++) {
    274               tmp = Walker->x.x[j] - (*Runner)->GetOtherAtom(Walker)->x.x[j];
     262              tmp = (*iter)->x.x[j] - (*Runner)->GetOtherAtom((*iter))->x.x[j];
    275263              if ((fabs(tmp)) > BondDistance) {
    276264                flag = false;
    277                 Log() << Verbose(0) << "Hit: atom " << Walker->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;
     265                Log() << Verbose(0) << "Hit: atom " << (*iter)->Name << " in bond " << *(*Runner) << " has to be shifted due to " << tmp << "." << endl;
    278266                if (tmp > 0)
    279267                  Translationvector.x[j] -= 1.;
     
    291279#ifdef ADDHYDROGEN
    292280        // now also change all hydrogens
    293         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    294           if ((*Runner)->GetOtherAtom(Walker)->type->Z == 1) {
    295             Testvector.CopyVector(&(*Runner)->GetOtherAtom(Walker)->x);
     281        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     282          if ((*Runner)->GetOtherAtom((*iter))->type->Z == 1) {
     283            Testvector.CopyVector(&(*Runner)->GetOtherAtom((*iter))->x);
    296284            Testvector.MatrixMultiplication(inversematrix);
    297285            Testvector.AddVector(&Translationvector);
     
    320308void molecule::PrincipalAxisSystem(bool DoRotate)
    321309{
    322   atom *ptr = start;  // start at first in list
    323310  double InertiaTensor[NDIM*NDIM];
    324311  Vector *CenterOfGravity = DetermineCenterOfGravity();
     
    331318
    332319  // sum up inertia tensor
    333   while (ptr->next != end) {
    334     ptr = ptr->next;
     320  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    335321    Vector x;
    336     x.CopyVector(&ptr->x);
     322    x.CopyVector(&(*iter)->x);
    337323    //x.SubtractVector(CenterOfGravity);
    338     InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
    339     InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
    340     InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
    341     InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
    342     InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
    343     InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
    344     InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
    345     InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
    346     InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
     324    InertiaTensor[0] += (*iter)->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
     325    InertiaTensor[1] += (*iter)->type->mass*(-x.x[0]*x.x[1]);
     326    InertiaTensor[2] += (*iter)->type->mass*(-x.x[0]*x.x[2]);
     327    InertiaTensor[3] += (*iter)->type->mass*(-x.x[1]*x.x[0]);
     328    InertiaTensor[4] += (*iter)->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
     329    InertiaTensor[5] += (*iter)->type->mass*(-x.x[1]*x.x[2]);
     330    InertiaTensor[6] += (*iter)->type->mass*(-x.x[2]*x.x[0]);
     331    InertiaTensor[7] += (*iter)->type->mass*(-x.x[2]*x.x[1]);
     332    InertiaTensor[8] += (*iter)->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
    347333  }
    348334  // print InertiaTensor for debugging
     
    382368
    383369    // sum up inertia tensor
    384     ptr = start;
    385     while (ptr->next != end) {
    386       ptr = ptr->next;
     370    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    387371      Vector x;
    388       x.CopyVector(&ptr->x);
     372      x.CopyVector(&(*iter)->x);
    389373      //x.SubtractVector(CenterOfGravity);
    390       InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
    391       InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
    392       InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
    393       InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
    394       InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
    395       InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
    396       InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
    397       InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
    398       InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
     374      InertiaTensor[0] += (*iter)->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
     375      InertiaTensor[1] += (*iter)->type->mass*(-x.x[0]*x.x[1]);
     376      InertiaTensor[2] += (*iter)->type->mass*(-x.x[0]*x.x[2]);
     377      InertiaTensor[3] += (*iter)->type->mass*(-x.x[1]*x.x[0]);
     378      InertiaTensor[4] += (*iter)->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
     379      InertiaTensor[5] += (*iter)->type->mass*(-x.x[1]*x.x[2]);
     380      InertiaTensor[6] += (*iter)->type->mass*(-x.x[2]*x.x[0]);
     381      InertiaTensor[7] += (*iter)->type->mass*(-x.x[2]*x.x[1]);
     382      InertiaTensor[8] += (*iter)->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
    399383    }
    400384    // print InertiaTensor for debugging
     
    420404void molecule::Align(Vector *n)
    421405{
    422   atom *ptr = start;
    423406  double alpha, tmp;
    424407  Vector z_axis;
     
    431414  alpha = atan(-n->x[0]/n->x[2]);
    432415  Log() << Verbose(1) << "Z-X-angle: " << alpha << " ... ";
    433   while (ptr->next != end) {
    434     ptr = ptr->next;
    435     tmp = ptr->x.x[0];
    436     ptr->x.x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->x.x[2];
    437     ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2];
     416  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     417    tmp = (*iter)->x.x[0];
     418    (*iter)->x.x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x.x[2];
     419    (*iter)->x.x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x.x[2];
    438420    for (int j=0;j<MDSteps;j++) {
    439       tmp = ptr->Trajectory.R.at(j).x[0];
    440       ptr->Trajectory.R.at(j).x[0] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];
    441       ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];
     421      tmp = (*iter)->Trajectory.R.at(j).x[0];
     422      (*iter)->Trajectory.R.at(j).x[0] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j).x[2];
     423      (*iter)->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j).x[2];
    442424    }
    443425  }
     
    451433
    452434  // rotate on z-y plane
    453   ptr = start;
    454435  alpha = atan(-n->x[1]/n->x[2]);
    455436  Log() << Verbose(1) << "Z-Y-angle: " << alpha << " ... ";
    456   while (ptr->next != end) {
    457     ptr = ptr->next;
    458     tmp = ptr->x.x[1];
    459     ptr->x.x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->x.x[2];
    460     ptr->x.x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->x.x[2];
     437  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     438    tmp = (*iter)->x.x[1];
     439    (*iter)->x.x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->x.x[2];
     440    (*iter)->x.x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->x.x[2];
    461441    for (int j=0;j<MDSteps;j++) {
    462       tmp = ptr->Trajectory.R.at(j).x[1];
    463       ptr->Trajectory.R.at(j).x[1] =  cos(alpha) * tmp + sin(alpha) * ptr->Trajectory.R.at(j).x[2];
    464       ptr->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * ptr->Trajectory.R.at(j).x[2];
     442      tmp = (*iter)->Trajectory.R.at(j).x[1];
     443      (*iter)->Trajectory.R.at(j).x[1] =  cos(alpha) * tmp + sin(alpha) * (*iter)->Trajectory.R.at(j).x[2];
     444      (*iter)->Trajectory.R.at(j).x[2] = -sin(alpha) * tmp + cos(alpha) * (*iter)->Trajectory.R.at(j).x[2];
    465445    }
    466446  }
     
    487467  Vector a,b,c,d;
    488468  struct lsq_params *par = (struct lsq_params *)params;
    489   atom *ptr = par->mol->start;
    490469
    491470  // initialize vectors
     
    497476  b.x[2] = gsl_vector_get(x,5);
    498477  // go through all atoms
    499   while (ptr != par->mol->end) {
    500     ptr = ptr->next;
    501     if (ptr->type == ((struct lsq_params *)params)->type) { // for specific type
    502       c.CopyVector(&ptr->x);  // copy vector to temporary one
     478  for (molecule::const_iterator iter = par->mol->begin(); iter != par->mol->end(); ++iter) {
     479    if ((*iter)->type == ((struct lsq_params *)params)->type) { // for specific type
     480      c.CopyVector(&(*iter)->x);  // copy vector to temporary one
    503481      c.SubtractVector(&a);   // subtract offset vector
    504482      t = c.ScalarProduct(&b);           // get direction parameter
  • src/molecule_graph.cpp

    re87acf r9879f6  
    135135    Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl;
    136136    AtomMap = Calloc<atom *> (AtomCount, "molecule::CreateAdjacencyList - **AtomCount");
    137     Walker = start;
    138     while (Walker->next != end) {
    139       Walker = Walker->next;
    140       AtomMap[Walker->nr] = Walker;
     137    for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     138      AtomMap[(*iter)->nr] = (*iter);
    141139    }
    142140
     
    496494  DepthFirstSearchAnalysis_Init(DFS, this);
    497495
    498   DFS.Root = start->next;
    499   while (DFS.Root != end) { // if there any atoms at all
     496  for (molecule::const_iterator iter = begin(); iter != end();) {
     497    DFS.Root = *iter;
    500498    // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all
    501499    DFS.AtomStack->ClearStack();
     
    537535
    538536    // step on to next root
    539     while ((DFS.Root != end) && (DFS.Root->GraphNr != -1)) {
    540       //Log() << Verbose(1) << "Current next subgraph root candidate is " << Root->Name << "." << endl;
    541       if (DFS.Root->GraphNr != -1) // if already discovered, step on
    542         DFS.Root = DFS.Root->next;
     537    while ((iter != end()) && ((*iter)->GraphNr != -1)) {
     538      //Log() << Verbose(1) << "Current next subgraph root candidate is " << (*iter)->Name << "." << endl;
     539      if ((*iter)->GraphNr != -1) // if already discovered, step on
     540        iter++;
    543541    }
    544542  }
     
    843841  if (MinRingSize != -1) { // if rings are present
    844842    // go over all atoms
    845     Root = mol->start;
    846     while (Root->next != mol->end) {
    847       Root = Root->next;
     843    for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     844      Root = *iter;
    848845
    849846      if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is
     
    13521349  // fill parent list with sons
    13531350  Log() << Verbose(3) << "Filling Parent List." << endl;
    1354   atom *Walker = mol->start;
    1355   while (Walker->next != mol->end) {
    1356     Walker = Walker->next;
    1357     ParentList[Walker->father->nr] = Walker;
     1351  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1352    ParentList[(*iter)->father->nr] = (*iter);
    13581353    // Outputting List for debugging
    1359     Log() << Verbose(4) << "Son[" << Walker->father->nr << "] of " << Walker->father << " is " << ParentList[Walker->father->nr] << "." << endl;
     1354    Log() << Verbose(4) << "Son[" << (*iter)->father->nr << "] of " << (*iter)->father << " is " << ParentList[(*iter)->father->nr] << "." << endl;
    13601355  }
    13611356
     
    13721367{
    13731368  bool status = true;
    1374   atom *Walker = NULL;
    13751369  atom *OtherAtom = NULL;
    13761370  // check each entry of parent list and if ok (one-to-and-onto matching) create bonds
    13771371  Log() << Verbose(3) << "Creating bonds." << endl;
    1378   Walker = Father->start;
    1379   while (Walker->next != Father->end) {
    1380     Walker = Walker->next;
    1381     if (ParentList[Walker->nr] != NULL) {
    1382       if (ParentList[Walker->nr]->father != Walker) {
     1372  for (molecule::const_iterator iter = Father->begin(); iter != Father->end(); ++iter) {
     1373    if (ParentList[(*iter)->nr] != NULL) {
     1374      if (ParentList[(*iter)->nr]->father != (*iter)) {
    13831375        status = false;
    13841376      } else {
    1385         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
    1386           OtherAtom = (*Runner)->GetOtherAtom(Walker);
     1377        for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1378          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    13871379          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
    1388             Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[Walker->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;
    1389             mol->AddBond(ParentList[Walker->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
     1380            Log() << Verbose(4) << "Endpoints of Bond " << (*Runner) << " are both present: " << ParentList[(*iter)->nr]->Name << " and " << ParentList[OtherAtom->nr]->Name << "." << endl;
     1381            mol->AddBond(ParentList[(*iter)->nr], ParentList[OtherAtom->nr], (*Runner)->BondDegree);
    13901382          }
    13911383        }
  • src/molecule_pointcloud.cpp

    re87acf r9879f6  
    88#include "atom.hpp"
    99#include "config.hpp"
     10#include "info.hpp"
    1011#include "memoryallocator.hpp"
    1112#include "molecule.hpp"
     
    3132};
    3233
    33 /** Return current atom in the list.
    34  * \return pointer to atom or NULL if none present
     34
     35/** PointCloud implementation of GoPoint
     36 * Uses atoms and STL stuff.
    3537 */
    36 TesselPoint *molecule::GetPoint() const
     38TesselPoint* molecule::GetPoint() const
    3739{
    38   if ((InternalPointer != start) && (InternalPointer != end))
    39     return InternalPointer;
    40   else
    41     return NULL;
     40  Info FunctionInfo(__func__);
     41  return (*InternalPointer);
    4242};
    4343
    44 /** Return pointer to one after last atom in the list.
    45  * \return pointer to end marker
    46  */
    47 TesselPoint *molecule::GetTerminalPoint() const
    48 {
    49   return end;
    50 };
    51 
    52 /** Return the greatest index of all atoms in the list.
    53  * \return greatest index
    54  */
    55 int molecule::GetMaxId() const
    56 {
    57   return last_atom;
    58 };
    59 
    60 /** Go to next atom.
    61  * Stops at last one.
     44/** PointCloud implementation of GoToNext.
     45 * Uses atoms and STL stuff.
    6246 */
    6347void molecule::GoToNext() const
    6448{
    65   if (InternalPointer != end)
    66     InternalPointer = InternalPointer->next;
     49  Info FunctionInfo(__func__);
     50  if (InternalPointer != end())
     51    InternalPointer++;
    6752};
    6853
    69 /** Go to previous atom.
    70  * Stops at first one.
    71  */
    72 void molecule::GoToPrevious() const
    73 {
    74   if (InternalPointer->previous != start)
    75     InternalPointer = InternalPointer->previous;
    76 };
    77 
    78 /** Goes to first atom.
     54/** PointCloud implementation of GoToFirst.
     55 * Uses atoms and STL stuff.
    7956 */
    8057void molecule::GoToFirst() const
    8158{
    82   InternalPointer = start->next;
     59  Info FunctionInfo(__func__);
     60  InternalPointer = begin();
    8361};
    8462
    85 /** Goes to last atom.
    86  */
    87 void molecule::GoToLast() const
    88 {
    89   InternalPointer = end->previous;
    90 };
    91 
    92 /** Checks whether we have any atoms in molecule.
    93  * \return true - no atoms, false - not empty
     63/** PointCloud implementation of IsEmpty.
     64 * Uses atoms and STL stuff.
    9465 */
    9566bool molecule::IsEmpty() const
    9667{
    97   return (start->next == end);
     68  Info FunctionInfo(__func__);
     69  return (empty());
    9870};
    9971
    100 /** Checks whether we are at the last atom
    101  * \return true - current atom is last one, false - is not last one
     72/** PointCloud implementation of IsLast.
     73 * Uses atoms and STL stuff.
    10274 */
    10375bool molecule::IsEnd() const
    10476{
    105   return (InternalPointer == end);
     77  Info FunctionInfo(__func__);
     78  return (InternalPointer == end());
    10679};
  • src/molecule_template.hpp

    re87acf r9879f6  
    2424template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const
    2525    {
    26   atom *Walker = start;
    27   while (Walker->next != end) {
    28     Walker = Walker->next;
    29     ((Walker->node)->*f)();
     26  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     27    (((*iter)->node)->*f)();
    3028  }
    3129};
    3230template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const
    3331    {
    34   atom *Walker = start;
    35   while (Walker->next != end) {
    36     Walker = Walker->next;
    37     ((Walker->node)->*f)();
     32  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     33    (((*iter)->node)->*f)();
    3834  }
    3935};
     
    4137template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const
    4238{
    43   atom *Walker = start;
    44   while (Walker->next != end) {
    45     Walker = Walker->next;
    46     ((Walker->node)->*f)(t);
     39  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     40    (((*iter)->node)->*f)(t);
    4741  }
    4842};
    4943template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const
    5044{
    51   atom *Walker = start;
    52   while (Walker->next != end) {
    53     Walker = Walker->next;
    54     ((Walker->node)->*f)(t);
     45  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     46    (((*iter)->node)->*f)(t);
    5547  }
    5648};
     
    5850template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const
    5951{
    60   atom *Walker = start;
    61   while (Walker->next != end) {
    62     Walker = Walker->next;
    63     ((Walker->node)->*f)(t, u);
     52  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     53    (((*iter)->node)->*f)(t, u);
    6454  }
    6555};
    6656template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const
    6757{
    68   atom *Walker = start;
    69   while (Walker->next != end) {
    70     Walker = Walker->next;
    71     ((Walker->node)->*f)(t, u);
     58  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     59    (((*iter)->node)->*f)(t, u);
    7260  }
    7361};
     
    7563template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const
    7664{
    77   atom *Walker = start;
    78   while (Walker->next != end) {
    79     Walker = Walker->next;
    80     ((Walker->node)->*f)(t, u, v);
     65  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     66    (((*iter)->node)->*f)(t, u, v);
    8167  }
    8268};
    8369template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V) const, T t, U u, V v) const
    8470{
    85   atom *Walker = start;
    86   while (Walker->next != end) {
    87     Walker = Walker->next;
    88     ((Walker->node)->*f)(t, u, v);
     71  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     72    (((*iter)->node)->*f)(t, u, v);
    8973  }
    9074};
     
    9680{
    9781  res result = 0;
    98   atom *Walker = start;
    99   while (Walker->next != end) {
    100     Walker = Walker->next;
    101     result += (Walker->*f)();
     82  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     83    result += ((*iter)->*f)();
    10284  }
    10385  return result;
     
    10688{
    10789  res result = 0;
    108   atom *Walker = start;
    109   while (Walker->next != end) {
    110     Walker = Walker->next;
    111     result += (Walker->*f)();
     90  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     91    result += ((*iter)->*f)();
    11292  }
    11393  return result;
     
    11797{
    11898  res result = 0;
    119   atom *Walker = start;
    120   while (Walker->next != end) {
    121     Walker = Walker->next;
    122     result += (Walker->*f)(t);
     99  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     100    result += ((*iter)->*f)(t);
    123101  }
    124102  return result;
     
    127105{
    128106  res result = 0;
    129   atom *Walker = start;
    130   while (Walker->next != end) {
    131     Walker = Walker->next;
    132     result += (Walker->*f)(t);
     107  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     108    result += ((*iter)->*f)(t);
    133109  }
    134110  return result;
     
    141117template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const
    142118{
    143   atom *Walker = start;
    144   while (Walker->next != end) {
    145     Walker = Walker->next;
    146     (*f)(Walker);
     119  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     120    (*f)((*iter));
    147121  }
    148122};
    149123template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const
    150124{
    151   atom *Walker = start;
    152   while (Walker->next != end) {
    153     Walker = Walker->next;
    154     (*f)(Walker);
     125  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     126    (*f)((*iter));
    155127  }
    156128};
     
    161133template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const
    162134{
    163   atom *Walker = start;
    164   while (Walker->next != end) {
    165     Walker = Walker->next;
    166     (copy->*f)(Walker);
     135  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     136    (copy->*f)((*iter));
    167137  }
    168138};
    169139template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const
    170140{
    171   atom *Walker = start;
    172   while (Walker->next != end) {
    173     Walker = Walker->next;
    174     (copy->*f)(Walker);
     141  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     142    (copy->*f)((*iter));
    175143  }
    176144};
     
    181149template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const
    182150{
    183   atom *Walker = start;
    184   while (Walker->next != end) {
    185     Walker = Walker->next;
    186     if ((Walker->*condition)())
    187       (copy->*f)(Walker);
     151  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     152    if (((*iter)->*condition)())
     153      (copy->*f)((*iter));
    188154  }
    189155};
    190156template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const
    191157{
    192   atom *Walker = start;
    193   while (Walker->next != end) {
    194     Walker = Walker->next;
    195     if ((Walker->*condition)())
    196       (copy->*f)(Walker);
     158  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     159    if (((*iter)->*condition)())
     160      (copy->*f)((*iter));
    197161  }
    198162};
    199163template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const
    200164{
    201   atom *Walker = start;
    202   while (Walker->next != end) {
    203     Walker = Walker->next;
    204     if ((Walker->*condition)())
    205       (copy->*f)(Walker);
     165  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     166    if (((*iter)->*condition)())
     167      (copy->*f)((*iter));
    206168  }
    207169};
    208170template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const
    209171{
    210   atom *Walker = start;
    211   while (Walker->next != end) {
    212     Walker = Walker->next;
    213     if ((Walker->*condition)())
    214       (copy->*f)(Walker);
     172  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     173    if (((*iter)->*condition)())
     174      (copy->*f)((*iter));
    215175  }
    216176};
     
    218178template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const
    219179{
    220   atom *Walker = start;
    221   while (Walker->next != end) {
    222     Walker = Walker->next;
    223     if ((Walker->*condition)(t))
    224       (copy->*f)(Walker);
     180  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     181    if (((*iter)->*condition)(t))
     182      (copy->*f)((*iter));
    225183  }
    226184};
    227185template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const
    228186{
    229   atom *Walker = start;
    230   while (Walker->next != end) {
    231     Walker = Walker->next;
    232     if ((Walker->*condition)(t))
    233       (copy->*f)(Walker);
     187  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     188    if (((*iter)->*condition)(t))
     189      (copy->*f)((*iter));
    234190  }
    235191};
    236192template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const
    237193{
    238   atom *Walker = start;
    239   while (Walker->next != end) {
    240     Walker = Walker->next;
    241     if ((Walker->*condition)(t))
    242       (copy->*f)(Walker);
     194  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     195    if (((*iter)->*condition)(t))
     196      (copy->*f)((*iter));
    243197  }
    244198};
    245199template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const
    246200{
    247   atom *Walker = start;
    248   while (Walker->next != end) {
    249     Walker = Walker->next;
    250     if ((Walker->*condition)(t))
    251       (copy->*f)(Walker);
     201  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     202    if (((*iter)->*condition)(t))
     203      (copy->*f)((*iter));
    252204  }
    253205};
     
    255207template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    256208{
    257   atom *Walker = start;
    258   while (Walker->next != end) {
    259     Walker = Walker->next;
    260     if ((Walker->*condition)(t,u))
    261       (copy->*f)(Walker);
     209  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     210    if (((*iter)->*condition)(t,u))
     211      (copy->*f)((*iter));
    262212  }
    263213};
    264214template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    265215{
    266   atom *Walker = start;
    267   while (Walker->next != end) {
    268     Walker = Walker->next;
    269     if ((Walker->*condition)(t,u))
    270       (copy->*f)(Walker);
     216  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     217    if (((*iter)->*condition)(t,u))
     218      (copy->*f)((*iter));
    271219  }
    272220};
    273221template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U), T t, U u ) const
    274222{
    275   atom *Walker = start;
    276   while (Walker->next != end) {
    277     Walker = Walker->next;
    278     if ((Walker->*condition)(t,u))
    279       (copy->*f)(Walker);
     223  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     224    if (((*iter)->*condition)(t,u))
     225      (copy->*f)((*iter));
    280226  }
    281227};
    282228template <typename res, typename T, typename U> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U) const, T t, U u ) const
    283229{
    284   atom *Walker = start;
    285   while (Walker->next != end) {
    286     Walker = Walker->next;
    287     if ((Walker->*condition)(t,u))
    288       (copy->*f)(Walker);
     230  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     231    if (((*iter)->*condition)(t,u))
     232      (copy->*f)((*iter));
    289233  }
    290234};
     
    292236template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    293237{
    294   atom *Walker = start;
    295   while (Walker->next != end) {
    296     Walker = Walker->next;
    297     if ((Walker->*condition)(t,u,v))
    298       (copy->*f)(Walker);
     238  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     239    if (((*iter)->*condition)(t,u,v))
     240      (copy->*f)((*iter));
    299241  }
    300242};
    301243template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    302244{
    303   atom *Walker = start;
    304   while (Walker->next != end) {
    305     Walker = Walker->next;
    306     if ((Walker->*condition)(t,u,v))
    307       (copy->*f)(Walker);
     245  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     246    if (((*iter)->*condition)(t,u,v))
     247      (copy->*f)((*iter));
    308248  }
    309249};
    310250template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V), T t, U u, V v ) const
    311251{
    312   atom *Walker = start;
    313   while (Walker->next != end) {
    314     Walker = Walker->next;
    315     if ((Walker->*condition)(t,u,v))
    316       (copy->*f)(Walker);
     252  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     253    if (((*iter)->*condition)(t,u,v))
     254      (copy->*f)((*iter));
    317255  }
    318256};
    319257template <typename res, typename T, typename U, typename V> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T, U, V) const, T t, U u, V v ) const
    320258{
    321   atom *Walker = start;
    322   while (Walker->next != end) {
    323     Walker = Walker->next;
    324     if ((Walker->*condition)(t,u,v))
    325       (copy->*f)(Walker);
     259  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     260    if (((*iter)->*condition)(t,u,v))
     261      (copy->*f)((*iter));
    326262  }
    327263};
     
    332268template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const
    333269{
    334   atom *Walker = start;
    335   while (Walker->next != end) {
    336     Walker = Walker->next;
    337     (Walker->*f)();
     270  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     271    ((*iter)->*f)();
    338272  }
    339273};
    340274template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const
    341275{
    342   atom *Walker = start;
    343   while (Walker->next != end) {
    344     Walker = Walker->next;
    345     (Walker->*f)();
     276  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     277    ((*iter)->*f)();
    346278  }
    347279};
     
    349281template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const
    350282{
    351   atom *Walker = start;
    352   while (Walker->next != end) {
    353     Walker = Walker->next;
    354     (Walker->*f)(t);
     283  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     284    ((*iter)->*f)(t);
    355285  }
    356286};
    357287template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const
    358288{
    359   atom *Walker = start;
    360   while (Walker->next != end) {
    361     Walker = Walker->next;
    362     (Walker->*f)(t);
     289  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     290    ((*iter)->*f)(t);
    363291  }
    364292};
     
    366294template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const
    367295{
    368   atom *Walker = start;
    369   while (Walker->next != end) {
    370     Walker = Walker->next;
    371     (Walker->*f)(t, u);
     296  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     297    ((*iter)->*f)(t, u);
    372298  }
    373299};
    374300template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const
    375301{
    376   atom *Walker = start;
    377   while (Walker->next != end) {
    378     Walker = Walker->next;
    379     (Walker->*f)(t, u);
     302  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     303    ((*iter)->*f)(t, u);
    380304  }
    381305};
     
    383307template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V), T t, U u, V v) const
    384308{
    385   atom *Walker = start;
    386   while (Walker->next != end) {
    387     Walker = Walker->next;
    388     (Walker->*f)(t, u, v);
     309  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     310    ((*iter)->*f)(t, u, v);
    389311  }
    390312};
    391313template <typename res, typename typ, typename T, typename U, typename V> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V) const, T t, U u, V v) const
    392314{
    393   atom *Walker = start;
    394   while (Walker->next != end) {
    395     Walker = Walker->next;
    396     (Walker->*f)(t, u, v);
     315  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     316    ((*iter)->*f)(t, u, v);
    397317  }
    398318};
     
    400320template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W), T t, U u, V v, W w) const
    401321{
    402   atom *Walker = start;
    403   while (Walker->next != end) {
    404     Walker = Walker->next;
    405     (Walker->*f)(t, u, v, w);
     322  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     323    ((*iter)->*f)(t, u, v, w);
    406324  }
    407325};
    408326template <typename res, typename typ, typename T, typename U, typename V, typename W> void molecule::ActOnAllAtoms( res (typ::*f)(T, U, V, W) const, T t, U u, V v, W w) const
    409327{
    410   atom *Walker = start;
    411   while (Walker->next != end) {
    412     Walker = Walker->next;
    413     (Walker->*f)(t, u, v, w);
     328  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     329    ((*iter)->*f)(t, u, v, w);
    414330  }
    415331};
     
    420336template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const
    421337{
    422   atom *Walker = start;
    423338  int inc = 1;
    424   while (Walker->next != end) {
    425     Walker = Walker->next;
    426     (*Setor) (&array[(Walker->*index)], &inc);
     339  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     340    (*Setor) (&array[((*iter)->*index)], &inc);
    427341  }
    428342};
    429343template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const
    430344{
    431   atom *Walker = start;
    432   while (Walker->next != end) {
    433     Walker = Walker->next;
    434     (*Setor) (&array[(Walker->*index)], &value);
     345  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     346    (*Setor) (&array[((*iter)->*index)], &value);
    435347  }
    436348};
    437349template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const
    438350{
    439   atom *Walker = start;
    440   while (Walker->next != end) {
    441     Walker = Walker->next;
    442     (*Setor) (&array[(Walker->*index)], value);
     351  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     352    (*Setor) (&array[((*iter)->*index)], value);
    443353  }
    444354};
     
    446356template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const
    447357{
    448   atom *Walker = start;
    449358  int inc = 1;
    450   while (Walker->next != end) {
    451     Walker = Walker->next;
    452     (*Setor) (&array[(Walker->type->*index)], &inc);
     359  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     360    (*Setor) (&array[((*iter)->type->*index)], &inc);
    453361  }
    454362};
    455363template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const
    456364{
    457   atom *Walker = start;
    458   while (Walker->next != end) {
    459     Walker = Walker->next;
    460     (*Setor) (&array[(Walker->type->*index)], &value);
     365  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     366    (*Setor) (&array[((*iter)->type->*index)], &value);
    461367  }
    462368};
    463369template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const
    464370{
    465   atom *Walker = start;
    466   while (Walker->next != end) {
    467     Walker = Walker->next;
    468     (*Setor) (&array[(Walker->type->*index)], value);
     371  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     372    (*Setor) (&array[((*iter)->type->*index)], value);
    469373  }
    470374};
     
    472376template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const
    473377{
    474   atom *Walker = start;
    475   while (Walker->next != end) {
    476     Walker = Walker->next;
    477     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     378  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     379    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    478380  }
    479381};
    480382template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const
    481383{
    482   atom *Walker = start;
    483   while (Walker->next != end) {
    484     Walker = Walker->next;
    485     array[(Walker->*index)] = (Walker->*Setor) (Walker->*value);
     384  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     385    array[((*iter)->*index)] = ((*iter)->*Setor) ((*iter)->*value);
    486386  }
    487387};
    488388template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const
    489389{
    490   atom *Walker = start;
    491   while (Walker->next != end) {
    492     Walker = Walker->next;
    493     array[(Walker->*index)] = (Walker->*Setor) (vect);
     390  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     391    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    494392  }
    495393};
    496394template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const
    497395{
    498   atom *Walker = start;
    499   while (Walker->next != end) {
    500     Walker = Walker->next;
    501     array[(Walker->*index)] = (Walker->*Setor) (vect);
     396  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     397    array[((*iter)->*index)] = ((*iter)->*Setor) (vect);
    502398  }
    503399};
    504400template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const
    505401{
    506   atom *Walker = start;
    507   while (Walker->next != end) {
    508     Walker = Walker->next;
    509     Walker->*value = array[(Walker->*index)];
    510     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*value); << endl;
     402  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     403    (*iter)->*value = array[((*iter)->*index)];
     404    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*value); << endl;
    511405  }
    512406};
     
    514408template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const
    515409{
    516   atom *Walker = start;
    517   while (Walker->next != end) {
    518     Walker = Walker->next;
    519     Walker->*ptr = value;
    520     //Log() << Verbose(2) << *Walker << " gets " << (Walker->*ptr) << endl;
     410  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
     411    (*iter)->*ptr = value;
     412    //Log() << Verbose(2) << *(*iter) << " gets " << ((*iter)->*ptr) << endl;
    521413  }
    522414};
  • src/moleculelist.cpp

    re87acf r9879f6  
    6868  int Count, Counter, aCounter, bCounter;
    6969  int flag;
    70   atom *aWalker = NULL;
    71   atom *bWalker = NULL;
    7270
    7371  // sort each atom list and put the numbers into a list, then go through
     
    8482
    8583      // fill the lists
    86       aWalker = (**(molecule **) a).start;
    87       bWalker = (**(molecule **) b).start;
    8884      Counter = 0;
    8985      aCounter = 0;
    9086      bCounter = 0;
    91       while ((aWalker->next != (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
    92         aWalker = aWalker->next;
    93         bWalker = bWalker->next;
    94         if (aWalker->GetTrueFather() == NULL)
     87      molecule::const_iterator aiter = (**(molecule **) a).begin();
     88      molecule::const_iterator biter = (**(molecule **) b).begin();
     89      for (;(aiter != (**(molecule **) a).end()) && (biter != (**(molecule **) b).end());
     90          ++aiter, ++biter) {
     91        if ((*aiter)->GetTrueFather() == NULL)
    9592          aList[Counter] = Count + (aCounter++);
    9693        else
    97           aList[Counter] = aWalker->GetTrueFather()->nr;
    98         if (bWalker->GetTrueFather() == NULL)
     94          aList[Counter] = (*aiter)->GetTrueFather()->nr;
     95        if ((*biter)->GetTrueFather() == NULL)
    9996          bList[Counter] = Count + (bCounter++);
    10097        else
    101           bList[Counter] = bWalker->GetTrueFather()->nr;
     98          bList[Counter] = (*biter)->GetTrueFather()->nr;
    10299        Counter++;
    103100      }
    104101      // check if AtomCount was for real
    105102      flag = 0;
    106       if ((aWalker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {
     103      if ((aiter == (**(molecule **) a).end()) && (biter != (**(molecule **) b).end())) {
    107104        flag = -1;
    108105      } else {
    109         if ((aWalker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))
     106        if ((aiter != (**(molecule **) a).end()) && (biter == (**(molecule **) b).end()))
    110107          flag = 1;
    111108      }
     
    142139{
    143140  element* Elemental = NULL;
    144   atom *Walker = NULL;
    145141  int Counts[MAX_ELEMENTS];
    146142  double size=0;
     
    160156      // count atoms per element and determine size of bounding sphere
    161157      size=0.;
    162       Walker = (*ListRunner)->start;
    163       while (Walker->next != (*ListRunner)->end) {
    164         Walker = Walker->next;
    165         Counts[Walker->type->Z]++;
    166         if (Walker->x.DistanceSquared(&Origin) > size)
    167           size = Walker->x.DistanceSquared(&Origin);
     158      for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     159        Counts[(*iter)->type->Z]++;
     160        if ((*iter)->x.DistanceSquared(&Origin) > size)
     161          size = (*iter)->x.DistanceSquared(&Origin);
    168162      }
    169163      // output Index, Name, number of atoms, chemical formula
     
    204198
    205199  // put all molecules of src into mol
    206   atom *Walker = srcmol->start;
    207   atom *NextAtom = Walker->next;
    208   while (NextAtom != srcmol->end) {
    209     Walker = NextAtom;
    210     NextAtom = Walker->next;
    211     srcmol->UnlinkAtom(Walker);
    212     mol->AddAtom(Walker);
     200  molecule::iterator runner;
     201  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     202    runner = iter++;
     203    srcmol->UnlinkAtom((*runner));
     204    mol->AddAtom((*runner));
    213205  }
    214206
     
    230222
    231223  // put all molecules of src into mol
    232   atom *Walker = srcmol->start;
    233   atom *NextAtom = Walker->next;
    234   while (NextAtom != srcmol->end) {
    235     Walker = NextAtom;
    236     NextAtom = Walker->next;
    237     Walker = mol->AddCopyAtom(Walker);
     224  atom *Walker = NULL;
     225  for (molecule::iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     226    Walker = mol->AddCopyAtom((*iter));
    238227    Walker->father = Walker;
    239228  }
     
    338327
    339328  // for each of the source atoms check whether we are in- or outside and add copy atom
    340   atom *Walker = srcmol->start;
    341329  int nr=0;
    342   while (Walker->next != srcmol->end) {
    343     Walker = Walker->next;
    344     Log() << Verbose(2) << "INFO: Current Walker is " << *Walker << "." << endl;
    345     if (!TesselStruct->IsInnerPoint(Walker->x, LCList)) {
    346       CopyAtoms[Walker->nr] = Walker->clone();
    347       mol->AddAtom(CopyAtoms[Walker->nr]);
     330  for (molecule::const_iterator iter = srcmol->begin(); iter != srcmol->end(); ++iter) {
     331    Log() << Verbose(2) << "INFO: Current Walker is " << *(*iter) << "." << endl;
     332    if (!TesselStruct->IsInnerPoint((*iter)->x, LCList)) {
     333      CopyAtoms[(*iter)->nr] = (*iter)->clone();
     334      mol->AddAtom(CopyAtoms[(*iter)->nr]);
    348335      nr++;
    349336    } else {
     
    384371bool MoleculeListClass::AddHydrogenCorrection(char *path)
    385372{
    386   atom *Walker = NULL;
    387   atom *Runner = NULL;
    388373  bond *Binder = NULL;
    389374  double ***FitConstant = NULL, **correction = NULL;
     
    490475        correction[k][j] = 0.;
    491476    // 2. take every hydrogen that is a saturated one
    492     Walker = (*ListRunner)->start;
    493     while (Walker->next != (*ListRunner)->end) {
    494       Walker = Walker->next;
    495       //Log() << Verbose(1) << "Walker: " << *Walker << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
    496       if ((Walker->type->Z == 1) && ((Walker->father == NULL)
    497           || (Walker->father->type->Z != 1))) { // if it's a hydrogen
    498         Runner = (*ListRunner)->start;
    499         while (Runner->next != (*ListRunner)->end) {
    500           Runner = Runner->next;
    501           //Log() << Verbose(2) << "Runner: " << *Runner << " with first bond " << *(Walker->ListOfBonds.begin()) << "." << endl;
     477    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     478      //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     479      if (((*iter)->type->Z == 1) && (((*iter)->father == NULL)
     480          || ((*iter)->father->type->Z != 1))) { // if it's a hydrogen
     481        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
     482          //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
    502483          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
    503           Binder = *(Runner->ListOfBonds.begin());
    504           if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (Binder->GetOtherAtom(Runner) != Binder->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!)
     484          Binder = *((*runner)->ListOfBonds.begin());
     485          if (((*runner)->type->Z == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
    505486            // 4. evaluate the morse potential for each matrix component and add up
    506             distance = Runner->x.Distance(&Walker->x);
    507             //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl;
     487            distance = (*runner)->x.Distance(&(*iter)->x);
     488            //Log() << Verbose(0) << "Fragment " << (*ListRunner)->name << ": " << *(*runner) << "<= " << distance << "=>" << *(*iter) << ":" << endl;
    508489            for (int k = 0; k < a; k++) {
    509490              for (int j = 0; j < b; j++) {
     
    579560  ofstream ForcesFile;
    580561  stringstream line;
    581   atom *Walker = NULL;
    582562  element *runner = NULL;
    583563
     
    594574        runner = runner->next;
    595575        if ((*ListRunner)->ElementsInMolecule[runner->Z]) { // if this element got atoms
    596           Walker = (*ListRunner)->start;
    597           while (Walker->next != (*ListRunner)->end) { // go through every atom of this element
    598             Walker = Walker->next;
    599             if (Walker->type->Z == runner->Z) {
    600               if ((Walker->GetTrueFather() != NULL) && (Walker->GetTrueFather() != Walker)) {// if there is a rea
    601                 //Log() << Verbose(0) << "Walker is " << *Walker << " with true father " << *( Walker->GetTrueFather()) << ", it
    602                 ForcesFile << SortIndex[Walker->GetTrueFather()->nr] << "\t";
     576          for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     577            if ((*iter)->type->Z == runner->Z) {
     578              if (((*iter)->GetTrueFather() != NULL) && ((*iter)->GetTrueFather() != (*iter))) {// if there is a rea
     579                //Log() << Verbose(0) << "Walker is " << *(*iter) << " with true father " << *( (*iter)->GetTrueFather()) << ", it
     580                ForcesFile << SortIndex[(*iter)->GetTrueFather()->nr] << "\t";
    603581              } else
    604582                // otherwise a -1 to indicate an added saturation hydrogen
     
    636614  bool result = true;
    637615  bool intermediateResult = true;
    638   atom *Walker = NULL;
    639616  Vector BoxDimension;
    640617  char *FragmentNumber = NULL;
     
    672649    // list atoms in fragment for debugging
    673650    Log() << Verbose(2) << "Contained atoms: ";
    674     Walker = (*ListRunner)->start;
    675     while (Walker->next != (*ListRunner)->end) {
    676       Walker = Walker->next;
    677       Log() << Verbose(0) << Walker->Name << " ";
     651    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
     652      Log() << Verbose(0) << (*iter)->Name << " ";
    678653    }
    679654    Log() << Verbose(0) << endl;
     
    751726{
    752727  molecule *mol = World::get()->createMolecule();
    753   atom *Walker = NULL;
    754   atom *Advancer = NULL;
    755728  bond *Binder = NULL;
    756729  bond *Stepper = NULL;
     
    758731  for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
    759732    // shift all atoms to new molecule
    760     Advancer = (*MolRunner)->start->next;
    761     while (Advancer != (*MolRunner)->end) {
    762       Walker = Advancer;
    763       Advancer = Advancer->next;
    764       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
    765       unlink(Walker);
    766       Walker->father = Walker;
    767       mol->AddAtom(Walker);    // counting starts at 1
     733    for (molecule::iterator iter = (*MolRunner)->begin(); (*MolRunner)->empty(); iter = (*MolRunner)->begin()) {
     734      Log() << Verbose(3) << "Re-linking " << *(*iter) << "..." << endl;
     735      (*iter)->father = (*iter);
     736      mol->AddAtom((*iter));    // counting starts at 1
     737      (*MolRunner)->erase(iter);
    768738    }
    769739    // remove all bonds
     
    812782  int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap");
    813783  MoleculeLeafClass *MolecularWalker = Subgraphs;
    814   Walker = NULL;
    815784  while (MolecularWalker->next != NULL) {
    816785    MolecularWalker = MolecularWalker->next;
    817     Walker = MolecularWalker->Leaf->start;
    818     while (Walker->next != MolecularWalker->Leaf->end) {
    819       Walker = Walker->next;
    820       MolMap[Walker->GetTrueFather()->nr] = FragmentCounter+1;
     786    for (molecule::const_iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
     787      MolMap[(*iter)->GetTrueFather()->nr] = FragmentCounter+1;
    821788    }
    822789    FragmentCounter++;
     
    824791
    825792  // 4c. relocate atoms to new molecules and remove from Leafs
    826   Walker = NULL;
    827   while (mol->start->next != mol->end) {
    828     Walker = mol->start->next;
    829     if ((Walker->nr <0) || (Walker->nr >= mol->AtomCount)) {
    830       eLog() << Verbose(0) << "Index of atom " << *Walker << " is invalid!" << endl;
     793  for (molecule::iterator iter = mol->begin(); !mol->empty(); iter = mol->begin()) {
     794    if (((*iter)->nr <0) || ((*iter)->nr >= mol->AtomCount)) {
     795      eLog() << Verbose(0) << "Index of atom " << *(*iter) << " is invalid!" << endl;
    831796      performCriticalExit();
    832797    }
    833     FragmentCounter = MolMap[Walker->nr];
     798    FragmentCounter = MolMap[(*iter)->nr];
    834799    if (FragmentCounter != 0) {
    835       Log() << Verbose(3) << "Re-linking " << *Walker << "..." << endl;
    836       unlink(Walker);
    837       molecules[FragmentCounter-1]->AddAtom(Walker);    // counting starts at 1
     800      Log() << Verbose(3) << "Re-linking " << *(*iter) << "..." << endl;
     801      molecules[FragmentCounter-1]->AddAtom((*iter));    // counting starts at 1
     802      mol->erase(iter);
    838803    } else {
    839       eLog() << Verbose(0) << "Atom " << *Walker << " not associated to molecule!" << endl;
     804      eLog() << Verbose(0) << "Atom " << *(*iter) << " not associated to molecule!" << endl;
    840805      performCriticalExit();
    841806    }
     
    845810  while (mol->first->next != mol->last) {
    846811    Binder = mol->first->next;
    847     Walker = Binder->leftatom;
     812    const atom * const Walker = Binder->leftatom;
    848813    unlink(Binder);
    849814    link(Binder,molecules[MolMap[Walker->nr]-1]->last);   // counting starts at 1
     
    867832int MoleculeListClass::CountAllAtoms() const
    868833{
    869   atom *Walker = NULL;
    870834  int AtomNo = 0;
    871835  for (MoleculeList::const_iterator MolWalker = ListOfMolecules.begin(); MolWalker != ListOfMolecules.end(); MolWalker++) {
    872     Walker = (*MolWalker)->start;
    873     while (Walker->next != (*MolWalker)->end) {
    874       Walker = Walker->next;
    875       AtomNo++;
    876     }
     836    AtomNo += (*MolWalker)->size();
    877837  }
    878838  return AtomNo;
     
    10491009bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList)
    10501010{
    1051   atom *Walker = NULL;
    10521011  atom *OtherWalker = NULL;
    10531012  atom *Father = NULL;
     
    10731032    }
    10741033
    1075     Walker = Leaf->start;
    1076     while (Walker->next != Leaf->end) {
    1077       Walker = Walker->next;
    1078       Father = Walker->GetTrueFather();
     1034    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1035      Father = (*iter)->GetTrueFather();
    10791036      AtomNo = Father->nr; // global id of the current walker
    10801037      for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
    1081         OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr]; // local copy of current bond partner of walker
     1038        OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    10821039        if (OtherWalker != NULL) {
    1083           if (OtherWalker->nr > Walker->nr)
    1084             Leaf->AddBond(Walker, OtherWalker, (*Runner)->BondDegree);
     1040          if (OtherWalker->nr > (*iter)->nr)
     1041            Leaf->AddBond((*iter), OtherWalker, (*Runner)->BondDegree);
    10851042        } else {
    1086           Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom(Walker->GetTrueFather())->nr << "] is NULL!" << endl;
     1043          Log() << Verbose(1) << "OtherWalker = ListOfLocalAtoms[" << FragmentCounter << "][" << (*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr << "] is NULL!" << endl;
    10871044          status = false;
    10881045        }
     
    11111068bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter)
    11121069{
    1113   atom *Walker = NULL, *Father = NULL;
     1070  atom *Father = NULL;
    11141071
    11151072  if (RootStack != NULL) {
     
    11171074    if (&(RootStack[FragmentCounter]) != NULL) {
    11181075      RootStack[FragmentCounter].clear();
    1119       Walker = Leaf->start;
    1120       while (Walker->next != Leaf->end) { // go through all (non-hydrogen) atoms
    1121         Walker = Walker->next;
    1122         Father = Walker->GetTrueFather();
     1076      for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
     1077        Father = (*iter)->GetTrueFather();
    11231078        if (AtomMask[Father->nr]) // apply mask
    11241079#ifdef ADDHYDROGEN
    1125           if (Walker->type->Z != 1) // skip hydrogen
     1080          if ((*iter)->type->Z != 1) // skip hydrogen
    11261081#endif
    1127           RootStack[FragmentCounter].push_front(Walker->nr);
     1082          RootStack[FragmentCounter].push_front((*iter)->nr);
    11281083      }
    11291084      if (next != NULL)
     
    11641119
    11651120  if ((ListOfLocalAtoms != NULL) && (ListOfLocalAtoms[FragmentCounter] == NULL)) { // allocate and fill list of this fragment/subgraph
    1166     status = status && CreateFatherLookupTable(Leaf->start, Leaf->end, ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
     1121    status = status && Leaf->CreateFatherLookupTable(ListOfLocalAtoms[FragmentCounter], GlobalAtomCount);
    11671122    FreeList = FreeList && true;
    11681123  }
  • src/tesselation.cpp

    re87acf r9879f6  
    11001100};
    11011101
    1102 /** PointCloud implementation of GetTerminalPoint.
    1103  * Uses PointsOnBoundary and STL stuff.
    1104  */   
    1105 TesselPoint * Tesselation::GetTerminalPoint() const
    1106 {
    1107         Info FunctionInfo(__func__);
    1108   PointMap::const_iterator Runner = PointsOnBoundary.end();
    1109   Runner--;
    1110   return (Runner->second->node);
    1111 };
    1112 
    11131102/** PointCloud implementation of GoToNext.
    11141103 * Uses PointsOnBoundary and STL stuff.
     
    11211110};
    11221111
    1123 /** PointCloud implementation of GoToPrevious.
    1124  * Uses PointsOnBoundary and STL stuff.
    1125  */   
    1126 void Tesselation::GoToPrevious() const
    1127 {
    1128         Info FunctionInfo(__func__);
    1129   if (InternalPointer != PointsOnBoundary.begin())
    1130     InternalPointer--;
    1131 };
    1132 
    11331112/** PointCloud implementation of GoToFirst.
    11341113 * Uses PointsOnBoundary and STL stuff.
     
    11381117        Info FunctionInfo(__func__);
    11391118  InternalPointer = PointsOnBoundary.begin();
    1140 };
    1141 
    1142 /** PointCloud implementation of GoToLast.
    1143  * Uses PointsOnBoundary and STL stuff.
    1144  */
    1145 void Tesselation::GoToLast() const
    1146 {
    1147         Info FunctionInfo(__func__);
    1148   InternalPointer = PointsOnBoundary.end();
    1149   InternalPointer--;
    11501119};
    11511120
  • src/tesselation.hpp

    re87acf r9879f6  
    234234  virtual Vector *GetCenter() const { return NULL; };
    235235  virtual TesselPoint *GetPoint() const { return NULL; };
    236   virtual TesselPoint *GetTerminalPoint() const { return NULL; };
    237236  virtual int GetMaxId() const { return 0; };
    238237  virtual void GoToNext() const {};
    239   virtual void GoToPrevious() const {};
    240238  virtual void GoToFirst() const {};
    241   virtual void GoToLast() const {};
    242239  virtual bool IsEmpty() const { return true; };
    243240  virtual bool IsEnd() const { return true; };
     
    342339    virtual Vector *GetCenter(ofstream *out) const;
    343340    virtual TesselPoint *GetPoint() const;
    344     virtual TesselPoint *GetTerminalPoint() const;
    345341    virtual void GoToNext() const;
    346     virtual void GoToPrevious() const;
    347342    virtual void GoToFirst() const;
    348     virtual void GoToLast() const;
    349343    virtual bool IsEmpty() const;
    350344    virtual bool IsEnd() const;
  • src/unittests/AnalysisCorrelationToPointUnitTest.cpp

    re87acf r9879f6  
    2525#include "periodentafel.hpp"
    2626#include "tesselation.hpp"
    27 #include "World.hpp"
    2827
    2928#ifdef HAVE_TESTRUNNER
  • src/unittests/analysisbondsunittest.cpp

    re87acf r9879f6  
    2525#include "molecule.hpp"
    2626#include "periodentafel.hpp"
     27#include "World.hpp"
    2728
    2829#ifdef HAVE_TESTRUNNER
  • src/unittests/bondgraphunittest.cpp

    re87acf r9879f6  
    110110};
    111111
     112/** Tests whether setup worked.
     113 */
     114void BondGraphTest::SetupTest()
     115{
     116  CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty());
     117  CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size());
     118};
     119
    112120/** UnitTest for BondGraphTest::LoadBondLengthTable().
    113121 */
     
    124132void BondGraphTest::ConstructGraphTest()
    125133{
    126   atom *Walker = TestMolecule->start->next;
    127   atom *Runner = TestMolecule->end->previous;
    128   CPPUNIT_ASSERT( TestMolecule->end != Walker );
     134  molecule::iterator Walker = TestMolecule->begin();
     135  molecule::iterator Runner = TestMolecule->begin();
     136  Runner++;
    129137  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
    130138  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    131   CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );
     139  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
    132140};
  • src/unittests/bondgraphunittest.hpp

    re87acf r9879f6  
    2222{
    2323    CPPUNIT_TEST_SUITE( BondGraphTest) ;
     24    CPPUNIT_TEST ( SetupTest );
    2425    CPPUNIT_TEST ( LoadTableTest );
    2526    CPPUNIT_TEST ( ConstructGraphTest );
     
    2930      void setUp();
    3031      void tearDown();
     32      void SetupTest();
    3133      void LoadTableTest();
    3234      void ConstructGraphTest();
  • src/unittests/listofbondsunittest.cpp

    re87acf r9879f6  
    9090};
    9191
     92/** Tests whether setup worked correctly.
     93 *
     94 */
     95void ListOfBondsTest::SetupTest()
     96{
     97  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() );
     98  CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() );
     99};
     100
    92101/** Unit Test of molecule::AddBond()
    93102 *
     
    96105{
    97106  bond *Binder = NULL;
    98   atom *atom1 = TestMolecule->start->next;
    99   atom *atom2 = atom1->next;
     107  molecule::iterator iter = TestMolecule->begin();
     108  atom *atom1 = *iter;
     109  iter++;
     110  atom *atom2 = *iter;
    100111  CPPUNIT_ASSERT( atom1 != NULL );
    101112  CPPUNIT_ASSERT( atom2 != NULL );
     
    124135{
    125136  bond *Binder = NULL;
    126   atom *atom1 = TestMolecule->start->next;
    127   atom *atom2 = atom1->next;
     137  molecule::iterator iter = TestMolecule->begin();
     138  atom *atom1 = *iter;
     139  iter++;
     140  atom *atom2 = *iter;
    128141  CPPUNIT_ASSERT( atom1 != NULL );
    129142  CPPUNIT_ASSERT( atom2 != NULL );
     
    150163{
    151164  bond *Binder = NULL;
    152   atom *atom1 = TestMolecule->start->next;
    153   atom *atom2 = atom1->next;
    154   atom *atom3 = atom2->next;
     165  molecule::iterator iter = TestMolecule->begin();
     166  atom *atom1 = *iter;
     167  iter++;
     168  atom *atom2 = *iter;
     169  iter++;
     170  atom *atom3 = *iter;
    155171  CPPUNIT_ASSERT( atom1 != NULL );
    156172  CPPUNIT_ASSERT( atom2 != NULL );
     
    189205{
    190206  bond *Binder = NULL;
    191   atom *atom1 = TestMolecule->start->next;
    192   atom *atom2 = atom1->next;
     207  molecule::iterator iter = TestMolecule->begin();
     208  atom *atom1 = *iter;
     209  iter++;
     210  atom *atom2 = *iter;
    193211  CPPUNIT_ASSERT( atom1 != NULL );
    194212  CPPUNIT_ASSERT( atom2 != NULL );
     
    215233{
    216234  bond *Binder = NULL;
    217   atom *atom1 = TestMolecule->start->next;
    218   atom *atom2 = atom1->next;
     235  molecule::iterator iter = TestMolecule->begin();
     236  atom *atom1 = *iter;
     237  iter++;
     238  atom *atom2 = *iter;
    219239  CPPUNIT_ASSERT( atom1 != NULL );
    220240  CPPUNIT_ASSERT( atom2 != NULL );
     
    240260{
    241261  bond *Binder = NULL;
    242   atom *atom1 = TestMolecule->start->next;
    243   atom *atom2 = atom1->next;
     262  molecule::iterator iter = TestMolecule->begin();
     263  atom *atom1 = *iter;
     264  iter++;
     265  atom *atom2 = *iter;
    244266  CPPUNIT_ASSERT( atom1 != NULL );
    245267  CPPUNIT_ASSERT( atom2 != NULL );
  • src/unittests/listofbondsunittest.hpp

    re87acf r9879f6  
    2020{
    2121    CPPUNIT_TEST_SUITE( ListOfBondsTest) ;
     22    CPPUNIT_TEST ( SetupTest );
    2223    CPPUNIT_TEST ( AddingBondTest );
    2324    CPPUNIT_TEST ( RemovingBondTest );
     
    3132      void setUp();
    3233      void tearDown();
     34      void SetupTest();
    3335      void AddingBondTest();
    3436      void RemovingBondTest();
Note: See TracChangeset for help on using the changeset viewer.