In COMPAS meshes are presented using a half-edge data structure. In a half-edge data structure, each edge is composed of two half-edges with opposite orientation. Each half-edge is part of exactly one face, unless it is on the boundary. An edge is thus incident to at least one face and at most to two. The half-edges of a face form a continuous cycle, connecting the vertices of the face in a specific order forming a closed n-sided polygon. The ordering of the vertices determines the direction of its normal.
In COMPAS a network is a “directed edge graph” that encodes the relationships between “nodes” with “edges”. Networks can, for example, be used to keep track of the relationships between the individual elements of a Discrete Element Assembly, or to represent the elements of a cable net.
>>> import os
>>> import compas
>>> from compas.datastructures import Mesh
>>> HERE = os.path.dirname(__file__)
>>> DATA = os.path.join(HERE, 'data')
>>> FILE = os.path.join(DATA, 'faces.obj')
>>> mesh = Mesh.from_obj(FILE)
>>> print(mesh.summary())
>>>
Mesh summary
============
- vertices: 36
- edges: 60
- faces: 25
>>> import os
>>> import compas
>>> from compas.datastructures import Network
>>> HERE = os.path.dirname(__file__)
>>> DATA = os.path.join(HERE, 'data')
>>> FILE = os.path.join(DATA, 'lines.obj')
>>> network = Network.from_obj(FILE)
>>> print(network.summary())
>>>
Graph summary
============
- nodes: 32
- edges: 43