[vtkusers] problem of image display

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Nov 15 09:56:12 EST 2006


付文宇 wrote:
> hi all:
>     I used the codes found in the web to display image. File type of data is
> DICOM(the dimension of file data is 512x512x211).There is no errors in compiling
> and linking,but I can see nothing when executing.I use vc++6.0 as my IDE. Source
> code is in the next:
> #include <vtkDICOMImageReader.h>
> #include <vtkImageViewer2.h>
> #include <vtkRenderer.h>
> #include <vtkImageData.h>
> int main()
> {
>    vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
>    vtkImageViewer2     *viewer = vtkImageViewer2::New();
>    viewer->SetInput(reader->GetOutput());
>    reader->SetDirectoryName("10171602");
>    reader->Update();
>    int VolData_Images = viewer->GetWholeZMax ();
>    for (int i=0;i<=VolData_Images;i++)
>   {
>      viewer->SetZSlice(i);
>      viewer->GetRenderer()->ResetCameraClippingRange();
>      viewer->Render();
>    }
>    reader->Delete();
>    viewer->Delete();
>    return 0;
> }
> ---------------------------------------------------------------------------------
> If I change the code to show only one slice image, I can see the image for a few
> seconds.But I want to see the image in the screen for arbitrary time, what should
> I do to achieve this result?


You need to use a vtkRenderWindowInteractor:

http://www.vtk.org/doc/nightly/html/classvtkRenderWindowInteractor.html

You can also search for vtkDICOMImageReader+vtkRenderWindowInteractor on 
the vtkusers ML.

HTH
Mathieu



More information about the vtkusers mailing list