[vtkusers] Setting the image orientation in vtkImageViewer

Anja Ende anja.ende at googlemail.com
Fri Aug 18 09:12:15 EDT 2006


Hi everyone,

vtkImageViewer2 allows the user to set the slice orientation to XY, XZ and
YZ planes. I am trying to implement the same functionality in
vtkImageViewer.

I call the SetExtent function on the input image data but it does not seem
to have any effect in the displayed slice. It always displays the slice in
the XY plane regardless of the extent values.

So, I have something like:

vtkImageData *input = this->GetInput();

if (!input || !this->ImageMapper)
{
    return;
}

input->UpdateInformation();
int *w_ext = input->GetWholeExtent();

// Is the slice in range ? If not, fix it
int slice_min = w_ext[this->m_sliceOrientation * 2];
int slice_max = w_ext[this->m_sliceOrientation * 2 + 1];

if (this->m_slice < slice_min || this->m_slice > slice_max)
{
    this->m_slice = static_cast<int>((slice_min + slice_max) * 0.5);
}

// Set the image actor
switch (this->m_sliceOrientation)
{
    case MyViewer::SliceOrientation_XY:
        input->SetExtent(
                w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->m_slice,
this->m_slice);
        break;

    case MyViewer::SliceOrientation_XZ:
        input->SetExtent(
                w_ext[0], w_ext[1], this->m_slice, this->m_slice, w_ext[4],
w_ext[5]);
        break;

    case MyViewer::SliceOrientation_YZ:
        input->SetExtent(
                this->m_slice, this->m_slice, w_ext[2], w_ext[3], w_ext[4],
w_ext[5]);
        break;
}

However, it always renders the first slice in the XY plane. Any ideas on how
to fix this?

Thanks,

Anna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060818/88490191/attachment.htm>


More information about the vtkusers mailing list