Пример #1
0
def dr_numpy_xfunc(network):
    from compas.datastructures import Network

    network = Network.from_data(network)

    vertices = network.get_vertices_attributes(('x', 'y', 'z'))
    edges = list(network.edges())
    fixed = network.vertices_where({'is_fixed': True})
    loads = network.get_vertices_attributes(('px', 'py', 'pz'))
    qpre = network.get_edges_attribute('qpre')
    fpre = network.get_edges_attribute('fpre')
    lpre = network.get_edges_attribute('lpre')
    linit = network.get_edges_attribute('linit')
    E = network.get_edges_attribute('E')
    radius = network.get_edges_attribute('radius')

    x, q, f, l, r = dr_numpy(vertices, edges, fixed, loads, qpre, fpre, lpre,
                             linit, E, radius)

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

    for index, (u, v, attr) in enumerate(network.edges(True)):
        attr['q'] = f[index, 0]
        attr['f'] = f[index, 0]
        attr['l'] = l[index, 0]

    return network.to_data()
Пример #2
0
def test_gen_grasp_planes(points_library, test_file_name, save_dir):
    b_struct_data, o_struct_data, _ = parse_saved_structure_data(
        os.path.join(save_dir, test_file_name))

    o_struct = Network.from_data(o_struct_data)
    b_struct = Network.from_data(b_struct_data)
    o_struct.struct_bar = b_struct

    offset_d1, offset_d2 = 5, 5
    nb_rot, nb_trans = 4, 4

    seq = [v for v in b_struct.vertex]
    for v in b_struct.vertex:
        calculate_gripping_plane(b_struct,
                                 v,
                                 b_struct.vertex[v]["mean_point"],
                                 nb_rot=nb_rot,
                                 nb_trans=nb_trans)
        calculate_offset(o_struct, b_struct, v, offset_d1, offset_d2, seq)
Пример #3
0
 def data(self, data):
     for _vkey, vdata in data['data']['node'].items():
         vdata['node'] = Node.from_data(vdata['node'])
     
     if 'is_constructed' in data:
         self.is_constructed = _deserialize_from_data(data['data']['attributes']['is_constructed'])
     if 'trajectory' in data:
         self.trajectory = _deserialize_from_data(data['data']['attributes']['trajectory'])
     if 'path' in data:
         self.path = [Frame.from_data(d) for d in data['data']['attributes']['path']]
     
     self.network = Network.from_data(data)
Пример #4
0
def network_embed_in_plane_proxy(data, fixed=None, straightline=True):
    from compas.datastructures import Network
    network = Network.from_data(data)
    network_embed_in_plane(network, fixed=fixed, straightline=straightline)
    return network.to_data()
    def data(self, data):
        # Deserialize elements from node dictionary
        for _vkey, vdata in data['data']['node'].items():
            vdata['element'] = Element.from_data(vdata['element'])

        self.network = Network.from_data(data)
Пример #6
0
 def is_planar(self, data):
     network = Network.from_data(data)
     return network_is_planar(network)
Пример #7
0
    def data(self, data):
        # Deserialize elements from vertex dictionary
        for _vkey, vdata in data['vertex'].items():
            vdata['element'] = Element.from_data(vdata['element'])

        self.network = Network.from_data(data)
Пример #8
0
def network_fd_numpy_xfunc(data):
    from compas.datastructures import Network
    network = Network.from_data(data)
    network_fd_numpy(network)
    return network.to_data()