fn to_atoms(&self, atoms_text: String) -> Atoms {
        let mut lines = atoms_text.lines();
        // skip the 2 comment lines + voxel info and then read the lattice information
        let _ = lines.next();
        let _ = lines.next();
        let _ = lines.next();
        let mut a = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        // density[z, y, x] so lets swap the c and a
        let mut b = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        let mut c = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        for i in 1..4 {
            c[i] *= c[0] * LENGTH_UNITS;
            b[i] *= b[0] * LENGTH_UNITS;
            a[i] *= a[0] * LENGTH_UNITS;
        }
        let lattice = Lattice::new([[a[1], a[2], a[3]],
                                    [b[1], b[2], b[3]],
                                    [c[1], c[2], c[3]]]);
        let mut positions: Vec<[f64; 3]> = vec![];
        // make the positions fractional and swap c and a
        for line in lines {
            let pos = line.split_whitespace()
                          .map(|x| x.parse::<f64>().unwrap() * LENGTH_UNITS)
                          .collect::<Vec<f64>>();
            let pos_frac =
                utils::dot([pos[2], pos[3], pos[4]], lattice.to_fractional)
                    .iter()
                    .map(|x| x.rem_euclid(1.))
                    .collect::<Vec<f64>>();
            let pos_cart = {
                utils::dot([pos_frac[0], pos_frac[1], pos_frac[2]],
                           lattice.to_cartesian)
            };
            positions.push(pos_cart);
        }
        Atoms::new(lattice, positions, atoms_text)
    }
/// Read atoms information from file header.
Read atoms information from file header.
Read atoms information from file header .
fn to_atoms(&self, atoms_text: String) -> Atoms {
        let mut lines = atoms_text.lines();
        // skip the 2 comment lines + voxel info and then read the lattice information
        let _ = lines.next();
        let _ = lines.next();
        let _ = lines.next();
        let mut a = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        // density[z, y, x] so lets swap the c and a
        let mut b = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        let mut c = {
            lines.next()
                 .unwrap()
                 .to_string()
                 .split_whitespace()
                 .map(|x| x.parse::<f64>().unwrap())
                 .collect::<Vec<f64>>()
        };
        for i in 1..4 {
            c[i] *= c[0] * LENGTH_UNITS;
            b[i] *= b[0] * LENGTH_UNITS;
            a[i] *= a[0] * LENGTH_UNITS;
        }
        let lattice = Lattice::new([[a[1], a[2], a[3]],
                                    [b[1], b[2], b[3]],
                                    [c[1], c[2], c[3]]]);
        let mut positions: Vec<[f64; 3]> = vec![];
        // make the positions fractional and swap c and a
        for line in lines {
            let pos = line.split_whitespace()
                          .map(|x| x.parse::<f64>().unwrap() * LENGTH_UNITS)
                          .collect::<Vec<f64>>();
            let pos_frac =
                utils::dot([pos[2], pos[3], pos[4]], lattice.to_fractional)
                    .iter()
                    .map(|x| x.rem_euclid(1.))
                    .collect::<Vec<f64>>();
            let pos_cart = {
                utils::dot([pos_frac[0], pos_frac[1], pos_frac[2]],
                           lattice.to_cartesian)
            };
            positions.push(pos_cart);
        }
        Atoms::new(lattice, positions, atoms_text)
    }
fn to_atoms ( & self , atoms_text : String ) -> Atoms { let mut lines = atoms_text . lines ( ) ; // skip the 2 comment lines + voxel info and then read the lattice information let _ = lines . next ( ) ; let _ = lines . next ( ) ; let _ = lines . next ( ) ; let mut a = { lines . next ( ) . unwrap ( ) . to_string ( ) . split_whitespace ( ) . map ( | x | x . parse :: < f64 > ( ) . unwrap ( ) ) . collect :: < Vec < f64 > > ( ) } ; // density[z, y, x] so lets swap the c and a let mut b = { lines . next ( ) . unwrap ( ) . to_string ( ) . split_whitespace ( ) . map ( | x | x . parse :: < f64 > ( ) . unwrap ( ) ) . collect :: < Vec < f64 > > ( ) } ; let mut c = { lines . next ( ) . unwrap ( ) . to_string ( ) . split_whitespace ( ) . map ( | x | x . parse :: < f64 > ( ) . unwrap ( ) ) . collect :: < Vec < f64 > > ( ) } ; for i in 1 .. 4 { c [ i ] *= c [ 0 ] * LENGTH_UNITS ; b [ i ] *= b [ 0 ] * LENGTH_UNITS ; a [ i ] *= a [ 0 ] * LENGTH_UNITS ; } let lattice = Lattice :: new ( [ [ a [ 1 ] , a [ 2 ] , a [ 3 ] ] , [ b [ 1 ] , b [ 2 ] , b [ 3 ] ] , [ c [ 1 ] , c [ 2 ] , c [ 3 ] ] ] ) ; let mut positions : Vec < [ f64 ; 3 ] > = vec ! [ ] ; // make the positions fractional and swap c and a for line in lines { let pos = line . split_whitespace ( ) . map ( | x | x . parse :: < f64 > ( ) . unwrap ( ) * LENGTH_UNITS ) . collect :: < Vec < f64 > > ( ) ; let pos_frac = utils :: dot ( [ pos [ 2 ] , pos [ 3 ] , pos [ 4 ] ] , lattice . to_fractional ) . iter ( ) . map ( | x | x . rem_euclid ( 1. ) ) . collect :: < Vec < f64 > > ( ) ; let pos_cart = { utils :: dot ( [ pos_frac [ 0 ] , pos_frac [ 1 ] , pos_frac [ 2 ] ] , lattice . to_cartesian ) } ; positions . push ( pos_cart ) ; } Atoms :: new ( lattice , positions , atoms_text ) }
Read atoms information from file header.
Read atoms information from file header .
&self
atoms_text
String
&self
atoms_text
String