You may want to look to a similar problem described here . The last post contains a script that extracts all cells around a point. You should be able to adapt it for your case.
Loop through each cell ID and check which points are inside/on the border of cell from in points input.
Isolate the points together with the cell.
import vtk
from vtkmodules.vtkCommonDataModel import vtkDataSet
from vtkmodules.util.vtkAlgorithm import VTKPythonAlgorithmBase
from paraview.util.vtkAlgorithm import smproxy, smproperty
@smproxy.filter(label="Extract Points Inside Cells")
@smproperty.input(name="Mesh Input")
@smproperty.input(name="Points Input")
class ExtractPointsInsideCells(VTKPythonAlgorithmBase):
def __init__(self):
VTKPythonAlgorithmBase.__init__(self, outputType='vtkUnstructuredGrid')
self.cell_ids = set()
def RequestData(self, request, inInfo, outInfo):
mesh_input = vtkDataSet.GetData(inInfo[0])
# points_input = vtkDataSet.GetData(inInfo[1]) This gives an error
return 1
def processGrid(self, ug):
# this routine is not working
allCellIdsList = vtk.vtkIdList()
for pointId in self.points:
cellIdsList = vtk.vtkIdList()
ug.GetPointCells(pointId, cellIdsList)
for i in range(cellIdsList.GetNumberOfIds()):
allCellIdsList.InsertNextId(cellIdsList.GetId(i))
# extract all cells into a separate grid
extract = vtk.vtkExtractCells()
extract.SetInputData(ug)
extract.SetCellList(allCellIdsList)
extract.Update()
return extract.GetOutput()
@smproperty.intvector(name="Cell ID", default_values=0)
def SetCellIDs(self, cell_ids_str):
self.cell_ids = []
if cell_ids_str:
self.cell_ids = [int(cell_id) for cell_id in cell_ids_str.split(',')]
self.Modified()
Question:
How can I get points_input from in_info?
Does paraview have any routine given the cell ID to collect the associated points and check if another point is inside the cell?
How can I print variables inside these functions. The print(var)does not appear to work