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.
- 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.
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]] >>> for x, y, z in vertices: ... vertex = cell_network.add_vertex(x=x, y=y, z=z) >>> for face_vertices in faces: ... face = cell_network.add_face(face_vertices) >>> for cell_faces in cells: ... cell = cell_network.add_cell(cell_faces) >>> print(cell_network) <CellNetwork with 8 vertices, 6 faces, 1 cells, 12 edges>
Methods
Constructors
Construct an object of this type from a JSON file. |
Conversions
Construct a mesh object from from a cell of a cell network. |
|
Return the vertices and faces of a cell. |
|
Convert the edges of the cell network to a graph. |
|
Construct a mesh from a list of faces. |
|
Convert an object to its native data representation and save it to a JSON file. |
Builders and Modifiers
Add a cell to the cell network object. |
|
Add an edge and specify its attributes. |
|
Add a face to the cell network. |
|
Add a vertex and specify its attributes. |
General
Calculate the axis aligned bounding box of the mesh. |
|
Compute the centroid of the cell network. |
|
Verify that the cell network is valid. |
|
Count the number of faces in the cell network. |
|
Count the number of edges in the cell network. |
|
Count the number of faces in the cell network. |
|
Count the number of vertices in the cell network. |
Vertex Accessors
Get the identifiers of a set of random vertices. |
|
Iterate over the vertices of the cell network. |
|
Get vertices for which a certain condition or set of conditions is true. |
|
Get vertices for which a certain condition or set of conditions is true using a lambda function. |
Vertex Attributes
Get or set an attribute of a vertex. |
|
Get or set multiple attributes of a vertex. |
|
Get or set an attribute of multiple vertices. |
|
Get or set multiple attributes of multiple vertices. |
|
Update the default vertex attributes. |
|
Unset the attribute of a vertex. |
Vertex Topology
Verify that a vertex is in the cell network. |
|
Return all cells connected to a vertex. |
|
Count the neighbors of a vertex. |
|
Return all faces connected to a vertex. |
|
Compute the maximum degree of all vertices. |
|
Compute the minimum degree of all vertices. |
|
Return the vertex neighbors of a vertex. |
|
Return the vertices in the neighborhood of a vertex. |
Vertex Geometry
Return the coordinates of a vertex. |
|
Return the point representation of a vertex. |
|
Return the coordinates of multiple vertices. |
|
Returns the point representation of multiple vertices. |
Edge Accessors
Get the identifiers of a set of random edges. |
|
Iterate over the edges of the cell network. |
|
Get edges for which a certain condition or set of conditions is true. |
|
Get edges for which a certain condition or set of conditions is true using a lambda function. |
Edge Attributes
Get or set an attribute of an edge. |
|
Get or set multiple attributes of an edge. |
|
Get or set an attribute of multiple edges. |
|
Get or set multiple attributes of multiple edges. |
|
Update the default edge attributes. |
|
Unset the attribute of an edge. |
Edge Topology
Ordered cells around edge (u, v). |
|
Return the faces adjacent to an edge. |
|
Verify that the cell network contains a directed edge (u, v). |
Edge Geometry
Return the direction vector of an edge. |
|
Return the end point of an edge. |
|
Return the length of an edge. |
|
Return the line representation of an edge. |
|
Return the vector of an edge. |
|
Return the start point of an edge. |
Face Accessors
Get the identifiers of a set of random faces. |
|
Iterate over the halffaces of the cell network and yield faces. |
|
Find the faces that are on the boundary. |
|
Get faces for which a certain condition or set of conditions is true. |
|
Get faces for which a certain condition or set of conditions is true using a lambda function. |
Face Attributes
Get or set an attribute of a face. |
|
Get or set multiple attributes of a face. |
|
Get or set an attribute of multiple faces. |
|
Get or set multiple attributes of multiple faces. |
|
Update the default face attributes. |
|
Unset the attribute of a face. |
Face Topology
Return the cells connected to a face. |
|
The edges of a face. |
|
The vertices of a face. |
|
Find the faces that are on the boundary. |
|
Verify that a face is on the boundary. |
Face Geometry
Compute the oriented area of a face. |
|
Compute the point at the center of mass of a face. |
|
Compute the point at the centroid of a face. |
|
Compute the coordinates of the vertices of a face. |
|
Compute the oriented normal of a face. |
|
Compute the points of the vertices of a face. |
|
Compute the polygon of a face. |
Cell Accessors
Get the identifiers of a set of random cells. |
|
Iterate over the cells of the volmesh. |
|
Find the cells on the boundary. |
|
Get cells for which a certain condition or set of conditions is true. |
|
Get cells for which a certain condition or set of conditions is true using a lambda function. |
Cell Attributes
Get or set an attribute of a cell. |
|
Get or set multiple attributes of a cell. |
|
Get or set an attribute of multiple cells. |
|
Get or set multiple attributes of multiple cells. |
|
Update the default cell attributes. |
|
Unset the attribute of a cell. |
Cell Topology
Return all edges of a cell. |
|
The halfedges of a face of a cell. |
|
Find the faces adjacent to a given face of a cell. |
|
The vertices of a face of a cell. |
|
The faces of a cell. |
|
Find the face corresponding to a specific halfedge of a cell. |
|
The halfedges of a cell. |
|
Ordered faces connected to a vertex of a cell. |
|
Ordered vertex neighbors of a vertex of a cell. |
|
The vertices of a cell. |
|
Find the cells on the boundary. |
|
Verify that a cell is on the boundary. |
Cell Geometry
Compute the point at the center of mass of a cell. |
|
Compute the point at the centroid of a cell. |
|
Compute the points of the vertices of a cell. |
|
Construct a polyhedron from the vertices and faces of a cell. |
Paths
Matrices
Mappings
Returns a dictionary that maps the indices of a vertex list to vertex identifiers. |
|
Returns a dictionary that maps vertex identifiers to the corresponding index in a vertex list or array. |
Utilities
Clear all the volmesh data. |
|
Make an independent copy of the data object. |