VTKBase.jl
The VTKBase.jl package contains common definitions used in the WriteVTK.jl and ReadVTK.jl packages.
VTK dataset types
VTKBase.AbstractVTKDataset — TypeAbstractVTKDatasetAbstract type representing any structured or unstructured VTK dataset.
The dataset classification is described in the VTK file format specification, page 12.
VTKBase.StructuredVTKDataset — TypeStructuredVTKDataset <: AbstractVTKDatasetAbstract type representing a structured VTK dataset.
Subtypes are VTKImageData, VTKRectilinearGrid and VTKStructuredGrid.
VTKBase.VTKImageData — TypeVTKImageData <: StructuredVTKDatasetRepresents the VTK image data format (.vti extension).
This corresponds to rectangular grids with uniform spacing in all directions.
VTKBase.VTKRectilinearGrid — TypeVTKRectilinearGrid <: StructuredVTKDatasetRepresents the VTK rectilinear grid format (.vtr extension).
This corresponds to rectangular grids with non-uniform spacing.
VTKBase.VTKStructuredGrid — TypeVTKStructuredGrid <: StructuredVTKDatasetRepresents the VTK structured grid format (.vts extension).
This corresponds to curvilinear grids, the most general kind of structured grid.
VTKBase.UnstructuredVTKDataset — TypeUnstructuredVTKDataset <: AbstractVTKDatasetAbstract type representing an unstructured VTK dataset.
Subtypes are VTKPolyData and VTKUnstructuredGrid.
VTKBase.VTKPolyData — TypeVTKPolyData <: UnstructuredVTKDatasetRepresents 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 <: UnstructuredVTKDatasetRepresents 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 — TypeAbstractFieldDataAbstract type representing any kind of dataset.
VTKBase.VTKPointData — TypeVTKPointData <: AbstractFieldDataRepresents data that is to be attached to grid points.
VTKBase.VTKCellData — TypeVTKCellData <: AbstractFieldDataRepresents data that is to be attached to grid cells.
VTKBase.VTKFieldData — TypeVTKFieldData <: AbstractFieldDataRepresents 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 — ModuleVTKCellTypesModule 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 — TypeAbstractMeshCellAbstract type specifying a VTK cell.
VTKBase.MeshCell — TypeMeshCell <: AbstractMeshCellSingle 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
PolyDatamodule.
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 — ModulePolyDataDefines cell types for polygonal datasets.
The following singleton types are defined:
PolyData.Vertsfor vertices,PolyData.Linesfor lines,PolyData.Stripsfor triangular strips,PolyData.Polysfor polygons.
VTKBase.VTKPolyhedron — TypeVTKPolyhedron <: AbstractMeshCellRepresents 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 — TypeVTKDataTypeUnion of integer, float and string data types allowed by VTK.