import torch


def get_boundary(boundary_type='cube', **kwargs):
    """get boundary plane for primitive

    Args:
        boundary_type (str, optional): specify the primitive type. 
            Defaults to 'cube'.
            Options are 
                - 'cube': must specify `min_vert` and `max_vert` in kwargs
        kwargs: 
            min_vert (tuple, optional): min vertex of cube. for example, min_vert = (-1, -1, -1)
            max_vert (tuple, optional): max vertex of cube. for example, max_vert = (1, 1, 1)
    Returns:
        w (torch.Tensor): directions of planes
        b (torch.Tensor): offsets of planes
    """
    if boundary_type == 'cube':
        max_vert = kwargs['max_vert']
        min_vert = kwargs['min_vert']
        w = torch.tensor([[1, 0, 0], [0, 1, 0], [0, 0, 1], [-1, 0, 0], [0, -1, 0], [0, 0, -1]], dtype=torch.float32)
        b = torch.tensor([-max_vert[0], -max_vert[1], -max_vert[2], min_vert[0], min_vert[1], min_vert[2]],
                         dtype=torch.float32)
    else:
        raise Exception(f'Error: No such {boundary_type}')

    return w, b