ddg.datastructures.halfedge.set module

ddg.datastructures.halfedge.set.bicolor_vertices(hds, color_attr='color', colors=[0, 1], initial_vertex_index=0)[source]

Bi-colors vertices of a half-edge data structure (bipartite simply connected graph).

Parameters:
hdsddg.datastructures.halfedge.Surface
color_attrstring (default=’color’)

Name of the vertex attribute that is set to distinguish the bi-coloring.

colorsiterable of shape (2,) (default=[0,1])

Values set to the vertex attribute ‘color_attr’. For the two families of vertices, the attribute value is set to colors[0], colors[1], respectively.

Returns:
v1 , v2list, list

Two lists of vertices with new attributes. Each list containing vertices of one color.

ddg.datastructures.halfedge.set.bicolor_faces(hds, color_attr='color', colors=[0, 1], initial_face_index=0)[source]

Bi-colors faces of a half-edge data structure (dual of a bipartite simply connected graph).

Parameters:
hdsddg.datastructures.halfedge.Surface
color_attrstring (default=’color’)

Name of the face attribute that is set to distinguish the bi-coloring.

colorsiterable of shape (2,) (default=[0,1])

Values set to the face attribute ‘color_attr’. For the two families of face, the attribute value is set to colors[0], colors[1], respectively.

Returns:
f1 , f2list, list

Two lists of faces with new attributes. Each list containing faces of one color.

ddg.datastructures.halfedge.set.bicolor_edges(hds, color_attr='color', colors=[0, 1], initial_edge_index=0, return_single_edges=True)[source]

Bi-colors single edges of a half-edge data structure (using a bfs algorithm) where a single edge corresponds to the join of e and e.opp (non-directed). Therefore e.color and e.opp.color always coincide. For this necessarily all interior vertices must have even valency (or 1, counting single edges) and all faces an even amount of adjacent edges. Boundary vertices may have uneven degree, given that there are exactly two consecutive boundary edges that will be assigned with the same color (for example considering a rectangular quad grid with all vertical and horizontal edges colored respectively).

Parameters:
hdsddg.datastructures.halfedge.Surface
color_attrstring (default=’color’)

Name of the edge attribute that is set to distinguish the bi-coloring.

colorsiterable of shape (2,) (default=[0,1])

Values set to the edge attribute ‘color_attr’. For the two families of edges, the attribute value is set to colors[0], colors[1], respectively.

initial_edge_indexint (default=0)

Begins by setting colors[0] to the edge of given index

return_single_edgesbool (default=True)

If True the lists returned will consist of one halfedge for each two incident vertices, otherwise both halfedges will be added to the corresponding list.

Returns:
[e1 , e2][list, list]

List of two lists of half-edges with new attributes. Each list containing half-edges of one color.

ddg.datastructures.halfedge.set.set_valency_attr(hds, cell_type='verts', attr_name='valency')[source]

Sets an attribute that stores the valency of vertices or faces of a halfedge surface, Depending on the given cell type the valency is the number of neighbouring vertices of a vertex, or the number of neighbouring faces of a face.

Parameters:
hdsddg.datastructures.halfedge.Surface
cell_typestring (default=’verts’)

String defining the cells, either ‘verts’ or ‘faces’.

attr_namestr (default=’valency’)

Name of the cell attribute that will store the assigned values.

Returns:
The newly generated attribute.
ddg.datastructures.halfedge.set.set_euclidean_length_attr(hds, co_attr='co', attr_name='length')[source]

Adds a length attribute to all edges of the surface.

It stores the Euclidean length on edges, calculated via vertex-coordinates of incident vertices.

Parameters:
hdsddg.datastructures.halfedge.Surface

The hds where vertices have a coordinate attribute that stores Euclidean coordinates.

co_attrstring (default=’co’)

Name of the vertex attribute that stores the coordinates.

attr_namestring (default=’length’)

Name of the new edge attribute.

Returns:
The newly generated attribute
Raises:
AttributeError:

If the vertices do not have the given coordinate attribute

ddg.datastructures.halfedge.set.set_attr_by_function(hds, function, cell_type='verts', attr_name='attr')[source]

Utility to set attributes of cells of a hds using a manually defined function. The function itself should get a single cell as the first argument. Further arguments can be passed using *args or **kwargs.

Parameters:
hdsddg.datastructures.halfedge.Surface
functionfunction of signature function(cell)

This function will be called for each cell of the corresponding cell type. The return value will be set as the cell’s attribute value.

cell_typestring (default=’verts’)

String defining the cells, either ‘verts’, ‘edges’ or ‘faces’.

attr_namestr (default=’attr’)

Name of the cell attribute that will store the assigned values.

Returns:
The newly generated attribute.
ddg.datastructures.halfedge.set.set_minimal_valency_attr(hds, cell_type='verts', attr_name='has_minimal_valency', attr_values=[True, False])[source]

Sets a cell attribute to true (or any given value) if the cell has minimal valency.

Parameters:
hdsddg.datastructures.halfedge.Surface
cell_typestring (default=’verts’)

String defining the cells, either ‘verts’, ‘edges’ or ‘faces’.

attr_namestr (default=’has_minimal_valency’)

Name of the cell attribute that will store the assigned values.

attr_values:

Values to be stored in the attribute that indicate whether the cell has minimal valency or not.

Returns:
The newly generated attribute