Skip to content

Commit

Permalink
Fix AAM file reader (atoms begin at line 2) (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
rc83 authored Sep 28, 2020
1 parent bc5085f commit be65e02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <cereal/archives/binary.hpp>
#include <fstream>
#include <iostream>
#include <range/v3/view.hpp>

namespace Faunus {

Expand Down Expand Up @@ -110,8 +111,10 @@ ParticleVector FormatAAM::load(const std::string &filename, bool _keepcharges) {
}
ParticleVector positions; // positions are loaded here
positions.reserve(number_of_atoms);
std::transform(lines.begin(), lines.begin() + number_of_atoms, std::back_inserter(positions),
auto lines_atoms = lines | ranges::views::slice(1uL, 1uL + number_of_atoms);
std::transform(lines_atoms.begin(), lines_atoms.end(), std::back_inserter(positions),
[](auto &i) { return recordToParticle(i); });
assert(positions.size() == number_of_atoms);
return positions;
}
}
Expand Down

0 comments on commit be65e02

Please sign in to comment.