import importDAE
import importOBJ
import Mesh
import FreeCAD as App
from model.files_generator import FolderGenerator
from helper.is_solid import is_object_solid
from enum import Enum
 
class EXPORT_TYPES(Enum):
    STL = 'STL'
    DAO = 'DAO'
    OBJ = 'OBJ'
 
#экспорт stl и urdf из freecad
class ExportUseCase:
    def call(path: str, type: EXPORT_TYPES):
        meshes = {}
        for el in App.ActiveDocument.Objects:
            if (is_object_solid(el)):
                match type.value:
                    case EXPORT_TYPES.STL.value:
                        Mesh.export([el], path + '/' + FolderGenerator.SDF.value +
                                    '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.stl')
                        meshes[el.Label] = '/' + FolderGenerator.MESHES.value + \
                            '/' + el.Label + '.stl'

                    case EXPORT_TYPES.DAO.value:
                        importDAE.export([el], path + '/' + FolderGenerator.SDF.value +
                                    '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.dae')
                    case EXPORT_TYPES.OBJ.value:
                        importOBJ.export([el], path + '/' + FolderGenerator.SDF.value +
                                    '/' + FolderGenerator.MESHES.value + '/' + el.Label + '.obj')
                        meshes[el.Label] = '/' + FolderGenerator.MESHES.value + \
                            '/' + el.Label + '.obj'

        return meshes
