vtkXMLPolyDataReader get data per each Piece

I have a VTP file with some number of Pieces in it, representing separate geometry regions. What I want to do is to assign a separate actor for each Piece to be able to differentiate them using picker in Paraview Shell script. There’s a reader in vtkmodules called vtkXMLPolyDataReader which has a property GetNumberOfPieces returning correct number of pieces in VTP file after reading.

The question is how to extract the data belonging to a particular Piece?

reader = vtkXMLPolyDataReader()
reader.SetFileName(filePath)
reader.Update()
mapper = vtkPolyDataMapper()
mapper.SetInputData(put here code to extract data for i-th piece)

Hi @CapLek ,

Is this a ParaView question or VTK question ?

Best,

Hi Mathieu,

This is VTK inside Paraview Python Shell question. I know there is a VTK specific forum but I`m sure this is a better place to ask. Because mentioned reader and overall approach should work inside Paraview.

Thanks, Oleh

VTK inside ParaView Python Sheel is not supposed.

In any case, what you want to do is not possible with ParaView, you need to separate your data. Maybe the Connectivity filter works for you.

If it is not supposed, why is it available through the API?

Let’s imagine that this is the VTK question under Python API. How can I get geometry data for separate piece from the VTP file red using vtkXMLPolyDataReader?

Thanks, Oleh

If it is not supposed, why is it available through the API?

It is not available unless you import VTK specifically.

Let’s imagine that this is the VTK question under Python API. How can I get geometry data for separate piece from the VTP file red using vtkXMLPolyDataReader?

Is your dataset separated in pieces ?
If that is the case, use UpdatePiece:

https://vtk.org/doc/nightly/html/classvtkAlgorithm.html#a3646e9bc4a9c088879adb82060f19c17

1 Like

Mathieu, thank you very much for the help! It worked!

1 Like