# Contribution including VTK filter

**URL:** https://discourse.paraview.org/t/contribution-including-vtk-filter/2884
**Category:** Development
**Tags:** vtk
**Created:** [October 31, 2019, 8:24am UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884 "2019-10-31T08:24:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![SimonFuet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@SimonFuet](https://discourse.paraview.org/u/SimonFuet)
#### Post date: [October 31, 2019, 8:24am UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/1 "2019-10-31T08:24:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [October 31, 2019, 8:41am UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/2 "2019-10-31T08:41:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Dave\_DeMarle](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dave_demarle/32/27_2.png) [@Dave\_DeMarle](https://discourse.paraview.org/u/Dave_DeMarle)
#### Post date: [October 31, 2019, 11:56am UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/3 "2019-10-31T11:56:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [October 31, 2019, 12:26pm UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/4 "2019-10-31T12:26:15Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![SimonFuet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@SimonFuet](https://discourse.paraview.org/u/SimonFuet)
#### Post date: [October 31, 2019, 1:35pm UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/5 "2019-10-31T13:35:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Dave\_DeMarle](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dave_demarle/32/27_2.png) [@Dave\_DeMarle](https://discourse.paraview.org/u/Dave_DeMarle)
#### Post date: [October 31, 2019, 9:27pm UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/6 "2019-10-31T21:27:05Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![SimonFuet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/e95f7d/32.png) [@SimonFuet](https://discourse.paraview.org/u/SimonFuet)
#### Post date: [November 1, 2019, 11:14am UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/7 "2019-11-01T11:14:00Z")

</div>

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](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

---

<div class="post-metadata">

### Author: ![HollowSun0](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hollowsun0/32/431_2.png) [@HollowSun0](https://discourse.paraview.org/u/HollowSun0)
#### Post date: [November 1, 2019, 1:49pm UTC](https://discourse.paraview.org/t/contribution-including-vtk-filter/2884/8 "2019-11-01T13:49:26Z")

</div>

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.
