CellNetwork

class compas.datastructures.CellNetwork[source]

Bases: Datastructure

Geometric implementation of a data structure for a collection of mixed topologic entities such as cells, faces, edges and nodes.

Parameters:
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.

default_cell_attributes: dict, optional

Default values for cell attributes.

namestr, optional

The name of the cell network.

**kwargsdict, optional

Additional keyword arguments, which are stored in the attributes dict.

Examples

>>> from compas.datastructures import CellNetwork
>>> cell_network = CellNetwork()
>>> vertices = [(0, 0, 0), (0, 1, 0), (1, 1, 0), (1, 0, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1)]
>>> faces = [[0, 1, 2, 3], [0, 3, 5, 4],[3, 2, 6, 5], [2, 1, 7, 6],[1, 0, 4, 7],[4, 5, 6, 7]]
>>> cells = [[0, 1, 2, 3, 4, 5]]
>>> [network.add_vertex(x=x, y=y, z=z) for x, y, z in vertices]
>>> [cell_network.add_face(fverts) for fverts in faces]
>>> [cell_network.add_cell(fkeys) for fkeys in cells]
>>> cell_network
Attributes:
default_vertex_attributesdict[str, Any]

Default attributes of the vertices.

default_edge_attributes: dict[str, Any]

Default values for edge attributes.

default_face_attributes: dict[str, Any]

Default values for face attributes.

default_cell_attributes: dict[str, Any]

Default values for cell attributes.

Methods

Constructors

from_json

Construct an object of this type from a JSON file.

Conversions

cell_to_mesh

Construct a mesh object from from a cell of a cell network.

cell_to_vertices_and_faces

Return the vertices and faces of a cell.

edges_to_graph

Convert the edges of the cell network to a graph.

faces_to_mesh

Construct a mesh from a list of faces.

to_json

Convert an object to its native data representation and save it to a JSON file.

Builders and Modifiers

add_cell

Add a cell to the cell network object.

add_edge

Add an edge and specify its attributes.

add_face

Add a face to the cell network.

add_vertex

Add a vertex and specify its attributes.

General

aabb

Calculate the axis aligned bounding box of the mesh.

centroid

Compute the centroid of the cell network.

is_valid

Verify that the cell network is valid.

number_of_cells

Count the number of faces in the cell network.

number_of_edges

Count the number of edges in the cell network.

number_of_faces

Count the number of faces in the cell network.

number_of_vertices

Count the number of vertices in the cell network.

Vertex Accessors

vertex_sample

Get the identifiers of a set of random vertices.

vertices

Iterate over the vertices of the cell network.

vertices_where

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

vertices_where_predicate

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

Vertex Attributes

vertex_attribute

Get or set an attribute of a vertex.

vertex_attributes

Get or set multiple attributes of a vertex.

vertices_attribute

Get or set an attribute of multiple vertices.

vertices_attributes

Get or set multiple attributes of multiple vertices.

update_default_vertex_attributes

Update the default vertex attributes.

unset_vertex_attribute

Unset the attribute of a vertex.

Vertex Topology

has_vertex

Verify that a vertex is in the cell network.

vertex_cells

Return all cells connected to a vertex.

vertex_degree

Count the neighbors of a vertex.

vertex_faces

Return all faces connected to a vertex.

vertex_max_degree

Compute the maximum degree of all vertices.

vertex_min_degree

Compute the minimum degree of all vertices.

vertex_neighbors

Return the vertex neighbors of a vertex.

vertex_neighborhood

Return the vertices in the neighborhood of a vertex.

Vertex Geometry

vertex_coordinates

Return the coordinates of a vertex.

vertex_point

Return the point representation of a vertex.

vertices_coordinates

Return the coordinates of multiple vertices.

vertices_points

Returns the point representation of multiple vertices.

Edge Accessors

edge_sample

Get the identifiers of a set of random edges.

edges

Iterate over the edges of the cell network.

