[vtkusers] vtkImageCanvasSource2D draw only first slice?

Davide Bianconi bianconi.davide at gmail.com
Tue Apr 12 03:51:57 EDT 2005


Hi,
I have a problem with VTK, I want to draw a simple 2D line on image.
I have tried to use vtkImageCanvasSource2D but I am successful to only
draw on the first slice of the volume.

My code follows the following steps:

1) vtkImageReader* reader  [ I read the volume]

2) vtkImageCanvasSource2D* ImgCanvas

[...]
this->ImgCanvas->SetNumberOfScalarComponents(1);
this->ImgCanvas->SetScalarTypeToFloat();
this->ImgCanvas->SetExtent(0, x-1,  0, y-1,  0, z-1);

this->ImgCanvas->SetDefaultZ( z/2 -1);

this->ImgCanvas->DrawImage(0, 0, reader->GetOutput());
this->ImgCanvas->SetDrawColor(pDoc->m_Range[1]);
this->ImgCanvas->DrawSegment(0, 0, 30, 100);

this->ImgCanvas->Update();

3) vtkImageViewer *ImgViewer
[...]
ImgViewer->SetInput(this->ImgCanvas->GetOutput());
[...]

When I change the ImgViewer->SetZSlice(...) in the slice z/2-1 I see
only the segment instead in the ZSlice(0) I see only the slice and
nothing in the others.
Please you would give a suggestion to me?

Many thanks!
Davide



More information about the vtkusers mailing list