- Timestamp:
- Mar 5, 2010, 10:16:47 AM (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:
- 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)
- Location:
- src
- Files:
-
- 1 deleted
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
re87acf r9879f6 447 447 break; 448 448 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 } 459 459 } 460 460 break; … … 466 466 Log() << Verbose(0) << "Upper boundary: "; 467 467 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)); 476 474 } 477 475 } … … 516 514 min[i] = 0.; 517 515 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; 522 518 tmp1 = 0.; 523 if (first != second) {519 if (first != (*iter)) { 524 520 x.CopyVector((const Vector *)&first->x); 525 x.SubtractVector((const Vector *)& second->x);521 x.SubtractVector((const Vector *)&(*iter)->x); 526 522 tmp1 = x.Norm(); 527 523 } 528 524 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; 530 526 } 531 527 for (int i=MAX_ELEMENTS;i--;) … … 767 763 vectors = new Vector *[count]; 768 764 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; 774 768 j++; 775 769 } … … 1029 1023 return; 1030 1024 } 1031 atom *Walker = mol->start;1032 1025 1033 1026 // generate some KeySets … … 1035 1028 KeySet TestSets[mol->AtomCount+1]; 1036 1029 i=1; 1037 while (Walker->next != mol->end) { 1038 Walker = Walker->next; 1030 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1039 1031 for (int j=0;j<i;j++) { 1040 TestSets[j].insert( Walker->nr);1032 TestSets[j].insert((*iter)->nr); 1041 1033 } 1042 1034 i++; … … 1044 1036 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1045 1037 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 } 1049 1046 } 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 } 1054 1049 1055 1050 // constructing Graph structure -
src/Makefile.am
re87acf r9879f6 41 41 Descriptors/MoleculeIdDescriptor.hpp 42 42 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 l ists.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.cpp43 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 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 44 44 HEADER = ${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 45 45 -
src/analysis_bonds.cpp
re87acf r9879f6 24 24 Mean = 0.; 25 25 26 atom *Walker = mol->start;27 26 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(); 31 29 if (Max < count) 32 30 Max = count; … … 56 54 57 55 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) { 64 60 const double distance = (*BondRunner)->GetDistanceSquared(); 65 61 if (Min > distance) -
src/analysis_correlation.cpp
re87acf r9879f6 41 41 if ((*MolWalker)->ActiveFlag) { 42 42 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)) { 48 46 for (MoleculeList::const_iterator MolOtherWalker = MolWalker; MolOtherWalker != molecules->ListOfMolecules.end(); MolOtherWalker++) 49 47 if ((*MolOtherWalker)->ActiveFlag) { 50 48 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)) ) ); 60 56 } 61 57 } … … 99 95 double * FullInverseMatrix = InverseMatrix(FullMatrix); 100 96 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); 107 101 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 108 102 // go through every range in xyz and get distance … … 116 110 if ((*MolOtherWalker)->ActiveFlag) { 117 111 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); 125 117 periodicOtherX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 126 118 // go through every range in xyz and get distance … … 132 124 checkOtherX.MatrixMultiplication(FullMatrix); 133 125 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)) ) ); 136 128 } 137 129 } … … 169 161 if ((*MolWalker)->ActiveFlag) { 170 162 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); 177 167 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) ) ); 179 169 } 180 170 } … … 211 201 double * FullInverseMatrix = InverseMatrix(FullMatrix); 212 202 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); 219 207 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 220 208 // go through every range in xyz and get distance … … 227 215 distance = checkX.Distance(point); 228 216 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) ) ); 230 218 } 231 219 } … … 262 250 if ((*MolWalker)->ActiveFlag) { 263 251 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 ); 270 256 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) ) ); 273 259 } 274 260 } … … 315 301 double * FullInverseMatrix = InverseMatrix(FullMatrix); 316 302 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); 323 307 periodicX.MatrixMultiplication(FullInverseMatrix); // x now in [0,1)^3 324 308 // go through every range in xyz and get distance … … 339 323 // insert 340 324 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; 343 327 } 344 328 } -
src/atom.cpp
re87acf r9879f6 59 59 atom::~atom() 60 60 { 61 unlink(this);62 61 }; 63 62 -
src/bondgraph.cpp
re87acf r9879f6 88 88 bool status = true; 89 89 90 if (mol-> start->next == mol->end) // only construct if molecule is not empty90 if (mol->empty()) // only construct if molecule is not empty 91 91 return false; 92 92 … … 121 121 max_distance = 0.; 122 122 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; 128 126 } 129 127 max_distance *= 2.; -
src/boundary.cpp
re87acf r9879f6 140 140 { 141 141 Info FunctionInfo(__func__); 142 atom *Walker = NULL;143 142 PointMap PointsOnBoundary; 144 143 LineMap LinesOnBoundary; … … 166 165 167 166 // 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); 172 169 ProjectedVector.SubtractVector(MolCenter); 173 170 ProjectedVector.ProjectOntoPlane(&AxisVector); … … 184 181 angle = 2. * M_PI - angle; 185 182 } 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)))); 188 185 if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity 189 186 Log() << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl; 190 187 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; 192 189 const double ProjectedVectorNorm = ProjectedVector.NormSquared(); 193 190 if ((ProjectedVectorNorm - BoundaryTestPair.first->second.first) > MYEPSILON) { 194 191 BoundaryTestPair.first->second.first = ProjectedVectorNorm; 195 BoundaryTestPair.first->second.second = Walker;192 BoundaryTestPair.first->second.second = (*iter); 196 193 Log() << Verbose(2) << "Keeping new vector due to larger projected distance " << ProjectedVectorNorm << "." << endl; 197 194 } else if (fabs(ProjectedVectorNorm - BoundaryTestPair.first->second.first) < MYEPSILON) { 198 helper.CopyVector(& Walker->x);195 helper.CopyVector(&(*iter)->x); 199 196 helper.SubtractVector(MolCenter); 200 197 const double oldhelperNorm = helper.NormSquared(); … … 202 199 helper.SubtractVector(MolCenter); 203 200 if (helper.NormSquared() < oldhelperNorm) { 204 BoundaryTestPair.first->second.second = Walker;201 BoundaryTestPair.first->second.second = (*iter); 205 202 Log() << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl; 206 203 } else { … … 705 702 int repetition[NDIM] = { 1, 1, 1 }; 706 703 int TotalNoClusters = 1; 707 atom *Walker = NULL;708 704 double totalmass = 0.; 709 705 double clustervolume = 0.; … … 729 725 730 726 // 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; 735 729 } 736 730 Log() << Verbose(0) << "RESULT: The summed mass is " << setprecision(10) << totalmass << " atomicmassunit." << endl; … … 811 805 Vector FillerDistance; 812 806 double FillIt = false; 813 atom *Walker = NULL;814 807 bond *Binder = NULL; 815 808 int i = 0; … … 884 877 885 878 // 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) { 889 880 // copy atom ... 890 CopyAtoms[ Walker->nr] = Walker->clone();881 CopyAtoms[(*iter)->nr] = (*iter)->clone(); 891 882 892 883 // create atomic random translation vector ... … … 913 904 // ... and put at new position 914 905 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); 919 910 920 911 // insert into Filling 921 912 922 913 // 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]); 925 916 } 926 917 … … 1036 1027 // // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles 1037 1028 // //->InsertStraddlingPoints(mol, LCList); 1038 // mol->GoToFirst();1029 // for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1039 1030 // class TesselPoint *Runner = NULL; 1040 // while (!mol->IsEnd()) { 1041 // Runner = mol->GetPoint(); 1031 // Runner = *iter; 1042 1032 // Log() << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl; 1043 1033 // if (!->IsInnerPoint(Runner, LCList)) { … … 1047 1037 // Log() << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl; 1048 1038 // } 1049 // mol->GoToNext();1050 1039 // } 1051 1040 -
src/builder.cpp
re87acf r9879f6 483 483 Log() << Verbose(0) << "Enter radius: "; 484 484 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)); 492 490 } 493 491 break; … … 499 497 Log() << Verbose(0) << "Upper boundary: "; 500 498 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)); 509 505 } 510 506 } … … 549 545 min[i] = 0.; 550 546 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; 555 549 tmp1 = 0.; 556 if (first != second) {550 if (first != (*iter)) { 557 551 x.CopyVector((const Vector *)&first->x); 558 x.SubtractVector((const Vector *)& second->x);552 x.SubtractVector((const Vector *)&(*iter)->x); 559 553 tmp1 = x.Norm(); 560 554 } 561 555 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; 563 557 } 564 558 for (int i=MAX_ELEMENTS;i--;) … … 829 823 vectors = new Vector *[count]; 830 824 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; 836 828 j++; 837 829 } … … 1184 1176 return; 1185 1177 } 1186 atom *Walker = mol->start;1187 1178 1188 1179 // generate some KeySets … … 1190 1181 KeySet TestSets[mol->AtomCount+1]; 1191 1182 i=1; 1192 while (Walker->next != mol->end) { 1193 Walker = Walker->next; 1183 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1194 1184 for (int j=0;j<i;j++) { 1195 TestSets[j].insert( Walker->nr);1185 TestSets[j].insert((*iter)->nr); 1196 1186 } 1197 1187 i++; … … 1199 1189 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1200 1190 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 } 1204 1199 } else { 1205 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;1200 eLog() << Verbose(1) << "No atoms to test on." << endl; 1206 1201 } 1207 TestSets[mol->AtomCount].insert(mol->end->previous->nr);1208 TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);1209 1202 1210 1203 // constructing Graph structure … … 1810 1803 double tmp1 = atof(argv[argptr+1]); 1811 1804 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)); 1820 1811 } 1821 1812 } else { … … 2082 2073 vectors = new Vector *[count]; 2083 2074 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; 2089 2078 j++; 2090 2079 } -
src/config.cpp
re87acf r9879f6 1542 1542 int AtomNo = -1; 1543 1543 int MolNo = 0; 1544 atom *Walker = NULL;1545 1544 FILE *f = NULL; 1546 1545 … … 1555 1554 fprintf(f, "# Created by MoleCuilder\n"); 1556 1555 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++) { 1559 1557 int *elementNo = Calloc<int>(MAX_ELEMENTS, "config::SavePDB - elementNo"); 1560 1558 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 1565 1562 fprintf(f, 1566 1563 "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 */ 1568 1565 name, /* atom name */ 1569 (* Runner)->name, /* residue name */1566 (*MolRunner)->name, /* residue name */ 1570 1567 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1571 1568 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 */ 1577 1574 "0", /* segment identifier */ 1578 Walker->type->symbol, /* element symbol */1575 (*iter)->type->symbol, /* element symbol */ 1579 1576 "0"); /* charge */ 1580 1577 AtomNo++; … … 1596 1593 { 1597 1594 int AtomNo = -1; 1598 atom *Walker = NULL;1599 1595 FILE *f = NULL; 1600 1596 … … 1611 1607 fprintf(f, "# Created by MoleCuilder\n"); 1612 1608 1613 Walker = mol->start;1614 1609 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 1619 1613 fprintf(f, 1620 1614 "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 */ 1622 1616 name, /* atom name */ 1623 1617 mol->name, /* residue name */ 1624 1618 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1625 1619 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 */ 1631 1625 "0", /* segment identifier */ 1632 Walker->type->symbol, /* element symbol */1626 (*iter)->type->symbol, /* element symbol */ 1633 1627 "0"); /* charge */ 1634 1628 AtomNo++; … … 1647 1641 bool config::SaveTREMOLO(const char * const filename, const molecule * const mol) const 1648 1642 { 1649 atom *Walker = NULL;1650 1643 ofstream *output = NULL; 1651 1644 stringstream * const fname = new stringstream; … … 1660 1653 1661 1654 // scan maximum number of neighbours 1662 Walker = mol->start;1663 1655 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(); 1667 1658 if (MaxNeighbours < count) 1668 1659 MaxNeighbours = count; 1669 1660 } 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"; 1677 1666 *output << mol->name << "\t"; 1678 1667 *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++) 1685 1675 *output << "-\t"; 1686 1676 *output << endl; … … 1701 1691 bool config::SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const 1702 1692 { 1703 atom *Walker = NULL;1704 1693 ofstream *output = NULL; 1705 1694 stringstream * const fname = new stringstream; … … 1716 1705 int MaxNeighbours = 0; 1717 1706 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(); 1722 1709 if (MaxNeighbours < count) 1723 1710 MaxNeighbours = count; 1724 1711 } 1725 1712 } 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; 1727 1714 1728 1715 // create global to local id map … … 1745 1732 int AtomNo = 0; 1746 1733 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) { 1750 1735 *output << AtomNo << "\t"; 1751 *output << Walker->Name << "\t";1736 *output << (*iter)->Name << "\t"; 1752 1737 *output << (*MolWalker)->name << "\t"; 1753 1738 *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++) 1760 1746 *output << "-\t"; 1761 1747 *output << endl; -
src/helpers.hpp
re87acf r9879f6 100 100 }; 101 101 102 /** Creates a lookup table for true father's Atom::Nr -> atom ptr.103 * \param *start begin of chain list104 * \paran *end end of chain list105 * \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 - failure108 */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 them121 if (count == 0) {122 Walker = start;123 while (Walker->next != end) { // create a lookup table (Atom::nr -> atom) used as a marker table lateron124 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 fill134 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 lateron142 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 158 102 /** Frees a two-dimensional array. 159 103 * \param *ptr pointer to array -
src/lists.hpp
re87acf r9879f6 8 8 #ifndef LISTS_HPP_ 9 9 #define LISTS_HPP_ 10 11 class atom;12 10 13 11 /******************************** Some templates for list management ***********************************/ … … 134 132 }; 135 133 136 /** Returns the first marker in a chain list.137 * \param *me one arbitrary item in chain list138 * \return poiner to first marker139 */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 list150 * \return poiner to last marker151 */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 160 134 #endif /* LISTS_HPP_ */ -
src/molecule.cpp
re87acf r9879f6 37 37 formula(this,boost::bind(&molecule::calcFormula,this)), 38 38 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 { 46 41 // init bond chain list 47 42 link(first,last); … … 67 62 delete(first); 68 63 delete(last); 69 end->getWorld()->destroyAtom(end);70 start->getWorld()->destroyAtom(start);71 64 }; 72 65 … … 103 96 for (int j = 0; j<MAX_ELEMENTS;j++) 104 97 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]++; 107 100 } 108 101 for(element* Elemental = elemente->end; Elemental != elemente->start; Elemental = Elemental->previous) { … … 124 117 } 125 118 126 molecule::iterator molecule::end e(){119 molecule::iterator molecule::end(){ 127 120 return molecule::iterator(atoms.end(),this); 128 121 } 129 122 130 molecule::const_iterator molecule::end e() const{123 molecule::const_iterator molecule::end() const{ 131 124 return atoms.end(); 125 } 126 127 bool molecule::empty() const 128 { 129 return (begin() == end()); 130 } 131 132 size_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 140 molecule::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 148 molecule::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 161 molecule::const_iterator molecule::find ( atom *& key ) const 162 { 163 return atoms.find( key ); 164 } 165 166 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 167 { 168 return atoms.insert(key); 132 169 } 133 170 … … 139 176 bool molecule::AddAtom(atom *pointer) 140 177 { 141 bool retval = false;142 178 OBSERVE; 143 179 if (pointer != NULL) { 144 180 pointer->sort = &pointer->nr; 145 pointer->nr = last_atom++; // increase number within molecule146 181 AtomCount++; 147 182 if (pointer->type != NULL) { … … 157 192 } 158 193 } 159 retval = add(pointer, end);160 } 161 return retval;194 insert(pointer); 195 } 196 return true; 162 197 }; 163 198 … … 175 210 walker->Name = Malloc<char>(strlen(pointer->Name) + 1, "atom::atom: *Name"); 176 211 strcpy (walker->Name, pointer->Name); 177 walker->nr = last_atom++; // increase number within molecule 178 add(walker, end); 212 insert(walker); 179 213 if ((pointer->type != NULL) && (pointer->type->Z != 1)) 180 214 NoNonHydrogen++; … … 701 735 ElementCount--; 702 736 RemoveBonds(pointer); 703 return remove(pointer, start, end); 737 erase(pointer); 738 return true; 704 739 }; 705 740 … … 718 753 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 719 754 ElementCount--; 720 unlink(pointer);755 erase(pointer); 721 756 return true; 722 757 }; … … 727 762 bool molecule::CleanupMolecule() 728 763 { 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)); 730 767 }; 731 768 … … 734 771 * \return pointer to atom or NULL 735 772 */ 736 atom * molecule::FindAtom(int Nr) const{ 737 atom * walker = find(&Nr, start,end); 738 if (walker != NULL) { 773 atom * 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()) { 739 780 //Log() << Verbose(0) << "Found Atom Nr. " << walker->nr << endl; 740 return walker;781 return (*iter); 741 782 } else { 742 783 Log() << Verbose(0) << "Atom not found in list." << endl; … … 896 937 void molecule::CountAtoms() 897 938 { 898 int i = 0; 899 atom *Walker = start; 900 while (Walker->next != end) { 901 Walker = Walker->next; 902 i++; 903 } 939 int i = size(); 904 940 if ((AtomCount == 0) || (i != AtomCount)) { 905 941 Log() << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl; … … 910 946 i=0; 911 947 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 917 951 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; 922 956 i++; 923 957 } … … 1092 1126 int * molecule::GetFatherSonAtomicMap(molecule *OtherMolecule) 1093 1127 { 1094 atom *Walker = NULL, *OtherWalker = NULL;1095 1128 Log() << Verbose(3) << "Begin of GetFatherAtomicMap." << endl; 1096 1129 int *AtomicMap = Malloc<int>(AtomCount, "molecule::GetAtomicMap: *AtomicMap"); … … 1103 1136 } else { 1104 1137 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; 1110 1141 } 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) { 1114 1143 //for (int i=0;i<AtomCount;i++) { // search atom 1115 1144 //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; 1119 1148 } 1120 1149 } 1121 Log() << Verbose(0) << AtomicMap[ Walker->nr] << "\t";1150 Log() << Verbose(0) << AtomicMap[(*iter)->nr] << "\t"; 1122 1151 } 1123 1152 Log() << Verbose(0) << endl; … … 1153 1182 void molecule::SetIndexedArrayForEachAtomTo ( atom **array, int ParticleInfo::*index) const 1154 1183 { 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); 1159 1186 } 1160 1187 }; -
src/molecule.hpp
re87acf r9879f6 137 137 iterator end(); 138 138 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 ); 139 145 140 146 … … 143 149 Vector *GetCenter() const ; 144 150 TesselPoint *GetPoint() const ; 145 TesselPoint *GetTerminalPoint() const ;146 151 int GetMaxId() const; 147 152 void GoToNext() const ; 148 void GoToPrevious() const ;149 153 void GoToFirst() const ; 150 void GoToLast() const ;151 154 bool IsEmpty() const ; 152 155 bool IsEnd() const ; … … 310 313 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); 311 314 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 315 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); 312 316 void BreadthFirstSearchAdd(molecule *Mol, atom **&AddedAtomList, bond **&AddedBondList, atom *Root, bond *Bond, int BondOrder, bool IsAngstroem); 313 317 /// -# BOSSANOVA … … 338 342 private: 339 343 int last_atom; //!< number given to last atom 340 mutable atom *InternalPointer; //!< internal pointer for PointCloud344 mutable iterator InternalPointer; //!< internal pointer for PointCloud 341 345 }; 342 346 -
src/molecule_dynamics.cpp
re87acf r9879f6 27 27 gsl_matrix *A = gsl_matrix_alloc(NDIM,NDIM); 28 28 gsl_vector *x = gsl_vector_alloc(NDIM); 29 atom * Runner = mol->start;30 29 atom *Sprinter = NULL; 31 30 Vector trajectory1, trajectory2, normal, TestVector; 32 31 double Norm1, Norm2, tmp, result = 0.; 33 32 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++) 37 35 break; 38 36 // determine normalized trajectories direction vector (n1, n2) … … 42 40 trajectory1.Normalize(); 43 41 Norm1 = trajectory1.Norm(); 44 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point42 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 45 43 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)); 47 45 trajectory2.Normalize(); 48 46 Norm2 = trajectory1.Norm(); 49 47 // check whether either is zero() 50 48 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)); 52 50 } else if (Norm1 < MYEPSILON) { 53 51 Sprinter = Params.PermutationMap[Walker->nr]; // find first target point 54 52 trajectory1.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep)); // copy first offset 55 trajectory1.SubtractVector(& Runner->Trajectory.R.at(Params.startstep)); // subtract second offset53 trajectory1.SubtractVector(&(*iter)->Trajectory.R.at(Params.startstep)); // subtract second offset 56 54 trajectory2.Scale( trajectory1.ScalarProduct(&trajectory2) ); // trajectory2 is scaled to unity, hence we don't need to divide by anything 57 55 trajectory1.SubtractVector(&trajectory2); // project the part in norm direction away 58 56 tmp = trajectory1.Norm(); // remaining norm is distance 59 57 } else if (Norm2 < MYEPSILON) { 60 Sprinter = Params.PermutationMap[ Runner->nr]; // find second target point58 Sprinter = Params.PermutationMap[(*iter)->nr]; // find second target point 61 59 trajectory2.CopyVector(&Sprinter->Trajectory.R.at(Params.endstep)); // copy second offset 62 60 trajectory2.SubtractVector(&Walker->Trajectory.R.at(Params.startstep)); // subtract first offset … … 65 63 tmp = trajectory2.Norm(); // remaining norm is distance 66 64 } 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: "; 68 66 // Log() << Verbose(0) << trajectory1; 69 67 // Log() << Verbose(0) << " and "; 70 68 // 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)); 72 70 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 73 71 } 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 "; 75 73 // Log() << Verbose(0) << endl; 76 74 // Log() << Verbose(0) << "First Trajectory: "; … … 88 86 gsl_matrix_set(A, 1, i, trajectory2.x[i]); 89 87 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])); 91 89 } 92 90 // solve the linear system by Householder transformations … … 96 94 // Log() << Verbose(0) << " with distance " << tmp << "." << endl; 97 95 // 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)); 99 97 trajectory2.Scale(gsl_vector_get(x,1)); 100 98 TestVector.AddVector(&trajectory2); … … 131 129 { 132 130 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)) { 137 133 // 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 "; 139 135 // Log() << Verbose(0) << Sprinter->Trajectory.R.at(endstep); 140 136 // Log() << Verbose(0) << ", penalting." << endl; … … 167 163 // go through every atom 168 164 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) { 172 166 // first term: distance to target 173 Runner = Params.PermutationMap[ Walker->nr]; // find target point174 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))); 175 169 tmp *= Params.IsAngstroem ? 1. : 1./AtomicLengthToAngstroem; 176 170 result += Params.PenaltyConstants[0] * tmp; … … 178 172 179 173 // second term: sum of distances to other trajectories 180 result += SumDistanceOfTrajectories( Walker, this, Params);174 result += SumDistanceOfTrajectories((*iter), this, Params); 181 175 182 176 // third term: penalty for equal targets 183 result += PenalizeEqualTargets( Walker, this, Params);177 result += PenalizeEqualTargets((*iter), this, Params); 184 178 } 185 179 … … 224 218 } 225 219 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)) ); 234 223 } 235 224 } … … 243 232 void CreateInitialLists(molecule *mol, struct EvaluatePotential &Params) 244 233 { 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; 253 240 } 254 241 }; … … 291 278 void MakeInjectivePermutation(molecule *mol, struct EvaluatePotential &Params) 292 279 { 293 atom *Walker = mol->start;280 molecule::const_iterator iter = mol->begin(); 294 281 DistanceMap::iterator NewBase; 295 282 double Potential = fabs(mol->ConstrainedPotential(Params)); 296 283 284 if (mol->empty()) { 285 eLog() << Verbose(1) << "Molecule is empty." << endl; 286 return; 287 } 297 288 while ((Potential) > Params.PenaltyConstants[2]) { 298 289 PrintPermutationMap(mol->AtomCount, Params); 299 Walker = Walker->next;300 if ( Walker == mol->end) // round-robin at the end301 Walker = mol->start->next;302 if (Params.DoubleList[Params.DistanceIterators[ Walker->nr]->second->nr] <= 1) // no need to make those injective that aren't290 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 303 294 continue; 304 295 // now, try finding a new one 305 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, Walker, Potential, Params);296 Potential = TryNextNearestNeighbourForInjectivePermutation(mol, (*iter), Potential, Params); 306 297 } 307 298 for (int i=mol->AtomCount; i--;) // now each single entry in the DoubleList should be <=1 … … 350 341 Params.StepList = Malloc<DistanceMap::iterator>(AtomCount, "molecule::MinimiseConstrainedPotential: Params.*StepList"); 351 342 int round; 352 atom * Walker = NULL, *Runner = NULL, *Sprinter = NULL;343 atom *Sprinter = NULL; 353 344 DistanceMap::iterator Rider, Strider; 354 345 … … 377 368 Log() << Verbose(2) << "Starting round " << ++round << ", at current potential " << OldPotential << " ... " << endl; 378 369 OlderPotential = OldPotential; 370 molecule::const_iterator iter; 379 371 do { 380 Walker = start; 381 while (Walker->next != end) { // pick one 382 Walker = Walker->next; 372 iter = begin(); 373 for (; iter != end(); ++iter) { 383 374 PrintPermutationMap(AtomCount, Params); 384 Sprinter = Params.DistanceIterators[ Walker->nr]->second; // store initial partner385 Strider = Params.DistanceIterators[ Walker->nr]; //remember old iterator386 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 on388 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(); 389 380 break; 390 381 } 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; 392 383 // 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; 397 388 break; 398 389 } 399 Runner = Runner->next;400 390 } 401 if ( Runner != end) { // we found the other source391 if (runner != end()) { // we found the other source 402 392 // 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++) 405 395 if (Rider->second == Sprinter) 406 396 break; 407 if (Rider != Params.DistanceList[ Runner->nr]->end()) { // if we have found one408 //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; 409 399 // exchange both 410 Params.PermutationMap[ Walker->nr] = Params.DistanceIterators[Walker->nr]->second; // put next farther distance into PermutationMap411 Params.PermutationMap[ Runner->nr] = Sprinter; // and hand the old target to its respective owner400 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 412 402 PrintPermutationMap(AtomCount, Params); 413 403 // calculate the new potential … … 416 406 if (Potential > OldPotential) { // we made everything worse! Undo ... 417 407 //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; 419 409 // 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; 421 411 // Undo for Walker 422 Params.DistanceIterators[ Walker->nr] = Strider; // take next farther distance target423 //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; 425 415 } else { 426 Params.DistanceIterators[ Runner->nr] = Rider; // if successful also move the pointer in the iterator list416 Params.DistanceIterators[(*runner)->nr] = Rider; // if successful also move the pointer in the iterator list 427 417 Log() << Verbose(3) << "Found a better permutation, new potential is " << Potential << " vs." << OldPotential << "." << endl; 428 418 OldPotential = Potential; … … 434 424 //Log() << Verbose(0) << endl; 435 425 } 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; 437 427 exit(255); 438 428 } 439 429 } 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! 441 431 } 442 Params.StepList[ Walker->nr]++; // take next farther distance target432 Params.StepList[(*iter)->nr]++; // take next farther distance target 443 433 } 444 } while ( Walker->next != end);434 } while (++iter != end()); 445 435 } while ((OlderPotential - OldPotential) > 1e-3); 446 436 Log() << Verbose(1) << "done." << endl; … … 489 479 // Get the Permutation Map by MinimiseConstrainedPotential 490 480 atom **PermutationMap = NULL; 491 atom * Walker = NULL, *Sprinter = NULL;481 atom *Sprinter = NULL; 492 482 if (!MapByIdentity) 493 483 MinimiseConstrainedPotential(PermutationMap, startstep, endstep, configuration.GetIsAngstroem()); … … 508 498 mol = World::get()->createMolecule(); 509 499 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) { 513 501 // add to molecule list 514 Sprinter = mol->AddCopyAtom( Walker);502 Sprinter = mol->AddCopyAtom((*iter)); 515 503 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); 517 505 // add to Trajectories 518 506 //Log() << Verbose(3) << step << ">=" << MDSteps-1 << endl; 519 507 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.; 523 511 } 524 512 } -
src/molecule_fragmentation.cpp
re87acf r9879f6 38 38 int FragmentCount; 39 39 // 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; 44 42 } 45 43 FragmentCount = NoNonHydrogen*(1 << (c*order)); … … 358 356 map<double, pair<int,int> > * ReMapAdaptiveCriteriaListToValue(map<int, pair<double,int> > *AdaptiveCriteriaList, molecule *mol) 359 357 { 360 atom *Walker = mol->start;358 atom *Walker = NULL; 361 359 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 362 360 Log() << Verbose(1) << "Root candidate list is: " << endl; … … 390 388 bool MarkUpdateCandidates(bool *AtomMask, map<double, pair<int,int> > &FinalRootCandidates, int Order, molecule *mol) 391 389 { 392 atom *Walker = mol->start;390 atom *Walker = NULL; 393 391 int No = -1; 394 392 bool status = false; … … 434 432 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 435 433 { 436 atom *Walker = start;437 434 bool status = false; 438 435 … … 456 453 if (AdaptiveCriteriaList->empty()) { 457 454 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) { 460 456 #ifdef ADDHYDROGEN 461 if ( Walker->type->Z != 1) // skip hydrogen457 if ((*iter)->type->Z != 1) // skip hydrogen 462 458 #endif 463 459 { 464 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms460 AtomMask[(*iter)->nr] = true; // include all (non-hydrogen) atoms 465 461 status = true; 466 462 } … … 477 473 Free(&FinalRootCandidates); 478 474 } 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) { 481 476 #ifdef ADDHYDROGEN 482 if ( Walker->type->Z != 1) // skip hydrogen477 if ((*iter)->type->Z != 1) // skip hydrogen 483 478 #endif 484 479 { 485 AtomMask[ Walker->nr] = true; // include all (non-hydrogen) atoms486 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])) 487 482 status = true; 488 483 } … … 523 518 524 519 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 */ 531 bool 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; 525 573 }; 526 574 … … 575 623 576 624 // create lookup table for Atom::nr 577 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable( start, end,ListOfAtoms, AtomCount);625 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, AtomCount); 578 626 579 627 // === compare it with adjacency file === … … 871 919 Leaf->CountAtoms(); 872 920 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(); ) { 876 925 LonelyFlag = true; 877 FatherOfRunner = Runner->father;926 FatherOfRunner = (*iter)->father; 878 927 if (SonList[FatherOfRunner->nr] != NULL) { // check if this, our father, is present in list 879 928 // create all bonds … … 886 935 // Log() << Verbose(3) << "Adding Bond: "; 887 936 // Log() << Verbose(0) << 888 Leaf->AddBond( Runner, SonList[OtherFather->nr], (*BondRunner)->BondDegree);937 Leaf->AddBond((*iter), SonList[OtherFather->nr], (*BondRunner)->BondDegree); 889 938 // Log() << Verbose(0) << "." << endl; 890 //NumBonds[ Runner->nr]++;939 //NumBonds[(*iter)->nr]++; 891 940 } else { 892 941 // Log() << Verbose(3) << "Not adding bond, labels in wrong order." << endl; … … 896 945 // Log() << Verbose(0) << ", who has no son in this fragment molecule." << endl; 897 946 #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)) 900 949 exit(1); 901 950 #endif 902 //NumBonds[ Runner->nr] += Binder->BondDegree;951 //NumBonds[(*iter)->nr] += Binder->BondDegree; 903 952 } 904 953 } 905 954 } 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; 907 956 } 908 957 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; 910 959 } 911 960 #ifdef ADDHYDROGEN 912 while (( Runner->next != Leaf->end) && (Runner->next->type->Z == 1)) // skip added hydrogen913 Runner = Runner->next;961 while ((iter != Leaf->end()) && ((*iter)->type->Z == 1)) // skip added hydrogen 962 iter++; 914 963 #endif 915 964 } … … 1559 1608 1560 1609 // Construct the complete KeySet which we need for topmost level only (but for all Roots) 1561 atom *Walker = start;1562 1610 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); 1566 1613 } 1567 1614 … … 1574 1621 RootKeyNr = RootStack.front(); 1575 1622 RootStack.pop_front(); 1576 Walker = FindAtom(RootKeyNr);1623 atom *Walker = FindAtom(RootKeyNr); 1577 1624 // check cyclic lengths 1578 1625 //if ((MinimumRingSize[Walker->GetTrueFather()->nr] != -1) && (Walker->GetTrueFather()->AdaptiveOrder+1 > MinimumRingSize[Walker->GetTrueFather()->nr])) { -
src/molecule_geometry.cpp
re87acf r9879f6 66 66 67 67 // Log() << Verbose(3) << "Begin of CenterEdge." << endl; 68 atom *ptr = start->next; // start at first in list69 if ( ptr != end) {//list not empty?68 molecule::const_iterator iter = begin(); // start at first in list 69 if (iter != end()) { //list not empty? 70 70 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); 77 76 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]; 80 79 } 81 80 } … … 101 100 { 102 101 int Num = 0; 103 atom *ptr = start; // start at first in list102 molecule::const_iterator iter = begin(); // start at first in list 104 103 105 104 Center.Zero(); 106 105 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 110 108 Num++; 111 Center.AddVector(& ptr->x);109 Center.AddVector(&(*iter)->x); 112 110 } 113 111 Center.Scale(-1./Num); // divide through total number (and sign for direction) … … 122 120 Vector * molecule::DetermineCenterOfAll() const 123 121 { 124 atom *ptr = start->next; // start at first in list122 molecule::const_iterator iter = begin(); // start at first in list 125 123 Vector *a = new Vector(); 126 124 Vector tmp; … … 129 127 a->Zero(); 130 128 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 134 131 Num += 1.; 135 tmp.CopyVector(& ptr->x);132 tmp.CopyVector(&(*iter)->x); 136 133 a->AddVector(&tmp); 137 134 } … … 147 144 Vector * molecule::DetermineCenterOfGravity() 148 145 { 149 atom *ptr = start->next; // start at first in list146 molecule::const_iterator iter = begin(); // start at first in list 150 147 Vector *a = new Vector(); 151 148 Vector tmp; … … 154 151 a->Zero(); 155 152 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 162 158 a->AddVector(&tmp); 163 159 } … … 195 191 void molecule::Scale(const double ** const factor) 196 192 { 197 atom *ptr = start; 198 199 while (ptr->next != end) { 200 ptr = ptr->next; 193 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 201 194 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); 204 197 } 205 198 }; … … 210 203 void molecule::Translate(const Vector *trans) 211 204 { 212 atom *ptr = start; 213 214 while (ptr->next != end) { 215 ptr = ptr->next; 205 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 216 206 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); 219 209 } 220 210 }; … … 251 241 void molecule::DeterminePeriodicCenter(Vector ¢er) 252 242 { 253 atom *Walker = start;254 243 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 255 244 double *inversematrix = InverseMatrix(cell_size); … … 261 250 Center.Zero(); 262 251 flag = true; 263 while (Walker->next != end) { 264 Walker = Walker->next; 252 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 265 253 #ifdef ADDHYDROGEN 266 if ( Walker->type->Z != 1) {254 if ((*iter)->type->Z != 1) { 267 255 #endif 268 Testvector.CopyVector(& Walker->x);256 Testvector.CopyVector(&(*iter)->x); 269 257 Testvector.MatrixMultiplication(inversematrix); 270 258 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 nothing259 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 273 261 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]; 275 263 if ((fabs(tmp)) > BondDistance) { 276 264 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; 278 266 if (tmp > 0) 279 267 Translationvector.x[j] -= 1.; … … 291 279 #ifdef ADDHYDROGEN 292 280 // 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); 296 284 Testvector.MatrixMultiplication(inversematrix); 297 285 Testvector.AddVector(&Translationvector); … … 320 308 void molecule::PrincipalAxisSystem(bool DoRotate) 321 309 { 322 atom *ptr = start; // start at first in list323 310 double InertiaTensor[NDIM*NDIM]; 324 311 Vector *CenterOfGravity = DetermineCenterOfGravity(); … … 331 318 332 319 // sum up inertia tensor 333 while (ptr->next != end) { 334 ptr = ptr->next; 320 for (molecule::const_iterator iter = begin(); iter != end(); ++iter) { 335 321 Vector x; 336 x.CopyVector(& ptr->x);322 x.CopyVector(&(*iter)->x); 337 323 //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]); 347 333 } 348 334 // print InertiaTensor for debugging … … 382 368 383 369 // 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) { 387 371 Vector x; 388 x.CopyVector(& ptr->x);372 x.CopyVector(&(*iter)->x); 389 373 //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]); 399 383 } 400 384 // print InertiaTensor for debugging … … 420 404 void molecule::Align(Vector *n) 421 405 { 422 atom *ptr = start;423 406 double alpha, tmp; 424 407 Vector z_axis; … … 431 414 alpha = atan(-n->x[0]/n->x[2]); 432 415 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]; 438 420 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]; 442 424 } 443 425 } … … 451 433 452 434 // rotate on z-y plane 453 ptr = start;454 435 alpha = atan(-n->x[1]/n->x[2]); 455 436 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]; 461 441 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]; 465 445 } 466 446 } … … 487 467 Vector a,b,c,d; 488 468 struct lsq_params *par = (struct lsq_params *)params; 489 atom *ptr = par->mol->start;490 469 491 470 // initialize vectors … … 497 476 b.x[2] = gsl_vector_get(x,5); 498 477 // 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 503 481 c.SubtractVector(&a); // subtract offset vector 504 482 t = c.ScalarProduct(&b); // get direction parameter -
src/molecule_graph.cpp
re87acf r9879f6 135 135 Log() << Verbose(2) << "Creating TesselPoint to atom map ... " << endl; 136 136 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); 141 139 } 142 140 … … 496 494 DepthFirstSearchAnalysis_Init(DFS, this); 497 495 498 DFS.Root = start->next;499 while (DFS.Root != end) { // if there any atoms at all496 for (molecule::const_iterator iter = begin(); iter != end();) { 497 DFS.Root = *iter; 500 498 // (1) mark all edges unused, empty stack, set atom->GraphNr = -1 for all 501 499 DFS.AtomStack->ClearStack(); … … 537 535 538 536 // 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 on542 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++; 543 541 } 544 542 } … … 843 841 if (MinRingSize != -1) { // if rings are present 844 842 // 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; 848 845 849 846 if (MinimumRingSize[Root->GetTrueFather()->nr] == mol->AtomCount) { // check whether MinimumRingSize is set, if not BFS to next where it is … … 1352 1349 // fill parent list with sons 1353 1350 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); 1358 1353 // 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; 1360 1355 } 1361 1356 … … 1372 1367 { 1373 1368 bool status = true; 1374 atom *Walker = NULL;1375 1369 atom *OtherAtom = NULL; 1376 1370 // check each entry of parent list and if ok (one-to-and-onto matching) create bonds 1377 1371 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)) { 1383 1375 status = false; 1384 1376 } 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)); 1387 1379 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); 1390 1382 } 1391 1383 } -
src/molecule_pointcloud.cpp
re87acf r9879f6 8 8 #include "atom.hpp" 9 9 #include "config.hpp" 10 #include "info.hpp" 10 11 #include "memoryallocator.hpp" 11 12 #include "molecule.hpp" … … 31 32 }; 32 33 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. 35 37 */ 36 TesselPoint *molecule::GetPoint() const38 TesselPoint* molecule::GetPoint() const 37 39 { 38 if ((InternalPointer != start) && (InternalPointer != end)) 39 return InternalPointer; 40 else 41 return NULL; 40 Info FunctionInfo(__func__); 41 return (*InternalPointer); 42 42 }; 43 43 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. 62 46 */ 63 47 void molecule::GoToNext() const 64 48 { 65 if (InternalPointer != end) 66 InternalPointer = InternalPointer->next; 49 Info FunctionInfo(__func__); 50 if (InternalPointer != end()) 51 InternalPointer++; 67 52 }; 68 53 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. 79 56 */ 80 57 void molecule::GoToFirst() const 81 58 { 82 InternalPointer = start->next; 59 Info FunctionInfo(__func__); 60 InternalPointer = begin(); 83 61 }; 84 62 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. 94 65 */ 95 66 bool molecule::IsEmpty() const 96 67 { 97 return (start->next == end); 68 Info FunctionInfo(__func__); 69 return (empty()); 98 70 }; 99 71 100 /** Checks whether we are at the last atom101 * \return true - current atom is last one, false - is not last one72 /** PointCloud implementation of IsLast. 73 * Uses atoms and STL stuff. 102 74 */ 103 75 bool molecule::IsEnd() const 104 76 { 105 return (InternalPointer == end); 77 Info FunctionInfo(__func__); 78 return (InternalPointer == end()); 106 79 }; -
src/molecule_template.hpp
re87acf r9879f6 24 24 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() ) const 25 25 { 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)(); 30 28 } 31 29 }; 32 30 template <typename res> void molecule::ActOnAllVectors( res (Vector::*f)() const ) const 33 31 { 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)(); 38 34 } 39 35 }; … … 41 37 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T), T t ) const 42 38 { 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); 47 41 } 48 42 }; 49 43 template <typename res, typename T> void molecule::ActOnAllVectors( res (Vector::*f)(T) const, T t ) const 50 44 { 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); 55 47 } 56 48 }; … … 58 50 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U), T t, U u ) const 59 51 { 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); 64 54 } 65 55 }; 66 56 template <typename res, typename T, typename U> void molecule::ActOnAllVectors( res (Vector::*f)(T, U) const, T t, U u ) const 67 57 { 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); 72 60 } 73 61 }; … … 75 63 template <typename res, typename T, typename U, typename V> void molecule::ActOnAllVectors( res (Vector::*f)(T, U, V), T t, U u, V v) const 76 64 { 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); 81 67 } 82 68 }; 83 69 template <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 84 70 { 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); 89 73 } 90 74 }; … … 96 80 { 97 81 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)(); 102 84 } 103 85 return result; … … 106 88 { 107 89 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)(); 112 92 } 113 93 return result; … … 117 97 { 118 98 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); 123 101 } 124 102 return result; … … 127 105 { 128 106 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); 133 109 } 134 110 return result; … … 141 117 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *)) const 142 118 { 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)); 147 121 } 148 122 }; 149 123 template <typename res> void molecule::ActWithEachAtom( res (molecule::*f)(atom *) const) const 150 124 { 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)); 155 127 } 156 128 }; … … 161 133 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) , molecule *copy) const 162 134 { 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)); 167 137 } 168 138 }; 169 139 template <typename res> void molecule::ActOnCopyWithEachAtom( res (molecule::*f)(atom *) const, molecule *copy) const 170 140 { 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)); 175 143 } 176 144 }; … … 181 149 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () ) const 182 150 { 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)); 188 154 } 189 155 }; 190 156 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) () const ) const 191 157 { 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)); 197 161 } 198 162 }; 199 163 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const , molecule *copy, bool (atom::*condition) () ) const 200 164 { 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)); 206 168 } 207 169 }; 208 170 template <typename res> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) () const ) const 209 171 { 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)); 215 175 } 216 176 }; … … 218 178 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T), T t ) const 219 179 { 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)); 225 183 } 226 184 }; 227 185 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) , molecule *copy, bool (atom::*condition) (T) const, T t ) const 228 186 { 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)); 234 190 } 235 191 }; 236 192 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T), T t ) const 237 193 { 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)); 243 197 } 244 198 }; 245 199 template <typename res, typename T> void molecule::ActOnCopyWithEachAtomIfTrue( res (molecule::*f)(atom *) const, molecule *copy, bool (atom::*condition) (T) const, T t ) const 246 200 { 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)); 252 204 } 253 205 }; … … 255 207 template <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 256 208 { 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)); 262 212 } 263 213 }; 264 214 template <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 265 215 { 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)); 271 219 } 272 220 }; 273 221 template <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 274 222 { 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)); 280 226 } 281 227 }; 282 228 template <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 283 229 { 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)); 289 233 } 290 234 }; … … 292 236 template <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 293 237 { 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)); 299 241 } 300 242 }; 301 243 template <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 302 244 { 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)); 308 248 } 309 249 }; 310 250 template <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 311 251 { 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)); 317 255 } 318 256 }; 319 257 template <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 320 258 { 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)); 326 262 } 327 263 }; … … 332 268 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)()) const 333 269 { 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)(); 338 272 } 339 273 }; 340 274 template <typename res, typename typ> void molecule::ActOnAllAtoms( res (typ::*f)() const) const 341 275 { 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)(); 346 278 } 347 279 }; … … 349 281 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T), T t ) const 350 282 { 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); 355 285 } 356 286 }; 357 287 template <typename res, typename typ, typename T> void molecule::ActOnAllAtoms( res (typ::*f)(T) const, T t ) const 358 288 { 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); 363 291 } 364 292 }; … … 366 294 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U), T t, U u ) const 367 295 { 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); 372 298 } 373 299 }; 374 300 template <typename res, typename typ, typename T, typename U> void molecule::ActOnAllAtoms( res (typ::*f)(T, U) const, T t, U u ) const 375 301 { 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); 380 304 } 381 305 }; … … 383 307 template <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 384 308 { 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); 389 311 } 390 312 }; 391 313 template <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 392 314 { 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); 397 317 } 398 318 }; … … 400 320 template <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 401 321 { 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); 406 324 } 407 325 }; 408 326 template <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 409 327 { 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); 414 330 } 415 331 }; … … 420 336 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *) ) const 421 337 { 422 atom *Walker = start;423 338 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); 427 341 } 428 342 }; 429 343 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T value ) const 430 344 { 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); 435 347 } 436 348 }; 437 349 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, void (*Setor)(T *, T *), T *value ) const 438 350 { 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); 443 353 } 444 354 }; … … 446 356 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *) ) const 447 357 { 448 atom *Walker = start;449 358 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); 453 361 } 454 362 }; 455 363 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T value ) const 456 364 { 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); 461 367 } 462 368 }; 463 369 template <typename T> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int element::*index, void (*Setor)(T *, T *), T *value ) const 464 370 { 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); 469 373 } 470 374 }; … … 472 376 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ atom::*value ) const 473 377 { 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); 478 380 } 479 381 }; 480 382 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ atom::*value ) const 481 383 { 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); 486 386 } 487 387 }; 488 388 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &), typ &vect ) const 489 389 { 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); 494 392 } 495 393 }; 496 394 template <typename T, typename typ> void molecule::SetIndexedArrayForEachAtomTo ( T *array, int ParticleInfo::*index, T (atom::*Setor)(typ &) const, typ &vect ) const 497 395 { 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); 502 398 } 503 399 }; 504 400 template <typename T, typename typ, typename typ2> void molecule::SetAtomValueToIndexedArray ( T *array, int typ::*index, T typ2::*value ) const 505 401 { 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; 511 405 } 512 406 }; … … 514 408 template <typename T, typename typ> void molecule::SetAtomValueToValue ( T value, T typ::*ptr ) const 515 409 { 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; 521 413 } 522 414 }; -
src/moleculelist.cpp
re87acf r9879f6 68 68 int Count, Counter, aCounter, bCounter; 69 69 int flag; 70 atom *aWalker = NULL;71 atom *bWalker = NULL;72 70 73 71 // sort each atom list and put the numbers into a list, then go through … … 84 82 85 83 // fill the lists 86 aWalker = (**(molecule **) a).start;87 bWalker = (**(molecule **) b).start;88 84 Counter = 0; 89 85 aCounter = 0; 90 86 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) 95 92 aList[Counter] = Count + (aCounter++); 96 93 else 97 aList[Counter] = aWalker->GetTrueFather()->nr;98 if ( bWalker->GetTrueFather() == NULL)94 aList[Counter] = (*aiter)->GetTrueFather()->nr; 95 if ((*biter)->GetTrueFather() == NULL) 99 96 bList[Counter] = Count + (bCounter++); 100 97 else 101 bList[Counter] = bWalker->GetTrueFather()->nr;98 bList[Counter] = (*biter)->GetTrueFather()->nr; 102 99 Counter++; 103 100 } 104 101 // check if AtomCount was for real 105 102 flag = 0; 106 if ((a Walker->next == (**(molecule **) a).end) && (bWalker->next != (**(molecule **) b).end)) {103 if ((aiter == (**(molecule **) a).end()) && (biter != (**(molecule **) b).end())) { 107 104 flag = -1; 108 105 } else { 109 if ((a Walker->next != (**(molecule **) a).end) && (bWalker->next == (**(molecule **) b).end))106 if ((aiter != (**(molecule **) a).end()) && (biter == (**(molecule **) b).end())) 110 107 flag = 1; 111 108 } … … 142 139 { 143 140 element* Elemental = NULL; 144 atom *Walker = NULL;145 141 int Counts[MAX_ELEMENTS]; 146 142 double size=0; … … 160 156 // count atoms per element and determine size of bounding sphere 161 157 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); 168 162 } 169 163 // output Index, Name, number of atoms, chemical formula … … 204 198 205 199 // 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)); 213 205 } 214 206 … … 230 222 231 223 // 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)); 238 227 Walker->father = Walker; 239 228 } … … 338 327 339 328 // for each of the source atoms check whether we are in- or outside and add copy atom 340 atom *Walker = srcmol->start;341 329 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]); 348 335 nr++; 349 336 } else { … … 384 371 bool MoleculeListClass::AddHydrogenCorrection(char *path) 385 372 { 386 atom *Walker = NULL;387 atom *Runner = NULL;388 373 bond *Binder = NULL; 389 374 double ***FitConstant = NULL, **correction = NULL; … … 490 475 correction[k][j] = 0.; 491 476 // 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; 502 483 // 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!) 505 486 // 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; 508 489 for (int k = 0; k < a; k++) { 509 490 for (int j = 0; j < b; j++) { … … 579 560 ofstream ForcesFile; 580 561 stringstream line; 581 atom *Walker = NULL;582 562 element *runner = NULL; 583 563 … … 594 574 runner = runner->next; 595 575 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"; 603 581 } else 604 582 // otherwise a -1 to indicate an added saturation hydrogen … … 636 614 bool result = true; 637 615 bool intermediateResult = true; 638 atom *Walker = NULL;639 616 Vector BoxDimension; 640 617 char *FragmentNumber = NULL; … … 672 649 // list atoms in fragment for debugging 673 650 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 << " "; 678 653 } 679 654 Log() << Verbose(0) << endl; … … 751 726 { 752 727 molecule *mol = World::get()->createMolecule(); 753 atom *Walker = NULL;754 atom *Advancer = NULL;755 728 bond *Binder = NULL; 756 729 bond *Stepper = NULL; … … 758 731 for (MoleculeList::iterator MolRunner = ListOfMolecules.begin(); !ListOfMolecules.empty(); MolRunner = ListOfMolecules.begin()) { 759 732 // 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); 768 738 } 769 739 // remove all bonds … … 812 782 int *MolMap = Calloc<int>(mol->AtomCount, "config::Load() - *MolMap"); 813 783 MoleculeLeafClass *MolecularWalker = Subgraphs; 814 Walker = NULL;815 784 while (MolecularWalker->next != NULL) { 816 785 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; 821 788 } 822 789 FragmentCounter++; … … 824 791 825 792 // 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; 831 796 performCriticalExit(); 832 797 } 833 FragmentCounter = MolMap[ Walker->nr];798 FragmentCounter = MolMap[(*iter)->nr]; 834 799 if (FragmentCounter != 0) { 835 Log() << Verbose(3) << "Re-linking " << * Walker<< "..." << endl;836 unlink(Walker);837 mol ecules[FragmentCounter-1]->AddAtom(Walker); // counting starts at 1800 Log() << Verbose(3) << "Re-linking " << *(*iter) << "..." << endl; 801 molecules[FragmentCounter-1]->AddAtom((*iter)); // counting starts at 1 802 mol->erase(iter); 838 803 } else { 839 eLog() << Verbose(0) << "Atom " << * Walker<< " not associated to molecule!" << endl;804 eLog() << Verbose(0) << "Atom " << *(*iter) << " not associated to molecule!" << endl; 840 805 performCriticalExit(); 841 806 } … … 845 810 while (mol->first->next != mol->last) { 846 811 Binder = mol->first->next; 847 Walker = Binder->leftatom;812 const atom * const Walker = Binder->leftatom; 848 813 unlink(Binder); 849 814 link(Binder,molecules[MolMap[Walker->nr]-1]->last); // counting starts at 1 … … 867 832 int MoleculeListClass::CountAllAtoms() const 868 833 { 869 atom *Walker = NULL;870 834 int AtomNo = 0; 871 835 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(); 877 837 } 878 838 return AtomNo; … … 1049 1009 bool MoleculeLeafClass::FillBondStructureFromReference(const molecule * const reference, int &FragmentCounter, atom ***&ListOfLocalAtoms, bool FreeList) 1050 1010 { 1051 atom *Walker = NULL;1052 1011 atom *OtherWalker = NULL; 1053 1012 atom *Father = NULL; … … 1073 1032 } 1074 1033 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(); 1079 1036 AtomNo = Father->nr; // global id of the current walker 1080 1037 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 walker1038 OtherWalker = ListOfLocalAtoms[FragmentCounter][(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker 1082 1039 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); 1085 1042 } 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; 1087 1044 status = false; 1088 1045 } … … 1111 1068 bool MoleculeLeafClass::FillRootStackForSubgraphs(KeyStack *&RootStack, bool *AtomMask, int &FragmentCounter) 1112 1069 { 1113 atom * Walker = NULL, *Father = NULL;1070 atom *Father = NULL; 1114 1071 1115 1072 if (RootStack != NULL) { … … 1117 1074 if (&(RootStack[FragmentCounter]) != NULL) { 1118 1075 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(); 1123 1078 if (AtomMask[Father->nr]) // apply mask 1124 1079 #ifdef ADDHYDROGEN 1125 if ( Walker->type->Z != 1) // skip hydrogen1080 if ((*iter)->type->Z != 1) // skip hydrogen 1126 1081 #endif 1127 RootStack[FragmentCounter].push_front( Walker->nr);1082 RootStack[FragmentCounter].push_front((*iter)->nr); 1128 1083 } 1129 1084 if (next != NULL) … … 1164 1119 1165 1120 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); 1167 1122 FreeList = FreeList && true; 1168 1123 } -
src/tesselation.cpp
re87acf r9879f6 1100 1100 }; 1101 1101 1102 /** PointCloud implementation of GetTerminalPoint.1103 * Uses PointsOnBoundary and STL stuff.1104 */1105 TesselPoint * Tesselation::GetTerminalPoint() const1106 {1107 Info FunctionInfo(__func__);1108 PointMap::const_iterator Runner = PointsOnBoundary.end();1109 Runner--;1110 return (Runner->second->node);1111 };1112 1113 1102 /** PointCloud implementation of GoToNext. 1114 1103 * Uses PointsOnBoundary and STL stuff. … … 1121 1110 }; 1122 1111 1123 /** PointCloud implementation of GoToPrevious.1124 * Uses PointsOnBoundary and STL stuff.1125 */1126 void Tesselation::GoToPrevious() const1127 {1128 Info FunctionInfo(__func__);1129 if (InternalPointer != PointsOnBoundary.begin())1130 InternalPointer--;1131 };1132 1133 1112 /** PointCloud implementation of GoToFirst. 1134 1113 * Uses PointsOnBoundary and STL stuff. … … 1138 1117 Info FunctionInfo(__func__); 1139 1118 InternalPointer = PointsOnBoundary.begin(); 1140 };1141 1142 /** PointCloud implementation of GoToLast.1143 * Uses PointsOnBoundary and STL stuff.1144 */1145 void Tesselation::GoToLast() const1146 {1147 Info FunctionInfo(__func__);1148 InternalPointer = PointsOnBoundary.end();1149 InternalPointer--;1150 1119 }; 1151 1120 -
src/tesselation.hpp
re87acf r9879f6 234 234 virtual Vector *GetCenter() const { return NULL; }; 235 235 virtual TesselPoint *GetPoint() const { return NULL; }; 236 virtual TesselPoint *GetTerminalPoint() const { return NULL; };237 236 virtual int GetMaxId() const { return 0; }; 238 237 virtual void GoToNext() const {}; 239 virtual void GoToPrevious() const {};240 238 virtual void GoToFirst() const {}; 241 virtual void GoToLast() const {};242 239 virtual bool IsEmpty() const { return true; }; 243 240 virtual bool IsEnd() const { return true; }; … … 342 339 virtual Vector *GetCenter(ofstream *out) const; 343 340 virtual TesselPoint *GetPoint() const; 344 virtual TesselPoint *GetTerminalPoint() const;345 341 virtual void GoToNext() const; 346 virtual void GoToPrevious() const;347 342 virtual void GoToFirst() const; 348 virtual void GoToLast() const;349 343 virtual bool IsEmpty() const; 350 344 virtual bool IsEnd() const; -
src/unittests/AnalysisCorrelationToPointUnitTest.cpp
re87acf r9879f6 25 25 #include "periodentafel.hpp" 26 26 #include "tesselation.hpp" 27 #include "World.hpp"28 27 29 28 #ifdef HAVE_TESTRUNNER -
src/unittests/analysisbondsunittest.cpp
re87acf r9879f6 25 25 #include "molecule.hpp" 26 26 #include "periodentafel.hpp" 27 #include "World.hpp" 27 28 28 29 #ifdef HAVE_TESTRUNNER -
src/unittests/bondgraphunittest.cpp
re87acf r9879f6 110 110 }; 111 111 112 /** Tests whether setup worked. 113 */ 114 void BondGraphTest::SetupTest() 115 { 116 CPPUNIT_ASSERT_EQUAL (false, TestMolecule->empty()); 117 CPPUNIT_ASSERT_EQUAL ((size_t)4, TestMolecule->size()); 118 }; 119 112 120 /** UnitTest for BondGraphTest::LoadBondLengthTable(). 113 121 */ … … 124 132 void BondGraphTest::ConstructGraphTest() 125 133 { 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++; 129 137 CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) ); 130 138 CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) ); 131 CPPUNIT_ASSERT_EQUAL( true , Walker->IsBondedTo(Runner) );139 CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) ); 132 140 }; -
src/unittests/bondgraphunittest.hpp
re87acf r9879f6 22 22 { 23 23 CPPUNIT_TEST_SUITE( BondGraphTest) ; 24 CPPUNIT_TEST ( SetupTest ); 24 25 CPPUNIT_TEST ( LoadTableTest ); 25 26 CPPUNIT_TEST ( ConstructGraphTest ); … … 29 30 void setUp(); 30 31 void tearDown(); 32 void SetupTest(); 31 33 void LoadTableTest(); 32 34 void ConstructGraphTest(); -
src/unittests/listofbondsunittest.cpp
re87acf r9879f6 90 90 }; 91 91 92 /** Tests whether setup worked correctly. 93 * 94 */ 95 void ListOfBondsTest::SetupTest() 96 { 97 CPPUNIT_ASSERT_EQUAL( false, TestMolecule->empty() ); 98 CPPUNIT_ASSERT_EQUAL( (size_t)4, TestMolecule->size() ); 99 }; 100 92 101 /** Unit Test of molecule::AddBond() 93 102 * … … 96 105 { 97 106 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; 100 111 CPPUNIT_ASSERT( atom1 != NULL ); 101 112 CPPUNIT_ASSERT( atom2 != NULL ); … … 124 135 { 125 136 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; 128 141 CPPUNIT_ASSERT( atom1 != NULL ); 129 142 CPPUNIT_ASSERT( atom2 != NULL ); … … 150 163 { 151 164 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; 155 171 CPPUNIT_ASSERT( atom1 != NULL ); 156 172 CPPUNIT_ASSERT( atom2 != NULL ); … … 189 205 { 190 206 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; 193 211 CPPUNIT_ASSERT( atom1 != NULL ); 194 212 CPPUNIT_ASSERT( atom2 != NULL ); … … 215 233 { 216 234 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; 219 239 CPPUNIT_ASSERT( atom1 != NULL ); 220 240 CPPUNIT_ASSERT( atom2 != NULL ); … … 240 260 { 241 261 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; 244 266 CPPUNIT_ASSERT( atom1 != NULL ); 245 267 CPPUNIT_ASSERT( atom2 != NULL ); -
src/unittests/listofbondsunittest.hpp
re87acf r9879f6 20 20 { 21 21 CPPUNIT_TEST_SUITE( ListOfBondsTest) ; 22 CPPUNIT_TEST ( SetupTest ); 22 23 CPPUNIT_TEST ( AddingBondTest ); 23 24 CPPUNIT_TEST ( RemovingBondTest ); … … 31 32 void setUp(); 32 33 void tearDown(); 34 void SetupTest(); 33 35 void AddingBondTest(); 34 36 void RemovingBondTest();
Note:
See TracChangeset
for help on using the changeset viewer.