Mesh

from mcot.surface.mesh import Mesh
class mcot.surface.mesh.Mesh[source]

General mesh object.

Defines methods that are independent of the number of dimensions.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Inheritance diagram

Inheritance diagram of mcot.surface.mesh.Mesh

Methods

closed()

Checks if the mesh is closed.

closest_vertex(points)

Finds the closest vertices on the surface for a bunch of vertices.

connected_components()

Returns a tuple with (number of connected components, labeling of connected components).

graph_connection_connection([weight, dtype])

Converts the mesh into a graph, where the nodes are the faces and the edges are between those faces sharing vertices.

graph_connection_point([dtype])

Returns the interactions between vertices and faces as a sparse matrix.

graph_point_point([weight, dtype, …])

Converts the mesh into a graph describing the edges between the individual vertices (nodes).

size_vertices()

Attributes the size of the faces to the vertices they connect.

surface_edge_distance([use, method, …])

Returns a matrix of the shortest distances across the edges connecting the vertices.

Attributes

faces

ndim

Dimensionality of the embedding space.

nfaces

Number of surface elements connecting the vertices.

nvertices

Number of vertices on the mesh.

tree

A KD tree used to compute the distance between the vertices defining the surface and any other vertices.

vertices

closed

Mesh.closed()[source]

Checks if the mesh is closed.

closest_vertex

Mesh.closest_vertex(points)[source]

Finds the closest vertices on the surface for a bunch of vertices.

Parameters

points – (ndim, nvertices) array with the reference vertices

Returns

tuple with

  • (nvertices, ) distance array

  • (nvertices, ) index array

connected_components

Mesh.connected_components()[source]

Returns a tuple with (number of connected components, labeling of connected components).

graph_connection_connection

Mesh.graph_connection_connection(weight=None, dtype='bool')[source]

Converts the mesh into a graph, where the nodes are the faces and the edges are between those faces sharing vertices.

Parameters
  • weight – Weights the boundaries by the distance between the connection centers if set to “distance”

  • dtype – datatype of the resulting sparse matrix (only used if weight is None)

Returns

(N, N) sparse matrix for N faces, which is one (or the value set by weight) if the faces share a vertex.

graph_connection_point

Mesh.graph_connection_point(dtype='bool')[source]

Returns the interactions between vertices and faces as a sparse matrix.

The resulting matrix can be used to multiply a vector of size M faces to get a vector of size N vertices.

The result of this method is cached in _graph (set _graph to None to re-compute the graph).

Parameters

dtype – data type of the resulting sparse matrix

Returns

(N, M) sparse matrix for N vertices and M faces, which is one if connection M interacts with N.

graph_point_point

Mesh.graph_point_point(weight=None, dtype='bool', include_diagonal=True)[source]

Converts the mesh into a graph describing the edges between the individual vertices (nodes).

Parameters
  • weight – Weights the boundaries by the distance between the vertices if set to “distance”

  • dtype – datatype of the resulting sparse matrix (only used if weight is None)

  • include_diagonal – if set to False exclude the diagonal from the sparse matrix

Returns

(N, N) sparse matrix for N vertices, which is one (or the value set by weight) if the vertices are connected.

size_vertices

Mesh.size_vertices()[source]

Attributes the size of the faces to the vertices they connect.

surface_edge_distance

Mesh.surface_edge_distance(use=None, method='auto', return_predecessors=False, use_connections=False)[source]

Returns a matrix of the shortest distances across the edges connecting the vertices.

This is an upper limit to the true distance across the surface, because the path is limited to following the edges of the triangular mesh.

This is a wrapper around scipy.sparse.csgraph.shortest_path.

Parameters
  • use – boolean array indicating which vertices or faces to use (default: use all)

  • method – method used by scipy.sparse.csgraph.shortest_path.

  • return_predecessors – whether to return the (N, N) predecessor matrix

  • use_connections – compute the shortest distance between the faces rather than the vertices.

Returns

(N, N) matrix of shortest distances across the graph