[vtkusers] Problem assigning vectors to vtkImageData

David E DeMarle dave.demarle at kitware.com
Sun Jan 22 08:22:50 EST 2012


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/4c7d8d46/attachment.htm>


More information about the vtkusers mailing list