Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/XyzParser.cpp

    rd74077 rdddbfe  
    88#include "Helpers/MemDebug.hpp"
    99
     10#include "Helpers/Log.hpp"
     11#include "Helpers/Verbose.hpp"
    1012#include "XyzParser.hpp"
    1113#include "World.hpp"
    1214#include "atom.hpp"
     15#include "molecule.hpp"
    1316#include "element.hpp"
    1417#include "periodentafel.hpp"
     
    3538 */
    3639void XyzParser::load(istream* file) {
    37   atom* newAtom;
     40  atom* newAtom = NULL;
     41  molecule* newmol = NULL;
    3842  int numberOfAtoms;
    3943  char commentBuffer[512], type[3];
    40   double tmp;
    4144
    4245  // the first line tells number of atoms, the second line is always a comment
     
    4548  comment = commentBuffer;
    4649
     50  newmol = World::getInstance().createMolecule();
     51  newmol->ActiveFlag = true;
     52  World::getInstance().getMolecules()->insert(newmol);
    4753  for (int i = 0; i < numberOfAtoms; i++) {
    4854    newAtom = World::getInstance().createAtom();
    49     *file >> type;
    50     for (int j=0;j<NDIM;j++) {
    51       *file >> tmp;
    52       newAtom->set(j, tmp);
    53     }
     55    *file >> type >> ws >> newAtom->x[0] >> ws >> newAtom->x[1] >> ws >> newAtom->x[2];
    5456    newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
     57    newmol->AddAtom(newAtom);
    5558  }
    5659}
     
    6265 */
    6366void XyzParser::save(ostream* file) {
     67  DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl);
    6468  if (comment == "") {
    6569    time_t now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
     
    7781  vector<atom*> atoms = World::getInstance().getAllAtoms();
    7882  for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) {
    79     *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->at(0) << "\t" << (*it)->at(1) << "\t" << (*it)->at(2) << endl;
     83    *file << noshowpoint << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;
    8084  }
    8185}
Note: See TracChangeset for help on using the changeset viewer.