cellcomplex.property_topomesh.analysis module

PropertyTopomesh Analysis

Implementing functions to compute geometrical and topological properties on a PropertyTopomesh, generally assuming it represents a triangular mesh (but not necessarily a 2-manifold one). Powerful computation of the values of the property for all the mesh elements at once. Convenient functions such as edge lengths, cell volumes, surface curvatures, vertex normals, face areas, and so on.

compute_topomesh_property(topomesh, …[, …])

Compute a property over the elements of a PropertyTopomesh.

compute_topomesh_triangle_properties(topomesh)

Compute an usual set of properties over the faces of a PropertyTopomesh.

compute_topomesh_vertex_property_from_faces(…)

Compute a property on degree 0 using the same property defined at degree 2.

compute_topomesh_cell_property_from_faces(…)

Compute a property on degree 3 using the same property defined at degree 2.

topomesh_property_gaussian_filtering(…[, …])

Filter an existing property by a gaussian-like operator.

cellcomplex.property_topomesh.analysis.compute_topomesh_cell_property_from_faces(topomesh, property_name, reduce='mean', weighting='area', verbose=False)[source]

Compute a property on degree 3 using the same property defined at degree 2.

The cell property is computed by averaging or summing the properties of its border faces, weighting them differently according to the chosen method.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on faces).

  • reduce (str) –

    The way weighted face properties are combined to compute the cell property (default is mean):
    • mean: the cell property is the weighted average of face properties

    • sum: the cell property is the weighted sum of face properties

  • weighting (str) –

    The way weights are assigned to each face to compute the property (default is area):
    • uniform: all the faces have the same weight (1)

    • area: the weight on the faces is equal to their area

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

cellcomplex.property_topomesh.analysis.compute_topomesh_face_property_from_cells(topomesh, property_name, weighting='uniform')[source]

Compute a property on degree 2 using the same property defined at degree 3.

The face property is computed by averaging the properties of its neighbor cells, weighting them differently according to the chosen method.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on faces).

  • weighting (str) –

    The way weights are assigned to each cell for the averaging of the property (default is volume)
    • uniform: all the cells have the same weight (1)

    • volume: the weight on the cells is equal to their volume

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

cellcomplex.property_topomesh.analysis.compute_topomesh_property(topomesh, property_name, degree=0, positions=None, normal_method='density', object_positions=None, object_radius=10.0, verbose=False)[source]

Compute a property over the elements of a PropertyTopomesh.

The function computes and fills a property of a PropertyTopomesh passed as argument. The given property is computed for all elements of the specified degree and stored as a dictionary in the PropertyTopomesh structure.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) –

    The name of the property to compute, among the following ones:
    • barycenter (degree : [0, 1, 2, 3])

    • vertices (degree : [0, 1, 2, 3])

    • triangles (degree : [0, 1, 2, 3])

    • cells (degree : [0, 1, 2, 3])

    • length (degree : [1])

    • area (degree : [2])

    • volume (degree : [3])

    • normal (degree : [0, 2])

    • skewness (degree : [2])

    • roughness (degree : [0])

    • vertex_neighbors (degree : [2])

  • degree (int) – The degree of the elements on which to compute the property.

  • positions (dict) – A position dictionary to use if the property (‘barycenter’,0) is empty.

  • normal_method (str) –

    The method used to re-orient the face normals (default is density)
    • barycenter: oriented using the direction of the mesh center

    • density: oriented using the gradient of object density

    • orientation: consistently oriented using topological propagation

  • object_positions (dict) –

    The position of the object(s) represented by the mesh.
    • used only for property (‘normal’,2)

  • object_radius (float) –

    The radius of the object(s) represented by the mesh.
    • used only for property (‘normal’,2)

  • verbose (bool) – Whether to display or not information on computed properties.

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from cellcomplex.property_topomesh.analysis import compute_topomesh_property
>>> topomesh = square_topomesh(side_length=1)
>>> compute_topomesh_property(topomesh,'length',1)
>>> print topomesh.wisp_property('length',1)
{0: 1.0, 1: 1.0, 2: 1.41421356237, 3: 1.0, 4: 1.0}
cellcomplex.property_topomesh.analysis.compute_topomesh_triangle_properties(topomesh, positions=None, verbose=False)[source]

Compute an usual set of properties over the faces of a PropertyTopomesh.

