[vtkusers] Getting the original cell id'sfrom vtkExtractUnstructuredGrid

Bryn Lloyd blloyd at vision.ee.ethz.ch
Wed Jul 23 11:41:05 EDT 2008


The vtkIdFilter adds point data/cell data (a vtkIdTypeArray) to your 
data set. You can retrieve it afterwards by selecting the appropriate 
data array.


I would suggest something like this (python script):



reader = vtkDataSetReader()
reader.SetFileName(fname)
reader.ReadAllFieldsOn()

idsname = "Ids"

ids = vtkIdFilter()
ids.SetInputConnection(reader.GetOutputPort())
ids.PointIdsOn()
ids.CellIdsOn()
ids.FieldDataOn()
ids.SetIdsArrayName(idsname)

# instead of extract surface, put your operation here ...
surface = vtkDataSetSurfaceFilter()
surface.SetInputConnection(ids.GetOutputPort())
surface.Update()


pointIdArray = surface.GetOutput().GetPointData().GetArray(idsname)
cellIdArray = surface.GetOutput().GetCellData().GetArray(idsname)


writer = vtkDataSetWriter()
writer.SetFileName('out.vtk')
writer.SetInputConnection(surface.GetOutputPort())
writer.ReadAllFieldsOn()






More information about the vtkusers mailing list