当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkPNGWriter方法代码示例

本文整理汇总了Python中vtk.vtkPNGWriter方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkPNGWriter方法的具体用法?Python vtk.vtkPNGWriter怎么用?Python vtk.vtkPNGWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkPNGWriter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: screenshot

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPNGWriter [as 别名]
def screenshot(self, filename=None):
        w2if = vtk.vtkWindowToImageFilter()
        w2if.SetInput(self.ren_win)
        w2if.Update()
        if filename is None:
            filename = 'screenshot'
        filename = filename + '%d.png' % self.screenshot_count
        writer = vtk.vtkPNGWriter()
        writer.SetFileName(filename)
        self.screenshot_count += 1
        writer.SetInputData(w2if.GetOutput())
        writer.Write() 
开发者ID:adityadua24,项目名称:robopy,代码行数:14,代码来源:graphics.py

示例2: WritePMG

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPNGWriter [as 别名]
def WritePMG(ren, fn, magnification=1):
    """
    Save the image as a PNG

    :param ren: The renderer.
    :param fn: The file name.
    :param magnification: The magnification, usually 1.
    """
    renLgeIm = vtk.vtkRenderLargeImage()
    imgWriter = vtk.vtkPNGWriter()
    renLgeIm.SetInput(ren)
    renLgeIm.SetMagnification(magnification)
    imgWriter.SetInputConnection(renLgeIm.GetOutputPort())
    imgWriter.SetFileName(fn)
    imgWriter.Write() 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:17,代码来源:test_code_vasp_01.py

示例3: vis_with_renderer

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPNGWriter [as 别名]
def vis_with_renderer(renderer):
    # Renderer

    # renderer.SetBackground(.2, .3, .4)
    renderer.SetBackground(1, 1, 1)
    renderer.ResetCamera()

    transform = vtk.vtkTransform()
    transform.Translate(1.0, 0.0, 0.0)
    axes = vtk.vtkAxesActor()
    renderer.AddActor(axes)

    # Render Window
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    # Interactor
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    def get_camera_info(obj, ev):
        if renderWindowInteractor.GetKeyCode() == "s":
            w2if = vtk.vtkWindowToImageFilter()
            w2if.SetInput(renderWindow)
            w2if.Update()

            writer = vtk.vtkPNGWriter()
            writer.SetFileName("screenshot.png")
            if vtk.VTK_MAJOR_VERSION == 5:
                writer.SetInput(w2if.GetOutput())
            else:
                writer.SetInputData(w2if.GetOutput())
            writer.Write()
            print "screenshot saved"

    style = vtk.vtkInteractorStyleSwitch()
    renderWindowInteractor.SetInteractorStyle(style)
    # style.SetCurrentStyleToTrackballActor()
    style.SetCurrentStyleToTrackballCamera()

    # Begin Interaction
    renderWindowInteractor.AddObserver(vtk.vtkCommand.KeyPressEvent, get_camera_info, 1)
    renderWindow.Render()
    renderWindowInteractor.Start() 
开发者ID:mfxox,项目名称:ILCC,代码行数:46,代码来源:utility.py

示例4: vtk_basic

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPNGWriter [as 别名]
def vtk_basic( actors, embed=False, magnification=1.0 ):
    """
    Create a window, renderer, interactor, add the actors and start the thing
    
    Parameters
    ----------
    actors :  list of vtkActors
    
    Returns
    -------
    nothing
    """     
    
    # create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    renWin.SetSize(600,600)
    # ren.SetBackground( 1, 1, 1)
 
    # create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    for a in actors:

        move( a, np.dot(Ry(-180),Rx(-180)) )
        
        # assign actor to the renderer
        ren.AddActor(a )
    
    # render
    renWin.Render()

    if embed:
        renWin.SetSize(300,300)
        grabber = vtk.vtkWindowToImageFilter()
        grabber.SetInput( renWin )
        grabber.SetMagnification( magnification )
        grabber.Update()
        
        writer = vtk.vtkPNGWriter()
        writer.SetInput( grabber.GetOutput() )
        writer.SetFileName( "screenshot.png" )
        writer.Write()
        return display.Image("screenshot.png")
    else:   
        # enable user interface interactor
        iren.Initialize()
        iren.Start() 
开发者ID:curiale,项目名称:Medical-Image-Analysis-IPython-Tutorials,代码行数:52,代码来源:volumerendering.py


注:本文中的vtk.vtkPNGWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。