Changes in src/Legacy/oldmenu.cpp [d74077:952f38]
- File:
-
- 1 edited
-
src/Legacy/oldmenu.cpp (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
rd74077 r952f38 20 20 #include "element.hpp" 21 21 #include "ellipsoid.hpp" 22 #include " helpers.hpp"22 #include "Helpers/helpers.hpp" 23 23 #include "leastsquaremin.hpp" 24 24 #include "linkedcell.hpp" 25 #include " log.hpp"25 #include "Helpers/Log.hpp" 26 26 #include "memoryusageobserverunittest.hpp" 27 27 #include "molecule.hpp" 28 28 #include "periodentafel.hpp" 29 29 #include "vector_ops.hpp" 30 #include " Plane.hpp"31 #include "Line .hpp"30 #include "LinearAlgebra/Plane.hpp" 31 #include "LinearAlgebra/Line.hpp" 32 32 33 33 #include "UIElements/UIFactory.hpp" … … 89 89 first = World::getInstance().createAtom(); 90 90 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); 92 92 dialog->queryElement("Please choose element: ",&elements); 93 93 if(dialog->display()){ 94 94 if (elements.size() == 1) { 95 first-> setType(elements.at(0));95 first->type = elements.at(0); 96 96 mol->AddAtom(first); // add to molecule 97 97 } else { … … 113 113 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 114 114 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); 116 116 if((aborted = !dialog->display())){ 117 117 continue; 118 118 } 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))); 121 121 if(!aborted){ 122 first-> AtomicElement= periode->AskElement(); // give type122 first->type = periode->AskElement(); // give type 123 123 mol->AddAtom(first); // add to molecule 124 124 } … … 136 136 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog()); 137 137 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); 139 139 dialog->display(); 140 140 for (int i=NDIM;i--;) { 141 first-> AtomicPosition[i] += second->AtomicPosition[i];141 first->x[i] += second->x[i]; 142 142 } 143 } while (!(valid = mol->CheckBounds((const Vector *)&first-> AtomicPosition)));144 first-> AtomicElement= periode->AskElement(); // give type143 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 144 first->type = periode->AskElement(); // give type 145 145 mol->AddAtom(first); // add to molecule 146 146 } … … 152 152 do { 153 153 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; 155 155 } 156 156 Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; … … 185 185 */ 186 186 // calc axis vector 187 x= second-> AtomicPosition - third->AtomicPosition;187 x= second->x - third->x; 188 188 x.Normalize(); 189 189 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(); 191 191 Log() << Verbose(0) << "z: " << z << endl; 192 192 y = Plane(x,z,0).getNormal(); … … 194 194 195 195 // 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, 199 199 // remove the projection onto the rotation plane of the second angle 200 200 n = y; 201 n.Scale(first-> AtomicPosition.ScalarProduct(y));201 n.Scale(first->x.ScalarProduct(y)); 202 202 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; 205 205 n = z; 206 n.Scale(first-> AtomicPosition.ScalarProduct(z));206 n.Scale(first->x.ScalarProduct(z)); 207 207 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; 210 210 211 211 // rotate another vector around second angle … … 215 215 216 216 // 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 type217 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 225 225 mol->AddAtom(first); // add to molecule 226 226 break; … … 239 239 if (j != -1) { 240 240 second = mol->FindAtom(j); 241 atoms[i++] = &(second-> AtomicPosition);241 atoms[i++] = &(second->x); 242 242 } 243 243 } while ((j != -1) && (i<128)); 244 244 if (i >= 2) { 245 LSQdistance(first-> AtomicPosition,(const Vector **)atoms, i);246 247 Log() << Verbose(0) << first-> AtomicPosition;248 first-> AtomicElement= periode->AskElement(); // give type245 LSQdistance(first->x,(const Vector **)atoms, i); 246 247 Log() << Verbose(0) << first->x; 248 first->type = periode->AskElement(); // give type 249 249 mol->AddAtom(first); // add to molecule 250 250 } else { … … 338 338 third = mol->AskAtom("Enter third atom: "); 339 339 340 n = Plane(first-> AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal();340 n = Plane(first->x,second->x,third->x).getNormal(); 341 341 break; 342 342 case 'b': // normal vector of mirror plane … … 354 354 second = mol->AskAtom("Enter second atom: "); 355 355 356 n = first-> AtomicPosition - second->AtomicPosition;356 n = first->x - second->x; 357 357 n.Normalize(); 358 358 break; … … 405 405 third = mol->AskAtom("Enter third atom: "); 406 406 407 n = Plane(first-> AtomicPosition,second->AtomicPosition,third->AtomicPosition).getNormal();407 n = Plane(first->x,second->x,third->x).getNormal(); 408 408 break; 409 409 case 'b': // normal vector of mirror plane … … 421 421 second = mol->AskAtom("Enter second atom: "); 422 422 423 n = first-> AtomicPosition - second->AtomicPosition;423 n = first->x - second->x; 424 424 n.Normalize(); 425 425 break; … … 464 464 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 465 465 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 ... 467 467 mol->RemoveAtom((*runner)); 468 468 } … … 479 479 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) { 480 480 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 ... 482 482 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 483 483 mol->RemoveAtom((*runner)); … … 526 526 527 527 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 528 Z = (*iter)-> getType()->Z;528 Z = (*iter)->type->Z; 529 529 tmp1 = 0.; 530 530 if (first != (*iter)) { 531 x = first-> AtomicPosition - (*iter)->AtomicPosition;531 x = first->x - (*iter)->x; 532 532 tmp1 = x.Norm(); 533 533 } … … 536 536 } 537 537 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; 539 539 break; 540 540 … … 544 544 for (int i=NDIM;i--;) 545 545 min[i] = 0.; 546 x = first-> AtomicPosition - second->AtomicPosition;546 x = first->x - second->x; 547 547 tmp1 = x.Norm(); 548 548 Log() << Verbose(1) << "Distance vector is " << x << "." << "/n" … … 556 556 third = mol->AskAtom("Enter last atom: "); 557 557 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; 560 560 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 561 561 Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl; … … 695 695 minBond = 0.; 696 696 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]); 698 698 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; 700 700 Log() << Verbose(0) << "Enter new bond length [a.u.]: "; 701 701 cin >> bond; 702 702 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); 704 704 } 705 705 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: "; … … 757 757 cin >> Z; 758 758 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; 760 760 } 761 761 break; … … 785 785 j = 0; 786 786 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; 789 789 j++; 790 790 } … … 798 798 for (int k=count;k--;) { // go through every atom of the original cell 799 799 first = World::getInstance().createAtom(); // create a new body 800 first-> AtomicPosition= (*vectors[k]) + x; // use coordinate of original atom801 first-> AtomicElement= Elements[k]; // insert original element800 first->x = (*vectors[k]) + x; // use coordinate of original atom 801 first->type = Elements[k]; // insert original element 802 802 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 803 803 }
Note:
See TracChangeset
for help on using the changeset viewer.
