[][src]Function vtkio::import

pub fn import(file_path: impl AsRef<Path>) -> Result<Vtk, Error>

Import a VTK file at the specified path.

This function determines the vtk file type from the extension as prescribed by the VTK file formats documentation:

  • Legacy (.vtk) -- Simple legacy file format (Non-XML)
  • Image data (.vti) -- Serial vtkImageData (structured)
  • PolyData (.vtp) -- Serial vtkPolyData (unstructured)
  • RectilinearGrid (.vtr) -- Serial vtkRectilinearGrid (structured)
  • StructuredGrid (.vts) -- Serial vtkStructuredGrid (structured)
  • UnstructuredGrid (.vtu) -- Serial vtkUnstructuredGrid (unstructured)
  • PImageData (.pvti) -- Parallel vtkImageData (structured)
  • PPolyData (.pvtp) -- Parallel vtkPolyData (unstructured)
  • PRectilinearGrid (.pvtr) -- Parallel vtkRectilinearGrid (structured)
  • PStructuredGrid (.pvts) -- Parallel vtkStructuredGrid (structured)
  • PUnstructuredGrid (.pvtu) -- Parallel vtkUnstructuredGrid (unstructured)

Examples

The following example imports a legacy .vtk file called tet.vtk, and panics with an appropriate error message if the file fails to load.

This example panics
use vtkio::{model, import, export_ascii};
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));