- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ParserAction/LoadXyzAction.cpp
rbcf653 r952f38 1 /*2 * Project: MoleCuilder3 * Description: creates and alters molecular systems4 * Copyright (C) 2010 University of Bonn. All rights reserved.5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.6 */7 8 1 /* 9 2 * LoadXyzAction.cpp … … 12 5 * Author: heber 13 6 */ 14 15 // include config.h16 #ifdef HAVE_CONFIG_H17 #include <config.h>18 #endif19 7 20 8 #include "Helpers/MemDebug.hpp" … … 86 74 input.open(filename.c_str()); 87 75 if (!input.fail()) { 76 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 77 set <atom*> UniqueList; 78 { 79 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 80 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 81 UniqueList.insert(*runner); 82 } 88 83 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 89 84 parser.load(&input); 85 { 86 vector<atom *> ListAfter = World::getInstance().getAllAtoms(); 87 pair< set<atom *>::iterator, bool > Inserter; 88 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed 89 MoleculeListClass *molecules = World::getInstance().getMolecules(); 90 molecule *mol = World::getInstance().createMolecule(); 91 molecules->insert(mol); 92 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) { 93 Inserter = UniqueList.insert(*runner); 94 if (Inserter.second) { // if not present, then new (just parsed) atom, add ... 95 cout << "Adding new atom " << **runner << " to new mol." << endl; 96 mol->AddAtom(*runner); 97 } 98 } 99 mol->doCountAtoms(); 100 } else { 101 cout << "No atoms parsed?" << endl; 102 } 103 } 90 104 } else { 91 105 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
Note:
See TracChangeset
for help on using the changeset viewer.