Commit d730d970 authored by Germain Clavier's avatar Germain Clavier
Browse files

Made struct fields public for lmpat and lmpbox

parent 2c4818bc
Loading
Loading
Loading
Loading
+44 −31
Original line number Diff line number Diff line
@@ -4,41 +4,54 @@ use crate::tools::parsers;

#[derive(Debug, Default)]
pub struct Atom {
    format: String,
    id: u32,
    attype: u32,
    mol: u32,
    q: f64,
    x: f64,
    y: f64,
    z: f64,
    vx: f64,
    vy: f64,
    vz: f64,
    fx: f64,
    fy: f64,
    fz: f64,
    xflag: u32,
    yflag: u32,
    zflag: u32,
    pub format: String,
    pub atid: u32,
    pub attype: u32,
    pub molid: u32,
    pub q: f64,
    pub x: f64,
    pub y: f64,
    pub z: f64,
    pub vx: f64,
    pub vy: f64,
    pub vz: f64,
    pub fx: f64,
    pub fy: f64,
    pub fz: f64,
    pub xflag: u32,
    pub yflag: u32,
    pub zflag: u32,
}

impl Atom {
    fn read_atom(input: &str, format:&str) -> Atom {
        if format == "atomic" {
    fn new() -> Atom {
        Atom{ ..Default::default() }
    }

    pub fn read_atom(input: &str, format:&str) -> Atom {
        let parsed = parsers::atom_parser(input).expect("Could not parse atom.").1;
            let id = parsed[0].parse::<u32>().expect("Could not parse id.");
            let attype = parsed[1].parse::<u32>().expect("Could not parse attype.");
            let x = parsed[2].parse::<f64>().expect("Could not parse x.");
            let y = parsed[3].parse::<f64>().expect("Could not parse y.");
            let z = parsed[4].parse::<f64>().expect("Could not parse z.");
            Atom {
                format: format.to_string(),
                id: id, attype: attype,
                x: x, y: y, z: z, ..Default::default()
        let mut atom = Atom::new();
        match format {
            "atomic" => {
                atom.atid = parsed[0].parse::<u32>().expect("Could not parse atid.");
                atom.attype = parsed[1].parse::<u32>().expect("Could not parse attype.");
                atom.x = parsed[2].parse::<f64>().expect("Could not parse x.");
                atom.y = parsed[3].parse::<f64>().expect("Could not parse y.");
                atom.z = parsed[4].parse::<f64>().expect("Could not parse z.");
                atom.format = format.to_string();
            }
            "full" => {
                atom.atid = parsed[0].parse::<u32>().expect("Could not parse atid.");
                atom.molid = parsed[1].parse::<u32>().expect("Could not parse molid.");
                atom.attype = parsed[2].parse::<u32>().expect("Could not parse attype.");
                atom.q = parsed[3].parse::<f64>().expect("Could not parse q.");
                atom.x = parsed[4].parse::<f64>().expect("Could not parse x.");
                atom.y = parsed[5].parse::<f64>().expect("Could not parse y.");
                atom.z = parsed[6].parse::<f64>().expect("Could not parse z.");
                atom.format = format.to_string();
            }
        } else {
            panic!("Unrecognized format.")
            _ => panic!("Could not understand format for atom parsing!")
        }
    atom
    }
}
+9 −9
Original line number Diff line number Diff line
@@ -2,13 +2,13 @@

#[derive(Default, Debug)]
pub struct Lmpbox {
    xlo: f64,
    xhi: f64,
    ylo: f64,
    yhi: f64,
    zlo: f64,
    zhi: f64,
    xy: f64,
    xz: f64,
    yz: f64,
    pub xlo: f64,
    pub xhi: f64,
    pub ylo: f64,
    pub yhi: f64,
    pub zlo: f64,
    pub zhi: f64,
    pub xy: f64,
    pub xz: f64,
    pub yz: f64,
}