VTK/Writing VTK files using python: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
Before writing VTK files, you have to know that there are two kinds of VTK files: "legacy" VTK files and "XML" VTK files. The first kind is quite obsolete now, but still widely used. Although it is easier to write than the XML kind | Before writing VTK files, you have to know that there are two kinds of VTK files: "legacy" VTK files and "XML" VTK files. The first kind is quite obsolete now, but still widely used. Although it is easier to write than the XML kind | ||
(understand: with low-level instructions like "printf" in C or "print" in python), this wiki will focus on the last kind, the XML format. | (understand: with low-level instructions like "printf" in C or "print" in python), this wiki will focus on the last kind, the XML format. | ||
= Datasets format = | |||
As you should already be aware if you have read the [http://www.vtk.org/pdf/file-formats.pdf VTK file formats documentation], VTK can handle several datasets. The mainly kinds of datasets are: | |||
* StructuredPoints; | |||
* RectilinearGrid; | |||
* StructuredGrid; | |||
* UnstructuredGrid; | |||
* PolyData. |
Revision as of 17:54, 11 August 2007
Before starting, you are strongly advised to read the VTK file formats documentation here.
Introduction
The purpose of this wiki is to show how one can write VTK files using python.
Why using python ? Because it's beautiful & powerful, of course ! ;-)
Obviously, you can use your favourite programming language to write such files. Mine is python. No more, no less.
In the following, the data you want to write to a VTK file are supposed to arise from scipy/numpy arrays. Please browse scipy.org to get more information if needed.
Before writing VTK files, you have to know that there are two kinds of VTK files: "legacy" VTK files and "XML" VTK files. The first kind is quite obsolete now, but still widely used. Although it is easier to write than the XML kind (understand: with low-level instructions like "printf" in C or "print" in python), this wiki will focus on the last kind, the XML format.
Datasets format
As you should already be aware if you have read the VTK file formats documentation, VTK can handle several datasets. The mainly kinds of datasets are:
- StructuredPoints;
- RectilinearGrid;
- StructuredGrid;
- UnstructuredGrid;
- PolyData.