cellcomplex.property_topomesh.optimization module

PropertyTopomesh Optimization

property_topomesh_vertices_deformation(topomesh)

Optimize the positions of the mesh vertices along multiple criteria.

property_topomesh_edge_flip_optimization(…)

Perform a topological optimization of a PropertyTopomesh using edge flips.

property_topomesh_edge_split_optimization(…)

Perform a topological optimization of a PropertyTopomesh using edge splits.

property_topomesh_edge_collapse_optimization(…)

Perform a topological optimization of a PropertyTopomesh using edge collapses.

property_topomesh_isotropic_remeshing(…[, …])

Perform a global optimization of a triangular PropertyTopomesh

topomesh_triangle_split(input_topomesh[, …])

Remesh a triangular PropertyTopomesh by spltting all faces into 4

cellcomplex.property_topomesh.optimization.property_topomesh_edge_collapse_optimization(topomesh, omega_energies={'error_quadrics': 0.65, 'length': 0.01}, minimal_length=None, target_triangles=None, iterations=1, verbose=False, debug=False, loglevel=0)[source]

Perform a topological optimization of a PropertyTopomesh using edge collapses.

The topomesh is decimated by successive edge collapse operations in order to minimize an energy function, while reaching the double goal of eliminating edges under a minimal length and reducing the total number of triangles. The collapse operations are performed in the ascending order of energy variation until either the target number of triangles or the maximal number of iterations is reached.

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

  • omega_energies (dict) –

    The weights (float) associated to each energy term:
    • error_quadics energy minimizing the decimation error

    • length energy maximizing total edge length

  • minimal_length (float) – The edge length under which the edges will be collapsed

  • target_triangles (int) – The number of triangles to reach after decimation

  • iterations (int) – Number of optimization passes to perform

Returns

n_collapses – Number of edges collapsed in the last iteration

Return type

int

Note

The PropertyTopomesh passed as argument is updated.

Warning

The PropertyTopomesh must be a triangular topomesh (cellcomplex.property_topomesh.analysis.is_triangular())

cellcomplex.property_topomesh.optimization.property_topomesh_edge_flip_optimization(topomesh, omega_energies={'neighborhood': 0.65, 'regularization': 0.15}, simulated_annealing=True, display=False, image_edges=None, verbose=False, debug=False, loglevel=0, **kwargs)[source]

Perform a topological optimization of a PropertyTopomesh using edge flips.

An energy functional is iteratively minimized by successively flipping edges of the triangular topomesh. Edge flips that allow a decrease of the energy while keeping the structure valid topologically and geometrically are applied in ascending order of energy variation. To avoid local minima of energy it is possible to apply energy increasing flips in a simulated annealing procedure.

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

  • omega_energies (dict) –

    The weights (float) associated to each energy term:
    • regularization energy optimizing triangle eccentricity

    • length energy minimizing total edge length

    • neighborhood energy optimizing vertex valency towards 6

    • image energy optimizing adjacencies to observed ones

  • simulated_annealing (bool) – Whether to allow or not energy increasing edge flips in the process

  • image_edges (numpy.ndarray) – The list of pairs of vertices used as reference if image energy is used

Returns

n_flips – Number of edges flipped in the last iteration

Return type

int

Note

The PropertyTopomesh passed as argument is updated.

Warning

The PropertyTopomesh must be a triangular topomesh (cellcomplex.property_topomesh.analysis.is_triangular())

cellcomplex.property_topomesh.optimization.property_topomesh_edge_split_optimization(topomesh, maximal_length=None, split_adjacent_faces=True, iterations=1, verbose=False, debug=False, loglevel=0)[source]

Perform a topological optimization of a PropertyTopomesh using edge splits.

The edges of the topomesh are iteratively splitted in order to become all lesser than a target maximal length, while keeping the structure valid topologically and geometrically. The edges are splitted in the descending order of their lengths, until no edge is longer than maximal_length or the maximal number of iterations is reached.

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

  • maximal_length (float) – The edge length above which the edges will be splitted

  • split_adjacent_faces (bool) – Whether to divide the faces adjacent to the splitted edges

  • iterations (int) – Number of optimization passes to perform

Returns

n_splits – Number of edges splitted in the last iteration

Return type

int

Note

The PropertyTopomesh passed as argument is updated.

Warning

If the PropertyTopomesh must is a triangular topomesh the split_adjacent_faces argument should be True

cellcomplex.property_topomesh.optimization.property_topomesh_isotropic_remeshing(initial_topomesh, maximal_length=None, minimal_length=None, collapse=False, iterations=1, verbose=False, debug=False, loglevel=0)[source]

Perform a global optimization of a triangular PropertyTopomesh

The topomesh is remeshed iteratively by applying only local topological operations and vertex deformation. Based on target minimal and maximal edge lengths, the mesh undergoes a split and collapse optimization, then a pass of edge flip optimization regularizes its topology and a Taubin smoothing its geometry. The process is repeated to perform a global isotropic remeshing of the initial mesh.

Parameters
  • input_topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The initial structure on which to perform the remeshing

  • maximal_length (float, optional:) – The edge length above which the edges will be splitted

  • minimal_length (float, optional) – The edge length under which the edges will be collapsed

  • collapse (bool) – Whether to use or not the edge collapse optimization

  • iterations (int) – Number of optimization passes to perform

Note

If no edge length is set, the target edge length l is set to the 8th decile of initial edge length and the heuristic setting minimal_length to 3/4 l and maximal_length to 4/3 l is used.

Returns

topomesh – The remeshed structure

Return type

cellcomplex.property_topomesh.PropertyTopomesh

Warning

The PropertyTopomesh must be a triangular topomesh (cellcomplex.property_topomesh.analysis.is_triangular())

cellcomplex.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, voxelsize=(1.0, 1.0, 1.0), target_normal=None, target_areas=None, fix_borders=False, verbose=False, debug=False, loglevel=0)[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 (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 (timagetk.SpatialImage) – The 3 derivatives of the gradient field (x, y, z) used for gradient optimization.

  • target_normal (numpy.ndarray, 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

Return type

None

Note

The PropertyTopomesh passed as argument is updated.

cellcomplex.property_topomesh.optimization.topomesh_triangle_split(input_topomesh, verbose=False, debug=False, loglevel=0)[source]

Remesh a triangular PropertyTopomesh by spltting all faces into 4

Performs a simple remeshing of a triangular topomesh by inserting a middle vertex on each edge, and splitting each triangle into four identical triangle by linking the middle vertices.

>>> "    •              •    "
>>> "   / \            / \   "
>>> "  /   \   --->   •---•  "
>>> " /     \        / \ / \ "
>>> "•-------•      •---•---•"
Parameters

input_topomesh (cellcomplex.property_topomesh.PropertyTopomesh) – The initial structure on which to perform the remeshing

Returns

topomesh – The remeshed structure

Return type

cellcomplex.property_topomesh.PropertyTopomesh

Warning

The PropertyTopomesh must be a triangular topomesh (cellcomplex.property_topomesh.analysis.is_triangular())