• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkCamera函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vtk.vtkCamera函数的典型用法代码示例。如果您正苦于以下问题:Python vtkCamera函数的具体用法?Python vtkCamera怎么用?Python vtkCamera使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: make_render_window_populate_views

 def make_render_window_populate_views(self):
     self.renderWindow.SetSize(self.rendererSize * self.gridDimensions, self.rendererSize * self.gridDimensions)
     self.cameras = [vtk.vtkCamera()] * 4
     for row in range(self.gridDimensions):
         for col in range(self.gridDimensions):
             idx = row * self.gridDimensions + col
             self.viewports[:] = []
             self.renderers[idx].ResetCamera()
             self.viewports.append(float(col) * self.rendererSize / (self.gridDimensions * self.rendererSize))
             self.viewports.append(float(self.gridDimensions - (row+1)) * self.rendererSize /
                                   (self.gridDimensions * self.rendererSize))
             self.viewports.append(float(col+1) * self.rendererSize / (self.gridDimensions * self.rendererSize))
             self.viewports.append(float(self.gridDimensions - row) *
                                   self.rendererSize / (self.gridDimensions * self.rendererSize))
             if idx > (4 - 1):
                 continue
             self.renderers[idx].SetViewport(self.viewports)
             ### make camera views / view ports
             camera = vtk.vtkCamera()
             camera.SetPosition(self.camera_positions[idx])
             camera.SetRoll(self.camera_rolls[idx])
             camera.SetFocalPoint(self.camera_focal_point[idx])
             camera.Azimuth(self.camera_azimuth[idx])
             camera.Elevation(self.camera_elevation[idx])
             self.renderers[idx].SetActiveCamera(camera)
             ### add actors to model
             for actor in self.actors:
                 self.renderers[idx].AddActor(actor)
             self.renderers[idx].AddViewProp(self.legend)
             self.renderers[idx].AddViewProp(self.timer_text)
             self.renderers[idx].SetBackground(0.3, 0.3, 0.3)
开发者ID:hardbyte,项目名称:QuakeCloud,代码行数:31,代码来源:mulitview_beta.py


示例2: __init__

    def __init__(self):
        # No cmd line time_index, use on screen rendering
        self.onScreen = len(sys.argv) == 1
        self.SetBackground( 0, 0, 0)

        self.renWin = vtk.vtkRenderWindow()
        self.renWin.AddRenderer( self )

        if self.onScreen:
            self.renWin.FullScreenOn()
            self.iren = vtk.vtkRenderWindowInteractor()
            self.iren.SetRenderWindow( self.renWin )
            self.iren.AddObserver("KeyPressEvent", self.Keypress_ShiftTime)
        else:
            self.renWin.OffScreenRenderingOn()
            self.renWin.SetSize( 1280, 720 )
            
        self.axesActor = vtk.vtkCubeAxesActor();
        self.axesActor.SetFlyModeToStaticTriad()
        #actorAxes->SetCamera(camOrtho);
        #double b[6] = {2,16,2,16,3,8};
        #actorAxes->SetBounds(b);
        self.axesCamera = vtk.vtkCamera()
        self.axesCamera.SetPosition( 7, 7, 7)
        self.axesCamera.SetFocalPoint( 0, 0, 0)
        self.axesActor.SetCamera( self.axesCamera )

        self.AddActor( self.axesActor )
开发者ID:adrielb,项目名称:DCell,代码行数:28,代码来源:DCellVTK.py


示例3: _makeImagePlane

def _makeImagePlane(imageData) :
    ''' Takes a vtkImageData object and
        returns a plane textured with that image
        and a camera for the background renderer
        http://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/BackgroundImage
        was the basis for this function
    '''
    imageActor = vtk.vtkImageActor()
    
    if vtk.VTK_MAJOR_VERSION <= 5 :
        imageActor.SetInput(imageData)
    else :
        imageActor.SetInputData(imageData)

    origin = imageData.GetOrigin()
    spacing = imageData.GetSpacing()
    extent = imageData.GetExtent()

    camera = vtk.vtkCamera()
    camera.ParallelProjectionOn()

    xc = origin[0] + 0.5*(extent[0] + extent[1])*spacing[0]
    yc = origin[1] + 0.5*(extent[2] + extent[3])*spacing[1]
    yd = (extent[3] - extent[2] + 1)*spacing[1]
    d = camera.GetDistance()
    camera.SetParallelScale(0.5*yd)
    camera.SetFocalPoint(xc,yc,0.0)
    camera.SetPosition(xc,yc,d)

    return camera, imageActor
