#parser #writer #io #mesh #vtk


Parser and writer for the legacy VTK file format

15 releases

✓ Uses Rust 2018 edition

0.3.1 Dec 6, 2019
0.3.0 Nov 6, 2019
0.2.4 Sep 10, 2019
0.2.1 Apr 6, 2019
0.1.6 Nov 10, 2018

#146 in Parser implementations

Download history 12/week @ 2020-01-23 11/week @ 2020-01-30 5/week @ 2020-02-06 28/week @ 2020-02-13 37/week @ 2020-02-20 35/week @ 2020-02-27 41/week @ 2020-03-05 22/week @ 2020-03-12 92/week @ 2020-03-19 15/week @ 2020-03-26 4/week @ 2020-04-02 85/week @ 2020-04-09 56/week @ 2020-04-16 4/week @ 2020-04-23 34/week @ 2020-04-30 29/week @ 2020-05-07

145 downloads per month
Used in 2 crates (via gut)




A parser and writer for the Visualization Toolkit (VTK) legacy file format.

On crates.io On docs.rs Build status

This is meant to be a feature complete parser of the legacy VTK file format. However, I have only used this parser for tetrahedral and triangle meshes, and I am still lacking real world tests. Pull requests welcome.

This parser is written using nom.


There are many sample files can be found in the assets directory. For the following example, we will load a VTK file named tet.vtk, modify it and write it back in ASCII VTK format.

extern crate vtkio;
use vtkio::model::*; // import model definition of a VTK file
use vtkio::{import, export_ascii};
fn main() {
    use std::path::PathBuf;
    let file_path = PathBuf::from("tet.vtk");
    let mut vtk_file = import(&file_path)
        .expect(&format!("Failed to load file: {:?}", file_path));
    vtk_file.version = Version::new((4,2)); // arbitrary change

    export_ascii(vtk_file, &file_path)
        .expect(&format!("Failed to save file: {:?}", file_path));


If you are working with binary files produced by ParaView, it is likely that they will be written in big endian format regardless of your platform. To load binary files in a specific endianness, use the import_le and import_be functions for little and big endian files respectively.


This repository is licensed under either of

at your option.


~23K SLoC