Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/examples/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod vertex;
24 changes: 24 additions & 0 deletions src/examples/vertex.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::model::*;

/// Creates a single vertex
pub fn example_vertex() -> Vtk {
Vtk {
version: Version { major: 4, minor: 2 },
title: String::new(),
byte_order: ByteOrder::BigEndian,
file_path: None,
data: DataSet::inline(UnstructuredGridPiece {
points: IOBuffer::F64(vec![1.0, 1.0, 0.0]),
cells: Cells {
cell_verts: VertexNumbers::XML {
connectivity: vec![0],
offsets: vec![1],
},
types: vec![CellType::Vertex; 1],
},
data: Attributes {
..Default::default()
},
}),
}
}
17 changes: 10 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
//! println!("{}", output);
//! }
//! ```
//!
//!
//! To quickly extract some data from a file, you can cast it to an `f64` type as follows
//!
//!
//! ```no_run
//! use vtkio::model::*; // import model definition of a VTK file
//!
//!
//! // Load up vtk file.
//! let file_path = "../assets/para_tet.vtk";
//! let mut vtk = Vtk::import(&file_path)
//! .expect(&format!("Failed to load file: {:?}", file_path));
//!
//!
//! // Get all the pieces knowing that type they are.
//! let pieces = if let DataSet::UnstructuredGrid { pieces, .. } = vtk.data {
//! pieces
Expand All @@ -68,7 +68,7 @@
//! // Often files have only a single piece, so we load it up here.
//! // To avoid cloning you can also use `into_loaded_piece_data` here.
//! let piece = pieces[0].load_piece_data(None).unwrap();
//!
//!
//! // Get the first cell attribute.
//! let attribute = &piece.data.cell[0];
//!
Expand All @@ -86,12 +86,15 @@
//! } else {
//! panic!("First attribute is not a field");
//! };
//!
//!
//! assert_eq!(data.as_slice(), &[0.0]);
//! ```
//! ```
#[macro_use]
extern crate nom;

#[doc = include_str!("examples/vertex.rs")]
mod examples;

#[macro_use]
pub mod basic;

Expand Down