开发者ID:gnastacast,项目名称:dvrk-vtk-registration,代码行数:30,代码来源:vtkTools.py


示例4: testChangeFiles

    def testChangeFiles(self):
        """
        Test that new files load when selected and save camera state.
        """
        self._widget.FilePlugin.onSetFilenames(self._filenames)

        # Setup a camera
        camera = vtk.vtkCamera()
        camera.SetViewUp(-0.7786, 0.2277, 0.5847)
        camera.SetPosition(9.2960, -0.4218, 12.6685)
        camera.SetFocalPoint(0.0000, 0.0000, 0.1250)
        self._window.onCameraChanged(camera)

        # The current view
        self.assertEqual(camera.GetViewUp(), self._window._result.getVTKRenderer().GetActiveCamera().GetViewUp())
        self._window.onResultOptionsChanged({'variable':'diffused'})
        self._window.onWindowRequiresUpdate()
        self.assertImage('testChangeFiles0.png')

        # Switch files
        self._widget.FilePlugin.AvailableFiles.setCurrentIndex(1)
        self._window.onResultOptionsChanged({'variable':'vel_'})
        self._window.onWindowRequiresUpdate()
        self.assertImage('testChangeFiles1.png')
        self.assertNotEqual(camera.GetViewUp(), self._window._result.getVTKRenderer().GetActiveCamera().GetViewUp())

        # Switch back to initial (using same file name as before)
        self._widget.FilePlugin.AvailableFiles.setCurrentIndex(0)
        self.assertEqual(camera.GetViewUp(), self._window._result.getVTKRenderer().GetActiveCamera().GetViewUp())
        self._window.onResultOptionsChanged({'variable':'diffused'})
        self._window.onWindowRequiresUpdate()
        self.assertImage('testChangeFiles0.png')
开发者ID:zachmprince,项目名称:moose,代码行数:32,代码来源:test_FilePlugin.py


示例5: testCameraLink

    def testCameraLink(self):
        """
        Test the gold toggle is working.
        """
        self.assertTrue(self._widget.GoldDiffPlugin.LinkToggle.isEnabled())
        self._widget.GoldDiffPlugin.DiffToggle.setChecked(QtCore.Qt.Checked)
        self._widget.GoldDiffPlugin.DiffToggle.clicked.emit(True)
        self._window.onResultOptionsChanged({'variable':'diffused'})
        self._window.onWindowRequiresUpdate()

        camera = vtk.vtkCamera()
        camera.SetViewUp(-0.7786, 0.2277, 0.5847)
        camera.SetPosition(9.2960, -0.4218, 12.6685)
        camera.SetFocalPoint(0.0000, 0.0000, 0.1250)
        self._window.onCameraChanged(camera)
        self._window.cameraChanged.emit(self._window._result.getVTKRenderer().GetActiveCamera())
        self.assertImage('testCameraLink.png', window=self._widget.GoldDiffPlugin.DiffVTKWindow)

        # Disconnect link, move the main window, the diff shouldn't move
        self._widget.GoldDiffPlugin.LinkToggle.setChecked(QtCore.Qt.Unchecked)
        self._widget.GoldDiffPlugin.LinkToggle.clicked.emit(False)
        camera.SetViewUp(0.7786, -0.2277, 0.5847)
        camera.SetPosition(9.2960, 0.4218, 12.6685)
        camera.SetFocalPoint(0.0000, 0.0000, 0.1250)
        self._window.onCameraChanged(camera)
        self._window.cameraChanged.emit(self._window._result.getVTKRenderer().GetActiveCamera())
        self.assertImage('testCameraLink.png', window=self._widget.GoldDiffPlugin.DiffVTKWindow)
