Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r112b09 r42a101  
    66 *
    77 */
    8 
    9 #include "Helpers/MemDebug.hpp"
    108
    119#include "Legacy/oldmenu.hpp"
     
    3836#include "Menu/DisplayMenuItem.hpp"
    3937#include "Menu/SubMenuItem.hpp"
    40 #include "Actions/MapOfActions.hpp"
    4138#include "Actions/MethodAction.hpp"
    4239#include "Actions/ErrorAction.hpp"
     
    427424void oldmenu::RemoveAtoms(molecule *mol)
    428425{
    429   atom *second;
     426  atom *first, *second;
    430427  int axis;
    431428  double tmp1, tmp2;
     
    450447      break;
    451448    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);
    462459      }
    463460      break;
     
    469466      Log() << Verbose(0) << "Upper boundary: ";
    470467      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);
    477476        }
    478477      }
     
    517516        min[i] = 0.;
    518517
    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;
    521522        tmp1 = 0.;
    522         if (first != (*iter)) {
    523           x = first->x - (*iter)->x;
     523        if (first != second) {
     524          x = first->x - second->x;
    524525          tmp1 = x.Norm();
    525526        }
    526527        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;
    528529      }
    529530      for (int i=MAX_ELEMENTS;i--;)
     
    608609  Log() << Verbose(0) << "What's the desired bond order: ";
    609610  cin >> Order1;
    610   if (mol->hasBondStructure()) {
     611  if (mol->first->next != mol->last) {  // there are bonds
    611612    start = clock();
    612613    mol->FragmentMolecule(Order1, configuration);
     
    754755    Log() << Verbose(0) << "State the factor: ";
    755756    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
    758761      Elements = new const element *[count];
    759762      vectors = new Vector *[count];
    760763      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;
    764769        j++;
    765770      }
     
    778783        }
    779784      }
    780       if (mol->hasBondStructure())
     785      if (mol->first->next != mol->last) // if connect matrix is present already, redo it
    781786        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    782787      // free memory
     
    904909  molecule *srcmol = NULL, *destmol = NULL;
    905910  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);
    908913  if(dialog->display()) {
    909914    molecules->SimpleAdd(srcmol, destmol);
     
    918923  molecule *srcmol = NULL, *destmol = NULL;
    919924  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);
    922927  if(dialog->display()) {
    923928    molecules->EmbedMerge(destmol, srcmol);
     
    10201025    return;
    10211026  }
     1027  atom *Walker = mol->start;
    10221028
    10231029  // generate some KeySets
    10241030  Log() << Verbose(0) << "Generating KeySets." << endl;
    1025   KeySet TestSets[mol->getAtomCount()+1];
     1031  KeySet TestSets[mol->AtomCount+1];
    10261032  i=1;
    1027   for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     1033  while (Walker->next != mol->end) {
     1034    Walker = Walker->next;
    10281035    for (int j=0;j<i;j++) {
    1029       TestSets[j].insert((*iter)->nr);
     1036      TestSets[j].insert(Walker->nr);
    10301037    }
    10311038    i++;
     
    10331040  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10341041  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;
    10431045  } 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);
    10461050
    10471051  // constructing Graph structure
     
    10511055  // insert KeySets into Subgraphs
    10521056  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++) {
    10541058    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    10551059  }
    10561060  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
    10571061  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.)));
    10591063  if (test2.second) {
    10601064    Log() << Verbose(1) << "Insertion worked?!" << endl;
Note: See TracChangeset for help on using the changeset viewer.