MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / mesh_to_dual_graph

Function mesh_to_dual_graph

python/pymesh/meshutils/mesh_to_graph.py:32–53  ·  view source on GitHub ↗

Convert a mesh into a dual graph :math:`(V, E)`, where :math:`V` represents the mesh faces, and :math:`E` represent the dual edges. Args: mesh (:class:`Mesh`): Input mesh. Returns: The graph :math:`(V, E)`.

(mesh)

Source from the content-addressed store, hash-verified

30 return vertices, np.array(edges, dtype=int)
31
32def mesh_to_dual_graph(mesh):
33 """
34 Convert a mesh into a dual graph :math:`(V, E)`, where :math:`V` represents
35 the mesh faces, and :math:`E` represent the dual edges.
36
37 Args:
38 mesh (:class:`Mesh`): Input mesh.
39
40 Returns:
41 The graph :math:`(V, E)`.
42 """
43
44 mesh.enable_connectivity()
45 mesh.add_attribute("face_centroid")
46 vertices = mesh.get_face_attribute("face_centroid")
47 edges = []
48 for fi in range(mesh.num_faces):
49 adj_faces = mesh.get_face_adjacent_faces(fi)
50 for fj in adj_faces:
51 if fj > fi:
52 edges.append((fi, fj))
53 return vertices, np.array(edges, dtype=int)

Callers

nothing calls this directly

Calls 4

get_face_attributeMethod · 0.80
enable_connectivityMethod · 0.45
add_attributeMethod · 0.45

Tested by

no test coverage detected