示例#1
0
def make_animation(filename, view, roll, anim_format, options):
    output_dir = tempfile.mkdtemp()
    
    viewer = Viewer(filename, watch=options.watch,
                    animate=True,
                    output_dir=output_dir,
                    offscreen=True)

    viewer(show=False, is_3d=options.is_3d, view=view,
           roll=roll, layout=options.layout,
           scalar_mode=options.scalar_mode,
           vector_mode=options.vector_mode,
           rel_scaling=options.rel_scaling,
           clamping=options.clamping, ranges=options.ranges,
           is_scalar_bar=options.is_scalar_bar,
           is_wireframe=options.is_wireframe,
           rel_text_width=options.rel_text_width,
           fig_filename=options.fig_filename, resolution=options.resolution,
           filter_names=options.filter_names, only_names=options.only_names,
           group_names=options.group_names,
           anti_aliasing=options.anti_aliasing)

    anim_name = viewer.encode_animation(options.fig_filename, anim_format,
                                        options.ffmpeg_options)

    import os.path as op
    shutil.move(anim_name, op.join(options.output_dir, op.split(anim_name)[1]))
    shutil.rmtree(output_dir)

    mlab.close(viewer.scene)
示例#2
0
def make_animation(filename,
                   view,
                   roll,
                   anim_format,
                   options,
                   reuse_viewer=None):
    output_dir = tempfile.mkdtemp()

    viewer = Viewer(filename,
                    watch=options.watch,
                    animate=True,
                    output_dir=output_dir,
                    offscreen=True)

    if reuse_viewer is None:
        viewer(show=False,
               is_3d=options.is_3d,
               view=view,
               roll=roll,
               layout=options.layout,
               scalar_mode=options.scalar_mode,
               vector_mode=options.vector_mode,
               rel_scaling=options.rel_scaling,
               clamping=options.clamping,
               ranges=options.ranges,
               is_scalar_bar=options.is_scalar_bar,
               is_wireframe=options.is_wireframe,
               opacity=options.opacity,
               subdomains_args=options.subdomains_args,
               rel_text_width=options.rel_text_width,
               fig_filename=options.fig_filename,
               resolution=options.resolution,
               filter_names=options.filter_names,
               only_names=options.only_names,
               group_names=options.group_names,
               anti_aliasing=options.anti_aliasing,
               domain_specific=options.domain_specific)

    else:
        viewer.file_source = reuse_viewer.file_source
        viewer.scene = reuse_viewer.scene
        viewer.set_step = reuse_viewer.set_step
        viewer.save_animation(options.fig_filename)

    op = os.path
    if anim_format != 'png':
        anim_name = viewer.encode_animation(options.fig_filename, anim_format,
                                            options.ffmpeg_options)

        shutil.move(anim_name,
                    op.join(options.output_dir,
                            op.split(anim_name)[1]))
        shutil.rmtree(output_dir)

    else:
        shutil.move(output_dir, op.join(options.output_dir, 'snapshots'))

    if reuse_viewer is None:
        mlab.close(viewer.scene)
示例#3
0
文件: viewer.py 项目: snilek/sfepy
def make_animation(filename, view, roll, anim_format, options,
                   steps=None, times=None, reuse_viewer=None):
    output_dir = tempfile.mkdtemp()

    viewer = Viewer(filename, watch=options.watch,
                    output_dir=output_dir,
                    offscreen=True)

    if reuse_viewer is None:
        viewer(show=False, is_3d=options.is_3d, view=view,
               roll=roll, layout=options.layout,
               scalar_mode=options.scalar_mode,
               vector_mode=options.vector_mode,
               rel_scaling=options.rel_scaling,
               clamping=options.clamping, ranges=options.ranges,
               is_scalar_bar=options.is_scalar_bar,
               is_wireframe=options.is_wireframe,
               opacity=options.opacity,
               subdomains_args=options.subdomains_args,
               rel_text_width=options.rel_text_width,
               fig_filename=options.fig_filename, resolution=options.resolution,
               filter_names=options.filter_names, only_names=options.only_names,
               group_names=options.group_names,
               anti_aliasing=options.anti_aliasing,
               domain_specific=options.domain_specific)

    else:
        viewer.file_source = reuse_viewer.file_source
        viewer.scene = reuse_viewer.scene
        viewer.set_step = reuse_viewer.set_step

    viewer.save_animation(options.fig_filename, steps=steps, times=times)

    op = os.path
    if anim_format != 'png':
        anim_name = viewer.encode_animation(options.fig_filename, anim_format,
                                            options.ffmpeg_options)

        shutil.move(anim_name, op.join(options.output_dir,
                                       op.split(anim_name)[1]))
        shutil.rmtree(output_dir)

    else:
        shutil.move(output_dir, op.join(options.output_dir, 'snapshots'))

    if reuse_viewer is None:
        mlab.close(viewer.scene)