开发者ID:aeslaughter,项目名称:moose,代码行数:27,代码来源:test_GoldDiffPlugin.py


示例6: create_render_window

def create_render_window(actors, callbacks, **kwargs):
    """ Creates VTK render window with an interactor.

    :param actors: list of VTK actors
    :type actors: list, tuple
    :param callbacks: callback functions for registering custom events
    :type callbacks: dict
    """
    # Get keyword arguments
    figure_size = kwargs.get('figure_size', (800, 600))
    camera_position = kwargs.get('camera_position', (0, 0, 100))

    # Find camera focal point
    center_points = []
    for actor in actors:
        center_points.append(actor.GetCenter())
    camera_focal_point = linalg.vector_mean(*center_points)

    # Create camera
    camera = vtk.vtkCamera()
    camera.SetPosition(*camera_position)
    camera.SetFocalPoint(*camera_focal_point)

    # Create renderer
    renderer = vtk.vtkRenderer()
    renderer.SetActiveCamera(camera)
    renderer.SetBackground(1.0, 1.0, 1.0)

    # Add actors to the scene
    for actor in actors:
        renderer.AddActor(actor)

    # Render window
    render_window = vtk.vtkRenderWindow()
    render_window.AddRenderer(renderer)
    render_window.SetSize(*figure_size)

    # Render window interactor
    window_interactor = vtk.vtkRenderWindowInteractor()
    window_interactor.SetRenderWindow(render_window)

    # Add event observers
    for cb in callbacks:
        window_interactor.AddObserver(cb, callbacks[cb][0], callbacks[cb][1])  # cb name, cb function ref, cb priority

    # Render actors
    render_window.Render()

    # Set window name after render() is called
    render_window.SetWindowName("geomdl")

    # Use trackball camera
    interactor_style = vtk.vtkInteractorStyleTrackballCamera()
    window_interactor.SetInteractorStyle(interactor_style)

    # Start interactor
    window_interactor.Start()

    # Return window interactor instance
    return window_interactor
开发者ID:orbingol,项目名称:NURBS-Python,代码行数:60,代码来源:vtk_helpers.py


示例7: main

def main():
    fan = ColorFan()

    # The usual (almost boilerplate for examples) rendering stuff.
    camera = vtk.vtkCamera()
    camera.SetPosition(1,1,1)
    camera.SetFocalPoint(0,0,0)

    renderer = vtk.vtkRenderer()
    renWin   = vtk.vtkRenderWindow()
    renWin.AddRenderer(renderer)

    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)

    renderer.AddActor( fan.getActor() )
    renderer.SetActiveCamera(camera)
    renderer.ResetCamera()
    renderer.SetBackground(1,1,1)

    renWin.SetSize(300,300)

    # interact with data
    renWin.Render()
    iren.Start()
开发者ID:EmmetCaulfield,项目名称:linux-misc,代码行数:25,代码来源:ColorFan.py


