[Paraview-developers] Accessing attributes in VTK geometric objects

Will Schroeder will.schroeder at kitware.com
Fri Jun 15 12:47:07 EDT 2018


I recommend that you check out the extensive examples:
https://lorensen.github.io/VTKExamples/site/

See for example:
https://lorensen.github.io/VTKExamples/site/Cxx/VTKConcepts/Scalars/

Or grep "GetPointData()" or "GetCellData()" in the VTK source code.

Basic ideas:
- A dataset represents geometry + topology e.g., vtkUnstructuredGrid.
- Attribute data (point data and cell data) is associated on a 1-for-1 with
dataset points and cells.
- Attributes (e.g., scalars) are created in vtkDataArrays using tuples of
one or more components
- Attributes can be associated with dataset via
dataset->GetPointData()->SetScalars(attrArray) or using AddArray() etc

Also see VTK/*/*/Testing/Cxx and  VTK/*/*/Testing/Python there are
literally more than a thousand tests.

Finally, I strongly recommend that you read the book
<https://lorensen.github.io/VTKExamples/site/VTKBook/> (these are works in
progress): either on-line LaTeX book
<https://raw.githubusercontent.com/lorensen/VTKExamples/master/src/VTKBookLaTex/VTKTextBook.pdf>
created by Andrew Maclean & friends;
or the Markdown document
<https://lorensen.github.io/VTKExamples/site/VTKBook/01Chapter1/> created
by Bill Lorensen & friends.


On Fri, Jun 15, 2018 at 11:34 AM rclaveria <rclaveria at dim.uchile.cl> wrote:

> Hello,
>
> I need to access and modify the data attributes of VTK geometric objects
> (e.g., an unstructured grid) from the code. For example, I'd like to
> write algorithm to assign a pressure or temperature value to each cell
> (or point) of my mesh according to a certain physical model. However, I
> haven't found code examples where data attributes are set, accessed or
> modified using C++ or python code. So far, I've relied on external code
> (python's FEniCS library, to be precise) to generate meshes, run
> simulations and set attributes, saving the output in a format readable
> by ParaView (.vtk extension with the flag UNSTRUCTURED_GRID).
>
> I'd be grateful to receive guidelines on how to set the attributes of a
> mesh using the VTK library.
>
> Thanks
> _______________________________________________
> Powered by www.kitware.com
>
> ParaView development discussion is moving! Please visit
> https://discourse.paraview.org/ for future posts.
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Search the list archives at:
> http://markmail.org/search/?q=Paraview-developers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/paraview-developers
>


-- 
William J. Schroeder, PhD
Kitware, Inc. - Building the World's Technical Computing Software
28 Corporate Drive
Clifton Park, NY 12065
will.schroeder at kitware.com
http://www.kitware.com
(518) 881-4902
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview-developers/attachments/20180615/7ca93b82/attachment.html>


More information about the Paraview-developers mailing list