Reader plugin to extent vtk reader not used when accessing files

Hi,
I’m trying to write a plugin to extend the functionality of the vtkFileSeriesReader and I’m having trouble getting ParaView to use my reader to access the .vtp files. At the moment ParaView loads my plugin (I put a warning in the constructor) and then falls back to using the vtkXMLPolyDataReader. I used the How to Plugin and the File Series resources and copied the .h and .cxx files of the vtkFileSeriesReader to create my plugin. Can somebody point me to the mechanism where ParaView decides which reader to use, when loading a file?

My vtk.module contains this:

NAME
FileSeriesReaders
DEPENDS
  VTK::IOCore
  VTK::CommonCore
  VTK::IOXML
  ParaView::VTKExtensionsIOCore

My ParaView.plugin file contains this:

NAME
  FileSeriesReader
DESCRIPTION
  Expose the vtkFileSeriesReader class to ParaView.
REQUIRES_MODULES
  VTK::IOCore
  VTK::CommonCore
  ParaView::VTKExtensionsIOCore

And my XML file contains this:

«ServerManagerConfiguration»
 «ProxyGroup name="internal_sources"»
   «SourceProxy name="legacyreader" 
                class="vtkXMLPolyDataReader"
                label="Legacy VTP reader"»
     «Documentation
       short_help="Read legacy VTP files."
       long_help="Read files stored in VTP'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="vtp vtp.series"
          file_description="Legacy VTP files" /»
     «/Hints»
   «!-- End legacyreader --»
   «/SourceProxy»
 «/ProxyGroup»
 «ProxyGroup name="sources"»
   «SourceProxy name="MyFileSeriesReader"
                          class="vtkMyFileSeriesReader"
                          label="FileSeriesReader"
                          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="FileNameInfo"
    command="GetCurrentFileName"
    information_only="1" »
    «SimpleStringInformationHelper /»
 «/StringVectorProperty»

 «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="vtp vtp.series"
      file_description="My VTP File Format" /»
 «/Hints»
 «!-- End legacyreader_t --»
   «/SourceProxy»
 «/ProxyGroup»
«/ServerManagerConfiguration»

Your reader seems to be using the legacy reader internally, which is unable to read .vtp file.

Is it still possible to use the FileSeriesReader to access a series of .vtp files? And if so is the vtkXMLPolyDataReader the right one or do I have to use a different reader?
P.S. Thank you for the edit.

Yes and Yes

So my XML file should look something like this? Because even with this XML I don’t see calls of any of the FileSeriesReaders methods except the constructor.

<ServerManagerConfiguration>
 <ProxyGroup name="internal_sources">
   <SourceProxy name="XMLPolyDataReader" 
				class="vtkXMLPolyDataReader"
				label="XML VTP reader">
	 <Documentation
	   short_help="Read XML VTP files."
	   long_help="Read files stored in VTP's XML file format.">
	 </Documentation>
	 <StringVectorProperty
		name="FileName"
		animateable="0"
		command="SetFileName"
		number_of_elements="1">
		<FileListDomain name="files"/>
		<Documentation>
		  This property specifies the file name for the XML VTK reader.
		</Documentation>
	 </StringVectorProperty>
	 <Hints>
	  <ReaderFactory extensions="vtp vtp.series"
		  file_description="My VTP File Format" />
	 </Hints>
   </SourceProxy>
 </ProxyGroup>

 <ProxyGroup name="sources">
   <SourceProxy name="MyFileSeriesReader"
						  class="vtkMyFileSeriesReader"
						  label="FileSeriesReader"
						  file_name_method="SetFileName">
	 <Documentation
	   short_help="Read XML VTK files."
	   long_help="Read files stored in VTK's XML file format.">
	 </Documentation>
  
	 <SubProxy>
		<Proxy name="Reader"
		  proxygroup="internal_sources" proxyname="XMLPolyDataReader">
		</Proxy>
	 </SubProxy>

	  <StringVectorProperty name="FileNameInfo"
		command="GetCurrentFileName"
		information_only="1" >
		<SimpleStringInformationHelper />
	 </StringVectorProperty>

	 <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="vtp vtp.series"
		  file_description="My VTP File Format" />
	 </Hints>
   </SourceProxy>
 </ProxyGroup>
</ServerManagerConfiguration>

Thank you very much for your help. I forgot to add the si_class in the XML-file. Everything is working as intended now.

1 Like