示例8: Render

 def Render(self):
     self.Viewport1 = [0.0, 0.0, 0.5, 0.5]
     self.Viewport2 = [0.5, 0.0, 1.0, 0.5]
     self.Viewport3 = [0.0, 0.5, 0.5, 1.0]
     self.Viewport4 = [0.5, 0.5, 1.0, 1.0]
     self.Renderer1 = vtk.vtkRenderer()
     self.Renderer2 = vtk.vtkRenderer()
     self.Renderer3 = vtk.vtkRenderer()
     self.Renderer4 = vtk.vtkRenderer()
     self.renderWindow.AddRenderer(self.Renderer1)
     self.Renderer1.SetViewport(self.Viewport1)
     self.Renderer1.SetBackground(0.6, 0.5, 0.3)
     self.renderWindow.AddRenderer(self.Renderer2)
     self.Renderer2.SetViewport(self.Viewport2)
     self.Renderer2.SetBackground(0.5, 0.5, 0.4)
     self.renderWindow.AddRenderer(self.Renderer3)
     self.Renderer3.SetViewport(self.Viewport3)
     self.Renderer3.SetBackground(0.4, 0.5, 0.5)
     self.renderWindow.AddRenderer(self.Renderer4)
     self.Renderer4.SetViewport(self.Viewport4)
     self.Renderer4.SetBackground(0.0, 0.5, 0.6)
     self.Renderer1.AddActor(self.inputActor1)
     self.Renderer2.AddActor(self.inputActor2)
     self.Renderer3.AddActor(self.inputActor3)
     self.Renderer4.AddActor(self.inputActor4)
     self.camera = vtk.vtkCamera()
     self.Renderer1.SetActiveCamera(self.camera)
     self.Renderer2.SetActiveCamera(self.camera)
     self.Renderer3.SetActiveCamera(self.camera)
     self.Renderer4.SetActiveCamera(self.camera)
     self.Renderer1.ResetCamera()
     self.renderWindow.Render()
     self.interactor.Start()
开发者ID:KaWaiTsoi,项目名称:Test,代码行数:33,代码来源:visualHierarchyCompare.py


示例9: draw

    def draw(self):

        # Update location and movement
        self.update()

        # create a rendering window and renderer
        ren = vtk.vtkRenderer()
        renWin = vtk.vtkRenderWindow()
        renWin.SetSize(1200, 900)
        renWin.AddRenderer(ren)

        # Create camera
        camera = vtk.vtkCamera()
        #camera.SetPosition(0.5,10.0,0.0);
        #camera.Roll(-90)
        #ren.SetActiveCamera(camera)

        # create a renderwindowinteractor
        iren = vtk.vtkRenderWindowInteractor()
        iren.SetRenderWindow(renWin)

        # Add actors
        ren.AddActor(self.modelActor)
        ren.AddActor(self.axesActor)

        # enable user interface interactor
        iren.Initialize()
        renWin.Render()
        style = vtk.vtkInteractorStyleMultiTouchCamera()
        iren.SetInteractorStyle(style)
        iren.Start()
开发者ID:dgmato,项目名称:LIAC-Guidance,代码行数:31,代码来源:PyRobotics.py


示例10: __init__

	def __init__(self):
		self.outputs=[]
		self.paint=rgbPainter()
		self.scalingFactor=1.0
		self.showAxes=True
		self.showScalarBar=True
		self.showCaption=True
		self.showXYPlane=True
		self.showYZPlane=True
		self.showZXPlane=True
		self.nbSize=80
		self.sampleSpacing=8.0
	
		self.camera = vtk.vtkCamera()

		self.ren = vtk.vtkRenderer();
		self.renWin = vtk.vtkRenderWindow();
		self.renWin.AddRenderer(self.ren);
		self.renWin.SetWindowName("DESICOS-viewer v0.1 ")
		self.iren = vtk.vtkRenderWindowInteractor();
		self.iren.SetRenderWindow(self.renWin);
		style1 = vtk.vtkInteractorStyleTrackballCamera()
		self.iren.SetInteractorStyle(style1)
		self.ren.SetBackground(1, 1, 1);
		self.renWin.SetSize(800, 600);
开发者ID:desicos,项目名称:desicos,代码行数:25,代码来源:viewer23062013.py


