HalfEdge

class compas.datastructures.HalfEdge(name=None, default_vertex_attributes=None, default_edge_attributes=None, default_face_attributes=None)[source]

Bases: compas.datastructures.datastructure.Datastructure

Base half-edge data structure for representing the topology of open oor closed surface meshes.

Parameters
  • name (str, optional) – The name of the graph. Defaults to “Graph”.

  • default_vertex_attributes (dict, optional) – Default values for vertex attributes.

  • default_edge_attributes (dict, optional) – Default values for edge attributes.

  • default_face_attributes (dict, optional) – Default values for face attributes.

Attributes
  • attributes (dict) – Named attributes related to the data structure as a whole.

  • default_vertex_attributes (dict) – Named attributes and default values of the vertices of the data structure.

  • default_edge_attributes (dict) – Named attributes and default values of the edges of the data structure.

  • default_face_attributes (dict) – Named attributes and default values of the faces of the data structure.

  • name (str) – Name of the data structure. Defaults to the value of self.__class__.__name__.

  • data (dict) – The data representation of the data structure.

  • adjacency (dict) – Alias for self.halfedge.

    Deprecated since version 0.17.0.

Methods

add_face(vertices[, fkey, attr_dict])

Add a face to the mesh object.

add_vertex([key, attr_dict])

Add a vertex to the mesh object.

clear()

Clear all the mesh data.

copy([cls])

Make an independent copy of the data object.

cull_vertices()

Remove all unused vertices from the mesh object.

delete_face(fkey)

Delete a face from the mesh object.

delete_vertex(key)

Delete a vertex from the mesh and everything that is attached to it.

edge_attribute(edge, name[, value])

Get or set an attribute of an edge.

edge_attributes(edge[, names, values])

Get or set multiple attributes of an edge.

edge_faces(u, v)

Find the two faces adjacent to an edge.

edge_loop(edge)

Find all edges on the same loop as a given edge.

edge_sample([size])

A random sample of the edges.

edge_strip(edge)

Find all edges on the same strip as a given edge.

edges([data])

Iterate over the edges of the mesh.

edges_attribute(name[, value, keys])

Get or set an attribute of multiple edges.

edges_attributes([names, values, keys])

Get or set multiple attributes of multiple edges.

edges_where(conditions[, data])

Get edges for which a certain condition or set of conditions is true.

edges_where_predicate(predicate[, data])

Get edges for which a certain condition or set of conditions is true using a lambda function.

euler()

Calculate the Euler characteristic.

face_adjacency_halfedge(f1, f2)

Find one half-edge over which two faces are adjacent.

face_adjacency_vertices(f1, f2)

Find all vertices over which two faces are adjacent.

face_attribute(key, name[, value])

Get or set an attribute of a face.

face_attributes(key[, names, values])

Get or set multiple attributes of a face.

face_corners(fkey)

Return triplets of face vertices forming the corners of the face.

face_degree(fkey)

Count the neighbors of a face.

face_halfedges(fkey)

The halfedges of a face.

face_max_degree()

Compute the maximum degree of all faces.

face_min_degree()

Compute the minimum degree of all faces.

face_neighborhood(key[, ring])

Return the faces in the neighborhood of a face.

face_neighbors(fkey)

Return the neighbors of a face across its edges.

face_sample([size])

A random sample of the faces.

face_vertex_after(fkey, key[, n])

Return the n-th vertex after the specified vertex in a specific face.

face_vertex_ancestor(fkey, key[, n])

Return the n-th vertex before the specified vertex in a specific face.

face_vertex_before(fkey, key[, n])

Return the n-th vertex before the specified vertex in a specific face.

face_vertex_descendant(fkey, key[, n])

Return the n-th vertex after the specified vertex in a specific face.

face_vertices(fkey)

The vertices of a face.

faces([data])

Iterate over the faces of the mesh.

faces_attribute(name[, value, keys])

Get or set an attribute of multiple faces.

faces_attributes([names, values, keys])

Get or set multiple attributes of multiple faces.

faces_where(conditions[, data])

Get faces for which a certain condition or set of conditions is true.

faces_where_predicate(predicate[, data])

Get faces for which a certain condition or set of conditions is true using a lambda function.

from_data(data)

Construct an object of this type from the provided data.