The function computes several geometrical properties assuming the structure passed as argument is a PropertyTopomesh representing a triangular mesh. The area, perimeter and eccentricity of each triangular face is computed and the corresponding properties updated in the structure.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • positions (dict, optional) – A position dictionary if the property (‘barycenter’,0) is empty.

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from cellcomplex.property_topomesh.analysis import compute_topomesh_triangle_properties
>>> topomesh = square_topomesh(side_length=1)
>>> compute_topomesh_triangle_properties(topomesh)
>>> print topomesh.wisp_property('area',2)
{0: 0.5, 1: 0.5}
cellcomplex.property_topomesh.analysis.compute_topomesh_vertex_property_from_cells(topomesh, property_name, weighting='volume')[source]

Compute a property on degree 0 using the same property defined at degree 3.

The vertex property is computed by averaging the properties of its neighbor cells, weighting them differently according to the chosen method.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on faces).

  • weighting (str) –

    The way weights are assigned to each cell for the averaging of the property (default is volume)
    • uniform: all the cells have the same weight (1)

    • volume: the weight on the cells is equal to their volume

Note

The PropertyTopomesh passed as argument is updated.

cellcomplex.property_topomesh.analysis.compute_topomesh_vertex_property_from_edges(topomesh, property_name, weighting='length', verbose=False)[source]

Compute a property on degree 0 using the same property defined at degree 1.

The vertex property is computed by averaging the properties of its neighbor edges, weighting them differently according to the chosen method.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on edges).

  • weighting (str) –

    The way weights are assigned to each edge for the averaging of the property (default is area)
    • uniform: all the edges have the same weight (1)

    • area: the weight on the edges is equal to their area

    • angle: the weight of the edges is equal to the incidence angle at the considered vertex (neighborhood=1)

    • cotangent: the weight of the edges is equal to the sum of cotangent of opposite angles (neighborhood=1)

    • angular sector: the weight of the edges is computed as the angular sector intersecting edge barycenter (neighborhood=1)

  • verbose (bool) – Whether to display information while the property is being computed

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

cellcomplex.property_topomesh.analysis.compute_topomesh_vertex_property_from_faces(topomesh, property_name, weighting='area', neighborhood=1, adjacency_sigma=0.5, verbose=False)[source]

Compute a property on degree 0 using the same property defined at degree 2.

The vertex property is computed by averaging the properties of its neighbor faces, weighting them differently according to the chosen method.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on faces).

  • weighting (str) –

    The way weights are assigned to each face for the averaging of the property (default is area)
    • uniform: all the faces have the same weight (1)

    • area: the weight on the faces is equal to their area

    • angle: the weight of the faces is equal to the incidence angle at the considered vertex (neighborhood=1)

    • cotangent: the weight of the faces is equal to the sum of cotangent of opposite angles (neighborhood=1)

    • angular sector: the weight of the faces is computed as the angular sector intersecting face barycenter (neighborhood=1)

  • neighborhood (int) – The ring-distance of faces considered around each vertex (1-ring is immediate neighbor faces).

  • adjacency_sigma (float) – The standard deviation of the gaussian weighting using the ring-distance.

  • verbose (bool) – Whether to display information while the property is being computed

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from cellcomplex.property_topomesh.analysis import compute_topomesh_property
>>> from cellcomplex.property_topomesh.analysis import compute_topomesh_vertex_property_from_faces
>>> topomesh = square_topomesh(side_length=1)
>>> compute_topomesh_property(topomesh,'normal',2,normal_method='orientation')
>>> compute_topomesh_vertex_property_from_faces(topomesh,'normal',weighting='area',neighborhood=3,adjacency_sigma=1.2)
cellcomplex.property_topomesh.analysis.is_triangular(topomesh)[source]

Check wether the structure is a triangular mesh.

Look at the number of vertices of each face of the topomesh to decide whether it can be processed as a triangular mesh in all the algorithms.

Parameters

topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure to evaluate.

Returns

triangular – True if the mesh has only triangular faces, False otherwise

Return type

bool

cellcomplex.property_topomesh.analysis.topomesh_property_gaussian_filtering(topomesh, property_name, degree, neighborhood=3, adjacency_sigma=1.0, distance_sigma=1.0)[source]

Filter an existing property by a gaussian-like operator.

A new value of an existing property is computed for each element of a given degree as a linear combination of all the property values. The coefficient associated with each other element is defined relatively to its distance in both space and topology (ring-distance) using the product of 2 gaussian functions.

Parameters
  • topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to compute the property.

  • property_name (str) – The name of the property to compute (must be already computed on faces).

  • degree (int) – The degree of the elements on which to compute the property.

  • neighborhood (int) – The maximal ring-distance up to which elements have a non-zero ceofficient.

  • adjacency_sigma (float) – The standard deviation of the gaussian function based on the ring-distance.

  • distance_sigma (float) – The standard deviation of the gaussian function based on the Euclidean distance.

Returns

Return type

None

Note

The PropertyTopomesh passed as argument is updated.