title: Example for vtkContourGrid
body: <p>I am trying to make contour plot from unstructured grid. My code does not work and I could not find an example to follow. I did not include the input file, hoping that a sample unstructured grid is easy to find. I managed to make work on Paraview by converting cell data to point data and then contouring "p" scalar. But I cannot do it with vtk. What's wrong in my code?</p>
  
  <pre><code>from vtk import *
  
  file_name = "results.vtk"
  
  reader = vtkUnstructuredGridReader()
  reader.SetFileName(file_name)
  reader.Update() 
  output = reader.GetOutput()
  scalar_range = output.GetScalarRange()
  
  c2p = vtkCellDataToPointData()
  c2p.SetInputData(output)
  
  contours = vtkContourGrid()
  contours.SetInputData(c2p.GetOutput())
  contours.SetValue(0, 0.007009505294263363)
  
  gridmapper = vtkDataSetMapper()
  gridmapper.SetInputData(output)
  gridmapper.GetInput().GetCellData().SetActiveScalars("p")
  gridmapper.SetScalarVisibility(1)
  gridmapper.SetScalarRange(scalar_range)
  
  mapper = vtkPolyDataMapper()
  #mapper = vtkDataSetMapper()
  mapper.SetInputConnection(contours.GetOutputPort())
  
  actor = vtkActor()
  actor.SetMapper(mapper)
  
  gridactor = vtkActor()
  gridactor.SetMapper(gridmapper)
  gridactor.GetProperty().EdgeVisibilityOn()
  
  renderer = vtkRenderer()
  renderer.AddActor(actor)
  renderer.AddActor(gridactor)
  #renderer.SetBackground(1, 1, 1) # Set background to white
  
  renderer_window = vtkRenderWindow()
  renderer_window.AddRenderer(renderer)
  
  interactor = vtkRenderWindowInteractor()
  interactor.SetRenderWindow(renderer_window)
  interactor.Initialize()
  interactor.Start()
  </code></pre>