[vtkusers] Problem assigning vectors to vtkImageData

Martijn Steenwijk martijnsteenwijk at gmail.com
Sun Jan 22 05:06:23 EST 2012


Dear all,

 

I would like to assign vectors to a vtkImageData which already contains
scalars which will be used for coloring. I'm using the code as below:

 

vtkImageData *im = reader->GetOutput();

vtkSmartPointer<vtkFloatArray> vec = 

       vtkSmartPointer<vtkFloatArray>::New();

vec->SetName("v1");

vec->SetNumberOfComponents(3);

 

for(int i = 0; i< im->GetDimensions()[0]; i++)

       {

              std::cout << i << std::endl;

              for(int j = 0; j< im->GetDimensions()[1]; j++)

              {

                     for(int k = 0; k< im->GetDimensions()[2]; k++)
// assign dummy vectors (1,1,1)

                     {

                           float tuple[3];

                           tuple[0] = (float)1.0;

                           tuple[1] = (float)1.0;

                           tuple[2] = (float)1.0;

                           vec->InsertNextTuple(tuple);

                     }

              }

       }

im->GetPointData()->SetVectors(vec);

im->GetPointData()->SetActiveVectors("v1");

 

When I try to visualise the vector field by using vtkHedgeHog now, VTK
complains that 'vtkHedgeHog (0000000003C0D9B0): No vectors in input data'.
Does somebody has a clue why?

 

Best,

Martijn

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120122/eab24b76/attachment.htm>


More information about the vtkusers mailing list