[vtkusers] Glyphing vtkImageData scalars (3D) as arrows

Jothy jothybasu at gmail.com
Tue Oct 5 12:03:09 EDT 2010


You can easily test this with paraview. Save your image as vtkImageData and
import into paraview.

After importing click Glyph toolbar button on top right, then you can play
around with different settings in the lower left window.

This will give you some idea.

Jothy

On Tue, Oct 5, 2010 at 4:55 PM, David Doria <daviddoria at gmail.com> wrote:

> I have an image with 3d scalars:
>
>  // Create an image
>  vtkSmartPointer<vtkImageData> image1 =
>    vtkSmartPointer<vtkImageData>::New();
>  image1->SetExtent(0, 1, 0, 1, 0, 0);
>  image1->SetNumberOfScalarComponents(3);
>  image1->SetScalarTypeToFloat();
>
>  int coord[3]; float* pixel;
>
>  // Fill the image with vectors
>  coord[0] = 0; coord[1] = 0; coord[2] = 0;
>  pixel = static_cast<float*>(image1->GetScalarPointer(coord));
>  pixel[0] = 1.0; pixel[1] = 0.0; pixel[2] = 0.0;
>
> ... fill the rest of the image
>
>
> Now I want to glyph arrows to show the vectors:
>
> I tried this:
>
>  vtkSmartPointer<vtkArrowSource> arrowSource =
>    vtkSmartPointer<vtkArrowSource>::New();
>
>  vtkSmartPointer<vtkGlyph3DMapper> glyph3Dmapper1 =
>    vtkSmartPointer<vtkGlyph3DMapper>::New();
>  glyph3Dmapper1->SetSourceConnection(arrowSource->GetOutputPort());
>  glyph3Dmapper1->SetInputConnection(image1->GetProducerPort());
>  glyph3Dmapper1->Update();
>
>  vtkSmartPointer<vtkActor> actor1 =
>    vtkSmartPointer<vtkActor>::New();
>  actor1->SetMapper(glyph3Dmapper1);
>
> but it colors the arrows rather than orients them. It looks like
> vtkGlyph3DMapper wants to use the Vectors attribute to orient the
> glyphs, but my ImageData doesn't have a Vectors since everything is in
> the Scalars (but they are not scalars, because they are 3d).
>
> So I guess two things would solve it:
> 1) How do you set the vectors of an imageData to be its scalars?
> 2) How could I tell vtkGlyph3DMapper to orient the arrows by the image
> scalars?
>
> 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
>



-- 
Research Scholar
Dept. of Medical Physics
Clatterbridge Centre for Oncology
UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101005/78cf0b29/attachment.htm>


More information about the vtkusers mailing list