pub fn from_text(text: &str) -> Result<Self, StrError> {
        // auxiliary data structure
        let mut data = DataForReadTextMesh::new();

        // read and parse sizes
        let mut lines_iter = text.lines();
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_sizes(line)? {
                        break;
                    }
                }
                None => return Err("text string is empty or header is missing"),
            }
        }

        // allocate mesh
        let mut mesh = Mesh {
            ndim: data.ndim,
            points: Vec::new(),
            cells: Vec::new(),
        };

        // read and parse points
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_point(&mut mesh, line)? {
                        if data.current_npoint == data.npoint {
                            break;
                        }
                    }
                }
                None => break,
            }
        }

        // check data
        if data.current_npoint != data.npoint {
            return Err("not all points have been found");
        }

        // read and parse cells
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_cell(&mut mesh, line)? {
                        if data.current_ncell == data.ncell {
                            break;
                        }
                    }
                }
                None => break,
            }
        }

        // check data
        if data.current_ncell != data.ncell {
            return Err("not all cells have been found");
        }

        // done
        Ok(mesh)
    }
/// Allocates a new Mesh by parsing raw mesh data from a text string
///
/// # Text format
///
/// The text includes three sections:
///
/// 1. The header with the space dimension (`ndim`), number of points (`npoint`), and number of cells (`ncell`);
/// 2. The points list where each line contains the `id` of the point, which must be **equal to the position** in the list,
///    followed by the `x` and `y` (and `z`) coordinates;
/// 3. The cells list where each line contains the `id` of the cell, which must be **equal to the position** in the list,
///    the attribute ID (`att`) of the cell, the `kind` of the cell, followed by the IDs of the points that define the cell (connectivity).
///
/// The text looks like this (the hash tag indicates a comment/the mesh below is just an example which won't work):
///
/// ```text
/// ## header
/// ## ndim npoint ncell
///      2      8     5
///
/// ## points
/// ## id    x   y
///    0  0.0 0.0
///    1  0.5 0.0
///    2  1.0 0.0
/// ## ... more points should follow
///
/// ## cells
/// ## id att kind  point_ids...
///    0   1 tri3  0 1 3
///    1   1 qua4  1 4 6 3
/// ```
///
/// where we can see that different cell (shape) kinds can be present in the same mesh.
/// However, this function does not check for element compatibility as required by finite element analyses.
///
/// See [GeoKind::from] for the keys used to identify the cell kind (the keys are **lowercase**).
///
/// # Examples
///
/// See `examples` and `data/meshes` directories for more examples
/// (with pretty formatted strings).
///
/// ```
/// use gemlab::mesh::Mesh;
/// use gemlab::StrError;
///
/// fn main() -> Result<(), StrError> {
///     // 1.0  3-------2
///     //      |`. [1] |
///     //      |  `.   |
///     //      | [0]`. |
///     // 0.0  0------`1
///     //     0.0     1.0
///     let mesh = Mesh::from_text(
///         "2 4 2\n# points\n0 0.0 0.0\n1 1.0 0.0\n2 1.0 1.0\n3 0.0 1.0\n# cells\n0 1 tri3  0 1 3\n1 1 tri3  2 3 1\n",
///     )?;
///     assert_eq!(mesh.points.len(), 4);
///     assert_eq!(mesh.cells.len(), 2);
///     assert_eq!(mesh.cells[0].points, &[0, 1, 3]);
///     assert_eq!(mesh.cells[1].points, &[2, 3, 1]);
///     Ok(())
/// }
/// ```
Allocates a new Mesh by parsing raw mesh data from a text string
Allocates a new Mesh by parsing raw mesh data from a text string
pub fn from_text(text: &str) -> Result<Self, StrError> {
        // auxiliary data structure
        let mut data = DataForReadTextMesh::new();
        // read and parse sizes
        let mut lines_iter = text.lines();
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_sizes(line)? {
                        break;
                    }
                }
                None => return Err("text string is empty or header is missing"),
            }
        }
        // allocate mesh
        let mut mesh = Mesh {
            ndim: data.ndim,
            points: Vec::new(),
            cells: Vec::new(),
        };
        // read and parse points
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_point(&mut mesh, line)? {
                        if data.current_npoint == data.npoint {
                            break;
                        }
                    }
                }
                None => break,
            }
        }
        // check data
        if data.current_npoint != data.npoint {
            return Err("not all points have been found");
        }
        // read and parse cells
        loop {
            match lines_iter.next() {
                Some(line) => {
                    if data.parse_cell(&mut mesh, line)? {
                        if data.current_ncell == data.ncell {
                            break;
                        }
                    }
                }
                None => break,
            }
        }
        // check data
        if data.current_ncell != data.ncell {
            return Err("not all cells have been found");
        }
        // done
        Ok(mesh)
    }
