VTK/Tutorials/DataStorage

From KitwarePublic
< VTK‎ | Tutorials
Revision as of 12:24, 26 October 2010 by Daviddoria (talk | contribs) (Created page with "FieldData, CellData, and PointData are all objects that allow you to store data along with the geometry/topology of your data set. You can store things like colors, velocity vect...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

FieldData, CellData, and PointData are all objects that allow you to store data along with the geometry/topology of your data set. You can store things like colors, velocity vectors, ids, names, or any other data that is associated either with the data set as a whole or with each point/cell in the data set. In all three of these cases, you must create an array (vtk*Array, e.g. vtkUnsignedCharArray) and then add it to the data with:

dataset->GetPointData()->AddArray(yourArray);

FieldData

Arrays attached to the FieldData of a dataset describe global properties of the data. That is, if you want to save the time at which the data was recorded, you would put that value in the FieldData. If you wanted to name the data set, you would also put that in the FieldData. There are no restrictions about the length of arrays that are added to the FieldData.

CellData

If you have a dataset which has values/data at every cell (e.g. every triangle in a mesh has a specified color), you should add this data to the CellData of the dataset. The length of arrays added to CellData must equal the number of cells in the dataset (dataset->GetNumberOfCells()).

PointData

If you have a dataset which has values/data at every point, you'll want to use PointData.

"Active" Data

You can add as many arrays as you would like to all of the *Data. A reasonable thing to want to do is switch between different data for your display. That is, if you have two sets of colors stored in the PointData, you should be able to choose which one to display at the moment.

This concept is called ActiveScalars and ActiveVectors. Some algorithms

vtkUnsignedCharArray* colors1 = vtkUnsignedCharArray::New(); colors1->SetName("colors1"); ... fill the colors array

vtkUnsignedCharArray* colors2 = vtkUnsignedCharArray::New(); colors2->SetName("colors2"); ... fill the colors array

polydata->GetPointData()->AddArray(colors1); polydata->GetPointData()->AddArray(colors2);

Now here is the key. To select which one is used, use this:

polydata->GetPointData()->SetActiveScalars("colors1");

I think that is what you were looking for? Give it a try and let us know if it wasn't.

David