surface_builder
SurfaceBuilder
Builder class for creating surface polydata from points or triangles.
Contains additional methods to manipulate surface polydata.
__init__()
build(coords, polygons)
staticmethod
Build polydata from vertices and triangles (polygons).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords |
ndarray[N, 3]
|
Array of vertices coordinates. |
required |
polygons |
ndarray
|
Array of vertices indexes forming triangles. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
surface polydata created from triangles. |
build_delaunay_2d(coords)
staticmethod
Build surface using vtkDelaunay2D.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords |
ndarray[N, 3]
|
Coords of the points. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Triangulated surface. |
build_from_elems(coords, elements)
staticmethod
Build surface from elements (tetrahedron)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords |
ndarray[N, 3]
|
Coords of the points. |
required |
elements |
ndarray[M, 4]
|
Vertex indices. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Extracted element's faces. |
build_from_points(coords, radius=10, space_step=1, normals=None)
staticmethod
Build triangulated surface from point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coords |
ndarray[N, 3]
|
Cloud of points. |
required |
radius |
float
|
Points within radius will be included for creating distance maps. Defaults to 10. |
10
|
space_step |
float or list
|
Space step given as value or list of values for each dimension. Defaults to 1. |
1
|
normals |
str
|
Name of normals array. Defaults to None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Surface polydata. |
clean(polydata)
staticmethod
Remove all points that are not part of triangles.
If polydata does not contain 'OriginalPointIds' it will be generated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
surface polydata that has to be filtered. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
filtered surface polydata. |
erode_boundary(polydata, iterations=1)
staticmethod
Erodes a VTK surface mesh by removing boundary triangles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Input surface mesh. |
required |
iterations |
int
|
Number of times to erode the boundary. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
The eroded surface mesh. |
extract_edges(polydata)
staticmethod
Extract boundary edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Surface polydata. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Polydata containing polylines. |
extract_points(polydata)
staticmethod
Extract all point coordinats from polydata surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Surface PolyData. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.npdarray[N, 3]: Extructed point coordinates. |
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.
extract_triangles(polydata)
staticmethod
Extract triangle vertices from polydata surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Surface PolyData. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.npdarray[N, 3]: Extructed triangle indices. |
point_data_to_cell_data(polydata, scalar_name, func=np.nanmin)
staticmethod
Convert point scalar to cell scalar using func.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Surface polydata. |
required |
scalar_name |
str or list
|
Name of scalar(s) array to convert. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Surface polydata with new cell array. |
remove_cells(polydata, point_ids=None, cell_ids=None, clean=True)
staticmethod
Remove cells from polydata.
If polydata does not contain 'OriginalPointIds' it will be generated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polydata |
vtkPolyData
|
Surface polydata. |
required |
point_ids |
array_like
|
All cells containing this points will be removed. Defaults to None. |
None
|
cell_ids |
array_like
|
Cell to be removed. Default to None. |
None
|
clean |
bool
|
If True, hanging point will be removed. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
vtkPolyData |
vtkPolyData
|
Surface polydata w |
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:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array of selected points ids. |