fixed = mesh.vertices_on_boundary() # add two additional fixed vertices # on the inside of the mesh # and set their z coordinates to a low point 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]
if __name__ == '__main__': #user inputs #---------------------------------------- #---------------------------------------- precision = '3f' trg_len = 0.7 mesh = get_initial_mesh(precision) #---------------------------------------- #---------------------------------------- coons_mesh = group_and_mesh(mesh, trg_len, precision) mesh_lines = lines_from_mesh(coons_mesh) conduit = LinesConduit(mesh_lines) with conduit.enabled(): while True: coons_mesh = group_and_mesh(mesh, trg_len, precision) mesh_lines = lines_from_mesh(coons_mesh) conduit.lines = mesh_lines conduit.redraw() interface_1 = { "options": ["openings", "triangle_corner", "target_length"], "message": "Select (ESC to exit)", "default": "openings", "show": None, "ID": "interface_1"
if __name__ == '__main__': #user inputs #---------------------------------------- #---------------------------------------- precision = '3f' trg_len = 0.75 mesh, crvs = get_initial_mesh(precision) #---------------------------------------- #---------------------------------------- coons_mesh = group_and_mesh(mesh, trg_len) mesh_lines = lines_from_mesh(coons_mesh) try: conduit = LinesConduit(mesh_lines) conduit.Enabled = True while True: if not set_tri_corners(mesh): break if not trg_len: break coons_mesh = group_and_mesh(mesh, trg_len) mesh_lines = lines_from_mesh(coons_mesh) conduit.lines = mesh_lines conduit.redraw() except Exception as e: print(e)
pointsconduit.points = [ mesh.vertex_coordinates(key) for key in mesh.vertices() ] 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()