示例11: RenderImageData

 def RenderImageData(self, ID, imgReader):
     # check if this is the first loaded image set
     if self.CISID == -1:
         self.imageLayer = {}
     
     self.CISID = ID
     self.imageLayer[self.CISID] = IBCRenderer(self.renderer, self.iren.Render)
     self.imageLayer[self.CISID].SetImageSet(ID)
     locator = self.imageLayer[self.CISID].Render(imgReader)
     self.initPicker()
     self.picker.AddLocator(locator)
     self.initBoxWidgetInteraction(imgReader.VolumeReader.GetOutput())
     
     if self.firstRender:
         self.iren.AddObserver("MouseMoveEvent", self.MoveCursor)
         self.iren.AddObserver("LeftButtonPressEvent", self.LeftClick)
         self.iren.AddObserver("RightButtonPressEvent", self.RightClick)
         
         # It is convenient to create an initial view of the data. The FocalPoint
         # and Position form a vector direction. Later on (ResetCamera() method)
         # this vector is used to position the camera to look at the data in
         # this direction.
         self.viewCam = vtk.vtkCamera()
         self.viewCam.SetViewUp(0, 0, -1)
         self.viewCam.SetPosition(0, 1.1, 2)
         self.viewCam.SetFocalPoint(0, -0.25, 0)
         self.viewCam.ComputeViewPlaneNormal()
         
         # This camera should generally stay stationary, 
         # and only be used for taking screenshots
         self.picCam = vtk.vtkCamera()
         self.picCam.SetViewUp(0, 0, -1)
         self.picCam.SetPosition(0, 1.1, 2)
         self.picCam.SetFocalPoint(0, -0.25, 0)
         self.picCam.ComputeViewPlaneNormal()
         
         # Actors are added to the renderer. An initial camera view is created.
         # The Dolly() method moves the camera towards the FocalPoint,
         # thereby enlarging the image.
         self.renderer.SetActiveCamera(self.viewCam)
         self.renderer.ResetCamera() 
         self.viewCam.Dolly(1.0)
         self.renderer.ResetCameraClippingRange()
         self.iren.Render()
         
         self.firstRender = False
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:46,代码来源:vtkRender.py


示例12: create_camera

def create_camera(position=(0, 0, 0), focal_point=(1, 0, 0),
                  view_up=(0, 0, 1), zoom=1):
    camera = vtk.vtkCamera()
    camera.SetPosition(*position)
    camera.SetFocalPoint(*focal_point)
    camera.SetViewUp(*view_up)
    camera.Zoom(zoom)

    return camera
开发者ID:asrob-uc3m,项目名称:augmented-fpv,代码行数:9,代码来源:vtk_utils.py


示例13: __init__

 def __init__(self):
     # ODE initialization
     self.world = ode.World()
     self.world.setGravity(GRAVITY)
     self.world.setERP(ERP)
     self.world.setCFM(CFM)
     self.space = ode.Space()
     self.floor = ode.GeomPlane(self.space, (0.0,1.0,0.0), 0.0)
     self.jointGroup = ode.JointGroup()
     self.time = 0.0
     # VTK initialization
     self.renderer = vtk.vtkRenderer()
     self.renderer.SetBackground(102.0/255.0,204/255.0,1.0)
     self.window = vtk.vtkRenderWindow()
     self.window.SetSize(WINDOW_WIDTH,WINDOW_HEIGHT)
     self.window.AddRenderer(self.renderer)
     self.interactor = vtk.vtkRenderWindowInteractor()
     self.interactor.SetRenderWindow(self.window)
     self.axes = vtk.vtkAxesActor()
     self.axes.SetAxisLabels(0)
     transform = vtk.vtkTransform()
     transform.Scale(0.1,0.1,0.1)
     self.axes.SetUserTransform(transform)
     self.renderer.AddActor(self.axes)
     # Create ground plane visualization
     self.floorVisual = vtk.vtkPlaneSource()
     self.floorVisual.SetNormal((0.0,1.0,0.0))
     self.floorVisual.SetResolution(10,10)
     self.floorReader = vtk.vtkJPEGReader()
     self.floorReader.SetFileName(FLOOR_IMAGE)
     self.floorTexture = vtk.vtkTexture()
     transform = vtk.vtkTransform()
     transform.Scale(50.0,50.0,50.0)
     self.floorTexture.SetTransform(transform)
     self.floorTexture.SetInput(self.floorReader.GetOutput())
     self.floorMap = vtk.vtkTextureMapToPlane()
     self.floorMap.SetInput(self.floorVisual.GetOutput())
     self.floorMapper = vtk.vtkPolyDataMapper()
     self.floorMapper.SetInput(self.floorMap.GetOutput())
     self.floorActor = vtk.vtkActor()
     transform = vtk.vtkTransform()
     transform.Scale(100.0,100.0,100.0)
     self.floorActor.SetUserTransform(transform)
     self.floorActor.SetMapper(self.floorMapper)
     self.floorActor.SetTexture(self.floorTexture)
     self.renderer.AddActor(self.floorActor)
     # VTK camera setup
     self.camera = vtk.vtkCamera()
     self.renderer.SetActiveCamera(self.camera)
     self.cameraFocus = [0.0, 0.0, 0.0]
     self.cameraPos = [4.0, 2.5, 1.5]
     self.cameraOffset = [0.0,1.0,3.0]
     self.cameraRoll = 0.0
     # Keep track of the simulated bodies and robots
     self.bodies = []
     self.robots = []
     self.controllers = []
