def _create_frame_file_name(frame): output_file = '{}/{}_{}.png'.format(SETTINGS.OutputImageDir, SETTINGS.OutputPrefix, str(round(frame, 2)).zfill(3)) logger.debug('["%s"] - output file: %s', sys._getframe().f_code.co_name, output_file) return output_file
def _render_scene(scene, frame_ids=None): """ Renders the scene to multiple output PNG files for use in animations """ # Clear 'images' folder containing previously rendered frames _remove_folder_contents(SETTINGS.OutputImageDir) # Calculate the time per frame (i.e. evaluate expression from config file) if frame_ids: logger.debug( '["%s"] - Specific frames given, rendering part of the simulation..', sys._getframe().f_code.co_name) nframes = len(frame_ids) id_list = frame_ids else: logger.debug( '["%s"] - No specific frames given, rendering complete simulation..', sys._getframe().f_code.co_name) nframes = ceil(eval(SETTINGS.NumberFrames)) id_list = range(nframes) # Render each scene using a thread pool or single-threaded if util.strtobool(SETTINGS.UsePool): scene_flist = [scene] * nframes # Render each scene, using a thread pool with Pool(int(SETTINGS.workers)) as p: p.map(render_scene_to_png, scene_flist, id_list) else: for frame_id in id_list: render_scene_to_png(scene, frame_id)
def _create_tmp_folder(): tmp_folder = mkdtemp() os.chdir(tmp_folder) logger.debug('["%s"] - tmp_folder: %s', sys._getframe().f_code.co_name, tmp_folder) return tmp_folder