vtkDataObjectTreeIterator uses fragile caching mechanism.
Consider the following code:
vtkDataObject newDObj = ...; vtkDataObjectTreeIterator *iter = ...; // Replace the data object pointed to by iter with newDObj: iter->GetDataSet()->SetDataSet(iter, newDObj); assert(this->GetDataSet()->GetDataSet(iter) == newDObj); // ok assert(iter->GetCurrentDataObject() == newDObj); // ERROR!
vtkDataObjectTreeIterator (and maybe other implementations of
vtkCompositeDataIterator) cache the current data object internally when they are created/incremented, and do not accurately reflect the current state of the container.
vtk::Range iterator implementations (!5158 (merged), !5201 (merged)) are implemented with workarounds to correct this behavior, but the original iterators will need some non-trivial refactoring to fix.