Произвольный доступ OpenMesh к атрибуту лица

#python #mesh #vertex #openmesh

Вопрос:

Я могу вывести координаты точки в приведенном ниже коде, но не могу получить доступ к атрибуту лица. Я использую неправильный метод?

 import openmesh as om
import numpy as np

mesh = om.TriMesh()

# add a a couple of vertices to the mesh
vh0 = mesh.add_vertex([0, 1, 0])
vh1 = mesh.add_vertex([1, 0, 0])
vh2 = mesh.add_vertex([2, 1, 0])
vh3 = mesh.add_vertex([0,-1, 0])
vh4 = mesh.add_vertex([2,-1, 0])

# add a couple of faces to the mesh
fh0 = mesh.add_face(vh0, vh1, vh2)
fh1 = mesh.add_face(vh1, vh3, vh4)
fh2 = mesh.add_face(vh0, vh3, vh1)

# add another face to the mesh, this time using a list
vh_list = [vh2, vh1, vh4]
fh3 = mesh.add_face(vh_list)

#  0 ==== 2
#  |  0 /|
#  |   / |
#  |2  1 3|
#  | /   |
#  |/  1 |
#  3 ==== 4

# get the point with vertex handle vh0
point = mesh.point(vh0)

# get all points of the mesh
point_array = mesh.points()


for x in mesh.vertices():
    print(x) 
    print(x.idx())
    print(mesh.point(x))

    
for x in mesh.faces():
    print(x) 
    print(x.idx())
    #print(mesh.face(x))    <== THIS LINE THROWS ERROR
 

Ответ №1:

 face_array = mesh.face_vertex_indices()
 

Это тот метод, который работает.