예제 #1
0
    loads = mesh.get_vertices_attributes(('px', 'py', 'pz'))
    q     = mesh.get_edges_attribute('q')
    fixed = mesh.vertices_where({'is_anchor': True})
    fixed = [k_i[k] for k in fixed]
    edges = [(k_i[u], k_i[v]) for u, v in mesh.edges()]

    # compute equilibrium
    # update the mesh geometry

    xyz, q, f, l, r = fd_numpy(xyz, edges, fixed, q, loads)

    for key, attr in mesh.vertices(True):
        index = k_i[key]
        attr['x'] = xyz[index, 0]
        attr['y'] = xyz[index, 1]
        attr['z'] = xyz[index, 2]

    # visualisae the result
    # color the vertices according to their elevation

    plotter = MeshPlotter(mesh)

    zmax = max(mesh.get_vertices_attribute('z'))

    plotter.draw_vertices(
        facecolor={key: i_to_black(attr['z'] / zmax) for key, attr in mesh.vertices(True)}
    )
    plotter.draw_faces()
    plotter.draw_edges()
    plotter.show()
예제 #2
0
    q = mesh.get_edges_attribute('q')
    fixed = mesh.vertices_where({'is_anchor': True})
    fixed = [k_i[k] for k in fixed]
    edges = [(k_i[u], k_i[v]) for u, v in mesh.edges()]

    # compute equilibrium
    # update the mesh geometry

    xyz, q, f, l, r = fd_numpy(xyz, edges, fixed, q, loads)

    for key, attr in mesh.vertices(True):
        index = k_i[key]
        attr['x'] = xyz[index, 0]
        attr['y'] = xyz[index, 1]
        attr['z'] = xyz[index, 2]

    # visualisae the result
    # color the vertices according to their elevation

    plotter = MeshPlotter(mesh)

    zmax = max(mesh.get_vertices_attribute('z'))

    plotter.draw_vertices(facecolor={
        key: i_to_black(attr['z'] / zmax)
        for key, attr in mesh.vertices(True)
    })
    plotter.draw_faces()
    plotter.draw_edges()
    plotter.show()
scale = vertical_from_zmax(form, 3.0)

# ==============================================================================
# visualise
# ==============================================================================

z = form.vertices_attribute('z')
zmin = min(z)
zmax = max(z)

plotter = MeshPlotter(form, figsize=(12, 8), tight=True)

plotter.draw_vertices(
    keys=list(form.vertices_where({'is_external': False})),
    facecolor={
        key: i_to_black((attr['z'] - zmin) / (zmax - zmin))
        for key, attr in form.vertices_where({'is_external': False}, True)
    },
    radius=0.1)

plotter.draw_edges(
    keys=list(form.edges_where({'is_edge': True})),
    color={key: '#00ff00'
           for key in form.edges_where({'is_external': True})},
    width={key: 2.0
           for key in form.edges_where({'is_external': True})})

plotter.draw_faces(keys=list(form.faces_where({'is_loaded': True})))

plotter.show()
예제 #4
0
assembly = Assembly.from_json(PATH)

# visualise

R = Rotation.from_axis_and_angle([1.0, 0, 0], -pi / 2)
assembly_transform(assembly, R)

plotter = AssemblyPlotter(assembly, figsize=(16, 6))

courses = assembly.get_vertices_attribute('course')

c_min = min(courses)
c_max = max(courses)
c_spn = c_max - c_min

facecolor = {
    key: i_to_black((attr['course'] - c_min) / c_spn)
    for key, attr in assembly.vertices(True)
}
edgecolor = {
    key: '#000000'
    for key in assembly.vertices_where({'is_support': True})
}
edgewidth = {key: 3 for key in assembly.vertices_where({'is_support': True})}

plotter.draw_blocks(facecolor=facecolor,
                    edgecolor=edgecolor,
                    edgewidth=edgewidth)
plotter.show()
예제 #5
0
force = ForceDiagram.from_formdiagram(form)

horizontal(form, force, alpha=100)
scale = vertical_from_zmax(form, 3.0)

# ==============================================================================
# visualise
# ==============================================================================

z = form.get_vertices_attribute('z')
zmin = min(z)
zmax = max(z)

plotter = MeshPlotter(form, figsize=(12, 8), tight=True)

plotter.draw_vertices(
    keys=list(form.vertices_where({'is_external': False})),
    facecolor={key: i_to_black((attr['z'] - zmin) / (zmax - zmin)) for key, attr in form.vertices_where({'is_external': False}, True)},
    radius=0.1
)

plotter.draw_edges(
    keys=list(form.edges_where({'is_edge': True})),
    color={key: '#00ff00' for key in form.edges_where({'is_external': True})},
    width={key: 2.0 for key in form.edges_where({'is_external': True})}
)

plotter.draw_faces(keys=list(form.faces_where({'is_loaded': True})))

plotter.show()