import pyvista as pv import matplotlib.pyplot as plt def visualize_results(simulator, length, width, thickness, stress, deformation): fig, ax = plt.subplots() ax.bar(["Stress", "Deformation"], [stress, deformation], color=["red", "blue"]) ax.set_title(f"Results ({simulator})") plt.savefig("results_2d.png") plt.close(fig) mesh = pv.Box(bounds=(0, length, 0, width, 0, thickness)) plotter = pv.Plotter(off_screen=True) plotter.add_mesh(mesh, color="white", show_edges=True) plotter.screenshot("results_3d.png") return "results_2d.png", "results_3d.png"