InsertNextCell does not work on various dataset types, if directly from reader
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
If a dataset is directly from a reader (e.g. vtkPolyDataReader or vtkXMLPolyDataReader) then the InsertionLocation is not correctly set (it is set to zero, even if the data contains N>0 cells).
If a user tries to insert a cell in this dataset, the result will be wrong, because the point ids of the cell will be set at the wrong location.
Simply copying does not work, because the DeepCopy operation does not use the InsertNextCell to copy cells. Instead it copies also the InsertionLocation variable.
The only way to fix such a dataset, is to create a new cell array, and insert the cells into this array. I am sure the bug is in the readers. I don't know if it happens in all readers, but have observed it for XML and legacy readers for polydata and unstructured grids.
I will post a test, which illustrates the problem, and which can be added to verify that a fix actually resolved the issue.