VTK (.vtk)

Visualization Toolkit format.
Used for storage of 3D models.
Native format of the open-source Visualization Toolkit software.
ASCII or binary format.
VTK is an acronym derived from Visualization Toolkit.
Stores a single 3D object as a collection of line, point, and polygon primitives and their properties.
Can also store nonlinear graphics primitives.
Allows user-defined format elements.
Originally developed by Kitware.
  • Import and Export are fully compatible with the ASCII and binary versions of the VTK format.

Import and ExportImport and Export

  • Import["file.vtk"] imports the polygon information from a VTK file and returns it as a Graphics3D object.
  • Export["file.vtk", expr] exports a Graphics3D or GraphicsComplex expression to a VTK file.
  • Import["file.vtk"] returns an expression of the form Graphics3D[ GraphicsComplex[...]].
  • Import["file.vtk", elem] imports the specified element from a VTK file.
  • Import["file.vtk", {elem, sub, ...}] imports a subelement.
  • Import["file.vtk", {{elem1, elem2, ...}}] imports multiple elements.
  • The import format can be specified with Import["file", "VTK"] or Import["file", {"VTK", elem, ...}].
  • Export["file.vtk", expr, elem] creates a VTK file by treating expr as specifying element elem.
  • Export["file.vtk", {expr1, expr2, ...}, {{elem1, elem2, ...}}] treats each as specifying the corresponding .
  • Export["file.vtk", expr, opt1->val1, ...] exports expr with the specified option elements taken to have the specified values.
  • Export["file.vtk", {elem1->expr1, elem2->expr2, ...}, "Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the VTK format.

ElementsElements

  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "CuboidData"cuboid data in indexed form
    "CuboidObjects"list of Cuboid primitives given in absolute coordinates
    "Graphics3D"VTK file represented as a Graphics3D object
    "GraphicsComplex"VTK file as a GraphicsComplex object
    "LineData"the line elements of a VTK file in indexed form, with integer indices referencing the vertices as given by
    "LineObjects"list of Line primitives given in absolute coordinates
    "PolygonData"the polygon elements in indexed form
    "PolygonObjects"list of Polygon primitives given in absolute coordinates
    "VertexData"list of vertex coordinates
    "PointData"point data in indexed form
    "PointObjects"list of Point primitives given in absolute coordinates
  • Import and Export use the element by default for VTK files.
  • The element corresponds to the first argument of GraphicsComplex.

OptionsOptions

  • General Import options:
  • BackgroundAutomaticwhat background color to use
    ImageSizeAutomaticoverall size of the graphics to display
    LightingAutomaticwhat simulated lighting to use in coloring 3D surfaces
  • All options of Graphics3D can be given when importing from VTK.
  • Export option:
  • "BinaryFormat"Falsewhether to create a binary VTK file
  • Advanced option:
  • "VerticalAxis"{0,0,1}orientation to assume for the coordinate system used in the file
  • By default, Mathematica assumes that in the coordinate system used by the VTK format the vertical axis corresponds to the third coordinate.
  • With the setting , Mathematica will apply the transformation to all graphics coordinates when importing from VTK, and the inverse transformation when exporting to VTK.

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Import a VTK file:

In[1]:=
Click for copyable input
Out[1]=

Export a 3D model to an ASCII VTK file:

In[1]:=
Click for copyable input
Out[1]=

Retrieve a list of available elements:

In[1]:=
Click for copyable input
Out[1]=

Directional red light:

In[1]:=
Click for copyable input
Out[1]=

Points-based representation of the model:

In[1]:=
Click for copyable input
Out[1]=
New in 8
New to Mathematica? Find your learning path »
Have a question? Ask support »