Delete/Modify a cell in a UnstructuredGrid

I have an UnstructuredGrid that consists of a collection of square cells. Given an id of a particular cell I would like to either (assume that the ids for the points defining this cell are p_0,p_1,p_2,p_3)

a) delete that cell and replace it with a new triangular cell defined by p_0,p_1,p_2; or
b) modify the cell such that new cell is triangular defined by p_0,p_1,p_2

If I was dealing with a PolyData object then I believe that I can delete a cell as follows

poly_data.BuildLinks()
poly_data.DeleteCell(id)
poly_data.RemoveDeletedCells()

and then simply add in a new cell with the appropriate properties. But how do I do this with an UnstructuredGrid? An answer using C++ or Python would be great.

hello ,did you solved you problem? I have same problem

I got curious and took a look at vtkUnstructuredGridBase:


Does this help?

Yes,it is wored. Do you know how to replace the cell to a empty cell?

Have you tried VTK_EMPTY_CELL?

I had tried to replace cell to a VTK_EMPTY_CELL, but not success. have you any example?

I know that this digging up an old question, but I did something similar, and I had to replace the cell array of the unstructured grid to do it. The rough idea is here.