[−][src]Crate vtkio
vtkio
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.
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 use vtkio::{import, export_ascii}; fn main() { use std::path::PathBuf; let file_path = 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)); }
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 use vtkio::{parse_legacy_be, write_legacy_ascii}; fn main() { let data: &[u8] = include_str!("../assets/tet.vtk").as_bytes(); // Or just include_bytes! let mut vtk_file = parse_legacy_be(data).expect(&format!("Failed to parse file")); vtk_file.version = Version::new((4,2)); // arbitrary change let mut output = String::new(); write_legacy_ascii(vtk_file, &mut output).expect(&format!("Failed to write file")); println!("{}", output); }
Re-exports
pub use model::IOBuffer; |
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. |
Functions
export | Export given |
export_ascii | Export given vtk data to the specified file in ASCII format. |
export_be | Export the given |
export_le | Export the given |
import | Import a VTK file at the specified path. |
import_be | Import a legacy VTK file at the specified path. |
import_le | Import a legacy VTK file at the specified path. |
parse_legacy_be | Parse a legacy VTK file from the given reader. |
parse_legacy_buf_be | Parse a legacy VTK file in big endian format from the given reader and a buffer. |
parse_legacy_buf_le | Parse a legacy VTK file in little endian format from the given reader and a buffer. |
parse_legacy_le | Parse a legacy VTK file from the given reader. |
parse_xml | Parse a modern XML style VTK file from a given reader. |
write_legacy | Write the given VTK file in binary legacy format to the specified |
write_legacy_ascii | Write the given VTK file in binary legacy format to the specified |
write_xml | Write the given VTK file in modern XML format to the specified |