VTKBase.jl
The VTKBase.jl package contains common definitions used in the WriteVTK.jl and ReadVTK.jl packages.
VTK dataset types
VTKBase.AbstractVTKDataset
— TypeAbstractVTKDataset
Abstract type representing any structured or unstructured VTK dataset.
The dataset classification is described in the VTK file format specification, page 12.
VTKBase.StructuredVTKDataset
— TypeStructuredVTKDataset <: AbstractVTKDataset
Abstract type representing a structured VTK dataset.
Subtypes are VTKImageData
, VTKRectilinearGrid
and VTKStructuredGrid
.
VTKBase.VTKImageData
— TypeVTKImageData <: StructuredVTKDataset
Represents the VTK image data format (.vti
extension).
This corresponds to rectangular grids with uniform spacing in all directions.
VTKBase.VTKRectilinearGrid
— TypeVTKRectilinearGrid <: StructuredVTKDataset
Represents the VTK rectilinear grid format (.vtr
extension).
This corresponds to rectangular grids with non-uniform spacing.
VTKBase.VTKStructuredGrid
— TypeVTKStructuredGrid <: StructuredVTKDataset
Represents the VTK structured grid format (.vts
extension).
This corresponds to curvilinear grids, the most general kind of structured grid.
VTKBase.UnstructuredVTKDataset
— TypeUnstructuredVTKDataset <: AbstractVTKDataset
Abstract type representing an unstructured VTK dataset.
Subtypes are VTKPolyData
and VTKUnstructuredGrid
.
VTKBase.VTKPolyData
— TypeVTKPolyData <: UnstructuredVTKDataset
Represents the VTK polydata format (.vtp
extension).
These are unstructured datasets that accept a limited set of cells types, defined in the PolyData
module.
VTKBase.VTKUnstructuredGrid
— TypeVTKUnstructuredGrid <: UnstructuredVTKDataset
Represents the VTK unstructured format (.vtu
extension).
This is the most general kind of unstructured grid, which accepts all cell types defined in the VTKCellTypes
module.
Field data types
In VTK, data can either be attached to the geometry (point and cell data), or not (field data).
VTKBase.AbstractFieldData
— TypeAbstractFieldData
Abstract type representing any kind of dataset.
VTKBase.VTKPointData
— TypeVTKPointData <: AbstractFieldData
Represents data that is to be attached to grid points.
VTKBase.VTKCellData
— TypeVTKCellData <: AbstractFieldData
Represents data that is to be attached to grid cells.
VTKBase.VTKFieldData
— TypeVTKFieldData <: AbstractFieldData
Represents data that is not attached to the grid geometry.
This is typically used for lightweight metadata, such as timestep information or strings.
Cells in unstructured grids
General unstructured datasets
These are useful when working with general unstructured datasets (.vtu
files).
VTKBase.VTKCellTypes
— ModuleVTKCellTypes
Module defining cell types for unstructured datasets.
Definitions are adapted from the VTK source code
.
VTKBase.VTKCellTypes.nodes
— Functionnodes(c::VTKCellTypes)
Returns the number of nodes (or grid points) required by the cell type.
For instance, this returns 3 for VTK_TRIANGLE
.
For cell types that can take any number of nodes, such as VTK_POLY_LINE
, this returns -1.
VTKBase.AbstractMeshCell
— TypeAbstractMeshCell
Abstract type specifying a VTK cell.
VTKBase.MeshCell
— TypeMeshCell <: AbstractMeshCell
Single cell element in unstructured or polygonal grid.
It is characterised by a cell type (for instance, VTKCellType.TRIANGLE
or PolyData.Strips
) and by a connectivity vector determining the points on the grid defining this cell.
MeshCell(cell_type, connectivity)
Define a single cell element of an unstructured grid.
The cell_type
argument characterises the type of cell (e.g. vertex, triangle, hexaedron, ...):
- cell types for unstructured datasets are defined in the
VTKCellTypes
module;
- cell types for polygonal datasets are defined in the
PolyData
module.
The connectivity
argument is a vector or tuple containing the indices of the points passed to vtk_grid
which define this cell.
Example
Define a triangular cell passing by points with indices [3, 5, 42]
.
julia> cell = MeshCell(VTKCellTypes.VTK_TRIANGLE, (3, 5, 42))
MeshCell{VTKCellType, Tuple{Int64, Int64, Int64}}(VTKCellType("VTK_TRIANGLE", 0x05, 3), (3, 5, 42))
Polygonal datasets
These are useful when working with polygonal datasets (.vtp
files).
VTKBase.PolyData
— ModulePolyData
Defines cell types for polygonal datasets.
The following singleton types are defined:
PolyData.Verts
for vertices,PolyData.Lines
for lines,PolyData.Strips
for triangular strips,PolyData.Polys
for polygons.
VTKBase.VTKPolyhedron
— TypeVTKPolyhedron <: AbstractMeshCell
Represents a polyhedron cell in an unstructured grid.
Using VTKPolyhedron
should be preferred to using a MeshCell
with a cell type VTKCellTypes.VTK_POLYHEDRON
, since the latter cannot hold all the necessary information to describe a polyhedron cell.
VTKPolyhedron(connectivity, faces...)
Construct polyhedron cell from connectivity vector (see MeshCell
for details) and from a list of polyhedron faces.
Example
Create a polyhedron with 8 points and 6 faces. This can represent a cube if the 8 points are properly positioned.
julia> cell = VTKPolyhedron(
1:8,
(1, 4, 3, 2),
(1, 5, 8, 4),
(5, 6, 7, 8),
(6, 2, 3, 7),
(1, 2, 6, 5),
(3, 4, 8, 7),
)
VTKPolyhedron{UnitRange{Int64}, NTuple{6, NTuple{4, Int64}}}(1:8, ((1, 4, 3, 2), (1, 5, 8, 4), (5, 6, 7, 8), (6, 2, 3, 7), (1, 2, 6, 5), (3, 4, 8, 7)))
Constants
VTKBase.VTKDataType
— TypeVTKDataType
Union of integer, float and string data types allowed by VTK.