[vtkusers] vtkImageReslice and cutting planes

David Gobbi david.gobbi at gmail.com
Thu Feb 18 10:59:28 EST 2016


There is a wiki page that describes these classes:
http://www.vtk.org/Wiki/VTK/Image_Rendering_Classes

The SetSlicePlane() method should work if you want to manually set the
position of the slice in 3D (note that the slice is in world coords).  And
of
course the SetSlicePlane() method is mutually exclusive with the settings
SliceAtFocalPointOn() and SliceFacesCameraOn().  You can control the
slice plane manually, or the slice plane can be controlled by the camera,
but not both!

 - David



On Thu, Feb 18, 2016 at 7:21 AM, Lonni Besançon <lonni.besancon at gmail.com>
wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160218/9ab99698/attachment.html>


More information about the vtkusers mailing list