Extract points near extracted cell


I have a mesh with information of the cell centers.

I have a .vtk file with information on the face centers. These are displayed as gaussian points.

I would like to extract one cell of the domain and get the corresponding face information.

How can I do that? Is there a way to extract closest points to a certain geometry (extracted cell)?

Hi @Chica_ron !

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.

I will take a look into it. Thanks!

I am kind of lost in this.

I understand what the script should do:

Ask the user for a mesh input and points input:

Ask for a list of cell_id’s

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()):

        # extract all cells into a separate grid
        extract = vtk.vtkExtractCells()
        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(',')]

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