Beginners question regarding vtkPointDataToCellData

Hello, everyone,

for me the topic VTK is very new, so I hope that the question is not too stupid.

I’m trying to create a simple program that allows me to select a contiguous area on an STL. For this I want to use the vtkPolyDataConnectivityFilter, and simply select all areas with the same RegionId.

Using a CellPicker I get the CellId, that all works too. Now I would like to have the RegionIds as CellData. In Paraview it works. In my example code (vtk 9.0.1, python 3.7) I only get the normals as CellData. What am I doing wrong?

stl_reader = vtkSTLReader()
stl_reader.SetFileName(stl_file)
stl_reader.Update()
normals = vtkPolyDataNormals()
normals.SetInputConnection(stl_reader.GetOutputPort())
normals.SplittingOn()
normals.Update()
connectivity = vtkPolyDataConnectivityFilter()
connectivity.SetInputConnection(normals.GetOutputPort())
connectivity.SetExtractionModeToAllRegions()
connectivity.ColorRegionsOn()
connectivity.Update()
print(connectivity.GetOutput().GetPointData().GetNumberOfArrays())
    # ==> 2, Normals & RegionId
print(connectivity.GetOutput().GetCellData().GetNumberOfArrays())
    # ==> 0
point_to_cell = vtkPointDataToCellData()
point_to_cell.SetInputConnection(connectivity.GetOutputPort())
point_to_cell.ProcessAllArraysOn()
point_to_cell.PassPointDataOff()
point_to_cell.Update()
print(point_to_cell.GetOutput().GetPointData().GetNumberOfArrays())
    # ==> 0
print(point_to_cell.GetOutput().GetCellData().GetNumberOfArrays())
    # ==> 1, Normals
print(point_to_cell.GetOutput().GetCellData().GetArray(0).GetName())

Hi,

Could you try to use a vtkConnectivityFilter instead of vtkPolyDataConnectivityFilter? This will generate the RegionIds array in both PointData and CellData.

Hi,

Thanks a lot! Works like a charm!