Esempio n. 1
0
    linit = mesh.get_edges_attribute('linit')
    E = mesh.get_edges_attribute('E')
    radius = mesh.get_edges_attribute('radius')

    lines = []
    for u, v in mesh.edges():
        lines.append({
            'start': mesh.vertex_coordinates(u, 'xy'),
            'end': mesh.vertex_coordinates(v, 'xy'),
            'color': '#cccccc',
            'width': 0.5
        })

    plotter = MeshPlotter(mesh, figsize=(10, 7), fontsize=6)

    plotter.draw_lines(lines)
    plotter.draw_vertices(facecolor={key: '#000000' for key in mesh.vertices_where({'is_fixed': True})})
    plotter.draw_edges()

    plotter.update(pause=1.0)

    def callback(k, xyz, crits, args):
        print(k)

        plotter.update_vertices()
        plotter.update_edges()
        plotter.update(pause=0.001)

        for key, attr in mesh.vertices(True):
            index = k_i[key]
            attr['x'] = xyz[index, 0]
Esempio n. 2
0
while len(st_faces) > 0:
    next_pt = [i for i in mesh.face_adjacency_vertices(st_faces[0], st_faces[1]) if i not in st_pt] # vertices which are touched by the two next faces; next vertex is the one which has not already been stored in the path
    st_pt.append(next_pt[0]) # add next vertex to the path
    st_faces = [i for i in mesh.vertex_faces(next_pt[0]) if i not in faces_old] # faces around next vertex; the next two faces are the ones which are not already in the path
    faces_old.extend(st_faces) # add next faces to the path

path = []

# print(mesh.vertex_coordinates(st_pt[0]))
arrow = []
for i in range(len(st_pt)-1):
    path.append({
        'start': mesh.vertex_coordinates(st_pt[i]),
        'end': mesh.vertex_coordinates(st_pt[i+1]),
        'width': 2.0,
        'color': (255,0,0)
    })
    arrow.extend(arrowhead(mesh.vertex_coordinates(st_pt[i]), mesh.vertex_coordinates(st_pt[i+1])))

print(st_pt)

plotter = MeshPlotter(mesh, figsize=(16, 10))
plotter.draw_vertices(
    text={key: key for key in mesh.vertices()},
    radius=0.2,
    facecolor=(255, 255, 255))
plotter.draw_edges()
plotter.draw_lines(path)
plotter.draw_lines(arrow)
plotter.show()