# Deleting vertices based on normal vector

I have a triangular mesh containing vertices that I would like to filter. I am able to filter based on the scalar values of the mean curvature, using vtkThreshold with Python3:

``````curvatureFilter = vtk.vtkCurvatures()
curvatureFilter.SetCurvatureTypeToMean()
curvatureFilter.SetInputData(polydata)
curvatureFilter.Update()
polydata = curvatureFilter.GetOutput()

threshold = vtk.vtkThreshold()
threshold.SetInputData(polydata)
threshold.ThresholdByUpper(0.01)
threshold.Update()
polydata = threshold.GetOutput()
``````

The nice thing about vtkThreshold is that it deletes all vertices and corresponding edges that do not meet the requirement. I would like to do a similar thing based on the normal vectors of the vertices. For example, remove a vertex if the x-value is higher than the y-value of the normal vector.

Does anyone know a proper way how to do this?

You can use vtkArrayCalculator to perform various scalar and vector operations on point data and store results in a new array that you can use for thresholding.

What is your end goal with this? Would you like to extract “one side” of a surface? There are much better methods for this than filtering based on normal vector direction.

It would be useful if you could give a context of your question (what is your application area, problem you want to solve, approach that you are implementing), and not just write about the very specific technical issue.

Hi Andras, my goal is indeed to extract the vertices that are on the sides.

This is the original mesh:

This is after thresholding on a mean curvature value of > 0.01:

And this is after thresholding and filtering on the direction of the normal vector:

I obtain the last image by adding the coordinates of every vertex that satisfies the condition for the normal vector to a vtkVertexGlyphFilter. However, I would like to maintain/include the corresponding edges between the vertices. In this way, I would be able to cluster the vertices that are connected to each other.

You can find continuous edge by computing curvature for each point and connecting them using vtkDijkstraGraphGeodesicPath, as suggested before:

Hi Andras, the objective of the post you referred to is different from what I am trying to accomplish for this experiment.

As you suggested, I now added an additional array to the polydata which has 1 for every index/vertex that should be considered and a 0 otherwise. If I visualize it with Paraview it looks like this:

When applying the threshold filter in Paraview on this new array:

This is exactly what I want. However, Paraview’s threshold filter allows specifying the scalar array to which the threshold should be applied. I cannot find this in vtk, so I was wondering if you’d know how to specify the array for the threshold filter in vtk (python3)?

You can choose an array to work by prepending an vtkAssignAttribute filter before the threshold filter; or using SetInputArrayToProcess() method of the threshold filter.

Dijkstra path search is usually needed for boundary extraction because the region that you get with thresholding is thick and noisy.