Changeset e08c46
- Timestamp:
- May 31, 2010, 6:41:12 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 1b9321
- Parents:
- 1024cb
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
r1024cb re08c46 605 605 Log() << Verbose(0) << "What's the desired bond order: "; 606 606 cin >> Order1; 607 if (mol-> first->next != mol->last) { // there are bonds607 if (mol->hasBondStructure()) { 608 608 start = clock(); 609 609 mol->FragmentMolecule(Order1, configuration); … … 775 775 } 776 776 } 777 if (mol-> first->next != mol->last) // if connect matrix is present already, redo it777 if (mol->hasBondStructure()) 778 778 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 779 779 // free memory -
src/boundary.cpp
r1024cb re08c46 817 817 filler->Center.Zero(); 818 818 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); 824 823 825 824 atom * CopyAtoms[filler->getAtomCount()]; … … 909 908 } 910 909 // 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 } 919 919 } 920 920 delete[](M); -
src/builder.cpp
r1024cb re08c46 2280 2280 mol->CreateAdjacencyList(atof(argv[argptr]), configuration.GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 2281 2281 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 2282 if (mol-> first->next != mol->last) {2282 if (mol->hasBondStructure()) { 2283 2283 ExitFlag = mol->FragmentMolecule(atoi(argv[argptr+1]), &configuration); 2284 2284 } -
src/molecule.cpp
r1024cb re08c46 36 36 */ 37 37 molecule::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), 39 39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 40 40 ActiveFlag(false), IndexNr(-1), … … 42 42 AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0), InternalPointer(begin()) 43 43 { 44 // init bond chain list45 link(first,last);46 44 47 45 // other stuff … … 61 59 { 62 60 CleanupMolecule(); 63 delete(first);64 delete(last);65 61 }; 66 62 … … 607 603 608 604 // copy all bonds 609 bond *Binder = first;605 bond *Binder = NULL; 610 606 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 } 624 622 // correct fathers 625 623 ActOnAllAtoms( &atom::CorrectFather ); … … 627 625 // copy values 628 626 copy->CountElements(); 629 if ( first->next != last) { // if adjaceny list is present627 if (hasBondStructure()) { // if adjaceny list is present 630 628 copy->BondDistance = BondDistance; 631 629 } … … 672 670 if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1)) 673 671 NoNonBonds++; 674 add(Binder, last);675 672 676 673 return Binder; … … 685 682 { 686 683 //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); 690 685 return true; 691 686 }; … … 785 780 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 786 781 erase(iter); 787 return (cleanup(first,last));788 782 }; 789 783 -
src/molecule.hpp
r1024cb re08c46 101 101 //atom *start; //!< start of atom list 102 102 //atom *end; //!< end of atom list 103 bond *first; //!< start of bond list104 bond *last; //!< end of bond list103 //bond *first; //!< start of bond list 104 //bond *last; //!< end of bond list 105 105 int MDSteps; //!< The number of MD steps in Trajectories 106 106 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms() … … 253 253 bool RemoveBond(bond *pointer); 254 254 bool RemoveBonds(atom *BondPartner); 255 bool hasBondStructure(); 256 unsigned int CountBonds() const; 255 257 256 258 /// Find atoms. -
src/molecule_fragmentation.cpp
r1024cb re08c46 683 683 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl); 684 684 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 685 if (MolecularWalker->Leaf-> first->next != MolecularWalker->Leaf->last) {685 if (MolecularWalker->Leaf->hasBondStructure()) { 686 686 // call BOSSANOVA method 687 687 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl); … … 1141 1141 int SpaceLeft; 1142 1142 int *TouchedList = new int[SubOrder + 1]; 1143 bond **BondsList = NULL;1144 1143 KeySetTestPair TestKeySetInsert; 1145 1144 … … 1424 1423 int molecule::PowerSetGenerator(int Order, struct UniqueFragments &FragmentSearch, KeySet RestrictedKeySet) 1425 1424 { 1426 bond **BondsList = NULL;1427 1425 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1428 1426 … … 1735 1733 Translationvector.Zero(); 1736 1734 // scan all bonds 1737 Binder = first;1738 1735 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 } 1750 1749 } 1751 1750 } 1752 }1753 1751 if (flag) { 1754 1752 // create translation vector from their periodically modified distance -
src/molecule_graph.cpp
r1024cb re08c46 127 127 DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl); 128 128 // 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)); 136 133 BondCount = 0; 137 134 … … 214 211 ; 215 212 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 */ 217 bool 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 */ 228 unsigned 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 216 238 /** Prints a list of all bonds to \a *out. 217 239 * \param output stream … … 220 242 { 221 243 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 } 227 249 DoLog(0) && (Log() << Verbose(0) << endl); 228 250 } … … 268 290 MoleculeLeafClass *Subgraphs = NULL; 269 291 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++; 286 309 delete (BackEdgeStack); 287 310 return NoCyclicBonds; … … 581 604 { 582 605 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 } 591 613 } 592 614 ; … … 607 629 void molecule::OutputGraphInfoPerBond() const 608 630 { 631 bond *Binder = NULL; 609 632 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 } 623 647 } 624 648 ; … … 975 999 void molecule::ResetAllBondsToUnused() const 976 1000 { 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(); 982 1005 } 983 1006 ; -
src/moleculelist.cpp
r1024cb re08c46 345 345 346 346 // 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 } 353 353 delete(LCList); 354 354 return true; … … 744 744 molecule *mol = World::getInstance().createMolecule(); 745 745 bond *Binder = NULL; 746 bond *Stepper = NULL;747 746 // 0. gather all atoms into single molecule 748 747 for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) { … … 755 754 } 756 755 // 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); 763 759 // remove the molecule 764 760 World::getInstance().destroyMolecule(*MolRunner); … … 835 831 } 836 832 // 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 844 834 // 4e. free Leafs 845 835 MolecularWalker = Subgraphs; … … 1052 1042 DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl); 1053 1043 // 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)); 1061 1048 1062 1049 for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) { -
src/unittests/listofbondsunittest.cpp
r1024cb re08c46 106 106 Binder = TestMolecule->AddBond(atom1, atom2, 1); 107 107 CPPUNIT_ASSERT( Binder != NULL ); 108 bond *TestBond = TestMolecule->first->next; 109 CPPUNIT_ASSERT_EQUAL ( TestBond, Binder ); 108 CPPUNIT_ASSERT_EQUAL ( true, TestMolecule->hasBondStructure() ); 110 109 111 110 // check that bond contains the two atoms … … 145 144 146 145 // check if removed from molecule 147 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);146 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 148 147 }; 149 148 … … 186 185 187 186 // 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() ); 190 189 }; 191 190 … … 215 214 216 215 // check if removed from molecule 217 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);216 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 218 217 }; 219 218 … … 242 241 243 242 // check if removed from molecule 244 CPPUNIT_ASSERT_EQUAL( TestMolecule->first->next, TestMolecule->last);243 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->hasBondStructure() ); 245 244 }; 246 245 … … 269 268 270 269 // 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.