[vtkusers] Not getting to use the vtkThreshold with a vtkRectilinearGrid

David Doria daviddoria+vtk at gmail.com
Thu Dec 17 08:45:30 EST 2009


2009/12/17 Adriano Gonçalves <adriano at esss.com.br>:
> Hi, good afternoon for everybody!
> I'm with a difficulty in using the vtkThreshold: I'm trying to kill, in a
> vtkRectilinearGrid, all the cells with value lower than a specific value.
> But, when I try to render the result, nothing appears. Can anybody give me a
> help? This is  my code:
>
>         thresh = vtk.vtkThreshold()
>         thresh.SetInput(vtk_grid.GetDataSet()) # vtk_grid.GetDataSet()
> returns me a vtkRectilinearGrid
>         thresh.ThresholdByLower(0.5) # The values of the cells are from 0 to
> 1
>
>         gridMapper = vtk.vtkDataSetMapper()
>         gridMapper.SetInputConnection(thresh.GetOutputPort())
>
>         gridActor = vtk.vtkActor()
>         gridActor.SetMapper(gridMapper)
>
>         ren1 = vtk.vtkRenderer()
>         ren1.AddActor(gridActor)
>         ren1.AddActor(gridActor)
>
>         ren1.SetBackground(0, 0, 0)
>
>         renWin = vtk.vtkRenderWindow()
>         renWin.AddRenderer(ren1)
>         renWin.SetSize(500, 500)
>
>         iren = vtk.vtkRenderWindowInteractor()
>         iren.SetRenderWindow(renWin)
>         iren.Initialize()
>         iren.Start()
>
>
> Thank you so much!
>
> --
>
>
> Adriano

Which array of the data set are you trying to threshold on?

>From the documentation, it seems like this method should be used:
  threshold->SetInputArrayToProcess(....);

But I'm not sure exactly what the fields mean. Anyone care to fix this example?:

http://www.vtk.org/Wiki/VTK/Examples/Thresholding

Thanks,

David



More information about the vtkusers mailing list