當前位置: 首頁>>代碼示例>>Python>>正文


Python vtk.vtkRenderer方法代碼示例

本文整理匯總了Python中vtk.vtkRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Python vtk.vtkRenderer方法的具體用法?Python vtk.vtkRenderer怎麽用?Python vtk.vtkRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vtk的用法示例。


在下文中一共展示了vtk.vtkRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: vis_segments

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def vis_segments(ind=1):
    renderer = vtk.vtkRenderer()
    seg_folder = os.path.join(params['base_dir'], "output/pcd_seg/" + str(ind).zfill(params["file_name_digits"])) + "/"
    seg_list = os.listdir(seg_folder)
    for seg in seg_list:
        if seg.split(".")[-1] == "txt":
            color_tup = (np.random.randint(1, 255, 3)).tolist()
            points_ls = list()
            jdcs_collection = cPickle.load(open(os.path.abspath(seg_folder + seg), 'rb'))
            if len(jdcs_collection) > 0:  # filter
                for jdc in jdcs_collection:
                    points_ls.extend(jdc)
            # print points_ls
            actor = vis_pcd_color_arr(np.array(points_ls), color_tup)
            renderer.AddActor(actor)
    vis_with_renderer(renderer) 
開發者ID:mfxox,項目名稱:ILCC,代碼行數:18,代碼來源:utility.py

示例2: vis_segments_only_chessboard_color

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def vis_segments_only_chessboard_color(ind=1):
    renderer = vtk.vtkRenderer()
    seg_folder = os.path.join(params['base_dir'], "output/pcd_seg/" + str(ind).zfill(params["file_name_digits"])) + "/"
    seg_list = os.listdir(seg_folder)
    chessboard_file_name = \
        cPickle.load(open(os.path.join(params['base_dir'], "output/pcd_seg/") + str(ind).zfill(
            params["file_name_digits"]) + "_pcd_result.pkl", "r"))[
            -1].split("/")[-1]
    for seg in seg_list:
        if seg.split(".")[-1] == "txt":
            if seg == chessboard_file_name:
                color_tup = np.array([0, 255, 0])
            else:
                color_tup = np.array([0, 0, 0])

            points_ls = list()
            jdcs_collection = cPickle.load(open(os.path.abspath(seg_folder + seg), 'rb'))
            if len(jdcs_collection) > 0:  # filter
                for jdc in jdcs_collection:
                    points_ls.extend(jdc)
            # print points_ls
            actor = vis_pcd_color_arr(np.array(points_ls), color_tup)
            renderer.AddActor(actor)
    vis_with_renderer(renderer) 
開發者ID:mfxox,項目名稱:ILCC,代碼行數:26,代碼來源:utility.py

示例3: __init__

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def __init__(self):
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(0.5, 0.5, 0.5)
        self.renderer.ResetCamera()

        axes_actor = vtk.vtkAxesActor()
        axes_actor.AxisLabelsOff()
        self.renderer.AddActor(axes_actor)

        self.window = vtk.vtkRenderWindow()
        self.window.AddRenderer(self.renderer)

        self.interactor = vtk.vtkRenderWindowInteractor()
        self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.interactor.SetRenderWindow(self.window)

        self.camera = vtk.vtkCamera()
        self.camera.SetViewUp(0.0, -1.0, 0.0)
        self.camera.SetPosition(0.0, 0.0, -5)
        self.camera.SetFocalPoint(0.0, 0.0, 0.0)
        # self.camera.SetClippingRange(0.0, 100000)

        self.renderer.SetActiveCamera(self.camera) 
開發者ID:tobiasfshr,項目名稱:MOTSFusion,代碼行數:25,代碼來源:vtkVisualization.py

示例4: viewer

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def viewer(pointclouds):
        assert all([isinstance(p, VtkPointCloud) for p in pointclouds])

        # Renderer
        renderer = vtk.vtkRenderer()
        renderer.SetBackground(1.0, 1.0, 1.0)

        for p in pointclouds:
            renderer.AddActor(p.vtkActor)
        renderer.ResetCamera()

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

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

        # Begin Interaction
        renderWindow.Render()
        renderWindow.SetWindowName("XYZ Data Viewer")

        renderWindowInteractor.Start() 
開發者ID:moberweger,項目名稱:deep-prior-pp,代碼行數:26,代碼來源:vtkpointcloud.py

示例5: make_render_window

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def make_render_window():

    #cone actor
    cone = vtk.vtkConeSource()
    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInputConnection(cone.GetOutputPort())
    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)

    #text actor following camera
    text = vtk.vtkVectorText()
    text.SetText("Origin")
    textMapper = vtk.vtkPolyDataMapper()
    textMapper.SetInputConnection(text.GetOutputPort())
    textActor = vtk.vtkFollower()
    textActor.SetMapper(textMapper)

    ren = vtk.vtkRenderer()
    ren.AddActor(coneActor)
    ren.AddActor(textActor)
    textActor.SetCamera(ren.GetActiveCamera())

    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    return renWin 
