[vtkusers] Using vtkFieldData
John Norris
jnorris at mcs.anl.gov
Tue Oct 11 10:43:06 EDT 2005
Hi,
I've using a vtkHierarchicalDataSet to represent my multi-block data.
I'd like to preserve certain block-specific information (e.g. the
block's text label), but haven't figured out a good way to do this yet.
I tried adding a vtkCharArray to the vtkFieldData of each of the
component datasets, but this doesn't appear to be passed down the pipe.
I've tried a simple example using a regular vtkStructuredPoints, and
it doesn't seem to pass along its vtkFieldData either. A code snippet
follows.
Is there any way, other than converting the string to cell or point
data, to get this data passed through filters?
Thanks,
John
vtkStructuredGrid* pStrGrid = vtkStructuredGrid::New();
<set the grid's points and point data>
// Create the array to add to the field data.
char* charData = new char[16];
strcpy(charData, "Hello!");
vtkCharArray* pText = vtkCharArray::New();
pText->SetArray(charData, strlen(charData) + 1, 0);
pText->SetName("Text Test");
// Add to the field data.
pStrGrid->GetFieldData()->AddArray(pText);
pText->Delete();
pStrGrid->GetFieldData()->CopyAllOn();
// Pass the data through a filter.
vtkContourFilter* pContour = vtkContourFilter::New();
pContour->UseScalarTreeOn();
pContour->GenerateValues(5, 0.1, 1.0);
pContour->SetInput(pStrGrid);
// Force an update.
pContour->GetOutput()->Update();
// Print info on the original grid.
// Its Field Data will contain one array named 'Text Test'.
std::cout << "Original Grid:\n";
pStrGrid->Print(std::cout);
// Print info on the contours.
// Its Field Data will not contain any arrays.
std::cout << "\nContours:\n";
pContour->GetOutput()->Print(std::cout);
--
John Norris
Research Programmer
Center for Simulation of Advanced Rockets
http://www.uiuc.edu/ph/www/jnorris
More information about the vtkusers
mailing list