[vtkusers] vtkPolyData and vtkGlyph3D problems

Ganesh Swami g5 at iamganesh.com
Sun Feb 13 04:51:39 EST 2005


Hi,

    I'm trying to visualize a set of vectors in 3D space, scaled by
magnitude. After a bit of reading, I realized that vtkGlyph3D with
vtkArrowSource would be an ideal solution.

    Unfortunately, I'm not able to get it working. Here's some sample
code:

    vtkPoints *points;
    vtkFloatArray *values;
    vtkPolyData *pointset;

    points = vtkPoints::New ();
    values = vtkFloatArray::New ();
    pointset = vtkPolyData::New ();

    points->SetNumberOfPoints (3);
    values->SetNumberOfComponents (3);

    for (int i=0; i<3; i++) {
        points->SetPoint (i, i+1, 0.0, 0.0);
        values->InsertTuple3 (i, 1.0, 0.0, 0.0);
    }

    pointset->SetPoints (points);

    vtkPointData *pointdata;
    pointdata = pointset->GetPointData ();
    pointdata->SetVectors (values);

<....>

    I create my glyphs, mappers and actors the usual way. With the
data above, I'm supposed to see three arrows points in the direction
<1,0,0> and with positions <1,0,0> <2,0,0> <3,0,0>. But all I see is
three overlapping arrows at the position <1,0,0>.

    I'd be grateful if somebody points out what I'm doing wrong.


    Thanks in advance,
        Ganesh





More information about the vtkusers mailing list