Skip to main content

VtuWriter

Struct VtuWriter 

Source
pub struct VtuWriter { /* private fields */ }
Expand description

Builder-style writer for VTK XML unstructured grid (.vtu) files.

Add points, cells, and optional point data; then call VtuWriter::to_xml or VtuWriter::write_to_file.

Implementations§

Source§

impl VtuWriter

Source

pub fn new() -> Self

Create an empty VTU writer.

Source

pub fn add_point(&mut self, p: [f64; 3]) -> usize

Add a point and return its index.

Source

pub fn add_points(&mut self, pts: &[[f64; 3]]) -> usize

Add multiple points at once and return the index of the first added point.

Source

pub fn num_points(&self) -> usize

Return the number of points currently stored.

Source

pub fn num_cells(&self) -> usize

Return the number of cells currently stored.

Source

pub fn add_cell(&mut self, connectivity: Vec<usize>, cell_type_id: u8)

Add a cell defined by its connectivity (0-based point indices) and VTK cell type.

Source

pub fn add_triangle(&mut self, i0: usize, i1: usize, i2: usize)

Add a triangle cell from three point indices.

Source

pub fn add_quad(&mut self, i0: usize, i1: usize, i2: usize, i3: usize)

Add a quad cell from four point indices.

Source

pub fn add_tet(&mut self, i0: usize, i1: usize, i2: usize, i3: usize)

Add a tetrahedron cell from four point indices.

Source

pub fn add_hex( &mut self, i0: usize, i1: usize, i2: usize, i3: usize, i4: usize, i5: usize, i6: usize, i7: usize, )

Add a hexahedron cell from eight point indices.

Source

pub fn add_point_data_scalar(&mut self, name: &str, values: &[f64])

Attach a named scalar field on points.

Source

pub fn add_point_data_vector(&mut self, name: &str, vectors: &[[f64; 3]])

Attach a named vector field on points.

Source

pub fn write_cell_data_tensor(name: &str, tensors: &[[f64; 6]]) -> String

Write symmetric tensor cell data as a VTK XML snippet.

Each cell supplies 6 components (Voigt notation): xx, yy, zz, xy, xz, yz. Returns an XML DataArray` element string ready to embed in CellData`.

Source

pub fn write_pvtu_parallel( piece_files: &[&str], point_data_names: &[&str], cell_data_names: &[&str], ) -> String

Generate a parallel VTU master file (.pvtu) referencing the given piece files.

piece_files is a slice of relative paths to the individual .vtu pieces. Returns the pvtu XML string.

Source

pub fn add_cell_data_scalar(&mut self, name: &str, values: &[f64])

Attach a named scalar field on cells.

Source

pub fn add_cell_data_vector(&mut self, name: &str, vectors: &[[f64; 3]])

Attach a named vector field on cells.

Source

pub fn bounding_box(&self) -> Option<([f64; 3], [f64; 3])>

Compute the bounding box of all points. Returns (min, max) or None if there are no points.

Source

pub fn to_xml(&self) -> String

Generate the complete VTU XML as a String.

Source

pub fn write_to_file(&self, path: &str) -> Result<()>

Write the VTU XML to a file.

Source

pub fn validate(&self) -> Result<()>

Validate the writer state: check that cell connectivity references only existing point indices and that data arrays have correct length.

Source

pub fn points(&self) -> &[[f64; 3]]

Return the point positions slice.

Source

pub fn cell_types(&self) -> &[u8]

Return the cell types slice.

Source

pub fn cells_per_cell(&self) -> &[Vec<usize>]

Return the per-cell connectivity (each entry is a Vec of point indices).

Source

pub fn cells_flat(&self) -> Vec<usize>

Return a flat connectivity array (concatenation of all cell index lists).

Trait Implementations§

Source§

impl Default for VtuWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.