[vtkusers] How to display the magnitude of a vector field directly

David E DeMarle dave.demarle at kitware.com
Tue Sep 3 17:56:34 EDT 2013


ParaView transparently puts a vtkPVPostFilter into the pipeline between the
data and rendering which does this and other simple conversions.



David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Tue, Sep 3, 2013 at 3:02 PM, Serge Lalonde <serge at infolytica.com> wrote:

>  Hello VTK users,
>
> This may seem like a simple question, but it seemed like it was possible
> to display the magnitude of a vector field (on an unstructured grid)
> without having to convert the vector field to a scalar field simply by
> setting the appropriate values in the lookup table and/or the mapper.
> However, no matter what I try, I can't get this to work and I can't find a
> VTK example that demonstrates this.
>
> Here's the code that I tried. Is there anything obvious missing?
>
>     vtkLookupTable *lookup = vtkLookupTable::New();
>     lookup->SetHueRange(2.0/3.0, 0.0);
>     if (PostField)
>       lookup->SetTableRange(PostField->getMini(), PostField->getMaxi());
>     else
>       lookup->SetTableRange(0.0, 1.0);
>     lookup->Build();
>
>     vtkDataSetMapper *mapper = vtkDataSetMapper::New();
>     vtkActor *actor = vtkActor::New();
>
>     mapper->SetInputConnection(producer->GetOutputPort());
>     mapper->SetLookupTable(lookup);
>     mapper->SetScalarRange(lookup->GetTableRange());
>     actor->SetMapper(mapper);
>     renderer->AddActor(actor);
>
>     m_m_vtk_render_window->Render();
>
>
> Any help would be appreciated!
>
> Note that I saw that it's done in ParaView, but maybe they do the vector
> to scalar conversion invisibly to the user?
> --
> www.infolytica.com
> 300 Leo Pariseau, Suite 2222, Montreal, QC, Canada, H2X 4B3
> (514) 849-8752 x236, Fax: (514) 849-4239
>
> _______________________________________________
> 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/20130903/e32cc8d4/attachment.htm>


More information about the vtkusers mailing list