def clear(self): self.clear_vertices() self.clear_edges() # ============================================================================== # Main # ============================================================================== if __name__ == "__main__": from compas_blender.utilities import get_objects from compas_blender.helpers import network_from_bmesh network = network_from_bmesh(bmesh=get_objects(layer=0)[0]) networkartist = NetworkArtist(network=network, layer=1) networkartist.clear_layer() networkartist.draw_vertices() networkartist.draw_vertexlabels() networkartist.clear_vertices(keys=[4]) networkartist.clear_vertexlabels(keys=[6]) networkartist.draw_edges() networkartist.draw_edgelabels() networkartist.clear_edges(keys=[(0, 4)]) networkartist.clear_edgelabels(keys=[(5, 4)])
def fn(l0, *args): tol, Xt, edges = args for c, uv in enumerate(edges): network.set_edge_attribute(uv[0], uv[1], 'l0', l0[c]) X, f, l = numba_dr_run(network, tol=tol) X[:, 2] /= max(X[:, 2]) norm = mean(normrow(X - Xt)) if isnan(norm) or isinf(norm): return 10**6 return norm # Network ds = 0.1 network = network_from_bmesh(draw_plane(Lx=1, Ly=1, dx=ds, dy=ds)) vertices = list(network.vertices()) edges = list(network.edges()) n = len(vertices) m = len(edges) Xt = zeros((n, 3)) network.set_vertices_attributes(vertices, {'B': [0, 0, 1], 'P': [0, 0, 1 / n]}) for c, key in enumerate(vertices): x, y, z = network.vertex_coordinates(key) if (x == 1) and (y == 1): network.set_vertex_attribute(key, 'B', [0, 0, 0]) zt = 1 - 0.5 * (x**2 + y**2) Xt[c, :] = [x, y, zt] network.set_edges_attributes(edges, {'E': 1, 'A': 1, 'ct': 't'}) clear_layers([0])
__license__ = 'MIT License' __email__ = '*****@*****.**' data = {'numpy': [], 'numba': [], 'nodes': []} for m in range(10, 71, 5): clear_layer(layer=0) # Set-up Network bmesh = draw_plane(dx=1/m, dy=1/m) blendermesh = BlenderMesh(object=bmesh) network = network_from_bmesh(bmesh=bmesh) Pz = 100 / network.number_of_vertices() network.update_default_vertex_attributes({'B': [0, 0, 1], 'P': [0, 0, Pz]}) network.update_default_edge_attributes({'E': 10, 'A': 1, 'ct': 't', 'l0': 1/m}) corners = [key for key in network.vertices() if network.vertex_degree(key) == 2] network.set_vertices_attributes(corners, {'B': [0, 0, 0]}) data['nodes'].append(network.number_of_vertices()) # Numpy-SciPy tic = time() X, f, l = drx_numpy(network=network, tol=0.01) data['numpy'].append(time() - tic) blendermesh.update_vertices(X)