Exemplo n.º 1
0
    network.beams = {'beam': {'nodes': list(range(n))}}

    # Plotter

    plotter = NetworkPlotter(network, figsize=(10, 7))

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

    plotter.draw_lines(lines)

    plotter.draw_vertices(
        radius=0.005,
        facecolor={
            key: '#ff0000'
            for key in network.vertices_where({'is_fixed': True})
        })
    plotter.draw_edges()

    # Solver

    drx_numpy(network=network,
              tol=0.01,
              refresh=10,
              factor=30,
import compas

from compas.datastructures import Network
from compas.topology import network_embed_in_plane
from compas.plotters import NetworkPlotter

network = Network.from_obj(compas.get('fink.obj'))

embedding = network.copy()

fix = (1, 12)

if network_embed_in_plane(embedding, fix=fix):

    plotter = NetworkPlotter(embedding)

    plotter.draw_lines([{
        'start': network.vertex_coordinates(u, 'xy'),
        'end': network.vertex_coordinates(v, 'xy'),
        'color': '#cccccc'
    } for u, v in network.edges()])

    plotter.draw_vertices(radius=0.3,
                          text={key: key
                                for key in embedding.vertices()},
                          facecolor={key: '#ff0000'
                                     for key in fix})

    plotter.draw_edges()
    plotter.show()