[vtkusers] Change slicing plane when using vtkImageResliceMapper

ochampao ochampao at hotmail.com
Wed Mar 14 08:21:09 EDT 2018


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. 



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list