pub fn from_text ( text : & str ) -> Result < Self , StrError > { // auxiliary data structure let mut data = DataForReadTextMesh :: new ( ) ; // read and parse sizes let mut lines_iter = text . lines ( ) ; loop { match lines_iter . next ( ) { Some ( line ) => { if data . parse_sizes ( line ) ? { break ; } } None => return Err ( " " ) , } } // allocate mesh let mut mesh = Mesh { ndim : data . ndim , points : Vec :: new ( ) , cells : Vec :: new ( ) , } ; // read and parse points loop { match lines_iter . next ( ) { Some ( line ) => { if data . parse_point ( & mut mesh , line ) ? { if data . current_npoint == data . npoint { break ; } } } None => break , } } // check data if data . current_npoint != data . npoint { return Err ( " " ) ; } // read and parse cells loop { match lines_iter . next ( ) { Some ( line ) => { if data . parse_cell ( & mut mesh , line ) ? { if data . current_ncell == data . ncell { break ; } } } None => break , } } // check data if data . current_ncell != data . ncell { return Err ( " " ) ; } // done Ok ( mesh ) }
Allocates a new Mesh by parsing raw mesh data from a text string
Allocates a new Mesh by parsing raw mesh data from a text string
text
&str
text
&str
text format
The text includes three sections.

1. The header with the space dimension (`ndim`), number of points (`npoint`), and number of cells (`ncell`);
2. The points list where each line contains the `id` of the point, which must be **equal to the position** in the list,
followed by the `x` and `y` (and `z`) coordinates;
3. The cells list where each line contains the `id` of the cell, which must be **equal to the position** in the list,
the attribute ID (`att`) of the cell, the `kind` of the cell, followed by the IDs of the points that define the cell (connectivity).

The text looks like this (the hash tag indicates a comment/the mesh below is just an example which won't work).


The text includes three sections . 1 . The header with the space dimension ( ` ndim ` ) number of points ( ` npoint ` ) and number of cells ( ` ncell ` ) ; 2 . The points list where each line contains the ` id ` of the point which must be ** equal to the position ** in the list followed by the ` x ` and ` y ` ( and ` z ` ) coordinates ; 3 . The cells list where each line contains the ` id ` of the cell which must be ** equal to the position ** in the list the attribute ID ( ` att ` ) of the cell the ` kind ` of the cell followed by the IDs of the points that define the cell ( connectivity ) . The text looks like this ( the hash tag indicates a comment / the mesh below is just an example which won ' t work ) .
header
None
ndim npoint ncell
2      8     5
2 8 5
points
None
id    x   y
None
... more points should follow
None
cells
None
id att kind  point_ids...




See [GeoKind::from] for the keys used to identify the cell kind (the keys are **lowercase**).
See [ GeoKind :: from ] for the keys used to identify the cell kind ( the keys are ** lowercase ** ) .
examples
See `examples` and `data/meshes` directories for more examples
(with pretty formatted strings).

```
use gemlab::mesh::Mesh;
use gemlab::StrError.


See ` examples ` and ` data / meshes ` directories for more examples ( with pretty formatted strings ) . ` ` ` use gemlab :: mesh :: Mesh ; use gemlab :: StrError .