示例#1
0
trimesh_remesh(delaunay, 1.0, allow_boundary_split=True)

points = [delaunay.vertex_coordinates(key) for key in delaunay.vertices()]
faces = delaunay_from_points(points)
delaunay = Mesh.from_vertices_and_faces(points, faces)

voronoi = voronoi_from_delaunay(delaunay)

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

plotter = MeshPlotter(delaunay, figsize=(10, 6))

plotter.draw_lines(lines)

plotter.draw_vertices(radius=0.075,
                      facecolor={
                          key: '#0092d2'
                          for key in delaunay.vertices()
                          if key not in delaunay.vertices_on_boundary()
                      })

plotter.draw_edges(color='#cccccc')

plotter.show()
示例#2
0
def plot_form(form, radius=0.1, fix_width=False, max_width=10, simple=False):
    """ Extended load-path plotting of a FormDiagram

    Parameters
    ----------
    form : obj
        FormDiagram to plot.
    radius : float
        Radius of vertex markers.
    fix_width : bool
        Fix edge widths as constant.
    max_width : float
        Maximum edge width.
    simple : bool
        Simple red and blue colour plotting.

    Returns
    -------
    obj
        Plotter object.

    """

    q = [attr['q'] for u, v, attr in form.edges(True)]
    qmax = max(abs(array(q)))
    lines = []

    for u, v in form.edges():
        qi = form.get_edge_attribute((u, v), 'q')

        if simple:
            if qi > 0:
                colour = ['ff', '00', '00']
            elif qi < 0:
                colour = ['00', '00', 'ff']
            else:
                colour = ['aa', 'aa', 'aa']

        else:
            colour = ['00', '00', '00']
            if qi > 0:
                colour[0] = 'ff'
            if form.get_edge_attribute((u, v), 'is_symmetry'):
                colour[1] = 'cc'
            if form.get_edge_attribute((u, v), 'is_ind'):
                colour[2] = 'ff'

        width = max_width if fix_width else (qi / qmax) * max_width

        lines.append({
            'start': form.vertex_coordinates(u),
            'end': form.vertex_coordinates(v),
            'color': ''.join(colour),
            'width': width,
        })

    plotter = MeshPlotter(form, figsize=(10, 10))
    if radius:
        plotter.draw_vertices(facecolor={
            i: '#aaaaaa'
            for i in form.vertices_where({'is_fixed': True})
        },
                              radius=radius)
    plotter.draw_lines(lines)

    return plotter