[vtkusers] vtkImageGradient with vtkStreamline

Basak Alper basakalper at gmail.com
Fri Feb 8 11:34:53 EST 2008

Hi all,
I am trying to pass output of an image gradient to a streamline object.

 vtkImageData *vol2 = vtkImageData::New();
 vol2->SetDimensions(91, 81, 85);
 vol2->SetOrigin(45, 40, 42);
 vol2->SetSpacing(1, 1, 1);
vol2->GetPointData()->SetScalars(scalars); //scalars is vtkFloatArray of
single components

vtkImageGradient* grad = vtkImageGradient::New();
grad->SetDimensionality( 3 );

//I tried below code sent its output to the streamline, but I got no vector
defined error from vtkStreamline.
vtkAssignAttribute* aa = vtkAssignAttribute::New();
aa->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS,

What I am trying to do a
1. create a data structure taht holds both scalar and vector information and
pass it to the imageGradient.
I tried to set vector field of an image data set manually like this.

vtkDataArray * array = grad->GetOutput()->GetPointData()->GetScalars();
vtkImageData *gradVecs = vtkImageData::New();


Then I get the "Requesting a cell from an empty image" error. Tried to
assign original image scalars
to the to this gradVecs image but it's not working.

Anybody knows how to set up a right input file for streamline?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080208/8f60d627/attachment.htm>

More information about the vtkusers mailing list