[vtkusers] help filtering using c++
Alberto Bert
abert at mauriziano.it
Thu Aug 22 11:11:34 EDT 2002
Ops, solved. The problem was that you have to get the ImageData through
GetOutput.
Alberto
On Thu, Aug 22, 2002 at 01:35:44PM +0200, Alberto Bert wrote:
> Hi all,
>
> I'm starting to practice a little with vtk (2 days) and this is the
> first message to the list.
>
> I need to work in c++ and unfortunately most of eaxamples are in tcl or
> python only, any suggestions?
>
> My problem is that I cannot filter a vtkImageData succesfully.
>
> Without filtering, I can extract a contour from vol and represent it. The filtering (say vtkImageGaussianSmooth)
> seems to change the nature of the image. I think I forget something but I cannot find examples in c++
>
> I know that the question probably is stupid, sorry,
> Alberto
>
> Here is the code:
>
> //Generation of the 3D vtkImageData vol
>
> // Gaussian smoothing
> vtkImageGaussianSmooth *smooth = vtkImageGaussianSmooth::New();
> smooth->SetInput(vol);
>
> vtkContourFilter *contour = vtkContourFilter::New();
> //contour->SetInput(vol);
> contour->SetInput(smooth);
> contour->SetValue(0,0.5);
>
> vtkPolyDataMapper *volMapper = vtkPolyDataMapper::New();
> volMapper->SetInput(contour->GetOutput());
> volMapper->ScalarVisibilityOff();
> vtkActor *volActor = vtkActor::New();
> volActor->SetMapper(volMapper);
>
> renderer->AddActor(volActor);
> renderer->SetBackground(1,1,1);
> renWin->SetSize(500,500);
> //// interact with data
> renWin->Render();
> //
> iren->Start();
> //
> // Clean up
> renderer->Delete();
> renWin->Delete();
> iren->Delete();
> vol->Delete();
> scalars->Delete();
> contour->Delete();
> volMapper->Delete();
> volActor->Delete();
> smooth->Delete();
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list