"""Cube surface triangulated in 3D space.

Dimensional: 2D manifold in 3D space (closed, no boundary).
"""

import pyvista as pv

from torchmesh.io import from_pyvista
from torchmesh.mesh import Mesh


def load(size: float = 1.0, device: str = "cpu") -> Mesh:
    """Create a cube surface triangulated in 3D space.

    Args:
        size: Side length of the cube
        device: Compute device ('cpu' or 'cuda')

    Returns:
        Mesh with n_manifold_dims=2, n_spatial_dims=3
    """
    # Create cube with PyVista (automatically triangulated)
    pv_cube = pv.Cube(x_length=size, y_length=size, z_length=size)

    mesh = from_pyvista(pv_cube, manifold_dim=2)

    # Move to specified device
    if device != str(mesh.points.device):
        mesh = mesh.to(device)

    return mesh
