[vtkusers] vtkContourWidget with vtkImageViewer2

Karthik Krishnan karthik.krishnan at kitware.com
Wed Jul 16 09:23:21 EDT 2008


Please see comments inlined.

Lars Friedrich Lars wrote:
> hi,
>
> <snip>
> How can I configure the vtkContourWidget (or its representation) to draw on the actual displayed slice?
>   
You need to use the vtkImageActorPointPlacer.

The contour widgets use "PointPlacers" that dictate how 2D picks are 
translated into 3D positions, to place the nodes. The default is the 
vtkFocalPlanePointPlacer and for the ImageViewer, the focal plane is 
always the same, somewhere beyond the first slice; that would explain 
the behaviour you are seeing.....

The fix is inlined in your code below.
>
>   ImageViewer->SetSlice((int)SliderRepres->GetValue());
>
>   vtkContourWidget *ContourWidget = vtkContourWidget::New();
>
>   
  vtkOrientedGlyphContourRepresentation *rep =
    vtkOrientedGlyphContourRepresentation::New();
  ContourWidget->SetRepresentation(rep);
 
  vtkImageActorPointPlacer * imageActorPointPlacer = 
vtkImageActorPointPlacer::New();
  imageActorPointPlacer->SetImageActor(ImageViewer->GetImageActor());
  rep->SetPointPlacer(imageActorPointPlacer);

  imageActorPointPlacer->Delete();
  rep->Delete();

>   ContourWidget->SetInteractor(iren);
>   ContourWidget->SetEnabled(true);
>   ContourWidget->ProcessEventsOn();
>
>   

BTW, since there is no test or usage example of vtkImageActorPointPlacer 
in the repository now, I wil be committing y our example as a test in 
VTK some time soon.... Thanks.

--
karthik



More information about the vtkusers mailing list