Reading File Series

From ParaQ Wiki
Jump to navigationJump to search

Overview

One feature we lost in 3.0 is the ability to read and animate file series. The common use cases for file series are:

  1. Read and animate a series of files. The file format used usually does not support time natively. The user ends up writing one file per time step. The files are named with a certain pattern such as foo_0.vtk, foo_1.vtk etc...
  2. Read a file series and treat it as time-dependent data, allowing time-aware algorithms such as plot over time, particle tracking etc.

Solution

File Series Reader

vtkFileSeriesReader is a time-aware reader that keeps track of a series of files and delegates the actual reading to an internal reader. It's public API allows addition of files (and possibly a file pattern). Once all files are added, it reports available time steps in RequestInformation(). In RequestUpdateExtent(), it takes the update request, converts it to a file name and sets this file name on the internal reader. Other than these, it forwards all pipeline requests to the internal reader. vtkFileSeriesReader also supports CanReadFile(). It forwards calls to the method to the internal reader if it supports it and returns the result. In order to support different reader types not necessarily with a common reader superclass, the vtkFileSeriesReader uses client/server streams to invoke certain methods on the internal reader.

In order to add a file series reader, you have to define 2 proxies. The first one is a proxy for the internal reader defined as usual. I will be putting these in an internal_sources group. Second, you have to define a FileSeriesReaderProxy that has a Reader sub-proxy pointing to the internal reader. This is the proxy that is exposed to the GUI. vtkSMFileSeriesReaderProxy is a pretty simple class. All it does is to call SetReader on the vtkFileSeriesReader with the internal reader.

File Dialog

From the user point of view (ideally), if user selects multiple files with different file formats and/or series from the file dialog, OR drag-n-drop multiple files directly from a file explorer into the pileline browser, ParaView3 should automatically find all proper readers for all file formats and series, and add all the files (readers) to the pipleline browser. For example, if user selects "foo.vtk, bar.vts, foo1.vti, foo2.vti, foo3.vti", the pipeline browser should add "foo.vtk", "bar.vts", "foo_...vti" to the tree, and if user selects "foo_...vti" in the tree, ParaView3 should know that this is a file series, and load whatever GUI is necessary. This, in theory, is not a big deal in terms of implementation, because we are getting the proper reader for the selected file already.

We can add more patterns internally to find more group of files, and we could also add something on the file dialog GUI to allow users to add more patterns themselves.

For now (3.2), we can make the vtkFileSeriesReader work first, which should(I think) only allow single-selection in the file dialog, and if user selects a group file name (foo_...vti), we use the vtkFileSeriesReader to load the file series. Of course, the rest of the application still needs to know how to deal with this vtkFileSeriesReader. If the user selects a non-group file or a single file within a group, we just deal with that as a single file.