Changeset 58fccca


Ignore:
Timestamp:
Feb 13, 2013, 3:47:45 PM (12 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
42f2f0
Parents:
b4b364
git-author:
Frederik Heber <heber@…> (01/08/13 14:40:11)
git-committer:
Frederik Heber <heber@…> (02/13/13 15:47:45)
Message:

FIX: XyzParser::load() stumbled if no empty line between timesteps.

  • also replaced char* by string and using getline().
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/XyzParser.cpp

    rb4b364 r58fccca  
    8181  molecule* newmol = NULL;
    8282  int numberOfAtoms;
    83   char commentBuffer[512], type[3];
    84   string number;
     83  string elementtype;
     84  string streambuffer;
    8585  std::vector<atom *> AddedAtoms;
    8686
     
    9393  // the first line tells number of atoms,
    9494  // where we need this construct due to skipping of empty lines below
    95   file->getline(commentBuffer, 512);
     95  getline(*file, streambuffer);
    9696  unsigned int step = 0;
    9797  while (file->good()) {
    98     std::stringstream numberstream(commentBuffer);
     98    std::stringstream numberstream(streambuffer);
    9999    numberstream >> numberOfAtoms;
    100100    if (step == 0)
    101101      AddedAtoms.resize(numberOfAtoms);
    102102    // the second line is always a comment
    103     file->getline(commentBuffer, 512);
    104     comment = commentBuffer;
     103    getline(*file, streambuffer);
     104    comment = streambuffer;
    105105    LOG(3, "DEBUG: comment is '" << comment << "'.");
    106106
    107107    for (int i = 0; i < numberOfAtoms; i++) {
    108108      // parse type and position
    109       *file >> type;
     109      *file >> elementtype;
    110110      Vector tempVector;
    111111      for (int j=0;j<NDIM;j++) {
    112112        *file >> tempVector[j];
    113113      }
    114       LOG(4, "INFO: Parsed type as " << type << " and position at "
     114      LOG(4, "INFO: Parsed type as " << elementtype << " and position at "
    115115          << tempVector << " for time step " << step);
    116116
    117117      if (step == 0) {
    118118        newAtom = World::getInstance().createAtom();
    119         newAtom->setType(World::getInstance().getPeriode()->FindElement(type));
     119        newAtom->setType(World::getInstance().getPeriode()->FindElement(elementtype.c_str()));
    120120        newmol->AddAtom(newAtom);
    121121        AddedAtoms[i] = newAtom;
     
    124124        newAtom = AddedAtoms[i];
    125125        LOG(5, "INFO: Using present atom " << *newAtom << " from " << i << " th component of AddedAtoms.");
    126         ASSERT(newAtom->getType() == World::getInstance().getPeriode()->FindElement(type),
    127             "FormatParser< xyz >::load() - atom has different type "+newAtom->getType()->getSymbol()+" than parsed now "+type+", mixed up order?");
     126        ASSERT(newAtom->getType() == World::getInstance().getPeriode()->FindElement(elementtype.c_str()),
     127            "FormatParser< xyz >::load() - atom has different type "+newAtom->getType()->getSymbol()+" than parsed now "+elementtype+", mixed up order?");
    128128      }
    129129      newAtom->setPositionAtStep(step, tempVector);
    130130    }
    131     getline (*file, number);  // eat away rest of last line
     131    getline (*file, streambuffer);  // eat away rest of last line
    132132    // skip empty lines
    133133    unsigned int counter = 0;
    134134    while (file->good()) {
    135       getline (*file, number);
    136       LOG(4, "INFO: Skipped line is '" << number << "'");
     135      getline (*file, streambuffer);
     136      LOG(4, "INFO: Skipped line is '" << streambuffer << "'");
    137137      counter++;
    138       if (!number.empty())
     138      if (!streambuffer.empty())
    139139        break;
    140140    }
Note: See TracChangeset for help on using the changeset viewer.