openalea.cellcomplex.property_topomesh package

Submodules

openalea.cellcomplex.property_topomesh.example_topomesh module

openalea.cellcomplex.property_topomesh.example_topomesh.hexagon_topomesh(side_length=1)[source]
openalea.cellcomplex.property_topomesh.example_topomesh.icosahedron_topomesh(size=1.0)[source]
openalea.cellcomplex.property_topomesh.example_topomesh.sphere_topomesh(radius=1.0, center=<Mock name='mock()' id='140548576227600'>)[source]
openalea.cellcomplex.property_topomesh.example_topomesh.square_topomesh(side_length=1)[source]
openalea.cellcomplex.property_topomesh.example_topomesh.vtk_ellipsoid_topomesh(ellipsoid_radius=50.0, ellipsoid_scales=[1, 1, 1], ellipsoid_axes=<Mock name='mock()' id='140548576228240'>, ellipsoid_center=<Mock name='mock()' id='140548576228560'>)[source]

openalea.cellcomplex.property_topomesh.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.
openalea.cellcomplex.property_topomesh.property_topomesh_analysis.compute_topomesh_cell_property_from_faces(topomesh, property_name, aggregate='mean', weighting='area')[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 (openalea.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).
  • aggregate (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:

None

Note

The PropertyTopomesh passed as argument is updated.

openalea.cellcomplex.property_topomesh.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 (openaela.mesh.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])
  • degree (int) – The degree of the elements on which to compute the property.
  • positions (dict, optional) – A position dictionary if the property (‘barycenter’,0) is empty.
  • normal_method (str, optional) –
    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, optional) –
    The position of the object(s) represented by the mesh.
    • used only for property (‘normal’,2)
  • object_radius (float, optional) –
    The radius of the object(s) represented by the mesh.
    • used only for property (‘normal’,2)
  • verbose (bool, optional) – Whether to display or not information on computed properties.
