A parser and writer for the Visualization Toolkit (VTK) file formats.
This is meant to be a feature complete parser of Legacy and XML VTK file formats. Both serial and parallel XML file formats are supported.
The Legacy format parser is written using nom.
XML VTK files are import and exported with quick-xml
and serde
crates.
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 Legacy ASCII format.
```rust use vtkio::model::*; // import model definition of a VTK file use vtkio::{import, exportascii}; fn main() { use std::path::PathBuf; let filepath = PathBuf::from("assets/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));
} ```
The previous version of the crate (v0.3) supports only Legacy VTK formats. For a list of changes
introduced in the new version of vtkio
(v0.4) see the CHANGELOG.
This repository is licensed under either of
at your option.