Changeset e08c46


Ignore:
Timestamp:
May 31, 2010, 6:41:12 PM (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:
1b9321
Parents:
1024cb
Message:

Removed molecule::first, molecule::last.

  • molecule does not have a chained list of bonds.
  • we have to go through atoms and its bonds, by checking (*BondRunner)->leftatom against (*AtomRunner) we exclude the other half.
  • first,last were present in only a few structures.
  • new functions:
    • molecule::hasBondStructure() - replaces first->next != last construct
    • molecule::CountBonds() - replaces first->next->next == last (i.e. one bond present) and alikes.

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r1024cb re08c46  
    605605  Log() << Verbose(0) << "What's the desired bond order: ";
    606606  cin >> Order1;
    607   if (mol->first->next != mol->last) {  // there are bonds
     607  if (mol->hasBondStructure()) {
    608608    start = clock();
    609609    mol->FragmentMolecule(Order1, configuration);
     
    775775        }
    776776      }
    777       if (mol->first->next != mol->last) // if connect matrix is present already, redo it
     777      if (mol->hasBondStructure())
    778778        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    779779      // free memory
  • src/boundary.cpp

    r1024cb re08c46  
    817817  filler->Center.Zero();
    818818  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
    819   Binder = filler->first;
    820   while(Binder->next != filler->last) {
    821     Binder = Binder->next;
    822     DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
    823   }
     819  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     820    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     821      if ((*BondRunner)->leftatom == *AtomRunner)
     822        DoLog(2) && (Log() << Verbose(2) << "  " << *Binder << endl);
    824823
    825824  atom * CopyAtoms[filler->getAtomCount()];
     
    909908        }
    910909        // go through all bonds and add as well
    911         Binder = filler->first;
    912         while(Binder->next != filler->last) {
    913           Binder = Binder->next;
    914           if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
    915             Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
    916             Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    917           }
    918         }
     910        for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
     911          for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     912            if ((*BondRunner)->leftatom == *AtomRunner) {
     913              Binder = (*BondRunner);
     914              if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) {
     915                Log()  << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl;
     916                Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
     917              }
     918            }
    919919      }
    920920  delete[](M);
  • src/builder.cpp

    r1024cb re08c46  
    22802280                mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    22812281                DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl);
    2282                 if (mol->first->next != mol->last) {
     2282                if (mol->hasBondStructure()) {
    22832283                  ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration);
    22842284                }
  • src/molecule.cpp

    r1024cb re08c46  
    3636 */
    3737molecule::molecule(const periodentafel * const teil) : elemente(teil),
    38   first(new bond(0, 0, 1, -1)), last(new bond(0, 0, 1, -1)), MDSteps(0),
     38  MDSteps(0),
    3939  BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.),
    4040  ActiveFlag(false), IndexNr(-1),
     
    4242  AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0),  InternalPointer(begin())
    4343{
    44   // init bond chain list
    45   link(first,last);
    4644
    4745  // other stuff
     
    6159{
    6260  CleanupMolecule();
    63   delete(first);
    64   delete(last);
    6561};
    6662
     
    607603
    608604  // copy all bonds
    609   bond *Binder = first;
     605  bond *Binder = NULL;
    610606  bond *NewBond = NULL;
    611   while(Binder->next != last) {
    612     Binder = Binder->next;
    613 
    614     // get the pendant atoms of current bond in the copy molecule
    615     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
    616     copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
    617 
    618     NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
    619     NewBond->Cyclic = Binder->Cyclic;
    620     if (Binder->Cyclic)
    621       copy->NoCyclicBonds++;
    622     NewBond->Type = Binder->Type;
    623   }
     607  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     608    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     609      if ((*BondRunner)->leftatom == *AtomRunner) {
     610        Binder = (*BondRunner);
     611
     612        // get the pendant atoms of current bond in the copy molecule
     613        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->leftatom, (const atom **)&LeftAtom );
     614        copy->ActOnAllAtoms( &atom::EqualsFather, (const atom *)Binder->rightatom, (const atom **)&RightAtom );
     615
     616        NewBond = copy->AddBond(LeftAtom, RightAtom, Binder->BondDegree);
     617        NewBond->Cyclic = Binder->Cyclic;
     618        if (Binder->Cyclic)
     619          copy->NoCyclicBonds++;
     620        NewBond->Type = Binder->Type;
     621      }
    624622  // correct fathers
    625623  ActOnAllAtoms( &atom::CorrectFather );
     
    627625  // copy values
    628626  copy->CountElements();
    629   if (first->next != last) {  // if adjaceny list is present
     627  if (hasBondStructure()) {  // if adjaceny list is present
    630628    copy->BondDistance = BondDistance;
    631629  }
     
    672670  if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
    673671    NoNonBonds++;
    674   add(Binder, last);
    675672
    676673  return Binder;
     
    685682{
    686683  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    687   pointer->leftatom->RegisterBond(pointer);
    688   pointer->rightatom->RegisterBond(pointer);
    689   removewithoutcheck(pointer);
     684  delete(pointer);
    690685  return true;
    691686};
     
    785780  for (molecule::iterator iter = begin(); !empty(); iter = begin())
    786781      erase(iter);
    787   return (cleanup(first,last));
    788782};
    789783
  • src/molecule.hpp

    r1024cb re08c46  
    101101    //atom *start;        //!< start of atom list
    102102    //atom *end;          //!< end of atom list
    103     bond *first;        //!< start of bond list
    104     bond *last;         //!< end of bond list
     103    //bond *first;        //!< start of bond list
     104    //bond *last;         //!< end of bond list
    105105    int MDSteps;        //!< The number of MD steps in Trajectories
    106106    //int AtomCount;          //!< number of atoms, brought up-to-date by CountAtoms()
     
    253253  bool RemoveBond(bond *pointer);
    254254  bool RemoveBonds(atom *BondPartner);
     255  bool hasBondStructure();
     256  unsigned int CountBonds() const;
    255257
    256258  /// Find atoms.
  • src/molecule_fragmentation.cpp

    r1024cb re08c46  
    683683      DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);
    684684      //MolecularWalker->Leaf->OutputListOfBonds(out);  // output atom::ListOfBonds for debugging
    685       if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) {
     685      if (MolecularWalker->Leaf->hasBondStructure()) {
    686686        // call BOSSANOVA method
    687687        DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);
     
    11411141  int SpaceLeft;
    11421142  int *TouchedList = new int[SubOrder + 1];
    1143   bond **BondsList = NULL;
    11441143  KeySetTestPair TestKeySetInsert;
    11451144
     
    14241423int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet)
    14251424{
    1426   bond **BondsList = NULL;
    14271425  int Counter = FragmentSearch.FragmentCounter; // mark current value of counter
    14281426
     
    17351733    Translationvector.Zero();
    17361734    // scan all bonds
    1737     Binder = first;
    17381735    flag = false;
    1739     while ((!flag) && (Binder->next != last)) {
    1740       Binder = Binder->next;
    1741       for (int i=NDIM;i--;) {
    1742         tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
    1743         //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
    1744         if (tmp > BondDistance) {
    1745           OtherBinder = Binder->next; // note down binding partner for later re-insertion
    1746           unlink(Binder);   // unlink bond
    1747           DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
    1748           flag = true;
    1749           break;
     1736    for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner)
     1737      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) {
     1738        Binder = (*BondRunner);
     1739        for (int i=NDIM;i--;) {
     1740          tmp = fabs(Binder->leftatom->x[i] - Binder->rightatom->x[i]);
     1741          //Log() << Verbose(3) << "Checking " << i << "th distance of " << *Binder->leftatom << " to " << *Binder->rightatom << ": " << tmp << "." << endl;
     1742          if (tmp > BondDistance) {
     1743            OtherBinder = Binder->next; // note down binding partner for later re-insertion
     1744            unlink(Binder);   // unlink bond
     1745            DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);
     1746            flag = true;
     1747            break;
     1748          }
    17501749        }
    17511750      }
    1752     }
    17531751    if (flag) {
    17541752      // create translation vector from their periodically modified distance
  • src/molecule_graph.cpp

    r1024cb re08c46  
    127127  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    128128  // remove every bond from the list
    129   bond *Binder = NULL;
    130   while (last->previous != first) {
    131     Binder = last->previous;
    132     Binder->leftatom->UnregisterBond(Binder);
    133     Binder->rightatom->UnregisterBond(Binder);
    134     removewithoutcheck(Binder);
    135   }
     129  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     130    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     131      if ((*BondRunner)->leftatom == *AtomRunner)
     132        delete((*BondRunner));
    136133  BondCount = 0;
    137134
     
    214211;
    215212
     213/** Checks for presence of bonds within atom list.
     214 * TODO: more sophisticated check for bond structure (e.g. connected subgraph, ...)
     215 * \return true - bonds present, false - no bonds
     216 */
     217bool molecule::hasBondStructure()
     218{
     219  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     220    if (!(*AtomRunner)->ListOfBonds.empty())
     221      return true;
     222  return false;
     223}
     224
     225/** Counts the number of present bonds.
     226 * \return number of bonds
     227 */
     228unsigned int molecule::CountBonds() const
     229{
     230  unsigned int counter = 0;
     231  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     232    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     233      if ((*BondRunner)->leftatom == *AtomRunner)
     234        counter++;
     235  return counter;
     236}
     237
    216238/** Prints a list of all bonds to \a *out.
    217239 * \param output stream
     
    220242{
    221243  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    222   bond *Binder = first;
    223   while (Binder->next != last) {
    224     Binder = Binder->next;
    225     DoLog(0) && (Log() << Verbose(0) << *Binder << "\t" << endl);
    226   }
     244  for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner)
     245    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     246      if ((*BondRunner)->leftatom == *AtomRunner) {
     247        DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl);
     248      }
    227249  DoLog(0) && (Log() << Verbose(0) << endl);
    228250}
     
    268290  MoleculeLeafClass *Subgraphs = NULL;
    269291  class StackClass<bond *> *BackEdgeStack = NULL;
    270   bond *Binder = first;
    271   if ((Binder->next != last) && (Binder->next->Type == Undetermined)) {
    272     DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    273     Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
    274     while (Subgraphs->next != NULL) {
    275       Subgraphs = Subgraphs->next;
    276       delete (Subgraphs->previous);
    277     }
    278     delete (Subgraphs);
    279     delete[] (MinimumRingSize);
    280   }
    281   while (Binder->next != last) {
    282     Binder = Binder->next;
    283     if (Binder->Cyclic)
    284       NoCyclicBonds++;
    285   }
     292  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     293    if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) {
     294      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
     295      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
     296      while (Subgraphs->next != NULL) {
     297        Subgraphs = Subgraphs->next;
     298        delete (Subgraphs->previous);
     299      }
     300      delete (Subgraphs);
     301      delete[] (MinimumRingSize);
     302      break;
     303    }
     304  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     305    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     306      if ((*BondRunner)->leftatom == *AtomRunner)
     307        if ((*BondRunner)->Cyclic)
     308          NoCyclicBonds++;
    286309  delete (BackEdgeStack);
    287310  return NoCyclicBonds;
     
    581604{
    582605  NoCyclicBonds = 0;
    583   bond *Binder = first;
    584   while (Binder->next != last) {
    585     Binder = Binder->next;
    586     if (Binder->rightatom->LowpointNr == Binder->leftatom->LowpointNr) { // cyclic ??
    587       Binder->Cyclic = true;
    588       NoCyclicBonds++;
    589     }
    590   }
     606  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     607    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     608      if ((*BondRunner)->leftatom == *AtomRunner)
     609        if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
     610          (*BondRunner)->Cyclic = true;
     611          NoCyclicBonds++;
     612        }
    591613}
    592614;
     
    607629void molecule::OutputGraphInfoPerBond() const
    608630{
     631  bond *Binder = NULL;
    609632  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    610   bond *Binder = first;
    611   while (Binder->next != last) {
    612     Binder = Binder->next;
    613     DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
    614     DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
    615     Binder->leftatom->OutputComponentNumber();
    616     DoLog(0) && (Log() << Verbose(0) << " ===  ");
    617     DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
    618     Binder->rightatom->OutputComponentNumber();
    619     DoLog(0) && (Log() << Verbose(0) << ">." << endl);
    620     if (Binder->Cyclic) // cyclic ??
    621       DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    622   }
     633  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     634    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     635      if ((*BondRunner)->leftatom == *AtomRunner) {
     636        Binder = *BondRunner;
     637        DoLog(2) && (Log() << Verbose(2) << ((Binder->Type == TreeEdge) ? "TreeEdge " : "BackEdge ") << *Binder << ": <");
     638        DoLog(0) && (Log() << Verbose(0) << ((Binder->leftatom->SeparationVertex) ? "SP," : "") << "L" << Binder->leftatom->LowpointNr << " G" << Binder->leftatom->GraphNr << " Comp.");
     639        Binder->leftatom->OutputComponentNumber();
     640        DoLog(0) && (Log() << Verbose(0) << " ===  ");
     641        DoLog(0) && (Log() << Verbose(0) << ((Binder->rightatom->SeparationVertex) ? "SP," : "") << "L" << Binder->rightatom->LowpointNr << " G" << Binder->rightatom->GraphNr << " Comp.");
     642        Binder->rightatom->OutputComponentNumber();
     643        DoLog(0) && (Log() << Verbose(0) << ">." << endl);
     644        if (Binder->Cyclic) // cyclic ??
     645          DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
     646      }
    623647}
    624648;
     
    975999void molecule::ResetAllBondsToUnused() const
    9761000{
    977   bond *Binder = first;
    978   while (Binder->next != last) {
    979     Binder = Binder->next;
    980     Binder->ResetUsed();
    981   }
     1001  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
     1002    for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     1003      if ((*BondRunner)->leftatom == *AtomRunner)
     1004        (*BondRunner)->ResetUsed();
    9821005}
    9831006;
  • src/moleculelist.cpp

    r1024cb re08c46  
    345345
    346346  // go through all bonds and add as well
    347   bond *Binder = srcmol->first;
    348   while(Binder->next != srcmol->last) {
    349     Binder = Binder->next;
    350     DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl);
    351     mol->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree);
    352   }
     347  for(molecule::iterator AtomRunner = srcmol->begin(); AtomRunner != srcmol->end(); ++AtomRunner)
     348    for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     349      if ((*BondRunner)->leftatom == *AtomRunner) {
     350        DoLog(3) && (Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[(*BondRunner)->leftatom->nr] << " and " << *CopyAtoms[(*BondRunner)->rightatom->nr]<< "." << endl);
     351        mol->AddBond(CopyAtoms[(*BondRunner)->leftatom->nr], CopyAtoms[(*BondRunner)->rightatom->nr], (*BondRunner)->BondDegree);
     352      }
    353353  delete(LCList);
    354354  return true;
     
    744744  molecule *mol = World::getInstance().createMolecule();
    745745  bond *Binder = NULL;
    746   bond *Stepper = NULL;
    747746  // 0. gather all atoms into single molecule
    748747  for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) {
     
    755754    }
    756755    // remove all bonds
    757     Stepper = (*MolRunner)->first->next;
    758     while (Stepper != (*MolRunner)->last) {
    759       Binder = Stepper;
    760       Stepper = Stepper->next;
    761       delete(Binder);
    762     }
     756    for(molecule::iterator AtomRunner = (*MolRunner)->begin(); AtomRunner != (*MolRunner)->end(); ++AtomRunner)
     757      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     758        delete(*BondRunner);
    763759    // remove the molecule
    764760    World::getInstance().destroyMolecule(*MolRunner);
     
    835831  }
    836832  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    837   Binder = mol->first;
    838   while (mol->first->next != mol->last) {
    839     Binder = mol->first->next;
    840     const atom * const Walker = Binder->leftatom;
    841     unlink(Binder);
    842     link(Binder,molecules[MolMap[Walker->nr]-1]->last);   // counting starts at 1
    843   }
     833  // TODO: check whether this is really not needed anymore
    844834  // 4e. free Leafs
    845835  MolecularWalker = Subgraphs;
     
    10521042    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    10531043    // remove every bond from the list
    1054     bond *Binder = NULL;
    1055     while (Leaf->last->previous != Leaf->first) {
    1056       Binder = Leaf->last->previous;
    1057       Binder->leftatom->UnregisterBond(Binder);
    1058       Binder->rightatom->UnregisterBond(Binder);
    1059       removewithoutcheck(Binder);
    1060     }
     1044    for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner)
     1045      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     1046        if ((*BondRunner)->leftatom == *AtomRunner)
     1047          delete((*BondRunner));
    10611048
    10621049    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
  • src/unittests/listofbondsunittest.cpp

    r1024cb re08c46  
    106106  Binder = TestMolecule->AddBond(atom1, atom2, 1);
    107107  CPPUNIT_ASSERT( Binder != NULL );
    108   bond *TestBond = TestMolecule->first->next;
    109   CPPUNIT_ASSERT_EQUAL ( TestBond, Binder );
     108  CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() );
    110109
    111110  // check that bond contains the two atoms
     
    145144
    146145  // check if removed from molecule
    147   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     146  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    148147};
    149148
     
    186185
    187186  // check if removed from molecule
    188   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, Binder );
    189   CPPUNIT_ASSERT_EQUAL( Binder->next, TestMolecule->last );
     187  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
     188  CPPUNIT_ASSERT_EQUAL( (unsigned int)1, TestMolecule->CountBonds() );
    190189};
    191190
     
    215214
    216215  // check if removed from molecule
    217   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     216  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    218217};
    219218
     
    242241
    243242  // check if removed from molecule
    244   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
     243  CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() );
    245244};
    246245
     
    269268
    270269  // check if removed from molecule
    271   CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last );
    272 };
     270  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
     271};
Note: See TracChangeset for help on using the changeset viewer.