Returns:

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from openalea.cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from openalea.cellcomplex.property_topomesh.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}
openalea.cellcomplex.property_topomesh.property_topomesh_analysis.compute_topomesh_triangle_properties(topomesh, positions=None)[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 (openalea.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:

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from openalea.cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from openalea.cellcomplex.property_topomesh.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}
openalea.cellcomplex.property_topomesh.property_topomesh_analysis.compute_topomesh_vertex_property_from_faces(topomesh, property_name, weighting='area', neighborhood=1, adjacency_sigma=0.5)[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 (openalea.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.
Returns:

None

Note

The PropertyTopomesh passed as argument is updated.

Example

>>> from openalea.cellcomplex.property_topomesh.example_topomesh import square_topomesh
>>> from openalea.cellcomplex.property_topomesh.property_topomesh_analysis import compute_topomesh_property
>>> from openalea.cellcomplex.property_topomesh.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)
openalea.cellcomplex.property_topomesh.property_topomesh_analysis.filter_topomesh_property(topomesh, property_name, degree, coef=0.5, normalize=False)[source]

Filter an existing property by a gaussian-like operator.

Warning

Deprecated function, use topomesh_property_gaussian_filtering() instead.

openalea.cellcomplex.property_topomesh.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 (openalea.cellcomplex.property_topomesh.PropertyTopomesh) – The structure to evaluate.
Returns:triangular – True if the mesh has only triangular faces, False otherwise
Return type:bool
openalea.cellcomplex.property_topomesh.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 (openalea.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:

None

Note

The PropertyTopomesh passed as argument is updated.

openalea.cellcomplex.property_topomesh.property_topomesh_creation module

openalea.cellcomplex.property_topomesh.property_topomesh_creation.edge_topomesh(edges, positions, **kwargs)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_creation.tetrahedra_topomesh(tetrahedra, positions, **kwargs)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_creation.triangle_topomesh(triangles, positions, **kwargs)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_creation.vertex_topomesh(positions, **kwargs)[source]

openalea.cellcomplex.property_topomesh.property_topomesh_extraction module

openalea.cellcomplex.property_topomesh.property_topomesh_extraction.cell_topomesh(input_topomesh, cells=None, copy_properties=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.clean_topomesh(input_topomesh, clean_properties=False, degree=2)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.cut_surface_topomesh(input_topomesh, z_cut=0, below=True)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.epidermis_topomesh(topomesh, cells=None)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.star_interface_topomesh(topomesh, inner_interfaces=True, verbose=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.surface_dual_topomesh(topomesh, vertex_placement='center', exterior_vertex=1, exterior_distance=0, face_positions=None, vertices_as_cells=None)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.topomesh_connected_components(topomesh, degree=2)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.triangulation_add_exterior(triangulation_topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_extraction.triangulation_remove_exterior(triangulation_topomesh, exterior_vertex=1)[source]

openalea.cellcomplex.property_topomesh.property_topomesh_image module

openalea.cellcomplex.property_topomesh.property_topomesh_image.spatial_image_from_topomesh(topomesh, shape, offset=<Mock name='mock()' id='140548575216144'>, scale=1.0)[source]

“todo

openalea.cellcomplex.property_topomesh.property_topomesh_image.topomesh_line_rasterization(topomesh, shape)[source]

openalea.cellcomplex.property_topomesh.property_topomesh_io module

openalea.cellcomplex.property_topomesh.property_topomesh_io.read_msh_property_topomesh(msh_filename, preserve_cells=True, verbose=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.read_obj_property_topomesh(obj_filename, verbose=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.read_ply_property_topomesh(ply_filename, verbose=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.save_obj_property_topomesh(topomesh, obj_filename, reorient_faces=False, verbose=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.save_ply_cellcomplex_topomesh(topomesh, ply_filename, color_faces=False, colormap=None, oriented=True)[source]

Implementing the PLY standard defined at Saisnbury Computational Workshop 2015

openalea.cellcomplex.property_topomesh.property_topomesh_io.save_ply_property_topomesh(topomesh, ply_filename, properties_to_save={0: [], 1: ['length'], 2: ['area', 'epidermis'], 3: []}, color_faces=False, colormap=None, coordinatepropname='barycenter', verbose=True)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.save_property_topomesh(topomesh, path, cells_to_save=None, properties_to_save={0: ['barycenter'], 1: [], 2: [], 3: []}, **kwargs)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_io.save_tissue_property_topomesh(topomesh, tissue_filename='tissue.zip')[source]

openalea.cellcomplex.property_topomesh.property_topomesh_optimization module

PropertyTopomesh Optimization

property_topomesh_vertices_deformation(topomesh) Optimize the positions of the mesh vertices along multiple criteria.
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_area_smoothing_force(topomesh, target_areas=None)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_cell_interface_planarization_force(topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_cell_vertex_force(topomesh, gradient_derivatives, resolution)[source]

Compute for each vertex of the topomesh the force guiding its displacement towards a cell vertex

openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_cotangent_laplacian_smoothing_force(topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_edge_collapse_optimization(topomesh, omega_energies={'length': 0.01, 'error_quadrics': 0.65}, minimal_length=None, target_triangles=None, iterations=1)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_edge_flip_optimization(topomesh, omega_energies={'regularization': 0.15, 'neighborhood': 0.65}, simulated_annealing=True, display=False, **kwargs)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_edge_split_optimization(topomesh, maximal_length=None, iterations=1)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_epidermis_convexity_force(topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_epidermis_planarization_force(topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_gaussian_smoothing_force(topomesh, gaussian_sigma=10.0)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_interface_planarization_force(topomesh)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_isotropic_remeshing(initial_topomesh, maximal_length=None, minimal_length=None, collapse=False, iterations=1)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_laplacian_epidermis_convexity_force(topomesh)[source]

todo

openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_laplacian_smoothing_force(topomesh, cellwise_smoothing=False)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_mean_curvature_smoothing_force(topomesh)[source]

todo

openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_taubin_smoothing_force(topomesh, gaussian_sigma=10.0, positive_factor=0.33, negative_factor=-0.34, cellwise_smoothing=True)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_triangle_regularization_force(topomesh)[source]

todo

openalea.cellcomplex.property_topomesh.property_topomesh_optimization.property_topomesh_vertices_deformation(topomesh, iterations=1, omega_forces={'taubin_smoothing': 0.65}, sigma_deformation=0.1, gradient_derivatives=None, gaussian_sigma=10.0, resolution=(1.0, 1.0, 1.0), target_normal=None, target_areas=None, fix_borders=False)[source]

Optimize the positions of the mesh vertices along multiple criteria.

The ‘barycenter’ property of the elements of degree 0 is updated following a different “force” vector for each vertex. This vector is computed as the opposite of the gradient of a composite energy functional defined over the mesh. The weights of the energy terms are to be specified in the function arguments. The deformation is constrained to a possibly small range around each vertex.

The function can for instance be used to apply a smoothing to the mesh (laplacian, curvature flow, taubin), or for more complex optimization such as planarization of interfaces, or triangle quality enhancement.

Parameters:
  • topomesh (openalea.cellcomplex.property_topomesh.PropertyTopomesh) – The structure on which to apply the optimization.
  • iterations (int) – The number of times the deformation is repeated.
  • omega_forces (dict) –
    The weights (float) associated to each energy term:
    • regularization: energy optimizing triangle eccentricity
    • area: energy optimizing triangle size homogeneity
    • gradient: energy pushing vertices towards local maxima of a gradient field
    • laplacian: energy regularizing cell edges towards straight lines
    • planarization: energy regularizing cell interfaces towards planar surfaces
    • epidermis_planarization: energy regularizing outer cell surfaces towards planar surfaces
    • convexity: energy regularizing outer cell surfaces towards spherical surfaces
    • laplacian_smoothing: energy regularizing the mesh using a Laplacian operator
    • gaussian_smoothing: energy regularizing the mesh using a Gaussian operator
    • curvature_flow_smoothing: energy regularizing the mesh using a Cotangent Laplacian operator
    • taubin_smoothing: energy regularizing the mesh using two-pass Gaussian operator
  • sigma_deformation (float) – The maximal allowed amplitude of a deformation of a vertex at each iteration.
  • gaussian_sigma (float) – The standard deviation used to compute gaussian weights in gaussian/taubin smoothing.
  • gradient_derivatives (openalea.image.SpatialImage) – The 3 derivatives of the gradient field (x, y, z) used for gradient optimization.
  • target_normal (numpy.array, optional) – The normal of the desired plane for the interface planarization optimization. If None, the direction linking cell centers is chosen.
  • target_areas (numpy.array, optional) – The values of areas to which the mesh triangles should tend in the area optimization. If None, the average area value is chosen.
  • fix_borders (bool) – Whether the border vertices should be fixed or not (in the case of open surfaces).
Returns:

None

Note

The PropertyTopomesh passed as argument is updated.

openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_collapse_edge(topomesh, eid, kept_pid=None, manifold=True)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_flip_edge(topomesh, eid)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_remove_boundary_vertex(topomesh, pid)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_remove_interface_edge(topomesh, eid)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_remove_interface_vertex(topomesh, pid)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_remove_vertex(topomesh, pid, kept_fid=None, triangulate=True)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_split_edge(topomesh, eid)[source]
openalea.cellcomplex.property_topomesh.property_topomesh_optimization.topomesh_triangle_split(input_topomesh)[source]

openalea.cellcomplex.property_topomesh.triangular_mesh module

openalea.cellcomplex.property_topomesh.triangular_mesh.topomesh_to_triangular_mesh(input_topomesh, degree=3, coef=1.0, mesh_center=None, epidermis=False, cell_edges=False, property_name=None, property_degree=None)[source]

Module contents