[vtkusers] Change slicing plane when using vtkImageResliceMapper

David Gobbi david.gobbi at gmail.com
Wed Mar 14 10:36:17 EDT 2018


Hi Panos,

Setting the clipping range is a good idea, the "Slice" interaction will not
move beyond the clipping planes.

I found another way to way to work around the "sliding" problem, but it
might cause the window/level interaction to slow down a bit:

  dicomMapper->SeparateWindowLevelOperationOff();

Once I find the root cause of the problem, I'll submit a patch to VTK.

Cheers,
 - David


On Wed, Mar 14, 2018 at 6:21 AM, ochampao <ochampao at hotmail.com> wrote:

> Hi David,
>
> Thanks a lot for your helpful comments. Based on your suggestions I've
> tried
> a few things. Here's what I got:
>
> 1. using style->SetImageOrientation(vLeftToRight, vBottomToTop);
>
> Using this approach I am able to change the slicing plane on demand. I can
> still see the "sliding image" effect that I have mentioned above.
>
> 2. using vtkImageSliceMapper instead of vtkImageResliceMapper:
>
> This approach solves the "sliding image".
>
> 3. Setting the camera's clipping range manually so that the min/max
> clipping
> planes coincide exactly with the first (i.e. closest to camera) and last
> (i.e. furthest from camera) slice of the volume (normal to the direction of
> projection). Note that I am still using vtkImageResliceMapper here.
>
> This approach solves the "sliding image" effect as well. What I have
> noticed
> is, when using renderer->ResetCameraClippingRange(), the clipping range
> calculated automatically does not coincide with the planes of the first and
> last slice of the volume. If the clipping range is set manually so that it
> does coincide using renderer->GetActiveCamera()->SetClippingRange(dMin,
> dMax), then the "sliding image" effect does not appear. In fact, if I
> compare the clipping range calculated automatically when using
> vtkImageSliceMapper this is exactly what happens i.e. the clipping range
> coincides with the first/last slices of the volume.
>
> Here are the changes to my code above that I made to set the clipping range
> manually:
>
> ==================================
> // ...
> dicomMapper->SliceAtFocalPointOn();
>
> // ... more code ...
>
> // Setup renderers
> vtkNew<vtkRenderer> renderer;
> renderer->AddViewProp(imageStack);
> renderer->GetActiveCamera()->ParallelProjectionOn();
> renderer->ResetCamera();
> renderer->GetActiveCamera()->Azimuth(270);
> renderer->GetActiveCamera()->OrthogonalizeViewUp();
>
> // Assuming that the origin of the volume is at (0,0,0)
> double* cameraPosition = renderer->GetActiveCamera()->GetPosition();
> int* dims = dicomReader->GetOutput()->GetDimensions();
> double* spacing = dicomReader->GetOutput()->GetSpacing();
>
> // Coordinates of points along the direction of projection that define the
> min/max clipping planes
> // such that the min/max clipping planes coincide with the slices closest
> and furthest from the camera.
> double pMin[3] = { 0, dims[1] / 2 * spacing[1], dims[2] / 2 * spacing[2] };
> double pMax[3] = { dims[0] * spacing[0], dims[1] / 2 * spacing[1], dims[2]
> /
> 2 * spacing[2] };
>
> // Calculate min/max clipping range along the direction of projection
> double dMin = sqrt(vtkMath::Distance2BetweenPoints(pMin, cameraPosition));
> double dMax = sqrt(vtkMath::Distance2BetweenPoints(pMax, cameraPosition));
>
> // Update clipping range
> renderer->GetActiveCamera()->SetClippingRange(dMin, dMax);
> ==================================
>
> Kind regards,
> Panayiotis.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180314/09144eeb/attachment.html>


More information about the vtkusers mailing list