Module vtk

Expand description

Conversion to Visual Toolkit (VTK) formats

This module handles all the conversions of weight window sets to Visual Toolkit formats, and is mostly a coupling layer between internal types and the vtkio crate.

§Overview

The intended workflow is to:

  1. Configure the converter
  2. Convert into a vtkio VTK
  3. Write to file in the required format with write_vtk()

Often the default configuration will suffice. The convenience function weights_to_vtk() will quickly convert to a VTK ready for writing with write_vtk().

// Convert to VTK with the default configuration
let vtk = weights_to_vtk(&WeightWindow::default());

// Wite the VTK to a file in one of several formats
write_vtk(vtk, "output.vtk", VtkFormat::Xml).unwrap();

For more comprehensive examples, see the relevant struct documentation and the next section.

§Manual conversion

The fields of WeightsToVtk are left public for direct use but builder patterns are also implemented. A builder helps separate the configuration from the conversion logic, and is often a style preference.

The following examples are therefore equivalent.

§The builder approach:

// Make a new builder, change some values
let converter = WeightsToVtk::builder()
    .resolution(3)
    .compressor(Compressor::LZMA)
    .byte_order(ByteOrder::LittleEndian)
    .build();

// Convert the weight windows using the parameters set
let vtk = weights_to_vtk(&WeightWindow::default());

§The direct approach:

// Make a new instance, change some values
let mut converter = WeightsToVtk::new();
converter.resolution = 2;
converter.compressor = Compressor::LZMA;
converter.byte_order = ByteOrder::LittleEndian;

// Convert the weight windows using the parameters set
let vtk = weights_to_vtk(&WeightWindow::default());

In the background, a call to WeightsToVtk::new() simply returns a default configuration generated by the builder anyway.

Structs§

Vertex
Vertex for use in cylindrical and unstructured mesh types
WeightsToVtk
Convert weight window sets to vtk formats for plotting
WeightsToVtkBuilder
Builder implementation for WeightsToVtk configuration

Enums§

VtkFormat
Enum of VTK output formats

Functions§

weights_to_vtk
Convert a set of weight windows to vtk using default options
write_vtk
Write any vtk to file