from stl import mesh
import numpy as np

# Définir les sommets du cube
vertices = np.array([
    [-1, -1, -1],
    [+1, -1, -1],
    [+1, +1, -1],
    [-1, +1, -1],
    [-1, -1, +1],
    [+1, -1, +1],
    [+1, +1, +1],
    [-1, +1, +1]
])

# Définir les faces du cube (triangles individuels)
faces = np.array([
    [0, 1, 2],
    [0, 2, 3],
    [0, 4, 5],
    [0, 5, 1],
    [1, 5, 6],
    [1, 6, 2],
    [2, 6, 7],
    [2, 7, 3],
    [3, 7, 4],
    [3, 4, 0],
    [4, 7, 6],
    [4, 6, 5]
])

# Créer le maillage STL
cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
    cube.vectors[i] = vertices[f]

# Sauvegarder le cube au format STL
cube.save('cube.stl')