开发者ID:tioguerra,项目名称:pyrobosim,代码行数:57,代码来源:sim.py


示例14: __set_pure_state__

	def __set_pure_state__(self, state):
		"""
		Update the item
		"""
		TrackItem.TrackItem.__set_pure_state__(self, state)
		self.point = state.point
		self.cam = vtk.vtkCamera()
		GUI.Urmas.UrmasPersist.setVTKState(self.cam, state.cam)
		self.parent.setSplinePoint(self.itemnum, self.point)
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:9,代码来源:KeyframePoint.py


示例15: visualize

def visualize():
    A = initPoints(particleA)
    B = initPoints(particleB)
    C = initPoints(particleC)
    displayDict = {}
    # Set up the renderer and redering window
    renderer = vtk.vtkRenderer()
    renwin = vtk.vtkRenderWindow()
    renwin.SetSize(1600, 1400)
    renwin.StereoCapableWindowOn()
    renwin.StereoRenderOn()
    renwin.SetStereoTypeToCrystalEyes()
    renwin.AddRenderer(renderer)
    ptsComp = vtk.vtkPoints()
    posComp = vnp.numpy_to_vtk(np.array([[0, 0, 0]], order='C'), deep=True)
    ptsComp.SetData(posComp)
    polyDataComp = vtk.vtkPolyData()
    polyDataComp.SetPoints(ptsComp)
    sourceComp = vtk.vtkCylinderSource()
    sourceComp.SetResolution(20)
    sourceComp.SetRadius(compartment['radius'] + particleScale)
    sourceComp.SetHeight(compartment['length'] + 2 * particleScale)
    sourceComp.SetCenter(0, -compartment['length']/2, 0)
    glyphComp = vtk.vtkGlyph3D()
    glyphComp.SetSource(sourceComp.GetOutput())
    glyphComp.SetInput(polyDataComp)
    glyphComp.ScalingOff()
    # glyphComp.SetScaleModeToDefault()
    # glyphComp.SetScaleFactor(particleScale)
    mapperComp = vtk.vtkPolyDataMapper()
    mapperComp.SetInput(glyphComp.GetOutput())
    mapperComp.ImmediateModeRenderingOn()
    actorComp = vtk.vtkActor()
    actorComp.SetMapper(mapperComp)
    actorComp.GetProperty().SetOpacity(0.2)
    actorComp.GetProperty().SetColor(1, 1, 1)
    actorComp.SetOrientation(0, 90, 90)
    renderer.AddActor(actorComp)
    renderer.AddActor(A['actor'])
    renderer.AddActor(B['actor'])
    renderer.AddActor(C['actor'])
    print 'Create camera'
    camera = vtk.vtkCamera()
    camera.SetPosition(300e-6, 200.0e-6, -300.0e-6)
    camera.SetFocalPoint(0, 0, 0)
    camera.ComputeViewPlaneNormal()    
    renderer.SetActiveCamera(camera)
    renderer.ResetCamera()
    interactor = vtk.vtkRenderWindowInteractor()
    interactor.SetRenderWindow(renwin)
    callback = TimerCallback(A, B, C)
    interactor.Initialize()
    interactor.AddObserver('TimerEvent', callback.execute)
    timerId = interactor.CreateRepeatingTimer(1)
    print 'Here'
    # renwin.FullScreenOn()
    interactor.Start()
