[vtkusers] Problem assigning vectors to vtkImageData

Martijn Steenwijk martijnsteenwijk at gmail.com
Sun Jan 22 13:32:19 EST 2012


That's obvious, but. overlooked it. Thanks David! 

 

 

 

Van: David E DeMarle [mailto:dave.demarle at kitware.com] 
Verzonden: zondag 22 januari 2012 14:23
Aan: martijnsteenwijk at gmail.com
CC: vtkusers at vtk.org
Onderwerp: Re: [vtkusers] Problem assigning vectors to vtkImageData

 

If reader executes after you assigned the vectors, the array will be
discarded. Try making a shallow copy of reader's output, add your array, and
visualize that instead.

On Jan 22, 2012 5:06 AM, "Martijn Steenwijk" <martijnsteenwijk at gmail.com>
wrote:

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

 


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

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


More information about the vtkusers mailing list