Medial axis
- class geoteqpy.MedialAxis(mesh: UnstructuredGrid, radius_ma: float, pca_method: str = 'sphere', cov_radius: float = 10000.0, cov_knearest: int = 100)
Class to compute the medial axis of a 3-dimensional shape. The medial axis is a set of points located at the centre of the shape. Medial axis is computed using the algorithm described in the paper:
Ma, J., Bae, S.W., Choi, S. (2019). 3D medial axis point approximation using nearest neighbors and the normal field. Computer-Aided Design, 114, 1-11. https://doi.org/10.1016/j.cad.2019.05.002
- Parameters:
mesh (pyvista.UnstructuredGrid) – Mesh of the shape for which the medial axis is computed.
radius_ma (float) – Radius of research for the medial axis.
pca_method (str) –
Method to compute the covariance matrix and its eigenvectors. Available methods are
"sphere"or"knearest"."sphere": compute the covariance matrix using a sphere of radiuscov_radius."knearest": compute the covariance matrix using thecov_knearestnearest neighbors.
cov_radius (float) – Radius of the sphere to select the points for the covariance matrix. Default is 1e4.
cov_knearest (int) – Number of nearest neighbors to select the points for the covariance matrix. Default is 100.
- Attributes:
- medial_axis: pyvista.PolyData
Pyvista mesh object of the medial axis points.
- radius_ma: float
Radius of research for the medial axis.
- pca: geoteqpy.PCA
PCA object to compute the covariance matrix and its eigenvectors.
- Example:
import pyvista as pvs import geoteqpy as gte # Load a mesh mesh = pvs.read("path/to/mesh.vtu") # Create a MedialAxis object, compute the medial axis and the orientation vectors ma = gte.MedialAxis(mesh=mesh,radius_ma=1e4,pca_method="knearest",cov_knearest=100)
- Methods:
- compute_medial_axis() PolyData
Compute the medial axis of the shape. Attach the result to the class attribute
medial_axis.
- get_medial_axis_mesh() PolyData
Get the medial axis mesh.
- Returns:
Pyvista mesh object of the medial axis points.
- Return type:
pyvista.PolyData
- get_orientation_vectors()
Register the eigen vectors of the covariance matrix on the
medial_axismesh if they are not already present.