2026-08-03 09:10:11 +02:00
|
|
|
|
# Visualizzazione della sola mesh a elementi shell della fascetta, in vista
|
|
|
|
|
|
# isometrica: facce chiare con i bordi degli elementi in evidenza.
|
|
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
import matplotlib
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
|
|
|
|
|
|
2026-08-03 11:44:58 +02:00
|
|
|
|
from config import USCITA
|
2026-08-03 09:10:11 +02:00
|
|
|
|
from mesh import genera_mesh, riepilogo_mesh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
|
|
dati = genera_mesh()
|
|
|
|
|
|
print(riepilogo_mesh(dati))
|
|
|
|
|
|
|
|
|
|
|
|
nodi = dati["nodi"]
|
|
|
|
|
|
facce = nodi[dati["elementi"]]
|
|
|
|
|
|
|
|
|
|
|
|
raggio_m = dati["raggio_m"]
|
|
|
|
|
|
lunghezza_m = dati["lunghezza_m"]
|
|
|
|
|
|
|
|
|
|
|
|
fig = plt.figure(figsize=(9, 7))
|
|
|
|
|
|
ax = fig.add_subplot(projection="3d")
|
|
|
|
|
|
ax.view_init(elev=35.264, azim=45)
|
|
|
|
|
|
ax.set_box_aspect((lunghezza_m, 2 * raggio_m, 2 * raggio_m))
|
|
|
|
|
|
ax.set_axis_off()
|
|
|
|
|
|
|
|
|
|
|
|
collezione = Poly3DCollection(
|
|
|
|
|
|
facce,
|
|
|
|
|
|
facecolors="#d9e3f0",
|
|
|
|
|
|
edgecolors="#2b3a55",
|
|
|
|
|
|
linewidths=0.4,
|
|
|
|
|
|
shade=True,
|
|
|
|
|
|
lightsource=matplotlib.colors.LightSource(azdeg=315, altdeg=45),
|
|
|
|
|
|
)
|
|
|
|
|
|
ax.add_collection3d(collezione)
|
|
|
|
|
|
|
|
|
|
|
|
ax.set_xlim(0.0, lunghezza_m)
|
|
|
|
|
|
ax.set_ylim(-raggio_m, raggio_m)
|
|
|
|
|
|
ax.set_zlim(-raggio_m, raggio_m)
|
|
|
|
|
|
ax.set_title(
|
|
|
|
|
|
f"Mesh shell: {dati['n_elementi_x']} × "
|
|
|
|
|
|
f"{dati['n_elementi_circonferenza']} elementi quadrangolari"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if matplotlib.get_backend().lower() == "agg":
|
2026-08-03 11:44:58 +02:00
|
|
|
|
cartella = Path(USCITA["cartella"])
|
2026-08-03 09:10:11 +02:00
|
|
|
|
cartella.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
percorso = cartella / "mesh.png"
|
|
|
|
|
|
fig.savefig(percorso, dpi=150)
|
|
|
|
|
|
print(f"Backend non interattivo: immagine salvata in {percorso}")
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
plt.show()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
main()
|