[vtkusers] Question about vtkImageData/Writer

Paul McGuinness mcguinpg at maths.tcd.ie
Mon Jul 28 09:57:52 EDT 2003


Hi Users,

I have a question that cannot be answered by the book and I hope one of
you know the answer.
My problem to start with is I am creating a sphere using vtkImageData and
using vol->GetPointData()->SetScalars(scalars) to insert the scalar values
that define the sphere where scalars is vtkFloatArray. (example Vol.cxx)
The pipeline is as follows:

vtkImageData -> vtkContourFilter -> vtkPolyDataMapper -> vtkActor
->vtkRenderer -> vtkRenderWindow

And the sphere appears correctly.

Now if I use vtkStructuredPointsWriter/Reader in the pipeline; use
structuredpoints writer to write the vtkImageData of a sphere to a file
and the structuredpointsreader to read it back in and continue the pipline
as before e.g.:

vtkImageData -> vtkStructuredPointsWriter ->
vtkStructuredPointsReader -> vtkContourFilter -> vtkPolyDataMapper ->
vtkActor ->vtkRenderer -> vtkRenderWindow

The image will appear correctly on the screen as a sphere.

But now if I use vtkImageWriter/Reader instead of
vtkStructuredPointsWriter/Reader e.g.:

vtkImageData -> vtkImageWriter -> vtkImageReader -> vtkContourFilter ->
vtkPolyDataMapper -> vtkActor ->vtkRenderer -> vtkRenderWindow

The image will not correctly appear on the screen as a sphere but as a
shape that resembles a cubic shaped sponge.

Does anyone know why I am getting the wrong shape because I need to use
vtkImageWriter's void  SetFilePrefix (char *filePrefix) to create multiple files rather
then having all the data in just one file? And if I cannot use
vtkImageWriter in the this example because how the vtkImageData object is
being defined (vtk example Vol.cxx) how should I create this sphere to
use vtkImageWriter?

Many Thanks,
Paul.




More information about the vtkusers mailing list