def compute_edge_types(machina, edge_index):
"""Classify the internal edges by type, and find the singular graph.
The edge type is determined by concatenating the matchings around the edges one-ring."""
# For each internal edge of the tetrahedral mesh.
for ei in edge_index:
try:
one_ring = machina.one_rings[ei]
except KeyError:
continue # Not an internal edge.
# Concatenate the matchings around the edge to find its type.
edge_type = np.identity(3)
for fi in one_ring['faces']:
matching = []
# Recall that in the one-ring, if 'fi' is negative, it is
# a 't-s' pair, as opposed to a 's-t' pair.
# If pair order is reversed, invert/transpose rotation matrix.
# Use copysign to distinguish +0 from -0.
if np.copysign(1, fi) > 0:
matching = chiral_symmetries[machina.matchings[fi]]
else:
matching = chiral_symmetries[machina.matchings[-fi]].T
# Concatenate transforms
edge_type = np.dot(edge_type, matching)
# Locate singular (not identity) and improper (not restricted) edges.
is_singular, is_improper = True, True
for si, restricted_type in enumerate(chiral_symmetries[0:9]):
if np.allclose(edge_type, restricted_type):
if si == 0 : is_singular = False
is_improper = False
break
# Classify as proper(0), singular(1), improper (2)
if is_singular: machina.edge_types[ei] = 1
if is_improper: machina.edge_types[ei] = 2
评论列表
文章目录