開發者ID:holoviz,項目名稱:panel,代碼行數:27,代碼來源:test_vtk.py

示例6: create_ren_list

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def create_ren_list(self):
        """
        Create a list of the 4 renderers we use. One general view and 3 cartersian projections
        Returns:
            list: list of renderers
        """

        # viewport dimensions setup
        xmins = [0, 0.6, 0.6, 0.6]
        xmaxs = [0.6, 1, 1, 1]
        ymins = [0, 0, 0.33, 0.66]
        ymaxs = [1, 0.33, 0.66, 1]

        # create list of renderers, set vieport values
        ren_list = []
        for i in range(self.n_ren):
            # append each renderer to list of renderers
            ren_list.append(vtk.vtkRenderer())
            # add each renderer to window
            self.renwin.AddRenderer(ren_list[-1])
            # set viewport for each renderer
            ren_list[-1].SetViewport(xmins[i], ymins[i], xmaxs[i], ymaxs[i])

        return ren_list 
開發者ID:cgre-aachen,項目名稱:gempy,代碼行數:26,代碼來源:visualization_3d.py

示例7: vis_csv_pcd

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def vis_csv_pcd(ind=1, color_style="monochrome"):
    pcd_arr = np.genfromtxt(
        os.path.join(params['base_dir'], "pcd/" + str(ind).zfill(params["file_name_digits"])) + ".csv", delimiter=",",
        skip_header=1)
    # actor = vis_3D_points(pcd_arr, color_style="intens")
    actor = vis_3D_points(pcd_arr, color_style=color_style)
    renderer = vtk.vtkRenderer()
    renderer.AddActor(actor)
    vis_with_renderer(renderer) 
開發者ID:mfxox,項目名稱:ILCC,代碼行數:11,代碼來源:utility.py

示例8: __init__

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def __init__(self, parent, opt_engine):
        QVTKRenderWindowInteractor.__init__(self, parent)
        self.opt_engine = opt_engine

        self.renderer = vtk.vtkRenderer()
        self.GetRenderWindow().AddRenderer(self.renderer)
        self.interactor = self.GetRenderWindow().GetInteractor()

        self.create_actor()
        self.renderer.AddActor(self.actor)
        self.renderer.SetBackground(0, 0, 0) 
開發者ID:maxorange,項目名稱:pix2vox,代碼行數:13,代碼來源:gui_viewer.py

示例9: QVTKRenderWidgetConeExample

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def QVTKRenderWidgetConeExample():
    """A simple example that uses the QVTKRenderWindowInteractor class."""

    # every QT app needs an app
    app = QtGui.QApplication(['QVTKRenderWindowInteractor'])

    # create the widget
    widget = QVTKRenderWindowInteractor()
    widget.Initialize()
    widget.Start()
    # if you dont want the 'q' key to exit comment this.
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtkConeSource()
    cone.SetResolution(8)

    coneMapper = vtkPolyDataMapper()
    coneMapper.SetInput(cone.GetOutput())

    coneActor = vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    # show the widget
    widget.show()
    # start event processing
    app.exec_() 
開發者ID:mmolero,項目名稱:pcloudpy,代碼行數:33,代碼來源:QVTKRenderWindowInteractor.py

示例10: __init__

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def __init__(self, parent=None):
        super(QVTKWidget, self).__init__(parent)
        self._enable_axis = False
        self._Iren.SetInteractorStyle (vtkInteractorStyleTrackballCamera ())

        self.renderer = vtkRenderer()
        self.renderer.GradientBackgroundOn()
        self.renderer.SetBackground2(255.0,255.0,255.0)
        self.renderer.SetBackground(37/255.0, 85/255.0,152/255.0)

        self.GetRenderWindow().AddRenderer(self.renderer)
        self.Initialize()
        self.Start()
        self.add_axes() 
開發者ID:mmolero,項目名稱:pcloudpy,代碼行數:16,代碼來源:QVTKWidget.py

示例11: display_from_actor

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def display_from_actor(actor):
    renderer = vtkRenderer()
    renderWindow = vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    renderer.AddActor(actor)
    # enable user interface interactor
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(renderWindow)
    iren.Initialize()
    renderWindow.Render()
    iren.Start() 
開發者ID:mmolero,項目名稱:pcloudpy,代碼行數:14,代碼來源:vtkhelpers.py

