Skip to content

T1 transitions

vertax.topo

Topology module to handle T1 transitions in meshes.

T1TensionReset dataclass

T1TensionReset(sigmoid_tensions: bool = False)

Reset the line tension of the edge created by a T1 transition, in a bounded mesh. Off unless passed.

In a bounded mesh an edge keeps its index, and so its parameter, through a T1: the new junction inherits the tension of the junction it replaces. When the outer optimization has raised that tension enough for the old junction to collapse, the new one collapses too, and the pair flips back and forth, or the junction is held at the T1 length. With this option the new edge starts at the mean tension of the other edges of its own kind (interior edges for a new interior edge, free-interface edges for a new free-interface edge). Physically, a new junction carries none of the tension built up on the junction it replaces.

The mean is taken over the tensions, not over their parameters. sigmoid_tensions must match the option of the same name of make_energy_line_tensions_bounded: with it, the parameters are mapped through 1 + sigmoid before averaging and the mean is mapped back. The reset is a smooth function of the other edges' parameters, so automatic differentiation of a relaxation differentiates through it.

update_T1

update_T1(vertTable: Array, heTable: Array, faceTable: Array, width: float, height: float, vert_params: Array, he_params: Array, face_params: Array, L_in: InnerLossFunction, min_dist_T1: float, selected_verts: Array | None, selected_hes: Array | None, selected_faces: Array | None, perform_energy_check: bool = False, reopen_margin: float = 0.1) -> tuple[Array, Array, Array]

Detect and apply T1 topological changes.

Every edge no longer than min_dist_T1 whose two cells are not triangles is flipped, and the new edge is given the length (1 + reopen_margin) * min_dist_T1 about the old edge's midpoint. With perform_energy_check the flip is kept only if its energy does not exceed that of the unflipped configuration with the short edge re-stretched to the same length along its own direction; otherwise the re-stretched, unflipped configuration is kept. Without it every flip is kept.

reopen_margin is keyword-only in practice: loops call this function with the thirteen positional arguments of UpdateT1Func plus perform_energy_check, so a different margin is passed with functools.partial(update_T1, reopen_margin=...).

do_not_update_T1

do_not_update_T1(vertTable: Array, heTable: Array, faceTable: Array, width: float, height: float, vert_params: Array, he_params: Array, face_params: Array, L_in: InnerLossFunction, min_dist_T1: float, selected_verts: Array | None, selected_hes: Array | None, selected_faces: Array | None, perform_energy_check: bool = False) -> tuple[Array, Array, Array]

Do nothing function.

update_T1_bounded

update_T1_bounded(vertTable: Array, angTable: Array, heTable: Array, faceTable: Array, vert_params: Array, he_params: Array, face_params: Array, L_in: InnerLossFunctionBounded, min_dist_T1: float, selected_verts: Array | None = None, selected_hes: Array | None = None, selected_faces: Array | None = None, perform_energy_check: bool = False, tension_reset: T1TensionReset | None = None, reopen_margin: float | None = None) -> tuple[Array, Array, Array, Array] | tuple[Array, Array, Array, Array, Array, Array]

Find and apply T1 topological transitions for bounded meshes.

Every edge shorter than min_dist_T1 is either flipped (case B) or, when perform_energy_check is true and flipping raises the energy, re-stretched about its midpoint without flipping (case A). Both candidates are compared at the moment of the transition, before either is relaxed.

tension_reset (off by default) gives the edge created by a T1 the mean line tension of the other edges of its kind, instead of the tension of the edge it replaces (see T1TensionReset). The energy check then compares case A at the current tensions with case B at the reset ones, the two states that would actually exist. With the option, the routine returns two more arrays: the edge parameters after every reset, and for each edge the number of transitions accepted in this call (0 or 1). Without it, the return value and every number are those of the routine without the option.

The new edge (case B), the re-stretched edge (case A) and the two vertices moved apart when a flip is impossible are all given the same length about the old edge's midpoint: by default min_dist_T1 + 1e-3, the length every committed bounded result was produced with, and with reopen_margin set, (1 + reopen_margin) * min_dist_T1, as for the periodic update_T1. A new edge only 1e-3 above the threshold can be shortened below it again by one relaxation step and flip straight back. Like the periodic margin, it is passed with functools.partial(update_T1_bounded, reopen_margin=...).

do_not_update_T1_bounded

do_not_update_T1_bounded(vertTable: Array, angTable: Array, heTable: Array, faceTable: Array, vert_params: Array, he_params: Array, face_params: Array, L_in: InnerLossFunctionBounded, min_dist_T1: float, selected_verts: Array | None = None, selected_hes: Array | None = None, selected_faces: Array | None = None, perform_energy_check: bool = False, tension_reset: T1TensionReset | None = None) -> tuple[Array, Array, Array, Array] | tuple[Array, Array, Array, Array, Array, Array]

Do nothing function for bounded meshes; with tension_reset, the same outputs as update_T1_bounded.