Can I return cell types from a vtkPolyData using the Python bindings


I’m trying to read the cell types in a vtkPolyData using the vtk Python bindings. The method returns the cell types by reference.

virtual void vtkDataSet::GetCellTypes	(	vtkCellTypes * 	types	)	

I’m trying to use the reference class for this as shon elow

from vtkmodules.vtkCommonCore import reference
cell_types = reference(('0'),)

where ‘my_poly’ is a vtkPolyData, but this throws an exception - ‘TypeError: GetCellTypes argument 1: method requires a VTK object’

Any ideas on how I can get the cell types from the vtkPolyData will be greatly appreciated

No “reference” required here. See vtkCellTypes.

cell_types = vtkCellTypes()
print("NumberOfCellTypes", cell_types.GetNumberOfTypes())

Thanks David - I realized I misread the argument type :frowning:

And I can get the type data directly into numpy:-

cell_types_np = np.array(cell_types.GetCellTypesArray())