Ejemplo n.º 1
0
def render_ANATOMY(file_type,
                   stl_path,
                   stl_files,
                   mesh_path,
                   mesh_files,
                   part_names,
                   mat_file,
                   mat_names,
                   tex_path,
                   render_path,
                   render_options,
                   render_name,
                   render_or_not):
    SCENE = SCE.NEW_SCENE()
    if(file_type=="MESH"):
        MESHES = MESH_TO_STL.read_meshes(inPath = mesh_path, inputFiles  = mesh_files)
        OBJECTS = [OBJ.OBJECT_FROM_MESH(MESH = m, objectName=n) 
                   for n, m in zip(part_names, MESHES)]
    elif(file_type=="STL"):
        OBJECTS   = [OBJ.OBJECT_FROM_STL(stl_path + f) for f in stl_files]
    MATERIALS = [MAT.MATERIAL_FROM_BLEND(mat_file, m) for m in mat_names]
    SCENE.remesh_and_smooth_objects("Masseter")
    SCENE.remesh_and_smooth_objects("Mass")
    SCENE.link_objects_and_materials(OBJECTS, MATERIALS)
    SCENE.update_texture_pathes(tex_path)
    SCENE.center_and_normalize_objects()
    SCENE.set_studio_parameters()
    SCENE.add_lamp(loc=(-1, 2, 3), s=0.7)
    SCENE.add_lamp(loc=(-2,0,3), s=0.4)
    SCENE.hide_lamps_and_studios()
    SCENE.set_render_parameters(render_options)
    for obj in SCENE.OBJECTS:
        obj.smooth()
    SCENE.set_camera_parameters(type="ORTHO")
    if(render_or_not): SCENE.render(render_path, render_name)
Ejemplo n.º 2
0
        file_list    = [file for file in os.listdir(mesh_directory)]
        end          = "Muscle.o1.mesh"
        patients     = set([name[0:-len(end)] for name in file_list if end in name])
        object_names = ["Muscle", "Bone", "Skin"]

        #Processing for each patient
        for p in patients:
                
                #Defining files
                mesh_files = [p + x + ".o1.mesh" for x in object_names]
                stl_files  = [p + x + ".stl"     for x in object_names]
        
                #Converting mesh to stl
                if(CONVERSION):
                        MESH_TO_STL.convert_files(inPath      = mesh_directory,
                                                  inputFiles  = mesh_files,
                                                  outPath     = stl_directory,
                                                  outputFiles = stl_files)

                if(RENDERFROMSTL):    files_type = "STL"
                elif(RENDERFROMMESH): files_type = "MESH"

                RENDER.render_ANATOMY(file_type      = files_type,
                                      stl_path       = stl_directory,
                                      stl_files      = stl_files,
                                      mesh_path      = mesh_directory,
                                      mesh_files     = mesh_files,
                                      part_names     = object_names,
                                      mat_file       = matFile,
                                      mat_names      = object_names,
                                      tex_path       = tex_directory,
                                      render_path    = render_directory,