[vtkusers] Getting the original cell id'sfrom vtkExtractUnstructuredGrid

Sarah Macumber S.Macumber at QuestReliability.com
Wed Jul 23 12:27:52 EDT 2008


Ahh, ok thank you Bryn.
 
Sarah

________________________________

From: Bryn Lloyd [mailto:blloyd at vision.ee.ethz.ch]
Sent: Wed 7/23/2008 10:41 AM
To: Sarah Macumber
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Getting the original cell id'sfrom vtkExtractUnstructuredGrid



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