Intermittent errors in Cell Centers
A thread on discourse has brought up a problem with the Cell Centers
filter. The filter seems to be unstable in that it intermittently creates bad centers. Here is a video from some data provided by the user. The geometry of the source does not change, but you can see the centers "sparkling" as in each frame you see an error in the computation.
I believe the issue is that this data stores its connectivity array as int32 values. In this condition, it causes the vtkCellCenters
filter to get cell connections in a thread-unsafe way. That in turn causes threads to interfere with each other.
Diving in more deeply, I point to this code in vtkUnstructuredGrid.cxx
, which is supposed to be thread safe.
void vtkUnstructuredGrid::GetCell(vtkIdType cellId, vtkGenericCell* cell)
{
int cellType = static_cast<int>(this->Types->GetValue(cellId));
cell->SetCellType(cellType);
vtkIdType numPts;
const vtkIdType* pts;
this->Connectivity->GetCellAtId(cellId, numPts, pts);
The problem is with this last line. GetCellAtId
is sometimes thread safe, but not always thread safe. It is thread safe if the connectivity array is a simple array of type vtkIdType
. However, if the array is of a different type, the values get copied to an object-local space (which is shared among threads), and this becomes very thread unsafe.