some fixes and updates

This commit is contained in:
danijoo
2017-01-30 09:40:35 +01:00
parent aa507b6278
commit 8b7d2ec1a2
6 changed files with 198 additions and 26 deletions

View File

@@ -178,4 +178,30 @@ impl TrjReader {
return true;
}
// skip x frames
pub fn skip(&mut self, skip: usize) {
if skip < 1 { return };
// find number of particles
let buffer_string = &mut String::new();
match self.reader.read_line(buffer_string) {
Ok(size) => {
if size == 0 {
panic!("no new frame!")
}
},
Err(e) => panic!("no new frame!")
}
let first_line_vec : Vec<&str> = buffer_string.split_whitespace().collect();
let num_particles = first_line_vec[0].parse::<usize>().unwrap();
let lines_to_skip = (num_particles + 1) * skip - 1;
let mut skipped = 0;
loop {
self.reader.read_line(&mut String::new());
skipped += 1;
if skipped == lines_to_skip { break; }
}
}
}