Contribution including VTK filter

Hi all,

I need an ImageData source (from just an origin, number of cells and size of cells (or grid extent). From what I’ve seen there isn’t any yet, so I’m going to create one (there’s not much work).
It should be a filter class (vtkImageDataSource) in VTK and an XML declaration in the Paraview repository.
Should I first create the VTK filter, integrate it in VTK and then add the XML declaration in Paraview or can I do both in one time merge request?

Thanks

Simon

Sounds a lot like the vtkRTAnalyticSource or the vtkImageSimpleSource.
You may want to check them out.

Yeah seems like you can do what you want as Mathieu suggested, just strip the Point and Cell data after that fact (Python Programmable Filter does this by default).

But in answer to your question the right way to go about it is to make a merge request to VTK first, and subsequently, after the VTK merge is accepted, make a merge request to ParaView that updates ParaView’s VTK to the new VTK master.

A shortcut is to add the VTK level filter to ParaView’s VTKExtensions directory, but that is not really recommended.

You can also strip the Point and Cell data with the Pass Arrays filter too. That filter is a little less intimidating than the Programmable Filter.

If you’re comfortable with the Programmable Filter though the Programmable Source is also a very simple option here for a bare vtkImageData.

Thank you all for your answers.
I had not found the vtkRTAnalyticSource and vtkImageSimpleSource classes (I didn’t even know there was some vtk classes in paraview’s VTKExtensions). I also found the vtkImageSimpleSource class.

The two mentionned sources seems to do more than what I really need. All I need is a way to create a vtkImageData without any data associated to it. so technically all I should need is an origin, a number of cells in each direction and a size of cell in each direction. I could quite easily do it with a Programmable Source (in fact I did it though I can’t see anything in the viewer or spreadsheet view…), but lambda users won’t, they will only want to enter the 9 required parameters.

Here is my programmable source:
Output data set type: vtkImageData
“”"
import numpy as np

output.SetOrigin([1, 0, 0])
output.SetExtent(0, 9, 0, 5, 0, 1)
output.SetSpacing(2, 4, 6)

prop = np.arange(0, 120, dtype=np.int32)
output.PointData.append(prop, ‘prop’)

prop2 = np.arange(0, 45, dtype=np.int32)
output.CellData.append(prop2, ‘prop2’)
“”"
When I apply it, the information tab is updated with consistent nb cells, nb points, data arrays, extent and bounds, but I can’t see anything in the viewer. Any idea why?

Sorry I’m just a beginner with Paraview, I followed the last trainings in Lyon (VTK, paraview beginner and advanced) and I’ve played a little with it but that’s all.

Since it is an image data, you also need to announce the extents in the programmable source’s RequestInformation stage otherwise ParaView doesn’t really understand what the source makes without that step.

Hi,

Thanks for the tip

I’ve tried this example: https://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters#Producing_Image_Data_.28Source.29
(which may be outdated?).

I have the following error: AttributeError: ‘vtkCommonExecutionModelPython.vtkCompositeDataPipe’ object has no attribute ‘SetExtentTranslator’ at the following line:
executive.SetExtentTranslator(outInfo, vtk.vtkExtentTranslator())

After a lot of research in the ParaView Guide, online doc, wiki…, the C++ vtkCompositeDataPipeline class (is it the equivalent of the Python one above?) doesn’t seem to have a SetExtentTranslator method, but I never found out what I shoud do instead…

In any case thank you all for your help

Storing the vtkImageData in a vtkMultiBlockDataSet removes the need for setting the (extent, origin, spacing) in RequestInformation, but in exchange of losing the “Volume” display representation.