vtkConnectedPointsFilter does not support vtkPointSet

Hi!

I was trying the newly concretized vtkPointSet class for dense pointcloud analysis and visualization. I wanted to calculate the connectivity of my point cloud using vtkConnectedPointsFilter() but it raises the following error

ERROR:root:Input dataset is not a polydata!

and the RegionId output is empty.
If I use a vtkPolyData the filter runs fine (without defining cell data). Is this behaviour intended, am I doing something wrong or it’s a bug? Why is PolyData needed if this filter does not need the presence of cells?

Steps to reproduce the behaviour:

import vtk 

plotter = pv.Plotter()

pc = some_VTK_FLOAT_data

points = vtk.vtkPoints()

points.SetData(pc)

vtk_ps = vtk.vtkPointSet()
vtk_ps.SetPoints(points)
vtk_ps.Modified()

connectivity_filter = vtk.vtkConnectedPointsFilter()
connectivity_filter.SetInputData(vtk_ps)
connectivity_filter.SetRadius(200)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update()

This throws the error.

But when doing

import vtk 

plotter = pv.Plotter()

pc = some_VTK_FLOAT_data

points = vtk.vtkPoints()

points.SetData(pc)

vtk_pd= vtk.vtkPolyData()
vtk_pd.SetPoints(points)
vtk_pd.Modified()

connectivity_filter = vtk.vtkConnectedPointsFilter()
connectivity_filter.SetInputData(vtk_pd)
connectivity_filter.SetRadius(200)
connectivity_filter.SetExtractionModeToAllRegions()
connectivity_filter.Update()

it works as intended.

Thanks!

I haven’t looked at this in a while, but I think the problem is that the filter has options to extract just a subset of the input points. This means that potentially the definition of any cells would be corrupted. My understanding is that you just want to label points with region ids so the cells would remain valid - I get it, but the filter is more general etc. which limits your workflow.

Short of writing a new filter, there are workarounds. Basically you can create a vtkPointSet with just the points added, run the connectivity filter to generate the point region ids, and then reassemble a vtkPolyData with the original points and cells and other attribute data, plus the addition of the region ids. This could be done manually, or if you wanted to get fancier some sort of programmable filter. HTH

Yes I thought of doing it like that but in reverse since I want my main object to remain as PointSet. I was hoping for a more direct approach. Thanks!