Changes in src/Parser/XyzParser.cpp [d74077:dddbfe]
- File:
-
- 1 edited
-
src/Parser/XyzParser.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/XyzParser.cpp
rd74077 rdddbfe 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 #include "Helpers/Log.hpp" 11 #include "Helpers/Verbose.hpp" 10 12 #include "XyzParser.hpp" 11 13 #include "World.hpp" 12 14 #include "atom.hpp" 15 #include "molecule.hpp" 13 16 #include "element.hpp" 14 17 #include "periodentafel.hpp" … … 35 38 */ 36 39 void XyzParser::load(istream* file) { 37 atom* newAtom; 40 atom* newAtom = NULL; 41 molecule* newmol = NULL; 38 42 int numberOfAtoms; 39 43 char commentBuffer[512], type[3]; 40 double tmp;41 44 42 45 // the first line tells number of atoms, the second line is always a comment … … 45 48 comment = commentBuffer; 46 49 50 newmol = World::getInstance().createMolecule(); 51 newmol->ActiveFlag = true; 52 World::getInstance().getMolecules()->insert(newmol); 47 53 for (int i = 0; i < numberOfAtoms; i++) { 48 54 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]; 54 56 newAtom->setType(World::getInstance().getPeriode()->FindElement(type)); 57 newmol->AddAtom(newAtom); 55 58 } 56 59 } … … 62 65 */ 63 66 void XyzParser::save(ostream* file) { 67 DoLog(0) && (Log() << Verbose(0) << "Saving changes to xyz." << std::endl); 64 68 if (comment == "") { 65 69 time_t now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time' … … 77 81 vector<atom*> atoms = World::getInstance().getAllAtoms(); 78 82 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; 80 84 } 81 85 }
Note:
See TracChangeset
for help on using the changeset viewer.
