[vtkusers] Visualize Vector Field Example Wrong?

Werner Sembach werner at sembach.de
Sat Oct 17 17:48:11 EDT 2015


yes i can reproduce the error and now i'm even more confused

(-10,5) behaves like (10,-5)

Am 15.10.2015 um 14:25 schrieb David Doria:
> On Wed, Oct 14, 2015 at 5:40 PM, Werner Sembach <werner at sembach.de> wrote:
>> Hello,
>> i want to do exactly this: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/VectorField
>> but when you try the example code the 2nd coordinate of the vectors is completly ignored (even the picture on the wiki shows 2 parrallel vectors while in the code the vectors are (10, 10) and (-10, 5).
>> hope someone can help me
> You are right - something is wrong. As it is, I get this warning:
>
> Warning: In /home/doriad/src/VTK-6.2.0/Common/DataModel/vtkDataSetAttributes.cxx,
> line 1165
> vtkPointData (0x23e62e0): Can not set attribute Vectors. Incorrect
> number of components.
>
> on this line:
>
> image->GetPointData()->SetActiveVectors("ImageScalars");
>
> The warning is resolved if I change
>
> image->AllocateScalars(VTK_FLOAT,2);
>
> to
>
> image->AllocateScalars(VTK_FLOAT,3);
>
> I'm not sure why 2D vectors are not allowed.
>
> Something else is wrong as well, though. Once I add pixel[2] = 0.0; to
> each of the pixels (to prevent referencing unallocated memory), the
> vectors still don't behave as I'd expect. With them both set to
> (10,10), they both point (up, right) as expected. If I change pixel
> (20,20) to (10, 10), it now points (down, right), again as I'd expect.
> However, when I change it to (-10, -10), it points (up, right) again
> (where I'd expect (down, left)), and it turns red (where everything
> previously had been blue.
>
> Sorry I don't have an answer, but at least that should help define the
> problem :)
>
> David



More information about the vtkusers mailing list