[vtkusers] Visualizing a vector field from a vtkImageData

Eric E. Monson emonson at cs.duke.edu
Mon Sep 12 09:17:41 EDT 2011


Hey David,

I just sent you a more detailed email off-list, but the problem is that you're adding 2-component Scalars to the ImageData, but then you're telling the glyph filter to use the ImageData's Vectors (which haven't been assigned). You need to add a third component to the scalars and then make a call to image->GetPointData()->SetActiveVectors("ImageScalars"); and I think it all works.

-Eric

· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Eric E Monson
Duke Visualization Technology Group


On Sep 11, 2011, at 2:03 PM, David Doria wrote:

> I have a 2D vtkImageData with pixels that represent 2D vectors. That is:
> 
> vtkImageData* image = vtkImageData::New();
> image->SetDimensions(50,50,1);
> image->SetNumberOfScalarComponents(2);
> image->SetScalarTypeToFloat();
> 
> I now want to display these vectors. I tried to use a vtkGlyphXD
> filter (I tried both N=2 and N=3), and it seems to produce an arrow at
> each of the non-zero vectors that I hard coded, but the vectors are
> not oriented correctly. That is, they both seem to be aligned with the
> X axis, and neither of the vectors I specified are parallel to the X
> axis.
> 
> Here is what I tried:
> 
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/WishList/Visualization/VectorField
> 
> Any suggestions on how to get these glyphs to point in the direction
> specified by the pixels?
> 
> Thanks,
> 
> David
> _______________________________________________
> 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




More information about the vtkusers mailing list