[vtkusers] help filtering using c++

Alberto Bert abert at mauriziano.it
Thu Aug 22 07:35:44 EDT 2002


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();



More information about the vtkusers mailing list