[vtkusers] pb trying to input vtkImageData into vtkHedgeHog

Thomas Deschamps tdeschamps at lbl.gov
Thu May 15 16:48:11 EDT 2003


Ok. So you were right. I fixed the number of scalar component of 
"vectors" to 3.
And it worked.
I thought I was not obliged to do that.

Thank you very much.

Berk Geveci wrote:

>Is imageDim not 3 by any chance?
>
>-Berk
>
>On Thu, 2003-05-15 at 15:01, Thomas Deschamps wrote:
>  
>
>>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)
>>
>>_______________________________________________
>>This is the private VTK discussion list. 
>>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>>Follow this link to subscribe/unsubscribe:
>>http://public.kitware.com/mailman/listinfo/vtkusers
>>    
>>
>
>
>
>  
>





More information about the vtkusers mailing list