Skip to content

surface_filter

SurfaceFilter

Tool class for manipulating surface polydata.

Class usage is possible for:

  • surface smoothering.
  • building normals based on the data points/cells.
  • surface refinment (triangles subdivision).
  • surface extraction.

__init__()

clean(polydata, distance=0, merge_duplicate=True) staticmethod

Construct filter to sample points from surface polydata by removing points that are within the distance (duplicate points).

Parameters:

Name Type Description Default
distance float

points within distance will be merged. Defaults to 0.

0
merge_duplicate bool

If True dublicate points will be merged. Defaults to True.

True

Returns:

Name Type Description
vtkCleanPolyData vtkCleanPolyData

initialized filter object.

contours(polydata, num, vmin, vmax, scalar_name) staticmethod

Construct filter to find contours on surface.

Parameters:

Name Type Description Default
num int

Number of contours levels.

required
vmin float

Lowest contour value.

required
vmax float

Highest contour values.

required
scalar_name str

Name of the scalar array used for contouring.

required

Returns:

Name Type Description
vtkContourFilter vtkContourFilter

Initialized filter object.

extract_region(polydata, ind=0) staticmethod

Extract connected region from surface.

If polydata does not contain 'OriginalPointIds' it will be generated.

Parameters:

Name Type Description Default
polydata vtkPolyData

Input surface polydata

required
ind int

Index of the region. Indexes are in order from largest to smallest. Defaults to 0.

0

Returns:

Name Type Description
vtkPolyData vtkPolyData

Output surface polydata.

Note

Returns largest region by default. If ind >= number of regions, None is returned.

extract_region_by_scalar(polydata, scalar_name, scalar_min, scalar_max, ind=0) staticmethod

Extract connected region from surface thresholding scalar.

If polydata does not contain 'OriginalPointIds' it will be generated.

Parameters:

Name Type Description Default
polydata vtkPolyData

Input surface polydata

required
scalar_name str

Scalar array name for thresholding

required
scalar_min float

Min scalar values

required
scalar_max float

Max scalar values

required
ind int

Index of the region. Indexes are in order from largest to smallest. Defaults to 0.

0

Returns:

Name Type Description
vtkPolyData vtkPolyData

Output surface polydata.

Note

Returns largest region by default. If ind >= number of regions, None is returned.

laplacian_smoother(polydata, iters=15, relaxation=0.1) staticmethod

Smoothe surface polydata based on Laplacian smoothing.

For more info see: https://vtk.org/doc/nightly/html/classvtkSmoothPolyDataFilter.html

Parameters:

Name Type Description Default
iters int

Number of iterations. Defaults to 15.

15
relaxation float

Relaxation factor. Defaults to 0.1.

0.1

Returns:

Name Type Description
vtkSmoothPolyDataFilter vtkSmoothPolyDataFilter

initialized laplacian filter.

normals(polydata) staticmethod

Generate normals for points and triangles.

Returns:

Name Type Description
vtkPolyDataNormals vtkPolyDataNormals

initialized polydata normal.

sample_regular_points(polydata, distance, resample_factor=0.1) staticmethod

Sample points from surface polydata. To sample point from polydata without cells - first apply vertex filter.

Parameters:

Name Type Description Default
polydata vtkPolyData

Input surface polydata.

required
distance float

Distance between sampled points.

required
resample_factor float

Points will be sampled from point cloud with distance multiplied by resample_factor. Defaults to 0.1.

0.1

Returns:

Name Type Description
vtkPolyData vtkPolyData

Surface polydata after the sampling.

select_regular_points(polydata, distance) staticmethod

Select regular points from surface. Unlike sample_regular_points, this method uses only points from input polydata.

If polydata does not contain 'OriginalPointIds' it will be generated.

Parameters:

Name Type Description Default
polydata vtkPolyData

Input surface polydata.

required
distance float

Distance between sampled points.

required

Returns:

Name Type Description
vtkPointSet vtkPointSet

Selected points

subdivide(polydata, edge_length, iterations=10) staticmethod

Subdivide triangles into parts with edge_length parameter.

Parameters:

Name Type Description Default
edge_length float

max triangles edge length.

required

Returns:

Name Type Description
vtkAdaptiveSubdivisionFilter vtkAdaptiveSubdivisionFilter

Initialized subdivision filter.

triangulate_polygons(polydata) staticmethod

Apply vtkTriangleFilter to make triangles from polygons.

Parameters:

Name Type Description Default
polydata vtkPolyData

Input polydata with polygons.

required

Returns:

Name Type Description
vtkPolyData vtkPolyData

Surface polydata with Triangles.

windowed_sinc_smoother(polydata, iters=20, pass_band=0.001, feature_angle=60.0) staticmethod

Smoothe surface polydata using windowed sinc function interpolation kernel.

For more info see: https://vtk.org/doc/nightly/html/classvtkWindowedSincPolyDataFilter.html

Parameters:

Name Type Description Default
iters int

number of iterations.

20
pass_band float

for more info see vtk doc.

0.001
feature_angle float

for more info see vtk doc.

60.0

Returns:

Name Type Description
vtkWindowedSincPolyDataFilter vtkWindowedSincPolyDataFilter

Initialized windowed sinc filter.