Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ParserAction/LoadXyzAction.cpp

    rbcf653 r952f38  
    1 /*
    2  * Project: MoleCuilder
    3  * Description: creates and alters molecular systems
    4  * 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 
    81/*
    92 * LoadXyzAction.cpp
     
    125 *      Author: heber
    136 */
    14 
    15 // include config.h
    16 #ifdef HAVE_CONFIG_H
    17 #include <config.h>
    18 #endif
    197
    208#include "Helpers/MemDebug.hpp"
     
    8674  input.open(filename.c_str());
    8775  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    }
    8883    XyzParser parser; // briefly instantiate a parser which is removed at end of focus
    8984    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    }
    90104  } else {
    91105    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
Note: See TracChangeset for help on using the changeset viewer.