from_json(filepath)

Construct an object from serialized data contained in a JSON file.

from_jsonstring(string)

Construct an object from serialized data contained in a JSON string.

genus()

Calculate the genus.

get_any_face()

Get the identifier of a random face.

get_any_face_vertex(fkey)

Get the identifier of a random vertex of a specific face.

get_any_vertex()

Get the identifier of a random vertex.

get_any_vertices(n[, exclude_leaves])

Get a list of identifiers of a random set of n vertices.

halfedge_after(u, v)

halfedge_before(u, v)

halfedge_face(u, v)

Find the face corresponding to a halfedge.

halfedge_strip(edge)

Find all edges on the same strip as a given halfedge.

has_edge(key)

Verify that the mesh contains a specific edge.

has_face(fkey)

Verify that a face is part of the mesh.

has_halfedge(key)

Verify that a halfedge is part of the mesh.

has_vertex(key)

Verify that a vertex is in the mesh.

index_key()

Returns a dictionary that maps the indices of a vertex list to keys in a vertex dictionary.

index_vertex()

Returns a dictionary that maps the indices of a vertex list to keys in a vertex dictionary.

is_closed()

Verify that the mesh is closed.

is_edge_on_boundary(u, v)

Verify that an edge is on the boundary.

is_empty()

Verify that the mesh is empty.

is_face_on_boundary(key)

Verify that a face is on a boundary.

is_manifold()

Verify that the mesh is manifold.

is_orientable()

Verify that the mesh is orientable.

is_quadmesh()

Verify that the mesh consists of only quads.

is_regular()

Verify that the mesh is regular.

is_trimesh()

Verify that the mesh consists of only triangles.

is_valid()

Verify that the mesh is valid.

is_vertex_connected(key)

Verify that a vertex is connected.

is_vertex_on_boundary(key)

Verify that a vertex is on a boundary.

key_index()

Returns a dictionary that maps vertex dictionary keys to the corresponding index in a vertex list or array.

number_of_edges()

Count the number of edges in the mesh.

number_of_faces()

Count the number of faces in the mesh.

number_of_vertices()

Count the number of vertices in the mesh.

remove_unused_vertices()

Remove all unused vertices from the mesh object.

summary()

Print a summary of the mesh.

to_data()

Convert an object to its native data representation.

to_json(filepath[, pretty])

Serialize the data representation of an object to a JSON file.

to_jsonstring([pretty])

Serialize the data representation of an object to a JSON string.

unset_edge_attribute(edge, name)

Unset the attribute of an edge.

unset_face_attribute(key, name)

Unset the attribute of a face.

unset_vertex_attribute(key, name)

Unset the attribute of a vertex.

update_default_edge_attributes([attr_dict])

Update the default edge attributes.

update_default_face_attributes([attr_dict])

Update the default face attributes.

update_default_vertex_attributes([attr_dict])

Update the default vertex attributes.

validate_data()

Validate the object's data against its data schema (self.DATASCHEMA).

validate_json()

Validate the object's data against its json schema (self.JSONSCHEMA).

vertex_attribute(key, name[, value])

Get or set an attribute of a vertex.

vertex_attributes(key[, names, values])

Get or set multiple attributes of a vertex.

vertex_degree(key)

Count the neighbors of a vertex.

vertex_edges(vertex)

vertex_faces(key[, ordered, include_none])

The faces connected to a vertex.

vertex_index()

Returns a dictionary that maps vertex dictionary keys to the corresponding index in a vertex list or array.

vertex_max_degree()

Compute the maximum degree of all vertices.

vertex_min_degree()

Compute the minimum degree of all vertices.

vertex_neighborhood(key[, ring])

Return the vertices in the neighborhood of a vertex.

vertex_neighbors(key[, ordered])

Return the neighbors of a vertex.

vertex_sample([size])

A random sample of the vertices.

vertices([data])

Iterate over the vertices of the mesh.

vertices_attribute(name[, value, keys])

Get or set an attribute of multiple vertices.

vertices_attributes([names, values, keys])

Get or set multiple attributes of multiple vertices.

vertices_where(conditions[, data])

Get vertices for which a certain condition or set of conditions is true.

vertices_where_predicate(predicate[, data])

Get vertices for which a certain condition or set of conditions is true using a lambda function.