# vtkPolyDataReader2

**URL:** <https://discourse.vtk.org/t/vtkpolydatareader2/10563>\
**Category:** Development\
**Created:** [January 30, 2023, 8:48pm UTC](https://discourse.vtk.org/t/vtkpolydatareader2/10563 "2023-01-30T20:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)\
**Post date:** [January 30, 2023, 8:48pm UTC](https://discourse.vtk.org/t/vtkpolydatareader2/10563/1 "2023-01-30T20:48:44Z")

</div>

I am making a PolyDataFileSeriesReader similar to what is found in ParaView for ImageData, but supporting streaming (to save memory) in the situation where all files are processed as a whole. Further, it supports temporal streaming when files are not read at once.

In this regards, it would be awesome if all poly data reader were inheriting from say vtkPolyDataReader2 and to create a collection and a factory for creating poly data readers.

Is there a reason why no abstract is present for all poly data reader? If there isn’t would you such an abstraction and corresponding collection and a factory?

If I would like to contribute with this, is there a nice pretty printer to make my code conform (identation etc.) to the form used in the repository?

Thanks in advance  
Jens Munk

---

<div class="post-metadata">

**Author:** ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)\
**Post date:** [January 31, 2023, 6:44pm UTC](https://discourse.vtk.org/t/vtkpolydatareader2/10563/2 "2023-01-31T18:44:52Z")

</div>

The [vtkAbstractPolyDataReader](https://vtk.org/doc/nightly/html/classvtkAbstractPolyDataReader.html) already exists but it’s only used as the base for a small number of readers. It isn’t used for the [classic .vtk readers](https://vtk.org/doc/nightly/html/classvtkReaderAlgorithm.html) or for the [VTK XML readers](https://vtk.org/doc/nightly/html/classvtkXMLReader.html). One of the reasons is that many VTK developers prefer to define their I/O abstractions at the level of vtkDataSet or even vtkDataObject rather than at the level of vtkPolyData.

I can’t say much about factory mechanisms for readers, I’ve generally done that at the application level rather than using VTK. In python, a simple dict with a bit of support code is easier to work with than a vtkCollection. Before making a factory, I’d suggest looking at how Paraview already handles choosing its readers.

The official “styler” for VTK is clang-format (the VTK repository has a [.clang-format](https://gitlab.kitware.com/vtk/vtk/-/blob/master/.clang-format) at its root). But because clang-format cannot automatically add braces, you might want to run the code through astyle first (e.g. `astyle -s2 -j -S -K file.cxx`) and then use clang-format as a second step.

---

<div class="post-metadata">

**Author:** ![Jens\_Munk\_Hansen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jens_munk_hansen/32/1215_2.png) [@Jens\_Munk\_Hansen](https://discourse.vtk.org/u/Jens_Munk_Hansen)\
**Post date:** [January 31, 2023, 6:59pm UTC](https://discourse.vtk.org/t/vtkpolydatareader2/10563/3 "2023-01-31T18:59:57Z")

</div>

I did a small factory with a wrapper object safe-down casting a vtkAlgothm to the respektive readers. I see now the challenges with generic formats which contain vtkDataSet. Looking back, I found it most elegant to create a SetReader which takes as argument a vtkAlgorithm - ParaView does the same.

Thanks for the feedback. I use astyle already with git hooks. I will change them to match those from VTK in case I make something general enough for a PR
