[vtkusers] vtkImageReslice and cutting planes

Lonni Besançon lonni.besancon at gmail.com
Thu Feb 18 09:21:53 EST 2016


Hello everybody,

So I want to implement an interface that would provide in a first part of my
window my whole 3D dataset and in the second part only the cutting plane
image of that data (a 2D slice of the dataset).

I looked at the examples provided  here (vtkImageSlice)
<http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/ImageReslice>   and 
here (vtkImageReslice)
<http://www.vtk.org/Wiki/VTK/Examples/Cxx/ImageData/ImageReslice>  .
I managed to adapt it to my dataset to get this code:

/std::string filename ="Data/ftlelog.vtk" ;
vtkSmartPointer<vtkDataSetReader> reader =
vtkSmartPointer<vtkDataSetReader>::New();
reader->SetFileName(filename.c_str());
reader->Update();
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
imageData->ShallowCopy(reader->GetOutput());
vtkSmartPointer<vtkImageData> datasetImage =
vtkSmartPointer<vtkImageData>::New();
datasetImage->ShallowCopy(reader->GetOutput());
vtkSmartPointer<vtkImageResliceMapper> imageResliceMapper =
vtkSmartPointer<vtkImageResliceMapper>::New();

vtkSmartPointer<vtkImageSlice> imageSlice =
vtkSmartPointer<vtkImageSlice>::New();
imageSlice->SetMapper(imageResliceMapper);

vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
renderer->AddViewProp(imageSlice);
renderer->ResetCamera();

// Setup render window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);

// Setup render window interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
    
vtkSmartPointer<vtkInteractorStyleImage> style =
vtkSmartPointer<vtkInteractorStyleImage>::New();
  
renderWindowInteractor->SetInteractorStyle(style);/

This compiles and works fine. Clicking and moving my mouse cursor updates
the slicing and it works like a charm. In other words, my image is always
located at the same place but I get different slices of the data displayed
onto it.
However, I would like to be able to slice according to normal and origin
that I would manually input.
I thought modifying the plane itself would work but apparently it doesn't.
I was therefore thinking that I should try and set the normal and origin of
the vtkImageSlice directly. But from the documentation I got that the slice
can be set manualy thanks to vtkImageMapper3D (abstract of
vtkImageResliceMapper). 
Thus, I tried to simply push my plane along one axis, to see what I would
get. In that case, I see my image moving (being pushed along the axis) but I
don't get to see any slices of the data.

I am pretty sure there is something that I did not understand with the
different classes involved here and their purpose. Get I can get some
clarifications?

Thanks in advance




--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkImageReslice-and-cutting-planes-tp5736627.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list