118. lib.clust — Point based clustering module.

118.1. Classes defined in module lib.clust

class lib.clust.Clustering(S, _opt=False)[source]

Uniform point clustering based on ACVD.

Parameters:

mesh (TriSurface) –

Notes

The algorithm is based on pyvista/pyacvd but is a reimplementation using pyFormex data types and techniques.

cluster(nclus, maxiter=100)[source]

Cluster points

create_mesh(flipnorm=True)[source]

Generates mesh from clusters

cluster_norm()[source]

Return cluster norms

118.2. Functions defined in module lib.clust

lib.clust.cluster_centroid(cent, area, clusters)[source]

Computes an area normalized centroid for each cluster

lib.clust.create_mesh(S, area, clusters, cnorm, flipnorm=True)[source]

Generates a new TriSurface given cluster data

Returns:

TriSurface

lib.clust.unique_row_indices(a)[source]

Indices of unique rows

lib.clust.weighted_points(S)[source]

Returns point weight based on area weight and weighted points. Points are weighted by adjcent area faces.

Parameters:

S (TriSurface) – Triangular surface mesh.

Returns:

  • pweight (np.ndarray, np.double) – Point weight array

  • wvertex (np.ndarray, np.double) – Vertices multiplied by their corresponding weights.

lib.clust.neighbors_from_mesh(S)[source]

Assemble neighbor array. Assumes all-triangular mesh.

Parameters:

S (TriSurface) – TriSurface to assemble neighbors from.

Returns:

  • neigh (int np.ndarray [:, ::1]) – Indices of each neighboring node for each node. -1 entries are at the end!

  • nneigh (int np.ndarray [::1]) – Number of neighbors for each node.

lib.clust.remesh_acvd(S, npoints=-1, ndiv=3)[source]

Remesh a TriSurface using an ACDV clustering method

Parameters:
  • S (TriSurface) – The TriSurface to be remeshed.

  • npoints (int, optional) – The approximat number of vertices in the output mesh. If negative(default), it is set to the number of vertices in the input surface.

  • ndiv (int, optional) – The number of subdivisions to created in order to have a finer mesh for the clustering method. A higher number results in a more regular mesh, at the expense of a longer computation time.

Returns:

TriSurface – The remeshed TriSurface, resembling the input mesh, but having a more regular mesh. Note that if the input Mesh contains sharp folds, you may need to clean up the surface by calling removeNonManifold() and/or fixNormals().

Notes

This uses a clustering technique based on https://www.creatis.insa-lyon.fr/site7/en/acvd to resample the mesh. The actual implementation is a modification of https://github.com/pyvista/pyacvd, directly using pyFormex data structures instead of pyvista/vtk PolyData.

The meaning of the ndiv paramter is different from that in the pyvista/pyacvd module. In pyFormex we can directly set the final number of subdivisions and the sub division is done in a single step. In pyvista/pyacvd one specifies a number of subdivision steps and each step subdivides in 2. Thus a value of nsub = 3 in pyvista/pyacvd corresponds to ndiv = 2^3 = 8 in pyFormex. pyFormex allows subdivision numbers that are not powers of two. This is not possible in pyvista/pyacvd.