Displaying image data read via vtkBMPReader (was: Re: [vtkusers] thank you for your answer!)

Obada Mahdi omahdi at gmx.de
Fri Dec 8 13:45:57 EST 2006


Hello liu,

it would be nice to have some more specific information about the problems or
errors you encounter--it is difficult to help without knowing what's wrong.

Anyway, based on the code below I assume that the problem is related to 
the fact that vtkPolyDataMapper cannot handle the output of vtkBMPReader,
which is of type vtkImageData.

If you want to render image data, you can, for example,
- use a vtkImageMapper in conjunction with a vtkActor2D, in order to render
   "true" 2D data (single slices, without perspective projection)
- use a vtkImageActor, which can be used if you want the image to behave like
   a 3D object which can be positioned, scaled and rotated in space
- use vtkImageViewer2

Please refer to the documentation for more information.

If your image data is meant to represent a volume, you probably want to apply
some kind of contouring filter on it, like in the examples found in
Examples/Medical/Cxx
in the VTK source tree?

What mechanism to use depends on what you want to do with your data.  If you
get stuck, maybe you can elaborate a bit on what you are trying to do, that
might help others to help you :-)


Regards

Obada


On Fri, 8 Dec 2006, u liu wrote:
> Date: Fri, 8 Dec 2006 10:35:32 +0800 (CST)
> From: u liu <lsenlee at yahoo.com.cn>
> To: vtkusers at vtk.org
> Subject: [vtkusers] thank you for your answer!
> 
> hi,
>  i use vtkBMPreader to read bmp image.to reconstuction!
>  a simple win32 code:
>  #include "vtkConeSource.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkRenderWindow.h"
> #include "vtkCamera.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include"vtkBMPReader.h"
> int main()
> { vtkBMPReader *cone=vtkBMPReader::New();
>        cone->Allow8BitBMPOn();
> cone->SetFilePrefix("E:\\bmp2\\yu");
> cone->SetFilePattern("%s%02d.bmp");
>        cone->SetDataExtent(0,379,0,260,1,13);
> cone->SetDataSpacing(1,1,50);
> cone->Update();
>         vtkPolyDataMapper *coneMapper = vtkPolyDataMapper::New();
>         coneMapper->SetInputConnection( cone->GetOutputPort() );
>        vtkActor *coneActor = vtkActor::New();
>         coneActor->SetMapper( coneMapper );
>         vtkRenderer *ren1= vtkRenderer::New();
>        ren1->AddActor( coneActor );
>        ren1->SetBackground( 0.1, 0.2, 0.4 );
>         vtkRenderWindow *renWin = vtkRenderWindow::New();
>         renWin->AddRenderer( ren1 );
>        renWin->SetSize( 300, 300 );
>        int i;
>       for (i = 0; i < 3600; ++i)
>       {
>        renWin->Render();//error here
>        ren1->GetActiveCamera()->Azimuth( 0.01 );
>          }
>  cone->Delete();
>  coneMapper->Delete();
>  coneActor->Delete();
>  ren1->Delete();
>  renWin->Delete();
>    return 0;
> }
>  who can help me ?thanks a lot!
>  newbie!



More information about the vtkusers mailing list