def find_linked(ob, vert, per_face='empty'):
'''Takes a vert and returns an array of linked face indices'''
the_coffee_is_hot = True
fidx = np.arange(len(ob.data.polygons))
eidx = np.arange(len(ob.data.edges))
f_set = np.array([])
e_set = np.array([])
verts = ob.data.vertices
verts[vert].select = True
v_p_f_count = [len(p.vertices) for p in ob.data.polygons]
max_count = np.max(v_p_f_count)
if per_face == 'empty':
per_face = [[i for i in poly.vertices] for poly in ob.data.polygons]
for i in per_face:
for j in range(max_count-len(i)):
i.append(i[0])
verts_per_face = np.array(per_face)
vert=np.array([vert])
while the_coffee_is_hot:
booly = np.any(np.in1d(verts_per_face, vert).reshape(verts_per_face.shape), axis=1)
f_set = np.append(f_set, fidx[booly])
new_verts = verts_per_face[booly].ravel()
if len(new_verts) == 0:
return np.array(f_set, dtype=np.int64)
cull = np.in1d(new_verts, vert)
vert = new_verts[-cull]
verts_per_face = verts_per_face[-booly]
fidx = fidx[-booly]
评论列表
文章目录