def do_the_work(inputFilePath, isSemantic, debugControl): #Init mid files if os.path.exists(MIDFILEPATH): os.remove(MIDFILEPATH) #Init datastructure ModelDataFuncs.Init() ModelData.strInputFileName, ext = os.path.splitext(inputFilePath) #read file print ("----Processing file----") print (inputFilePath) if isSemantic == True: if os.path.splitext(inputFilePath)[1] == '.obj': print('WARNING: obj format does not contain semantics') print('Semantics will be deduced') print ("Check and tessellate the file...") MyCov = ConvProvider() MyCov.convert(inputFilePath, MIDFILEPATH, True) #read a tesselated objfile if ModelDataFuncs.reader_obj(MIDFILEPATH) == False: raise Exception else: #poly with semantics try: if not ModelDataFuncs.reader_poly_with_semantics(inputFilePath): return except: raise ImportError else: #preprocess (convert and tessellation) print ("Check and tessellate the file...") MyCov = ConvProvider() MyCov.convert(inputFilePath, MIDFILEPATH, True) #read a tesselated objfile if ModelDataFuncs.reader_obj(MIDFILEPATH) == False: raise Exception #invert the normal of the input model if ModelData.global_INVERT_NORMAL: ModelDataFuncs.invert_poly_normal() #only for debug #tmp = ModelData.centerVertex #ModelData.centerVertex = (0.0, 0.0, 0.0) #ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_CLS.obj") #ModelData.centerVertex = tmp # if int(debugControl) == 1: #Decomposit all the triangles DecomposeFunc.model_decompositionEx() #Merge all the coplaner dictFaces #coplaner_face_merge() #ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_DEC.obj") elif int(debugControl) == 2: #Constrained Tetrahedralization if False == TetraFunc.CDT(): print("Constrained Delauney Tetrahedralization FAILED!") return #ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_CDT.obj") #Heuristic carving CarveFunc.heuristic_tet_carving() #ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_CARVE.obj") #Reconstruct the mesh from tetrahedron TetraFunc.extract_mesh_from_tet(isSemantic) #Output ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_OUTPUT.obj") if isSemantic: ModelDataFuncs.writer_poly_with_semantics(ModelData.strInputFileName + "_OUTPUT.poly") elif int(debugControl) == 3: #only deduce the semantics TetraFunc.deduce_semantics_of_poly(isSemantic) ModelDataFuncs.writer_poly_with_semantics(ModelData.strInputFileName + "_OUTPUT.poly") else: #Decomposit all the triangles DecomposeFunc.model_decompositionEx() #Merge all the coplaner dictFaces #coplaner_face_merge() ModelDataFuncs.writer_obj(ModelData.strInputFileName +"_DEC.obj") #Constrained Tetrahedralization if False == TetraFunc.CDT(): print("Constrained Delauney Tetrahedralization FAILED!") return ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_CDT.obj") #Heuristic carving CarveFunc.heuristic_tet_carving() ModelDataFuncs.writer_obj(ModelData.strInputFileName+"_CARVE.obj") #Reconstruct the mesh from tetrahedron TetraFunc.extract_mesh_from_tet(isSemantic) #Output ModelDataFuncs.writer_obj(ModelData.strInputFileName + "_OUTPUT.obj") if isSemantic: ModelDataFuncs.writer_poly_with_semantics(ModelData.strInputFileName + "_OUTPUT.poly")