Crate vtkio[−][src]
Import and export library for Visualization Toolkit (VTK) files.
Legacy .vtk
files as well as modern XML formats are supported.
Both “serial” and “parallel” XML files are supported with facilities for lazily loading.
The Vtk
struct exposes the primary IO API.
Examples
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.
use vtkio::model::*; // import model definition of a VTK file fn main() { use std::path::PathBuf; let file_path = PathBuf::from("../assets/tet.vtk"); let mut vtk_file = Vtk::import(&file_path) .expect(&format!("Failed to load file: {:?}", file_path)); vtk_file.version = Version::new((4,2)); // arbitrary change vtk_file.export_ascii(&file_path) .expect(&format!("Failed to save file: {:?}", file_path)); }
Files are sometimes provided as strings or byte slices, so it is also useful to be able to parse VTK files and write them back to a string or byte slice.
use vtkio::model::*; // import model definition of a VTK file fn main() { let data: &[u8] = include_str!("../assets/tet.vtk").as_bytes(); // Or just include_bytes! let mut vtk_file = Vtk::parse_legacy_be(data).expect(&format!("Failed to parse file")); vtk_file.version = Version::new((4,2)); // arbitrary change let mut output = String::new(); Vtk::write_legacy_ascii(vtk_file, &mut output).expect(&format!("Failed to write file")); println!("{}", output); }
Re-exports
pub use model::IOBuffer; |
pub use model::Vtk; |
Modules
basic | |
model | VTK Data Model |
parser | |
writer | |
xml | Internal APIs for dealing with XML VTK file types. |
Macros
match_buf | Evaluate the expression |
Enums
Error | Error type for Import/Export operations. |