edges_where

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

edges_where_predicate

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

Edge Attributes

edge_attribute

Get or set an attribute of an edge.

edge_attributes

Get or set multiple attributes of an edge.

edges_attribute

Get or set an attribute of multiple edges.

edges_attributes

Get or set multiple attributes of multiple edges.

update_default_edge_attributes

Update the default edge attributes.

unset_edge_attribute

Unset the attribute of an edge.

Edge Topology

edge_cells

Ordered cells around edge (u, v).

edge_faces

Return the faces adjacent to an edge.

has_edge

Verify that the cell network contains a directed edge (u, v).

Edge Geometry

edge_direction

Return the direction vector of an edge.

edge_end

Return the end point of an edge.

edge_length

Return the length of an edge.

edge_line

Return the line representation of an edge.

edge_vector

Return the vector of an edge.

edge_start

Return the start point of an edge.

Face Accessors

face_sample

Get the identifiers of a set of random faces.

faces

Iterate over the halffaces of the cell network and yield faces.

faces_on_boundaries

Find the faces that are on the boundary.

faces_where

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

faces_where_predicate

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

Face Attributes

face_attribute

Get or set an attribute of a face.

face_attributes

Get or set multiple attributes of a face.

faces_attribute

Get or set an attribute of multiple faces.

faces_attributes

Get or set multiple attributes of multiple faces.

update_default_face_attributes

Update the default face attributes.

unset_face_attribute

Unset the attribute of a face.

Face Topology

face_cells

Return the cells connected to a face.

face_edges

The edges of a face.

face_vertices

The vertices of a face.

faces_on_boundaries

Find the faces that are on the boundary.

is_face_on_boundary

Verify that a face is on the boundary.

isolated_faces

Find the faces that are not part of a cell.

Face Geometry

face_area

Compute the oriented area of a face.

face_center

Compute the point at the center of mass of a face.

face_centroid

Compute the point at the centroid of a face.

face_coordinates

Compute the coordinates of the vertices of a face.

face_normal

Compute the oriented normal of a face.

face_points

Compute the points of the vertices of a face.

face_polygon

Compute the polygon of a face.

Cell Accessors

cell_sample

Get the identifiers of a set of random cells.

cells

Iterate over the cells of the volmesh.

cells_on_boundaries

Find the cells on the boundary.

cells_where

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

cells_where_predicate

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

Cell Attributes

cell_attribute

Get or set an attribute of a cell.

cell_attributes

Get or set multiple attributes of a cell.

cells_attribute

Get or set an attribute of multiple cells.

cells_attributes

Get or set multiple attributes of multiple cells.

update_default_cell_attributes

Update the default cell attributes.

unset_cell_attribute

Unset the attribute of a cell.

Cell Topology

cell_edges

Return all edges of a cell.

cell_face_halfedges

The halfedges of a face of a cell.

cell_face_neighbors

Find the faces adjacent to a given face of a cell.

cell_face_vertices

The vertices of a face of a cell.

cell_faces

The faces of a cell.

cell_halfedge_face

Find the face corresponding to a specific halfedge of a cell.

cell_halfedges

The halfedges of a cell.

cell_vertex_faces

Ordered faces connected to a vertex of a cell.

cell_vertex_neighbors

Ordered vertex neighbors of a vertex of a cell.

cell_vertices

The vertices of a cell.

cells_on_boundaries

Find the cells on the boundary.

is_cell_on_boundary

Verify that a cell is on the boundary.

Cell Geometry

cell_center

Compute the point at the center of mass of a cell.

cell_centroid

Compute the point at the centroid of a cell.

cell_points

Compute the points of the vertices of a cell.

cell_polyhedron

Construct a polyhedron from the vertices and faces of a cell.

Paths

Matrices

Mappings

index_vertex

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

vertex_index

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

Utilities

clear

Clear all the volmesh data.

copy

Make an independent copy of the data object.

Other