Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    rd74077 r952f38  
    2020#include "element.hpp"
    2121#include "ellipsoid.hpp"
    22 #include "helpers.hpp"
     22#include "Helpers/helpers.hpp"
    2323#include "leastsquaremin.hpp"
    2424#include "linkedcell.hpp"
    25 #include "log.hpp"
     25#include "Helpers/Log.hpp"
    2626#include "memoryusageobserverunittest.hpp"
    2727#include "molecule.hpp"
    2828#include "periodentafel.hpp"
    2929#include "vector_ops.hpp"
    30 #include "Plane.hpp"
    31 #include "Line.hpp"
     30#include "LinearAlgebra/Plane.hpp"
     31#include "LinearAlgebra/Line.hpp"
    3232
    3333#include "UIElements/UIFactory.hpp"
     
    8989        first = World::getInstance().createAtom();
    9090        std::vector<element *> elements;
    91         dialog->queryVector("Please enter coordinates: ",&first->AtomicPosition,World::getInstance().getDomain(), false);
     91        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
    9292        dialog->queryElement("Please choose element: ",&elements);
    9393        if(dialog->display()){
    9494          if (elements.size() == 1) {
    95             first->setType(elements.at(0));
     95            first->type = elements.at(0);
    9696            mol->AddAtom(first);  // add to molecule
    9797          } else {
     
    113113          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
    114114          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
    115           dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false);
     115          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
    116116          if((aborted = !dialog->display())){
    117117            continue;
    118118          }
    119           first->AtomicPosition += x;
    120         } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition)));
     119          first->x += x;
     120        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
    121121        if(!aborted){
    122           first->AtomicElement = periode->AskElement();  // give type
     122          first->type = periode->AskElement();  // give type
    123123          mol->AddAtom(first);  // add to molecule
    124124        }
     
    136136          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
    137137          second = mol->AskAtom("Enter atom number: ");
    138           dialog->queryVector("Enter relative coordinates.",&first->AtomicPosition,World::getInstance().getDomain(), false);
     138          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
    139139          dialog->display();
    140140          for (int i=NDIM;i--;) {
    141             first->AtomicPosition[i] += second->AtomicPosition[i];
     141            first->x[i] += second->x[i];
    142142          }
    143         } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition)));
    144         first->AtomicElement = periode->AskElement();  // give type
     143        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     144        first->type = periode->AskElement();  // give type
    145145        mol->AddAtom(first);  // add to molecule
    146146      }
     
    152152        do {
    153153          if (!valid) {
    154             eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->AtomicPosition << endl;
     154            eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
    155155          }
    156156          Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
     
    185185          */
    186186          // calc axis vector
    187           x= second->AtomicPosition - third->AtomicPosition;
     187          x= second->x - third->x;
    188188          x.Normalize();
    189189          Log() << Verbose(0) << "x: " << x << endl;
    190           z = Plane(second->AtomicPosition,third->AtomicPosition,fourth->AtomicPosition).getNormal();
     190          z = Plane(second->x,third->x,fourth->x).getNormal();
    191191          Log() << Verbose(0) << "z: " << z << endl;
    192192          y = Plane(x,z,0).getNormal();
     
    194194
    195195          // rotate vector around first angle
    196           first->AtomicPosition = x;
    197           first->AtomicPosition = Line(zeroVec,z).rotateVector(first->AtomicPosition,b - M_PI);
    198           Log() << Verbose(0) << "Rotated vector: " << first->AtomicPosition << endl,
     196          first->x = x;
     197          first->x = Line(zeroVec,z).rotateVector(first->x,b - M_PI);
     198          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
    199199          // remove the projection onto the rotation plane of the second angle
    200200          n = y;
    201           n.Scale(first->AtomicPosition.ScalarProduct(y));
     201          n.Scale(first->x.ScalarProduct(y));
    202202          Log() << Verbose(0) << "N1: " << n << endl;
    203           first->AtomicPosition -= n;
    204           Log() << Verbose(0) << "Subtracted vector: " << first->AtomicPosition << endl;
     203          first->x -= n;
     204          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
    205205          n = z;
    206           n.Scale(first->AtomicPosition.ScalarProduct(z));
     206          n.Scale(first->x.ScalarProduct(z));
    207207          Log() << Verbose(0) << "N2: " << n << endl;
    208           first->AtomicPosition -= n;
    209           Log() << Verbose(0) << "2nd subtracted vector: " << first->AtomicPosition << endl;
     208          first->x -= n;
     209          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
    210210
    211211          // rotate another vector around second angle
     
    215215
    216216          // add the two linear independent vectors
    217           first->AtomicPosition += n;
    218           first->AtomicPosition.Normalize();
    219           first->AtomicPosition.Scale(a);
    220           first->AtomicPosition += second->AtomicPosition;
    221 
    222           Log() << Verbose(0) << "resulting coordinates: " << first->AtomicPosition << endl;
    223         } while (!(valid = mol->CheckBounds((const Vector *)&first->AtomicPosition)));
    224         first->AtomicElement = periode->AskElement();  // give type
     217          first->x += n;
     218          first->x.Normalize();
     219          first->x.Scale(a);
     220          first->x += second->x;
     221
     222          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
     223        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
     224        first->type = periode->AskElement();  // give type
    225225        mol->AddAtom(first);  // add to molecule
    226226        break;
     
    239239          if (j != -1) {
    240240            second = mol->FindAtom(j);
    241             atoms[i++] = &(second->AtomicPosition);
     241            atoms[i++] = &(second->x);
    242242          }
    243243        } while ((j != -1) && (i<128));
    244244        if (i >= 2) {
    245           LSQdistance(first->AtomicPosition,(const Vector **)atoms, i);
    246 
    247           Log() << Verbose(0) << first->AtomicPosition;
    248           first->AtomicElement = periode->AskElement();  // give type
     245          LSQdistance(first->x,(const Vector **)atoms, i);
     246
     247          Log() << Verbose(0) << first->x;
     248          first->type = periode->AskElement();  // give type
    249249          mol->AddAtom(first);  // add to molecule
    250250        } else {
     
    338338      third = mol->AskAtom("Enter third atom: ");
    339339
    340       n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal();
     340      n = Plane(first->x,second->x,third->x).getNormal();
    341341      break;
    342342    case 'b': // normal vector of mirror plane
     
    354354      second = mol->AskAtom("Enter second atom: ");
    355355
    356       n = first->AtomicPosition - second->AtomicPosition;
     356      n = first->x - second->x;
    357357      n.Normalize();
    358358      break;
     
    405405      third = mol->AskAtom("Enter third atom: ");
    406406
    407       n = Plane(first->AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal();
     407      n = Plane(first->x,second->x,third->x).getNormal();
    408408      break;
    409409    case 'b': // normal vector of mirror plane
     
    421421      second = mol->AskAtom("Enter second atom: ");
    422422
    423       n = first->AtomicPosition - second->AtomicPosition;
     423      n = first->x - second->x;
    424424      n.Normalize();
    425425      break;
     
    464464        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
    465465          runner = iter++;
    466           if ((*runner)->AtomicPosition.DistanceSquared((*runner)->AtomicPosition) > tmp1*tmp1) // distance to first above radius ...
     466          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
    467467            mol->RemoveAtom((*runner));
    468468        }
     
    479479      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
    480480        runner = iter++;
    481         if (((*runner)->AtomicPosition[axis] < tmp1) || ((*runner)->AtomicPosition[axis] > tmp2)) {// out of boundary ...
     481        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
    482482          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    483483          mol->RemoveAtom((*runner));
     
    526526
    527527      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    528         Z = (*iter)->getType()->Z;
     528        Z = (*iter)->type->Z;
    529529        tmp1 = 0.;
    530530        if (first != (*iter)) {
    531           x = first->AtomicPosition - (*iter)->AtomicPosition;
     531          x = first->x - (*iter)->x;
    532532          tmp1 = x.Norm();
    533533        }
     
    536536      }
    537537      for (int i=MAX_ELEMENTS;i--;)
    538         if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->getType()->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
     538        if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
    539539      break;
    540540
     
    544544      for (int i=NDIM;i--;)
    545545        min[i] = 0.;
    546       x = first->AtomicPosition - second->AtomicPosition;
     546      x = first->x - second->x;
    547547      tmp1 = x.Norm();
    548548      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
     
    556556      third  = mol->AskAtom("Enter last atom: ");
    557557      tmp1 = tmp2 = tmp3 = 0.;
    558       x = first->AtomicPosition - second->AtomicPosition;
    559       y = third->AtomicPosition - second->AtomicPosition;
     558      x = first->x - second->x;
     559      y = third->x - second->x;
    560560      Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
    561561      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
     
    695695        minBond = 0.;
    696696        for (int i=NDIM;i--;)
    697           minBond += (first->AtomicPosition[i]-second->AtomicPosition[i])*(first->AtomicPosition[i] - second->AtomicPosition[i]);
     697          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
    698698        minBond = sqrt(minBond);
    699         Log() << Verbose(0) << "Current Bond length between " << first->getType()->name << " Atom " << first->nr << " and " << second->getType()->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
     699        Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
    700700        Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
    701701        cin >> bond;
    702702        for (int i=NDIM;i--;) {
    703           second->AtomicPosition[i] -= (second->AtomicPosition[i]-first->AtomicPosition[i])/minBond*(minBond-bond);
     703          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
    704704        }
    705705        //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
     
    757757        cin >> Z;
    758758        first->setType(Z);
    759         Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->getType()->name << "." << endl;
     759        Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
    760760      }
    761761      break;
     
    785785      j = 0;
    786786      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    787         Elements[j] = (*iter)->AtomicElement;
    788         vectors[j] = &(*iter)->AtomicPosition;
     787        Elements[j] = (*iter)->type;
     788        vectors[j] = &(*iter)->x;
    789789        j++;
    790790      }
     
    798798        for (int k=count;k--;) { // go through every atom of the original cell
    799799          first = World::getInstance().createAtom(); // create a new body
    800           first->AtomicPosition = (*vectors[k]) + x;  // use coordinate of original atom
    801           first->AtomicElement = Elements[k];  // insert original element
     800          first->x = (*vectors[k]) + x;  // use coordinate of original atom
     801          first->type = Elements[k];  // insert original element
    802802          mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
    803803        }
Note: See TracChangeset for help on using the changeset viewer.