[vtkusers] Change slicing plane when using vtkImageResliceMapper
David Gobbi
david.gobbi at gmail.com
Mon Mar 12 11:15:28 EDT 2018
The dicomMapper->SliceFacesCameraOn() option causes the normal to
automatically be set from the direction-of-projection of the camera. So if
you use this option, you cannot directly set the normal. Instead, you
would have to change the normal by changing the position of the camera.
- David
On Mon, Mar 12, 2018 at 5:56 AM, ochampao <ochampao at hotmail.com> wrote:
> Hello vtkUsers,
>
> I am using a pipeline with vtkImageResliceMapper --> vtkImageSlice -->
> vtkImageStack for displayng a slice of a volume imported from a dicom
> series. This works well with the default slicing plane (0,0,1), however,
> when I try changing the slicing plane using
> vtkImageResliceMapper::GetSlicePlane()->SetNormal() the plane does not
> change. When I print the SlicePlane normal, I can see that the new normal
> is
> registered. Also, using UpdateInformation() or Modified() did not have any
> effect.
>
> My undersanding is that the SlicePlane is what determines the plane that
> the
> camera will follow when SliceFacesCameraOn() and SliceAtFocalPointOn() are
> used.
>
> What is the correct approach for changing the slicing plane of
> vtkImageResliceMapper?
>
> Below is the code that I am currently using.
>
> Thanks for your help.
> Panos.
>
> ============================
> vtkNew<vtkDICOMImageReader> dicomReader;
> dicomReader->SetDirectoryName("path/to/dicom/series");
> dicomReader->Update();
>
> vtkNew<vtkImageResliceMapper> dicomMapper;
> dicomMapper->SetInputData(dicomReader->GetOutput());
> dicomMapper->GetSlicePlane()->SetNormal(0.0, 1.0, 0.0);
> dicomMapper->SliceFacesCameraOn();
> dicomMapper->SliceAtFocalPointOn();
>
> vtkNew<vtkImageSlice> dicomSlice;
> dicomSlice->SetMapper(dicomMapper);
> dicomSlice->GetProperty()->UseLookupTableScalarRangeOn();
>
> vtkNew<vtkImageStack> imageStack;
> imageStack->AddImage(dicomSlice);
>
> vtkNew<vtkRenderer> renderer;
> renderer->AddViewProp(imageStack);
> renderer->GetActiveCamera()->ParallelProjectionOn();
> renderer->ResetCamera();
> renderer->ResetCameraClippingRange();
>
> vtkNew<vtkRenderWindow> renderWindow;
> renderWindow->AddRenderer(renderer);
>
> vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
> vtkNew<vtkInteractorStyleImage> style;
> style->SetInteractionModeToImageSlicing();
>
> renderWindowInteractor->SetInteractorStyle(style);
> renderWindowInteractor->SetRenderWindow(renderWindow);
> renderWindowInteractor->Initialize();
> renderWindowInteractor->Start();
> =============================
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180312/8e794a9c/attachment.html>
More information about the vtkusers
mailing list