Animating legacy VTK file series
It is now possible to animate legacy VTK file series. ParaView recognizes file series named using certain patterns including fooN.vtk, foo-N.vtk, foo.N.vtk, Nfoo.vtk, N.foo.vtk where N is an integer (with any number of leading zeros). To load a file series, first make sure that the file names match one of the patterns described above. Next, navigate to the directory where the file series is. The file browser should look like this:
You will see that the file series is collapsed into a group. The picture above shows the group after I clicked on the disclosure triangle. You don't have to do that. Simply select the group (in the picture named blow..vtk) and click ok. The reader will store all the filenames and treat each file as a time step. You can now animate, use annotate time filter, do anything you can do with readers that natively support time.
Making custom readers work with file series
We implemented a reader called vtkFileSeriesReader. This reader can work with any time-unaware reader to read file series as time-steps. For this to work, a vtkFileSeriesReader and a time-unaware reader are created. The vtkFileSeriesReader is what the pipeline sees. Internally, it stores a reference to the time-unaware reader. All file names in the series are passed to the vtkFileSeriesReader. As the time-step is changed, the vtkFileSeriesReader sets the right filename on the internal reader and forwards pipeline requests to it. To setup a vtkFileSeriesReader, all you have to do is to add a new proxy to your xml file. For example, here (/Servers/ServerManager/Resources/reader.xml) is how the VTK legacy reader is converted into a file series reader:
<ProxyGroup name="internal_sources"> <SourceProxy name="legacyreader" class="vtkPDataSetReader" label="Legacy VTK reader"> <Documentation short_help="Read legacy VTK files." long_help="Read files stored in VTK's legacy file format."> The Legacy VTK reader loads files stored in VTK's legacy file format (before VTK 4.2, although still supported). The expected file extension is .vtk. The type of the dataset may be structured grid, uniform rectilinear grid (image/volume), non-uniform rectiinear grid, unstructured grid, or polygonal. </Documentation> <StringVectorProperty name="FileName" animateable="0" command="SetFileName" number_of_elements="1"> <FileListDomain name="files"/> <Documentation> This property specifies the file name for the Legacy VTK reader. </Documentation> </StringVectorProperty> <Hints> <ReaderFactory extensions="vtk" file_description="Legacy VTK files" /> </Hints> <!-- End legacyreader --> </SourceProxy> </ProxyGroup> ... <ProxyGroup name="sources"> ... <FileSeriesReaderProxy name="LegacyVTKFileReader" class="vtkFileSeriesReader" label="Legacy VTK reader" file_name_method="SetFileName"> <Documentation short_help="Read legacy VTK files." long_help="Read files stored in VTK's legacy file format."> The Legacy VTK reader loads files stored in VTK's legacy file format (before VTK 4.2, although still supported). The expected file extension is .vtk. The type of the dataset may be structured grid, uniform rectilinear grid (image/volume), non-uniform rectiinear grid, unstructured grid, or polygonal. This reader also supports file series. </Documentation> <SubProxy> <Proxy name="Reader" proxygroup="internal_sources" proxyname="legacyreader"> </Proxy> </SubProxy> <StringVectorProperty name="FileNames" clean_command="RemoveAllFileNames" command="AddFileName" animateable="0" number_of_elements="0" repeat_command="1"> <FileListDomain name="files"/> <Documentation> The list of files to be read by the reader. If more than 1 file is specified, the reader will switch to file series mode in which it will pretend that it can support time and provide 1 file per time step. </Documentation> </StringVectorProperty> <DoubleVectorProperty name="TimestepValues" repeatable="1" information_only="1"> <TimeStepsInformationHelper/> <Documentation> Available timestep values. </Documentation> </DoubleVectorProperty> <Hints> <ReaderFactory extensions="vtk" file_description="Legacy VTK files" /> </Hints> <!-- End legacyreader_t --> </FileSeriesReaderProxy> ...
Note that the reader xml is unchanged, other than being moved into another group (internal_sources). The name of this group is arbitrary. A FileSeriesReaderProxy element is put in the sources group. This proxy element has a few important attributes/elements:
- file_name_method: this is the method used to set the file name of the internal reader. In this case, vtkPDataSetReader
- SubProxy named reader: This should point to the time-unaware reader proxy group and name
- FileNames property - copy this verbatim
- TimestepValues property - copy this verbatim