code: def cluster(points, radius):
      
      if isinstance(points, vtk.vtkActor):
          poly = points.GetMapper().GetInput()
      else:
          src = vtk.vtkPointSource()
          src.SetNumberOfPoints(len(points))
          src.Update()
          vpts = src.GetOutput().GetPoints()
          for i, p in enumerate(points):
              vpts.SetPoint(i, p)
          poly = src.GetOutput()
  
      cluster = vtk.vtkEuclideanClusterExtraction()
      cluster.SetInputData(poly)
      cluster.SetExtractionModeToAllClusters()
      cluster.SetRadius(radius)
      cluster.ColorClustersOn()
      cluster.Update()
  
      idsarr = cluster.GetOutput().GetPointData().GetArray("ClusterId")
      Nc = cluster.GetNumberOfExtractedClusters()
  
      sets = [[] for i in range(Nc)]
      for i, p in enumerate(points):
          sets[idsarr.GetValue(i)].append(p)
  
      acts = []
      for i, aset in enumerate(sets):
          acts.append(vs.Points(aset, c=i))
  
      actor = Assembly(acts)
  
      actor.info["clusters"] = sets
      print("Nr. of extracted clusters", Nc)
      if Nc > 10:
          print("First ten:")
      for i in range(Nc):
          if i > 9:
              print("...")
              break
          print("Cluster #" + str(i) + ",  N =", len(sets[i]))
      print("Access individual clusters through attribute: actor.cluster")
      return actor
docs: Clustering of points in space.
  
      `radius` is the radius of local search.
      Individual subsets can be accessed through ``actor.clusters``.
  
      .. hint:: |clustering| |clustering.py|_