[vtkusers] VTK contour Widget

Iyas Hamdan iyas.hamdan at gmail.com
Fri Aug 25 09:51:13 EDT 2017


Hello,

I have a problem using the vtkcontourwidget in 3D. What I'm trying to do is
to draw contours on my 3D image, where a different contour can be drawn on
each slice of the image.

The problem that I'm getting is that when I draw a contour on one of the
slices, the same contour appears on all the other slices as well.

Here's a piece of the code i'm using:

    vtkSmartPointer<vtkImageViewer2> ImageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
    ImageViewer->SetInputData(reader->GetOutput());
    ImageViewer->SetColorLevel(127);
    ImageViewer->SetColorWindow(255);

    vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
    ImageViewer->SetupInteractor(iren);
    ImageViewer->Render();
    ImageViewer->GetRenderer()->ResetCamera();
    ImageViewer->Render();

    vtkSmartPointer<vtkSliderWidget> SliderWidget =
vtkSmartPointer<vtkSliderWidget>::New();
    SliderWidget->SetInteractor(iren);
    SliderWidget->SetRepresentation(SliderRepres2D);
    SliderWidget->KeyPressActivationOff();
    SliderWidget->SetAnimationModeToAnimate();
    SliderWidget->SetEnabled(true);

    vtkSmartPointer<vtkSliderCallback> SliderCb =
vtkSmartPointer<vtkSliderCallback>::New();
    SliderCb->SetImageViewer(ImageViewer);
    SliderWidget->AddObserver(vtkCommand::InteractionEvent, SliderCb);

    ImageViewer->SetSlice(static_cast<int>(SliderRepres2D->GetValue()));

vtkSmartPointer<vtkContourWidget> ContourWidget =
vtkSmartPointer<vtkContourWidget>::New();
    vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep =
vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
    ContourWidget->SetRepresentation(rep);

    vtkSmartPointer<vtkImageActorPointPlacer>  imageActorPointPlacer =
vtkSmartPointer<vtkImageActorPointPlacer>::New();
    imageActorPointPlacer->SetImageActor(ImageViewer->GetImageActor());
    rep->SetPointPlacer(imageActorPointPlacer);
    rep->GetProperty()->SetColor(0, 1, 0);

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

    iren->Start();


Any idea what's causing this problem and eventually how to fix it ?

Any help would be really appreciated,

Thanks in advance,

Iyas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170825/881a01a1/attachment.html>


More information about the vtkusers mailing list