[vtkusers] Help Display Slice of images on 3D ((vtkImageActor))

Julien Finet julien.finet at kitware.com
Sat Mar 3 11:57:07 EST 2012


Have you checked the value of vol_data ?(why is it named vol_data, it doesn't fit it's meaning?)
If it's 0 or 1, you might want to have an up to date sink before querying output information.

Julien.

On Mar 3, 2012, at 7:28 AM, Hellice <saouli-abdelhak at hotmail.com> wrote:

> Hi I real need help ;I wanna dispaly slices image on 3D.the problem is the
> only first image in slice is shown so plz thx for your time
> 
> 
> #include "vtkPolyDataMapper.h"
> #include "vtkRenderWindow.h"
> #include "vtkCamera.h"
> #include "vtkLODActor.h"
> #include "vtkRenderer.h"
> #include "vtkProperty.h"
> #include "vtkRenderWindowInteractor.h"
> #include <vtkDICOMImageReader.h>
> #include <vtkImageActor.h>
> #include <vtkImageCast.h>
> #include <vtkImageData.h>
> 
> using namespace std;
> 
> int main()
> {
> 
> 
> vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
> vtkImageActor     *viewer = vtkImageActor::New();
> reader->SetDirectoryName("Data");
> 
> 
> vtkImageCast *cast = vtkImageCast::New();
> cast->SetInput(reader->GetOutput());
> cast->SetOutputScalarTypeToUnsignedChar();
> viewer->SetInput(cast->GetOutput());
> 
> int vol_data = viewer->GetSliceNumber();
> reader->Update();
> 
>  vtkRenderer *ren1= vtkRenderer::New();
>  vtkRenderWindow *renWin = vtkRenderWindow::New();
> for(int i =0;i<vol_data; i++)
> {
>  viewer->SetZSlice(i);
> 
> }
> 
>  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>  iren->SetRenderWindow(renWin);
> 
>  renWin->SetSize( 600, 600 );
> 
>  ren1->AddActor(viewer);
>  renWin->AddRenderer( ren1 );
>  ren1->ResetCamera();
>  ren1->GetActiveCamera()->Zoom(1.5);
> 
>  renWin->Render();
>  iren->Start();
> 
>  return 0;
> } 
> 
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Help-Display-Slice-of-images-on-3D-vtkImageActor-tp5533571p5533571.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list