[vtkusers] VTK contour Widget
Andras Lasso
lasso at queensu.ca
Fri Aug 25 10:05:23 EDT 2017
Hello Iyas,
There are many VTK-based applications that allow contouring on image slices. I would recommend to extend/modify these applications to suit your needs, instead of reimplementing everything from scratch. If you just want to implement this as a learning experience, then you can check out the source code of these existing applications, you can learn a lot about how to implement this and many other features.
For example:
www.slicer.org<http://www.slicer.org>
www.itksnap.org<http://www.itksnap.org>
www.mitk.org<http://www.mitk.org>
Andras
From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of Iyas Hamdan
Sent: Friday, August 25, 2017 9:51 AM
To: VTK Users <vtkusers at vtk.org>
Subject: [vtkusers] VTK contour Widget
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/416dec36/attachment.html>
More information about the vtkusers
mailing list