VTK/Tutorials/DataStorage: Difference between revisions

From KitwarePublic
< VTK‎ | Tutorials
Jump to navigationJump to search
(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...")
 
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:


==FieldData==
==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.
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 were 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==
==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()).
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 these 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==
==PointData==
Line 16: Line 16:
This concept is called ActiveScalars and ActiveVectors. Some algorithms  
This concept is called ActiveScalars and ActiveVectors. Some algorithms  


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


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


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


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


polydata->GetPointData()->SetActiveScalars("colors1");
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

Latest revision as of 19:39, 25 April 2014

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 were 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 these 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");