VTK (.vtk)
Background & Context
-
- 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 & 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 expri as specifying the corresponding elemi.
- 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 following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - 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 "VertexData" "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 "Graphics3D" element by default for VTK files.
- The "VertexData" element corresponds to the first argument of GraphicsComplex.
Options
- General Import options:
-
Background Automatic what background color to use ImageSize Automatic overall size of the graphics to display Lighting Automatic what simulated lighting to use in coloring 3D surfaces - All options of Graphics3D can be given when importing from VTK.
- Export option:
-
"BinaryFormat" False whether 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, the Wolfram Language assumes that in the coordinate system used by the VTK format, the vertical axis corresponds to the third coordinate.
- With the setting "VerticalAxis"->{0,1,0}, the Wolfram Language will apply the transformation {x,y,z}->{x,-z,y} to all graphics coordinates when importing from VTK, and the inverse transformation when exporting to VTK.