Changes in src/Legacy/oldmenu.cpp [112b09:42a101]
- File:
-
- 1 edited
-
src/Legacy/oldmenu.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
r112b09 r42a101 6 6 * 7 7 */ 8 9 #include "Helpers/MemDebug.hpp"10 8 11 9 #include "Legacy/oldmenu.hpp" … … 38 36 #include "Menu/DisplayMenuItem.hpp" 39 37 #include "Menu/SubMenuItem.hpp" 40 #include "Actions/MapOfActions.hpp"41 38 #include "Actions/MethodAction.hpp" 42 39 #include "Actions/ErrorAction.hpp" … … 427 424 void oldmenu::RemoveAtoms(molecule *mol) 428 425 { 429 atom * second;426 atom *first, *second; 430 427 int axis; 431 428 double tmp1, tmp2; … … 450 447 break; 451 448 case 'b': 452 {453 second = mol->AskAtom("Enter number of atom as reference point: ");454 Log() << Verbose(0) << "Enter radius: ";455 cin >> tmp1;456 molecule::iterator runner;457 for (molecule::iterator iter = mol->begin(); iter != mol->end();) {458 runner = iter++;459 if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...460 mol->RemoveAtom((*runner));461 }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(second->x) > tmp1*tmp1) // distance to first above radius ... 458 mol->RemoveAtom(first); 462 459 } 463 460 break; … … 469 466 Log() << Verbose(0) << "Upper boundary: "; 470 467 cin >> tmp2; 471 molecule::iterator runner; 472 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 473 runner = iter++; 474 if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ... 475 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 476 mol->RemoveAtom((*runner)); 468 first = mol->start; 469 second = first->next; 470 while(second != mol->end) { 471 first = second; 472 second = first->next; 473 if ((first->x[axis] < tmp1) || (first->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); 477 476 } 478 477 } … … 517 516 min[i] = 0.; 518 517 519 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 520 Z = (*iter)->type->Z; 518 second = mol->start; 519 while ((second->next != mol->end)) { 520 second = second->next; // advance 521 Z = second->type->Z; 521 522 tmp1 = 0.; 522 if (first != (*iter)) {523 x = first->x - (*iter)->x;523 if (first != second) { 524 x = first->x - second->x; 524 525 tmp1 = x.Norm(); 525 526 } 526 527 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1; 527 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;528 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl; 528 529 } 529 530 for (int i=MAX_ELEMENTS;i--;) … … 608 609 Log() << Verbose(0) << "What's the desired bond order: "; 609 610 cin >> Order1; 610 if (mol-> hasBondStructure()) {611 if (mol->first->next != mol->last) { // there are bonds 611 612 start = clock(); 612 613 mol->FragmentMolecule(Order1, configuration); … … 754 755 Log() << Verbose(0) << "State the factor: "; 755 756 cin >> faktor; 756 if (mol->getAtomCount() != 0) { // if there is more than none 757 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 757 758 mol->CountAtoms(); // recount atoms 759 if (mol->AtomCount != 0) { // if there is more than none 760 count = mol->AtomCount; // is changed becausing of adding, thus has to be stored away beforehand 758 761 Elements = new const element *[count]; 759 762 vectors = new Vector *[count]; 760 763 j = 0; 761 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 762 Elements[j] = (*iter)->type; 763 vectors[j] = &(*iter)->x; 764 first = mol->start; 765 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 766 first = first->next; 767 Elements[j] = first->type; 768 vectors[j] = &first->x; 764 769 j++; 765 770 } … … 778 783 } 779 784 } 780 if (mol-> hasBondStructure())785 if (mol->first->next != mol->last) // if connect matrix is present already, redo it 781 786 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 782 787 // free memory … … 904 909 molecule *srcmol = NULL, *destmol = NULL; 905 910 Dialog *dialog = UIFactory::getInstance().makeDialog(); 906 dialog->queryMolecule(" molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));907 dialog->queryMolecule(" molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));911 dialog->queryMolecule("Enter index of destination molecule: ",&destmol, molecules); 912 dialog->queryMolecule("Enter index of source molecule to add from: ",&srcmol, molecules); 908 913 if(dialog->display()) { 909 914 molecules->SimpleAdd(srcmol, destmol); … … 918 923 molecule *srcmol = NULL, *destmol = NULL; 919 924 Dialog *dialog = UIFactory::getInstance().makeDialog(); 920 dialog->queryMolecule(" molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));921 dialog->queryMolecule(" molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));925 dialog->queryMolecule("Enter index of matrix molecule (the variable one): ",&srcmol,molecules); 926 dialog->queryMolecule("Enter index of molecule to merge into (the fixed one): ",&destmol,molecules); 922 927 if(dialog->display()) { 923 928 molecules->EmbedMerge(destmol, srcmol); … … 1020 1025 return; 1021 1026 } 1027 atom *Walker = mol->start; 1022 1028 1023 1029 // generate some KeySets 1024 1030 Log() << Verbose(0) << "Generating KeySets." << endl; 1025 KeySet TestSets[mol-> getAtomCount()+1];1031 KeySet TestSets[mol->AtomCount+1]; 1026 1032 i=1; 1027 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1033 while (Walker->next != mol->end) { 1034 Walker = Walker->next; 1028 1035 for (int j=0;j<i;j++) { 1029 TestSets[j].insert( (*iter)->nr);1036 TestSets[j].insert(Walker->nr); 1030 1037 } 1031 1038 i++; … … 1033 1040 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1034 1041 KeySetTestPair test; 1035 molecule::const_iterator iter = mol->begin(); 1036 if (iter != mol->end()) { 1037 test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr); 1038 if (test.second) { 1039 Log() << Verbose(1) << "Insertion worked?!" << endl; 1040 } else { 1041 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl; 1042 } 1042 test = TestSets[mol->AtomCount-1].insert(Walker->nr); 1043 if (test.second) { 1044 Log() << Verbose(1) << "Insertion worked?!" << endl; 1043 1045 } else { 1044 eLog() << Verbose(1) << "No atoms to test double insertion." << endl; 1045 } 1046 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl; 1047 } 1048 TestSets[mol->AtomCount].insert(mol->end->previous->nr); 1049 TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr); 1046 1050 1047 1051 // constructing Graph structure … … 1051 1055 // insert KeySets into Subgraphs 1052 1056 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl; 1053 for (int j=0;j<mol-> getAtomCount();j++) {1057 for (int j=0;j<mol->AtomCount;j++) { 1054 1058 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1055 1059 } 1056 1060 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1057 1061 GraphTestPair test2; 1058 test2 = Subgraphs.insert(GraphPair (TestSets[mol-> getAtomCount()],pair<int, double>(counter++, 1.)));1062 test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.))); 1059 1063 if (test2.second) { 1060 1064 Log() << Verbose(1) << "Insertion worked?!" << endl;
Note:
See TracChangeset
for help on using the changeset viewer.
