'start': mesh.vertex_coordinates(u, 'xy'), 'end': mesh.vertex_coordinates(v, 'xy'), 'color': '#cccccc', 'width': 0.5 }) plotter.draw_lines(lines) # draw the vertices and edges in the starting configuration # and pause for a second before starting the dynamic visualization plotter.draw_vertices(facecolor={ key: '#000000' for key in mesh.vertices() if mesh.vertex_degree(key) == 2 }) plotter.draw_edges() plotter.update(pause=0.5) # run the smoother xyz = smooth_centroid_cpp(vertices, adjacency, fixed, kmax=kmax, callback=callback) # keep the plot alive plotter.show()
mesh = Mesh.from_vertices_and_faces(vertices, faces) key = mesh.insert_vertex(0) fixed = [key] plotter = MeshPlotter(mesh, figsize=(10, 7)) plotter.draw_edges(width=0.5) def callback(mesh, k, args): print(k) plotter.update_edges() plotter.update() trimesh_remesh( mesh, 0.5, kmax=200, allow_boundary_split=True, allow_boundary_swap=True, allow_boundary_collapse=True, fixed=fixed, callback=callback) mesh_smooth_area(mesh, fixed=mesh.vertices_on_boundary()) plotter.update_edges() plotter.update(pause=2.0) plotter.show()
mesh = Mesh.from_obj(compas.get('faces.obj')) u = [key for key in mesh.vertices() if mesh.vertex_degree(key) == 2][0] plotter = MeshPlotter(mesh, figsize=(10, 7)) plotter.defaults['face.facecolor'] = '#eeeeee' plotter.defaults['face.edgecolor'] = '#cccccc' plotter.draw_vertices() plotter.draw_faces() plotter.draw_edges() mesh_quads_to_triangles(mesh) while True: nbrs = mesh.vertex_neighbors(u, ordered=True) if not nbrs: break for v in nbrs: if mesh.vertex_degree(u): if mesh.collapse_edge_tri(u, v, t=0.0, allow_boundary=True): plotter.update_vertices() plotter.update_faces() plotter.update_edges() plotter.update(0.1) plotter.show()
'width': 0.5 }) # ============================================================================== # make a plotter for visualisation plotter = MeshPlotter(mesh, figsize=(10, 7), fontsize=6) plotter.draw_lines(lines) plotter.draw_vertices(facecolor={ key: '#000000' for key in mesh.vertices_where({'is_fixed': True}) }) plotter.draw_edges() plotter.update(pause=1.0) # ============================================================================== # define a callback for visualising the iterative process def callback(k, xyz, crits, args): print(k) plotter.update_vertices() plotter.update_edges() plotter.update(pause=0.001) for key, attr in mesh.vertices(True): index = k_i[key] attr['x'] = xyz[index, 0]