示例#1
0
# ==============================================================================
# Visualize
# ==============================================================================

edges = list(cablenet.edges_where({'is_edge': True}))

stress = [cablenet.stress(key) for key in edges]
cmap = Colormap(stress, 'rgb')
edgecolor = {key: cmap(s) for key, s in zip(edges, stress)}

utilization = [cablenet.stress(key) / cablenet.edge_attribute(key, 'yield') for key in edges]
cmap = Colormap(utilization, 'red')
edgecolor = {key: cmap(u) for key, u in zip(edges, utilization)}

print(min(utilization))
print(max(utilization))

plotter = MeshPlotter(cablenet, figsize=(16, 9))
plotter.draw_vertices(radius=0.05, facecolor={key: (0.0, 0.0, 0.0) for key in cablenet.vertices_where({'is_anchor': True})})
plotter.draw_edges(width=2.0, color=edgecolor, keys=edges)

plotter.save(FILE_P, dpi=150)
# plotter.show()

# ==============================================================================
# Export
# ==============================================================================

cablenet.to_json(FILE_O)
示例#2
0
    mesh = Mesh.from_vertices_and_faces(points, cycles)

    # e1 = network.edge_coordinates(0, 4)
    # e2 = network.edge_coordinates(1, 3)

    # xyz = intersection_line_line_xy(e1, e2)

    # network.delete_edge(0, 4)
    # network.delete_edge(1, 3)

    # x = network.add_node(x=xyz[0], y=xyz[1], z=xyz[2])

    # network.add_edge(x, 0)
    # network.add_edge(x, 1)
    # network.add_edge(x, 3)
    # network.add_edge(x, 4)

    # plotter = NetworkPlotter(network, figsize=(8, 5))
    # plotter.draw_nodes(text='key', radius=0.25)
    # plotter.draw_edges()
    # plotter.show()

    plotter = MeshPlotter(mesh, figsize=(8, 5))
    plotter.draw_vertices(text='key', radius=0.25)
    plotter.draw_edges(
        keys=list(set(mesh.edges()) - set(mesh.edges_on_boundary())))
    plotter.draw_faces(
        text='key',
        keys=list(set(mesh.faces()) - set(mesh.faces_on_boundary())))
    plotter.save('find_cycles.png')
示例#3
0
# ==============================================================================
# Input
# ==============================================================================

mesh = Mesh.from_off(igl.get('tubemesh.off'))
mesh.quads_to_triangles()

# ==============================================================================
# Geodesic distance
# ==============================================================================

source = mesh.get_any_vertex()
distance = igl.trimesh_geodistance(mesh.to_vertices_and_faces(),
                                   source,
                                   method='heat')

# ==============================================================================
# Visualize
# ==============================================================================

cmap = Colormap(distance, 'red')

plotter = MeshPlotter(mesh, figsize=(16, 9), tight=True)
plotter.draw_vertices(radius=0.2,
                      facecolor={
                          key: cmap(distance[index])
                          for index, key in enumerate(mesh.vertices())
                      })
plotter.draw_faces()
plotter.save('examples/geodistance.png')
linit = mesh.edges_attribute('l0')
E = mesh.edges_attribute('E')
radius = mesh.edges_attribute('r')

# make a plotter
# and draw the initial configuration

plotter = MeshPlotter(mesh, figsize=(8, 5), tight=True)
plotter.draw_vertices(facecolor={key: "ff0000" for key in corners})
plotter.draw_edges()

# save the initial configuarion to file
# add multiple copies to simulate a pause at the start of the DR process

imagepath = os.path.join(TEMPDIR, "plot_{}.png".format(0))
plotter.save(imagepath, dpi=150)
IMAGES.append(imagepath)
IMAGES.append(imagepath)
IMAGES.append(imagepath)

# define a callback for plotting every 5th iteration of the DR process


def save_image(k, xyz, crits, args):
    if k == 0:
        return
    if k % 5 != 0:
        return
    for key, attr in mesh.vertices(True):
        attr['x'] = xyz[key][0]
        attr['y'] = xyz[key][1]