Convert a mesh into a graph :math:`(V, E)`, where :math:`V` represents the mesh vertices, and :math:`E` represent the edges. Args: mesh (:class:`Mesh`): Input mesh. Returns: The graph :math:`(V, E)`.
(mesh)
| 2 | from ..meshio import form_mesh |
| 3 | |
| 4 | def mesh_to_graph(mesh): |
| 5 | """ |
| 6 | Convert a mesh into a graph :math:`(V, E)`, where :math:`V` represents the |
| 7 | mesh vertices, and :math:`E` represent the edges. |
| 8 | |
| 9 | Args: |
| 10 | mesh (:class:`Mesh`): Input mesh. |
| 11 | |
| 12 | Returns: |
| 13 | The graph :math:`(V, E)`. |
| 14 | """ |
| 15 | |
| 16 | if mesh.num_voxels > 0: |
| 17 | # Avoid extracting voxel edges. |
| 18 | vertices = mesh.vertices |
| 19 | faces = mesh.faces |
| 20 | mesh = form_mesh(vertices, faces) |
| 21 | |
| 22 | mesh.enable_connectivity() |
| 23 | vertices = mesh.vertices |
| 24 | edges = [] |
| 25 | for vi in range(mesh.num_vertices): |
| 26 | adj_vertices = mesh.get_vertex_adjacent_vertices(vi) |
| 27 | for vj in adj_vertices: |
| 28 | if vj > vi: |
| 29 | edges.append((vi, vj)) |
| 30 | return vertices, np.array(edges, dtype=int) |
| 31 | |
| 32 | def mesh_to_dual_graph(mesh): |
| 33 | """ |
nothing calls this directly
no test coverage detected