title: How to write a ProgrammableSource filter to display a numpy array as a vtkImageData in ParaView?
body: <p>So instead of storing every data we have in yet another format to make it displayable by ParaView, I wanted to use the python interface ParaView offers to directly load our data from our current file format and display it.</p>
  
  <p>To test this out I wanted to create a simple <code>ProgrammableSource</code> filter that outputs a vtkImageData and fill it with some data.</p>
  
  <p>I encountered three issues:</p>
  
  <ul>
  <li>First, the data is not displayed (not even as an outline representation)</li>
  <li>I could not find a way to set the values without looping </li>
  <li>I did not find a good online source that could help me</li>
  </ul>
  
  <p>Here is what I have so far. No complaints from ParaView, but also nothing is rendered.</p>
  
  <pre class="lang-python prettyprint-override"><code>import numpy as np
  import vtk
  import vtk.util.numpy_support as ns
  
  img = self.GetImageDataOutput()
  img.SetDimensions(3,4,5)
  img.AllocateScalars(vtk.VTK_DOUBLE, 1)
  
  
  dims = img.GetDimensions()
  img.SetOrigin(0,0,0)
  img.SetSpacing(0.55, 0.55, 0.55)
  
  for z in range(dims[2]):
    for y in range(dims[1]):
      for x in range(dims[0]):
        img.SetScalarComponentFromDouble(x,y,z,0, 1.0*x*y*z)
  </code></pre>
  
  <p><strong>NOTE:</strong> If it is easier to use the python shell of ParaView directly instead of the ProgrammableSource, this would also be ok.</p>