示例12: __init__

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def __init__(self, background=(0.15, 0.15, 0.15), total_time_steps=None, timer_rate=60, gif_file=None):
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(background[0], background[1], background[2])
        self.ren_win = vtk.vtkRenderWindow()
        self.ren_win.AddRenderer(self.ren)
        self.iren = vtk.vtkRenderWindowInteractor()
        self.iren.SetRenderWindow(self.ren_win)
        self.iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
        self.actor_list = []
        self.mapper_list = []
        self.source_list = []
        self.screenshot_count = 0
        self.timer_rate = timer_rate
        self.gif_data = []
        if gif_file is not None:
            try:
                assert type(gif_file) is str
            except AssertionError:
                gif_file = str(gif_file)
            self.gif_file = gif_file
        else:
            self.gif_file = None

        if total_time_steps is not None:
            assert type(total_time_steps) is int
            self.timer_count = 0
            self.total_time_steps = total_time_steps 
開發者ID:adityadua24,項目名稱:robopy,代碼行數:29,代碼來源:graphics.py

示例13: check_depth_peeling

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def check_depth_peeling(number_of_peels=100, occlusion_ratio=0.0):
    """Check if depth peeling is available.

    Attempts to use depth peeling to see if it is available for the current
    environment. Returns ``True`` if depth peeling is available and has been
    successfully leveraged, otherwise ``False``.

    """
    # Try Depth Peeling with a basic scene
    source = vtk.vtkSphereSource()
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(source.GetOutputPort())
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    # requires opacity < 1
    actor.GetProperty().SetOpacity(0.5)
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindow.SetOffScreenRendering(True)
    renderWindow.SetAlphaBitPlanes(True)
    renderWindow.SetMultiSamples(0)
    renderer.AddActor(actor)
    renderer.SetUseDepthPeeling(True)
    renderer.SetMaximumNumberOfPeels(number_of_peels)
    renderer.SetOcclusionRatio(occlusion_ratio)
    renderWindow.Render()
    return renderer.GetLastRenderingUsedDepthPeeling() == 1 
開發者ID:pyvista,項目名稱:pyvista,代碼行數:30,代碼來源:helpers.py

示例14: QVTKRenderWidgetConeExample

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def QVTKRenderWidgetConeExample():
    """A simple example that uses the QVTKRenderWindowInteractor class."""

    # every QT app needs an app
    app = QApplication(['QVTKRenderWindowInteractor'])

    # create the widget
    widget = QVTKRenderWindowInteractor()
    widget.Initialize()
    widget.Start()
    # if you don't want the 'q' key to exit comment this.
    widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit())

    ren = vtk.vtkRenderer()
    widget.GetRenderWindow().AddRenderer(ren)

    cone = vtk.vtkConeSource()
    cone.SetResolution(8)

    coneMapper = vtk.vtkPolyDataMapper()
    coneMapper.SetInputConnection(cone.GetOutputPort())

    coneActor = vtk.vtkActor()
    coneActor.SetMapper(coneMapper)

    ren.AddActor(coneActor)

    # show the widget
    widget.show()
    # start event processing
    app.exec_() 
開發者ID:pyCGNS,項目名稱:pyCGNS,代碼行數:33,代碼來源:Q7VTKRenderWindowInteractor.py

示例15: visualize_prediction

# 需要導入模塊: import vtk [as 別名]
# 或者: from vtk import vtkRenderer [as 別名]
def visualize_prediction(pointcloud, colors, poses=None, renwin=None):
    """ render point cloud and cameras """

    renderer = vtk.vtkRenderer()
    renderer.SetBackground(0, 0, 0)

    pointcloud_actor = create_pointcloud_actor(points=pointcloud, colors=colors)
    pointcloud_actor.GetProperty().SetPointSize(2)
    renderer.AddActor(pointcloud_actor)

    for pose in poses:
        R, t = pose[:3, :3], pose[:3, 3]
        cam_actor = create_camera_actor(R,t)
        cam_actor.GetProperty().SetColor((255, 255, 0))
        renderer.AddActor(cam_actor)

    camera = vtk.vtkCamera()
    camera.SetPosition((1, -1, -2));
    camera.SetViewUp((0, -1, 0));
    camera.SetFocalPoint((0, 0, 2));

    renderer.SetActiveCamera(camera)
    renwin = vtk.vtkRenderWindow()

    renwin.SetWindowName("Point Cloud Viewer")
    renwin.SetSize(800,600)
    renwin.AddRenderer(renderer)
 
    # An interactor
    interactor = vtk.vtkRenderWindowInteractor()
    interstyle = vtk.vtkInteractorStyleTrackballCamera()
    interactor.SetInteractorStyle(interstyle)
    interactor.SetRenderWindow(renwin)

    # Render and interact
    renwin.Render()
    interactor.Initialize()
    interactor.Start() 
開發者ID:princeton-vl,項目名稱:DeepV2D,代碼行數:40,代碼來源:vis.py


注:本文中的vtk.vtkRenderer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。