开发者ID:subhacom,项目名称:misc,代码行数:57,代码来源:molmotionvtk.py


示例16: __init__

 def __init__(self, body_fixed=True):
     """
     body_fixed: if true Body part is automatically placed at origin
     """
     self.body_fixed = body_fixed
     # vtk objects for rendering
     self.vtkrenderer = vtk.vtkRenderer()
     
     self.viewpoint_count = len(self.camera_pos)
     self.vtkcamera = [] # one camera for each viewpoint
     for pos, up in zip(self.camera_pos, self.camera_up):
         camera = vtk.vtkCamera()
         camera.SetPosition(pos)
         camera.SetFocalPoint(0, 0, 0)
         camera.SetViewUp(up)
         self.vtkcamera.append(camera)
     
     self.vtkviewcamera = vtk.vtkCamera();
     self.vtkviewcamera.SetPosition(self.view_camera_pos);
     self.vtkviewcamera.SetFocalPoint(0, 0, 0);
     self.vtkviewcamera.SetViewUp(self.camera_up[0])
     
     self.vtkrender_window = vtk.vtkRenderWindow()
     self.vtkrender_window.AddRenderer(self.vtkrenderer)
     self.vtkrender_window.SetSize(self.render_size)
     self.vtkrender_window_interactor = vtk.vtkRenderWindowInteractor()
     self.vtkrender_window_interactor.SetRenderWindow(self.vtkrender_window)
     
     # vtk objects for reading, and rendering object parts
     self.vtkreader = {}
     self.vtkpolydata = {}
     self.vtkmapper = {}
     # read each part from its stl file
     for part in self.parts:
         self.vtkreader[part] = vtk.vtkSTLReader()
         self.vtkreader[part].SetFileName(self.models_folder + part + '.stl')
         self.vtkpolydata[part] = self.vtkreader[part].GetOutput()
         self.vtkmapper[part] = vtk.vtkPolyDataMapper()
         self.vtkmapper[part].SetInput(self.vtkpolydata[part])
     if self.body_fixed:
         # actor for body part (every object has part named body at origin)
         self.vtkbodyactor = vtk.vtkActor()
         self.vtkbodyactor.SetMapper(self.vtkmapper['Body'])
         self.vtkbodyactor.SetPosition(0, 0, 0)
开发者ID:gokererdogan,项目名称:ShapeGrammar,代码行数:44,代码来源:vision_forward_model.py


示例17: _cameraFromMatrix

def _cameraFromMatrix(camMatrix, imageDims, windowDims) :
    ''' Takes a camera matrix derived from OpenCV
        returns a camera for registration
        http://stackoverflow.com/questions/25539898/how-to-apply-the-camera-pose-transformation-computed-using-epnp-to-the-vtk-camer
        was a great help

        Input: 
            camMatrix (np.ndarray) = 4x4 camera intrinsic matrix
            imageDims ((float, float))  = width and height of image to register
            imageDims ((float, float))  = width and height of render window

        Output:
            camera (vtk.vtkCamera) = camera to use for registration
    '''
    # Initialize camera
    camera = vtk.vtkCamera()

    # Set view angle
    focalLengthY = camMatrix[1,1]
    if( windowDims[1] != imageDims[1] ):
        factor = float(windowDims[1])/float(imageDims[1])
        focalLengthY = camMatrix[1,1] * factor
    viewAngle = np.arctan((windowDims[1]/2.0)/focalLengthY)*360/np.pi
    camera.SetViewAngle(viewAngle)

    #Set window center
    py = 0
    height = 0
    if imageDims[0] != windowDims[0] or imageDims[1] != windowDims[1] :
        factor = float(windowDims[1])/float(imageDims[1])
        px = factor * camMatrix[0,2]
        width = windowDims[0]
        expectedWindowSize = np.round(factor * float(imageDims[0]))
        if( expectedWindowSize != windowDims[0] ):
            diffX = (windowDims[0] - expectedWindowSize) / 2
            px = px + diffX
        py = factor * camMatrix[1,2]
        height = windowDims[1]
    else :
        px = camMatrix[0,2]
        width = imageDims[0]
        py = camMatrix[1,2]
        height = imageDims[1]
    cx = width - px
    cy = py
    windowCenter = [0,0]
    windowCenter[0] = cx / ( ( width-1)/2 ) - 1 
    windowCenter[1] = cy / ( ( height-1)/2 ) - 1
    camera.SetWindowCenter(windowCenter[0],windowCenter[1])

    # Set camera to look forward from center
    camera.SetPosition(0,0,0)
    camera.SetFocalPoint(0,0,1)

    return camera
