vtkFileSeriesReader Multi-Output-Port Support

Allow vtkFileSeriesReader to support multi-output-port readers


Summary

We’ve successfully implemented file series support for a 3-output-port reader by subclassing vtkFileSeriesReader and overriding just the constructor. This works because the base class code is already generic with respect to output count—only the hardcoded SetNumberOfOutputPorts(1) in the constructor limits it to single-port readers. We’d like to request this be made configurable upstream.

Background

We developed the WARPM ParaView Reader Plugin with two reader classes:

  1. vtkWARPMReader - Single output port (standard physical-space data)
  2. vtkWARPMPhaseSpaceReader - Three output ports:
    • Port 0: Physical space mesh
    • Port 1: Velocity space mesh (at user-selected location)
    • Port 2: Probe position marker

The Problem

When wrapping the 3-port reader with vtkFileSeriesReader using the standard XML pattern:

<SourceProxy name="WARPMPhaseSpaceReader"
             class="vtkFileSeriesReader"
             si_class="vtkSIMetaReaderProxy"
             file_name_method="SetFileName">
  <SubProxy>
    <Proxy name="Reader" proxygroup="internal_sources"
           proxyname="WARPMPhaseSpaceReaderCore" />
  </SubProxy>
  <OutputPort index="0" name="Physical Space" />
  <OutputPort index="1" name="Velocity Space" />
  <OutputPort index="2" name="Slice Position" />
</SourceProxy>

…the plugin crashes with a segmentation fault on UpdatePipeline().

Root Cause

Looking at the vtkFileSeriesReader source, the constructor explicitly sets:

this->SetNumberOfOutputPorts(1);

However, the rest of the class (including FillOutputPortInformation, RequestInformation, RequestData, etc.) is written generically and works fine with multiple output ports.

Our Solution

Following the approach described by @Keith_Ballard_CIV in this thread, we created a minimal subclass:

vtkWARPMPhaseSpaceFileSeriesReader.h:

class WARPMREADERCORE_EXPORT vtkWARPMPhaseSpaceFileSeriesReader : public vtkFileSeriesReader
{
public:
  static vtkWARPMPhaseSpaceFileSeriesReader* New();
  vtkTypeMacro(vtkWARPMPhaseSpaceFileSeriesReader, vtkFileSeriesReader);

protected:
  vtkWARPMPhaseSpaceFileSeriesReader();
  ~vtkWARPMPhaseSpaceFileSeriesReader() override = default;
  // ...
};

vtkWARPMPhaseSpaceFileSeriesReader.cxx:

vtkWARPMPhaseSpaceFileSeriesReader::vtkWARPMPhaseSpaceFileSeriesReader()
{
  // Override base class's SetNumberOfOutputPorts(1) to support 3 outputs
  this->SetNumberOfOutputPorts(3);
}

Updated XML (WARPMReader.xml):

<SourceProxy name="WARPMPhaseSpaceReader"
             class="vtkWARPMPhaseSpaceFileSeriesReader"
             si_class="vtkSIMetaReaderProxy"
             file_name_method="SetFileName">
  <!-- ... same SubProxy and OutputPort declarations ... -->
</SourceProxy>

Result: File series support works perfectly for our 3-output-port reader. Users can select multiple .h5 files and ParaView treats them as a time series with all three output ports updating correctly.

Feature Request

Since the workaround is so minimal (literally one line in the constructor), would it be possible to make vtkFileSeriesReader configurable for the number of output ports? Options could include:

  1. Query the internal reader: In FillOutputPortInformation, if a reader is set, use Reader->GetNumberOfOutputPorts() to determine the count
  2. XML attribute: Add an optional attribute like number_of_output_ports="3" to the ServerManager XML
  3. Constructor parameter: Allow the output port count to be specified at construction time

This would eliminate the need for plugin developers to create trivial subclasses just to change the port count (and need to locate these forum posts revealing the workaround).

Environment

  • ParaView 6.0 (built from source)
  • VTK 9.5.2
  • macOS / Darwin

References

Thank you for considering this enhancement!

You definitely can open a merge request to share these improvements :slight_smile:

MR: https://gitlab.kitware.com/paraview/paraview/-/merge_requests/7637

Sorry, I didn’t mean to make it sound trivial for me. I would have never gotten this far without my buddy Claude.