[vtkusers] pb trying to input vtkImageData into vtkHedgeHog

Thomas Deschamps tdeschamps at lbl.gov
Thu May 15 15:01:02 EDT 2003


Hi vtkUsers

I've tried something different to try to understand what is going on.
I took the example sgrid.cxx accessible through the vtkHedgeHog doxygen 
page and I've adapted it to make it the following

void testHedgehog( vtkImageData * vectorField,
int dims, // the dimensions
int imageDim ) // the number of scalar components
{
     vtkStructuredGrid *sgrid = vtkStructuredGrid::New();
     sgrid -> SetDimensions( dims );

     vtkFloatArray *vectors = vtkFloatArray::New();
     vectors -> SetNumberOfComponents( imageDim );
     vectors -> SetNumberOfTuples( dims[0] * dims[1] * dims[2] );

     vtkPoints *points = vtkPoints::New();
     points -> Allocate( dims[0] * dims[1] * dims[2] );

     float x[3],v[3];

     for( int k = 0,index = 0 ; k < dims[2] ; k++ )
         for( int j = 0 ; j < dims[1] ; j++ )
             for( int i = 0 ; i < dims[0] ; i++,index++ )
             {
               x[0] = i;
               x[1] = j;
               v[0] = vectorField -> GetScalarComponentAsFloat(i,j,k,0);
               v[1] = vectorField -> GetScalarComponentAsFloat(i,j,k,1);

               if( imageDim > 2 )
               {
                x[2] = k;
                v[2] = vectorField -> GetScalarComponentAsFloat(i,j,k,2);
               }

               points -> InsertPoint(index,x);
               vectors -> InsertTuple(index,v);
             }

     sgrid -> SetPoints( points );
     sgrid -> GetPointData() -> SetVectors( vectors ); <--- first warning

     vtkHedgeHog * hedgehog = vtkHedgeHog::New();
     hedgehog -> SetInput( sgrid );
     hedgehog -> Update();  <---- second error;
....
}

Now I have several errors:

Warning: ...
vtkPointData (0x85bac68): Can not set attribute Vectors. Incorrect 
number of components.

ERROR: ...
vtkHedgeHog (0x85bba70): No vectors in input data

My vectorField image is correct. I can represent its magnitude easily.
But I don't understand why it is giving me those errors...
Thanks

Thomas (TDeschamps at lbl.gov)




More information about the vtkusers mailing list