Sunday, February 19, 2012

python VTK tricks

python 2.7.2 VTK 5.8
In python, vtkUnstructuredGrid.GetCell(n) always return a global static object. Assume that we have an unstructured grid object "ug". [ug.GetCell(i) for i in range(ug.GetNumberOfCells())] gives you a list of copies of the same, maybe global, cell object, which should be the copy of the last cell. If you wanna do sth with each single cell, do it before the return cell get override. Ex. [ map(ug.GetCell(i).GetPointId, range(4)) for i in range(ug.GetNumberOfCells())]

I did not test any other function such as GetFace.


No comments:

Post a Comment