[vtkusers] ImageData reader

tom fogal tfogal at apollo.sr.unh.edu
Wed Aug 17 16:07:58 EDT 2005


Hi all, I've been trying to create a reader derived from vtkImageSource
with not as much luck as I would like.  Maybe someone else out there
can see an obvious problem with my setup.

My data is a uniform grid, ranging from 0 to <dir>_{max}, which for my
test dataset is 258 in all of x, y, and z.  I use ImageData because
vtkUniformGrid is derived from vtkDataSet and not vtkImageData in
VTK4.4. Also there conveniently is a vtkImageSource but no
vtkUniformGridSource, in either 4.4 or CVS.

In my constructor, I allocate a new vtkImageData object and set it as
the output.  I then immediately do:

   this->Outputs[0]->ReleaseData();
   this->Outputs[0]->Delete();

without really knowing the consequences, for a reason I don't remember
anymore other than it was copied from other, working code.

I override ::Update().  I'm not quite sure on how the PipelineMTime
stuff works, and couldn't get it right in 10 minutes, so this just
calls ::Execute() and ::ExecuteInformation(), in that order.

I override ::Execute().  Psuedo-code is easier than words:

   Output->GetPointData()->RemoveArray("B");
   Output->GetPointData()->RemoveArray("DENSITY");

   if(need_be) { ReadDataAndPopulateInternalArrays(); }

   Output->SetDimensions(258,258,258);
   Output->SetExtent(0,258, 0,258, 0,258);

   /* add output arrays "B" and "DENSITY" by getting a vtkFloatArray,
    * 'AddArray()'ing to point data, and using SetVectors(),
    * SetScalars(), SetActiveVectors(), and SetActiveScalars() */
   [. . .]
   Output->SetScalarTypeToFloat();
   Output->SetSpacing(1.0, 1.0, 1.0);
   Output->SetOrigin(0, 0, 0); /* correct ? */

Finally I override ::ExecuteInformation().  This sets the whole extent
of the output dataset to (0,258, 0,258, 0,258), and runs
ComputeBounds() on it.

Thats about the gist of how the reader object is structured.  I'm using
vtkStreamTracer to look at the results and not getting anything that
I'm expecting.  The streamlines are waving slightly back and forth,
presumably because it is a series of discrete operations.  It looks
like they eventually hit the edge of the dataset, because the 30 or so
of them all turn along a vertical line, and then move in a similar
fashion, but more chaotically. This is with a seed source of radius 5,
centered at (0, 1, 4).
You can see a picture of this at:

https://apollo.sr.unh.edu/~tfogal/stream.png

The second visualization i'm using to test is a plane of glyphs.  I
can't even get this to render -- it segfaults in some method of
vtkDataSetAttributes while its trying to copy one float array to
another.  The pipeline for this one is:

	vtkCutter using vtkPlane at (0,0,0) w/ Normal (0,0,1)
	vtkGlyph3D with input vtkCutter and source of a vtkGlyphSource2D
   Glyph->SetScaleModeToScaleByVector();
   Glyph->SetColorModeToColorByScalar();

   PolyDataMapper takes Glyph's output
   Actor's mapper is set to aforementioned PolyDataMapper


Any Ideas? Am I doing something glaringly wrong? Am I forgetting to set
some crucial Extent/Spacing/Origin parameter, or perhaps setting it in
the wrong place such that it gets overwritten later?

Thanks for any help,

-tom



More information about the vtkusers mailing list