Exemple #1
0
from compas_rhino.helpers import NetworkArtist

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

# for u, v, attr in network.edges(True):
#     attr['q'] = 1.0 * random.randint(1, 5)

vertices = network.get_vertices_attributes('xyz')
loads    = network.get_vertices_attributes(('px', 'py', 'pz'), (0.0, 0.0, 0.0))
fixed    = network.leaves()
free     = [i for i in range(len(vertices)) if i not in fixed]
edges    = list(network.edges())
q        = network.get_edges_attribute('q', 1.0)


artist = NetworkArtist(network, layer='Network')

artist.clear_layer()
artist.draw_edges(color='#cccccc')
artist.redraw()

xyz = fd_cpp(vertices, edges, fixed, q, loads)

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

artist.draw_vertices(color={key: '#ff0000' for key in network.leaves()})
artist.draw_edges(color='#000000')
artist.redraw()
## dumping 0.025
nc_in, f_in, q_in = XFunc('iter.multistepFDM_inexact')(vertices,
                                                       edges,
                                                       fixed,
                                                       q,
                                                       fcs=force_constraints,
                                                       lcs=length_constraints,
                                                       tol_f=1.e-4,
                                                       tol_l=1.e-3,
                                                       i_tol_min=5e-07,
                                                       damping=0.025,
                                                       steps=10000)
l_in = XFunc('iter.list_of_element_lengths')(edges, nc_in)

res = [nc_in, l_in, f_in]
xyz = res[0]

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

artist = NetworkArtist(network)

artist.clear()

artist.draw_vertices()
artist.draw_edges()

artist.redraw()