[vtkusers] Does vtkUnstructuredGrid behaves differently in 5.0.4 than 4.4.2?

Thuc Bui bui at calcreek.com
Tue Oct 21 19:14:20 EDT 2008


Hi All,

I hope someone can help me out. I am porting my application using VTK 4.4.2
to 5.0.4 and encountering a behavior of vtkUnstructuredGrid that is
different (and fatal in my case) from 4.4.2. Below are the codes that I use
showing 5.0.4 returns zero for both the number of cells and points whilst
4.4.2 returns correct numbers.

Can any one point out for me what should I modify my codes to get the
correct behavior of 4.4.2?

Many thanks in advance for your help,
Thuc Bui

vtkDataSetReader* unstructGridReader = vtkDataSetReader::New();

// the file is in unstructured grid format
unstructGridReader->SetFileName("myVTKdata.txt");

// to force a re-read because in actual code, unstructGridReader is 
// instantiated else where and the file could be modified in between
unstructGridReader->Modified();

// correctly return fRes = 1 for both VTK 4.4.2 and 5.0.4
int fRes = unstructGridReader->IsFileUnstructuredGrid();

// correctly return the number of scalar and vector fields in the file 
// for both VTK 4.4.2 and 5.0.4
int nScalarFlds = unstructGridReader->GetNumberOfScalarsInFile();
int nVecFlds = unstructGridReader->GetNumberOfVectorsInFile();

unstructGridReader->SetScalarsName(0);	// set to 1st scalar field

vtkUnstructuredGrid* unstructuredGridData =
dynamic_cast<vtkUnstructuredGrid*>(unstructGridReader->GetOutput());

// VTK 4.4.2 returns correctly the number of cells and points
// but 5.0.4 returns both zero
int numCells = unstructuredGridData->GetNumberOfCells();
int numPts1 = unstructuredGridData->GetNumberOfPoints();





More information about the vtkusers mailing list