for key in (161, 256): vertices[key][2] -= dz fixed.append(key) # make a conduit for visualisation edges = list(mesh.edges()) lines = [[vertices[u], vertices[v]] for u, v in edges] conduit = LinesConduit(lines, refreshrate=5) # run the smoothing algorithm # update the mesh # and display the results with conduit.enabled(): smooth_area(vertices, faces, adjacency, fixed=fixed, kmax=100, callback=callback) for key, attr in mesh.vertices(True): attr['x'] = vertices[key][0] attr['y'] = vertices[key][1] attr['z'] = vertices[key][2] artist = MeshArtist(mesh) artist.draw_faces(join_faces=True) artist.redraw()
linesconduit.lines = [mesh.edge_coordinates(u, v) for u, v in edges] pointsconduit.redraw(k) linesconduit.redraw(k) for key, attr in mesh.vertices(True): attr['x'] = float(xyz[key][0]) attr['y'] = float(xyz[key][1]) attr['z'] = float(xyz[key][2]) pointsconduit = PointsConduit(radius=10, refreshrate=5) linesconduit = LinesConduit(refreshrate=5) with pointsconduit.enabled(): with linesconduit.enabled(): xyz = smooth_centroid_cpp(vertices, adjacency, fixed, kmax=kmax, callback=callback) for key, attr in mesh.vertices(True): attr['x'] = xyz[key][0] attr['y'] = xyz[key][1] attr['z'] = xyz[key][2] artist.clear_edges() artist.draw_vertices() artist.draw_edges() artist.redraw()