EdgeList = list[np.ndarray] # list of 2xdim arrays
def get_cuts(N: Net) -> EdgeList:
return np.concatenate([N.tope.meta[2][i]["cuts"] for i in range(len(N.
↪facets))])
def get_edges(N: Net) -> EdgeList: # apply to unfolded Net edges = []
for i, vertices in N.facets.items():
facet_template = N.tope.get_face(i) # has correct indices edges.extend((vertices[list(e)] for e in facet_template.faces[1]))
return edges
import itertools
Net2d = None # new format of Net
def iter_edges(N: Net2d) -> Iterable[np.ndarray[2,2]]: # apply to unfolded 2d␣ ↪Net
return N.iter_faces_as_vertices(dim=1)
FacetLabels = list[tuple[str, np.ndarray]] # label, position
def get_facet_labels(N: Net) -> FacetLabels: labels = []
for i, vertices in N.facets.items(): labels.append((N.tope.meta[N.tope.dim-1][i]["index"], vertices.
↪mean(axis=0))) return labels
def iter_facet_labels(N: Net2d, key: str) -> Iterable[str]:
return zip(N.iter_meta(dim=2, key="index"), map(N.cells.values(), lambda x:␣
↪x.vertices.mean(axis=0)))