开发者ID:gnastacast,项目名称:dvrk-vtk-registration,代码行数:55,代码来源:vtkTools.py


示例18: __create_camera

    def __create_camera(self):
        # Create a camera
        camera = vtk.vtkCamera()

        camera.SetFocalPoint(numpy.array(self.settings.camera_focal_point) * self.settings.scaling)
        camera.SetPosition(numpy.array(self.settings.camera_base_position) * self.settings.scaling)

        camera.Azimuth(self.settings.camera_azimuth)
        camera.Elevation(self.settings.camera_elevation)
        camera.SetViewAngle(self.settings.camera_view_angle)
        return camera
开发者ID:ecell,项目名称:newio,代码行数:11,代码来源:epdp.py


示例19: setZAxisView

 def setZAxisView(self):
     """ set z axis view """
     cam = vtk.vtkCamera()
     cam.ParallelProjectionOff()
     cam.SetViewUp(0, 1, 0)
     cam.SetPosition(0, 0, self.distance)
     cam.SetFocalPoint(0, 0, -self.center[2])
     self.renderer.SetActiveCamera(cam)
     self.renderer.ResetCamera()
     self.renderer.ResetCameraClippingRange()
     self.redraw()
开发者ID:viz4biz,项目名称:PyDataNYC2015,代码行数:11,代码来源:vtk_surface.py


示例20: build_panel

    def build_panel(self):
                
        self._iren = MyRenderWindowInteractor(self, wx.ID_ANY, size=self.GetSize())
        self._iren.SetPosition((0,0))

        # define interaction style
        self._iren.GetInteractorStyle().SetCurrentStyleToTrackballCamera() # change interaction style

        self._iren.Enable(1)
        
        # create renderer  
        self._renderer = vtk.vtkRenderer()
        self._iren.GetRenderWindow().AddRenderer(self._renderer)
    
        # cam stuff
        self.camera=vtk.vtkCamera() # create camera 
        self._renderer.SetActiveCamera(self.camera) # associate camera to renderer
        self.camera.SetFocalPoint(0, 0, 0)
        self.camera.SetPosition(0, 0, 20)
        
        self.__pickerObserverId = None
        self.picker = vtk.vtkCellPicker()
        self.picker.SetTolerance(0.005)
        
        self._iren.AddObserver("TimerEvent", self.on_timer)
        self._iren.RemoveObservers("CharEvent")
        self._iren.AddObserver("CharEvent", self.on_keyboard_input)
        self._iren.AddObserver("LeftButtonPressEvent", self.emulate_focus)

        pub.subscribe(self.check_switch_consistancy, ('Switch'))
        
        self._iren.Bind(wx.EVT_CONTEXT_MENU, self.on_show_popup_menu)
                
        self._mgr.AddPane(self._iren, aui.AuiPaneInfo().Dock().Center().CaptionVisible(False).CloseButton(False))
                
        self._mgr.Update()

        self._first = True    
        self._timerCounter = 0
        self._timerInterval = 5
        self._animationLoop = False
        self._trajectoryLoaded = False
        self._currentFrame = 0
        self._maxLaps = 100
        self.display_bbox = False
        self.bbox = None
        
        self._surface = None
        self._iso = None
                
        # Atoms picked from mouse or selection box.
        self.__pickedAtoms = set()
        
        self.SetFocusIgnoringChildren()
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:54,代码来源:MolecularViewerPlugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkCellArray函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkBoxWidget函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap