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

Python vtk.vtkLight函数代码示例

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

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



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

示例1: __init__

    def __init__(self):
        """
        Initializes VTK objects for rendering.
        """
        # vtk objects for rendering
        self.vtkrenderer = vtk.vtkRenderer()
        
        self.vtkcamera = vtk.vtkCamera()
        self.vtkcamera.SetPosition(self.camera_pos)
        self.vtkcamera.SetFocalPoint(0, 0, 0)
        self.vtkcamera.SetViewUp(self.camera_up)
 
        # lighting
        self.light1 = vtk.vtkLight()
        self.light1.SetIntensity(.4)
        self.light1.SetPosition(10, -10, 10)
        self.light1.SetDiffuseColor(1, 1, 1)
        self.light2 = vtk.vtkLight()
        self.light2.SetIntensity(.4)
        self.light2.SetPosition(-10, -10, 10)
        self.light2.SetDiffuseColor(1, 1, 1)
        self.light3 = vtk.vtkLight()
        self.light3.SetIntensity(.4)
        self.light3.SetPosition(10, -10, -10)
        self.light3.SetDiffuseColor(1, 1, 1)
        self.light4 = vtk.vtkLight()
        self.light4.SetIntensity(.4)
        self.light4.SetPosition(-10, -10, -10)
        self.light4.SetDiffuseColor(1, 1, 1)
        self.vtkrenderer.AddLight(self.light1)
        self.vtkrenderer.AddLight(self.light2)
        self.vtkrenderer.AddLight(self.light3)
        self.vtkrenderer.AddLight(self.light4)
        self.vtkrenderer.SetBackground(0.1, 0.1, 0.1) # Background color

        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.part_source = vtk.vtkCubeSource()
        self.part_output = self.part_source.GetOutput()
        self.part_mapper = vtk.vtkPolyDataMapper()
        self.part_mapper.SetInput(self.part_output)

        # exporters
        self.vtkvrml_exporter = vtk.vtkVRMLExporter()
        self.vtkobj_exporter = vtk.vtkOBJExporter()
        self.stl_writer = vtk.vtkSTLWriter()
开发者ID:gokererdogan,项目名称:BDAoOSS_ShapeGrammar,代码行数:51,代码来源:bdaooss_vision_forward_model.py


示例2: setup_renderer

def setup_renderer(renderer, actors, bboxpolydata=None):
    ren = renderer
    for actor in actors:
        # assign actor to the renderer
        ren.AddActor(actor)
    ############################################
    # Create a vtkOutlineFilter to draw the bounding box of the data set.
    # Also create the associated mapper and actor.
    if bboxpolydata is not None:
        outline = vtk.vtkOutlineFilter()
        outline.SetInput(bboxpolydata.GetOutput())
        mapOutline = vtk.vtkPolyDataMapper()
        mapOutline.SetInputConnection(outline.GetOutputPort())
        outlineActor = vtk.vtkActor()
        outlineActor.SetMapper(mapOutline)
        outlineActor.GetProperty().SetColor(100, 100, 100)
        ren.AddViewProp(outlineActor)
        ren.AddActor(outlineActor)
    

    # Create a vtkLight, and set the light parameters.
    light = vtk.vtkLight()
    light.SetFocalPoint(0.21406, 1.5, 0)
    light.SetPosition(8.3761, 4.94858, 4.12505)
    ren.AddLight(light)
    return ren
开发者ID:HerrMuellerluedenscheid,项目名称:seismerize,代码行数:26,代码来源:vtk_focmec.py


示例3: takeScreenShort

 def takeScreenShort(self):
     graphics_factory = vtk.vtkGraphicsFactory();
     graphics_factory.SetOffScreenOnlyMode(1);
     graphics_factory.SetUseMesaClasses(1);
     windows = vtk.vtkRenderWindow();
     #Do not open the window!!
     windows.SetOffScreenRendering(True);
     windows.SetSize(self.width,self.height);
     mapper = vtk.vtkPolyDataMapper();
     mapper.SetInputData(self.data);
     for d in ("X","Y",):
         for degree in range(0,100,90):
             actor = vtk.vtkActor()
             actor.SetMapper(mapper);
             getattr(actor,"Rotate{}".format(d))(degree);
             actor.GetProperty().SetColor(0,0,0)
             ren = vtk.vtkRenderer();
             windows.AddRenderer(ren);
             ren.AddActor(actor);
             ren.SetBackground(255.0, 255.0, 255.0);
             ren.ResetCamera();
             cen = ren.GetActiveCamera().GetFocalPoint();
             bounds = actor.GetBounds();
             lightOne = vtk.vtkLight();
             lightOne.SetFocalPoint(cen);
             lightOne.SetPosition(cen);
             lightOne.PositionalOff();
             lightTwo = vtk.vtkLight();
             lightTwo.SetFocalPoint(cen);
             lightTwo.SetPosition(bounds[0],bounds[2],bounds[4]);
             lightTwo.PositionalOn();
             lightThree = vtk.vtkLight();
             lightThree.SetFocalPoint(cen);
             lightThree.SetPosition(bounds[1],bounds[3],bounds[5]);
             lightThree.PositionalOn();
             ren.AddLight(lightOne);
             ren.AddLight(lightTwo);
             ren.AddLight(lightThree);
             windows.Render();
             self.saveToImage(windows,"{}_{}_{}".format(self.fileName,d,degree));
             windows.RemoveRenderer(ren);
开发者ID:avontd2868,项目名称:OU_Final_Year,代码行数:41,代码来源:vtkOperations.py


示例4: importLight

 def importLight(self, l):
     print 'importing light...'
     light = vtk.vtkLight()
     
     a = str(l.get('AmbientColor')).split(" ")
     light.SetAmbientColor(float(a[0]), float(a[1]), float(a[2]))
     a = str(l.get('SpecularColor')).split(" ")
     light.SetSpecularColor(float(a[0]), float(a[1]), float(a[2]))
     a = str(l.get('DiffuseColor')).split(" ")
     light.SetDiffuseColor(float(a[0]), float(a[1]), float(a[2]))
     light.SetIntensity(float(l.get('Intensity')))
     light.SetPositional(int(l.get('Positional')))
     light.SetConeAngle(float(l.get('ConeAngle')))
     
     if(l.get('Type') == "Scene"):
         light.SetLightTypeToSceneLight()
     elif(l.get('Type') == "Head"):
         light.SetLightTypeToHeadlight()
     elif(l.get('Type') == "Camera"):
         light.SetLightTypeToCameraLight()
     
     return light
开发者ID:Motiva,项目名称:vtkESQui,代码行数:22,代码来源:SRMLImporter.py


示例5: Light

    def Light(self, currentElement):
        self.logger.debug('  inside a <Light> element: "%s"' % currentElement.get('name'))
        light = vtk.vtkLight()

        try:
            light.SetPosition( coordsFromString(currentElement.get('SetPosition')) )
        except:
            self.logger.error("  .. <Light> failed to SetPosition")
        try:
            light.SetFocalPoint( coordsFromString(currentElement.get('SetFocalPoint')) )
        except:
            self.logger.error("  .. <Light> failed to SetFocalPoint")
        if 'SetPositional' in currentElement.keys():
            try:
                light.SetPositional( int(currentElement.get('SetPositional')) )
            except:
                self.logger.error("  .. <Light> failed to SetPositional")
        if 'SetColor' in currentElement.keys():
            try:
                light.SetColor( coordsFromString(currentElement.get('SetColor')) )
            except:
                self.logger.error("  .. <Light> failed to SetColor")
        if 'color' in currentElement.keys():  # give people the option of using HTML-style color:
            try:
                light.SetColor( webColorToVtkColor(currentElement.get('color')) )
            except:
                self.logger.error("  .. <Light> failed to set HTML-style color")
        if 'SetConeAngle' in currentElement.keys():
            try:
                light.SetConeAngle( float(currentElement.get('SetConeAngle')) )
            except:
                self.logger.error("  .. <Light> failed to SetConeAngle")
        if 'SetIntensity' in currentElement.keys():
            try:
                light.SetIntensity( float(currentElement.get('SetIntensity')) )
            except:
                self.logger.error("  .. <Light> failed to SetIntensity")
        return light
开发者ID:mfassler,项目名称:jaivis,代码行数:38,代码来源:xmlReader.py


示例6: vtkAttachProp

quadric = vtk.vtkQuadric()
quadric.SetCoefficients(.5,1,.2,0,.1,0,0,.2,0,0)

sample = vtk.vtkSampleFunction()
sample.SetSampleDimensions(50,50,50)
sample.SetImplicitFunction(quadric)

contours = vtk.vtkContourFilter()
contours.SetInputConnection(sample.GetOutputPort())
contours.GenerateValues(6, 0.0, 2)

normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(contours.GetOutputPort())
normals.SetFeatureAngle(270.0)

contMapper = vtk.vtkPolyDataMapper()
contMapper.SetInputConnection(normals.GetOutputPort())
contMapper.SetScalarRange(0.0, 1.2)
contMapper.SetScalarVisibility(1)
actor = vtk.vtkActor()
actor.SetMapper(contMapper)

vtkAttachProp(actor, vtkNode)

l = vtk.vtkLight()
vtkAddLight(l)
#l.PositionalOn()
l.SetPosition(0, 4, 0)
l.SetColor(1,1,1)
开发者ID:omega-hub,项目名称:omegaVtk,代码行数:29,代码来源:Sample.py


示例7: vtkGetDataRoot

#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
lgt = vtk.vtkLight()
# create pipeline
#
locator = vtk.vtkMergePoints()
locator.SetDivisions(32,32,46)
locator.SetNumberOfPointsPerBucket(2)
locator.AutomaticOff()
v16 = vtk.vtkVolume16Reader()
v16.SetDataDimensions(64,64)
v16.GetOutput().SetOrigin(0.0,0.0,0.0)
v16.SetDataByteOrderToLittleEndian()
v16.SetFilePrefix("" + str(VTK_DATA_ROOT) + "/Data/headsq/quarter")
v16.SetImageRange(1,93)
v16.SetDataSpacing(3.2,3.2,1.5)
iso = vtk.vtkMarchingCubes()
iso.SetInputConnection(v16.GetOutputPort())
iso.SetValue(0,1150)
iso.ComputeGradientsOn()
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:headBone.py


示例8: main


#.........这里部分代码省略.........
  # Visualization model
  vis_l_lever_r = vtkesqui.vtkVisualizationModel()
  vis_l_lever_r.SetName("vis_l_lever_r")
  vis_l_lever_r.SetFileName(fn1)
  vis_l_lever_r.SetTextureFileName(fn0t)
  vis_l_lever_r.SetOpacity(1.0)
  vis_l_lever_r.SetColor(0.0, 1.0, 0.0)
  
  # Collision model
  col_l_lever_r = vtkesqui.vtkCollisionModel()
  col_l_lever_r.SetName("col_l_lever_r_vtkbioeng")
  col_l_lever_r.SetFileName(fn1c)
  col_l_lever_r.SetOpacity(1.0)
  col_l_lever_r.SetColor(1.0, 1.0, 1.0)
  
  # Second tool element (l_lever_r)
  l_lever_r = vtkesqui.vtkScenarioElement()
  l_lever_r.SetName("l_lever_r")
  l_lever_r.SetPosition(3.0, 0.0, 0.0)
  l_lever_r.SetOrientation(0, 0, -20)
  l_lever_r.SetOrigin(0,0,6)
  l_lever_r.SetVisualizationModel(vis_l_lever_r)
  l_lever_r.SetCollisionModel(col_l_lever_r)
  
    # Visualization model
  vis_r_lever_r = vtkesqui.vtkVisualizationModel()
  vis_r_lever_r.SetName("vis_r_lever_r")
  vis_r_lever_r.SetFileName(fn2)
  vis_r_lever_r.SetTextureFileName(fn0t)
  vis_r_lever_r.SetOpacity(1.0)
  vis_r_lever_r.SetColor(0.0, 1.0, 0.0)
  
  # Collision model
  col_r_lever_r = vtkesqui.vtkCollisionModel()
  col_r_lever_r.SetName("col_r_lever_r_vtkbioeng")
  col_r_lever_r.SetFileName(fn2c)
  col_r_lever_r.SetOpacity(1.0)
  col_r_lever_r.SetColor(1.0, 1.0, 1.0)
  
  # Second tool element (r_lever_r)
  r_lever_r = vtkesqui.vtkScenarioElement()
  r_lever_r.SetName("r_lever_r")
  r_lever_r.SetPosition(3.0, 0.0, 0.0)
  r_lever_r.SetOrientation(0, 0, -20)
  r_lever_r.SetOrigin(0,0,6)
  r_lever_r.SetVisualizationModel(vis_r_lever_r)
  r_lever_r.SetCollisionModel(col_r_lever_r)
  
  grasper_r = vtkesqui.vtkToolGrasper()
  grasper_r.SetStick(stick_r)
  grasper_r.SetLeftLever(l_lever_r)
  grasper_r.SetRightLever(r_lever_r)
  
    # Add objects to the scenario
  scenario.AddObject(probe_l)
  scenario.AddObject(grasper_r)

  #for i in range(2):
  #i = 0
  
  b = createBall(0)
  scenario.AddObject(b)
  
  # Scenario camera
  camera = vtk.vtkCamera()
  camera.SetPosition(0, 0, 6)
  camera.SetFocalPoint(0, 0, -6)
  camera.Yaw(0)
  camera.Elevation(20)
  camera.Pitch(-15)
  camera.ParallelProjectionOff()
  camera.SetViewAngle(70)
  scenario.SetCamera(camera)
  
  #/********** Lights  **********/
  headLight = vtk.vtkLight()
  headLight.SetLightTypeToHeadlight()
  headLight.PositionalOn()
  headLight.SetIntensity(0.8)
  headLight.SetConeAngle(20)
  scenario.AddLight(headLight)
  
  ambientLight = vtk.vtkLight()
  ambientLight.SetIntensity(0.8)
  ambientLight.SetLightTypeToHeadlight()
  ambientLight.PositionalOff()
  scenario.AddLight(ambientLight)

  # Force the scenario to initialize
  scenario.Update()
  
  # Sign up to receive TimerEvent
  iren = scenario.GetRenderWindowInteractor()
  cb = vtkTimerCallback()
  iren.AddObserver('TimerEvent', cb.execute)
  # 1ms timer
  timerId = iren.CreateRepeatingTimer(1);
  cb.scenario = scenario
  
  iren.Start()
开发者ID:Motiva,项目名称:vtkESQui,代码行数:101,代码来源:Scenario.py


示例9: main


#.........这里部分代码省略.........
  probe_r.AddElement(stick_r)
  probe_r.AddElement(tip_r)
  scenario.AddObject(probe_r)
  
  # Add an Organ (Cavity)
  # Visualization model
  vis_cavity = vtkesqui.vtkVisualizationModel()
  vis_cavity.SetName("vis_cavity")
  vis_cavity.SetFileName(fn5)
  vis_cavity.SetTextureFileName(fn5t)
  vis_cavity.SetOpacity(1.0)
  
  # Organ element (cavity)
  e_cavity = vtkesqui.vtkScenarioElement()
  e_cavity.SetName("e_cavity")
  e_cavity.SetPosition(0.0, 0.0, -1.0)
  e_cavity.SetOrientation(-45, 0, 0)
  e_cavity.SetVisualizationModel(vis_cavity)
  
  cavity = vtkesqui.vtkOrgan()
  cavity.SetName("cavity")
  cavity.AddElement(e_cavity)
  scenario.AddObject(cavity)
  
   # Add a ball
  # Visualization model
  vis_ball = vtkesqui.vtkVisualizationModel()
  vis_ball.SetName("vis_ball")
  vis_ball.SetFileName(fn4)
  vis_ball.SetColor(1.0,1.0,0.2)
  vis_ball.SetOpacity(1.0)
  
  # Collision model
  col_ball = vtkesqui.vtkCollisionModel()
  col_ball.SetName("col_ball_vtkbioeng")
  col_ball.SetFileName(fn4c)
  col_ball.SetVisibility(0.0)
  col_ball.SetOpacity(0.0)

  # Organ element (ball)
  e_ball = vtkesqui.vtkScenarioElement()
  e_ball.SetName("e_ball")
  e_ball.SetVisualizationModel(vis_ball)
  e_ball.SetCollisionModel(col_ball)
  
  ball = vtkesqui.vtkOrgan()
  ball.SetName("ball")
  ball.AddElement(e_ball)
 
  scenario.AddObject(ball)

  # Scenario camera
  camera = vtk.vtkCamera()
  camera.SetPosition(0, 0, 6)
  camera.SetFocalPoint(0, 0, -6)
  camera.Yaw(0)
  camera.Elevation(20)
  camera.Pitch(-15)
  camera.ParallelProjectionOff()
  camera.SetViewAngle(70)
  camera.Dolly(1.2)
  scenario.SetCamera(camera)
  
  #/********** Lights  **********/
  headLight = vtk.vtkLight()
  headLight.SetLightTypeToHeadlight()
  headLight.PositionalOn()
  headLight.SetIntensity(0.7)
  headLight.SetConeAngle(90)
  scenario.AddLight(headLight)
  
  ambientLight = vtk.vtkLight()
  ambientLight.SetLightTypeToSceneLight()
  ambientLight.PositionalOff()
  ambientLight.SetPosition(0,1,1)
  ambientLight.SetIntensity(0.5)
  scenario.AddLight(ambientLight)

  simulation = vtkesqui.vtkSimulation()
  simulation.SetScenario(scenario)
  simulation.SetRenderTimerRate(30)
  simulation.SetSimulationTimerRate(1)
  simulation.SetInteractionTimerRate(1)
  simulation.InteractionOn()
  simulation.CollisionOn()
  simulation.Initialize()
  
  #Wait for initialization to set collision mode
  simulation.SetCollisionModeToSimple()
  
  # Sign up to receive TimerEvent
  iren = scenario.GetRenderWindowInteractor()
  cb = vtkTimerCallback()
  iren.AddObserver('TimerEvent', cb.execute)
  # 100ms timer
  timerId = iren.CreateRepeatingTimer(100);
  cb.simulation = simulation
  cb.target = ball
  
  simulation.Run()
开发者ID:Motiva,项目名称:vtkESQui,代码行数:101,代码来源:LapCoordination.py


示例10:

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

# 将多边形渲染导入场景渲染器,并设置场景和窗口的初始参数
ren.AddActor(cylinderActor)
ren.SetBackground(0.1, 0.2, 0.4)
renWin.SetSize(200, 200)

# 普通的鼠标交互控件
style = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(style)


# 这一段用于设置照明,一共两个,蓝色和绿色
myLight = vtk.vtkLight()
myLight.SetColor(0, 1,0)
myLight.SetPosition(0, 0, 1)
myLight.SetFocalPoint(ren.GetActiveCamera().GetFocalPoint())
ren.AddLight(myLight)

myLight2 = vtk.vtkLight()
myLight2.SetColor(0, 0, 1)
myLight2.SetPosition(0, 0, -1)
myLight2.SetFocalPoint(ren.GetActiveCamera().GetFocalPoint())
ren.AddLight(myLight2)


# 开始进行可视化的开始
iren.Initialize()
开发者ID:EntropyAran,项目名称:GraduationProjectOnVTK,代码行数:30,代码来源:初始化例子.py


示例11:

outline.SetInputConnection(normals.GetOutputPort())
mapOutline = vtk.vtkPolyDataMapper()
mapOutline.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(mapOutline)
outlineActor.GetProperty().SetColor(0, 0, 0)

# Create a vtkCamera, and set the camera parameters.
camera = vtk.vtkCamera()
camera.SetClippingRange(1.60187, 20.0842)
camera.SetFocalPoint(0.21406, 1.5, 0)
camera.SetPosition(8.3761, 4.94858, 4.12505)
camera.SetViewUp(0.180325, 0.549245, -0.815974)

# Create a vtkLight, and set the light parameters.
light = vtk.vtkLight()
light.SetFocalPoint(0.21406, 1.5, 0)
light.SetPosition(8.3761, 4.94858, 4.12505)

# Create the Renderers.  Assign them the appropriate viewport
# coordinates, active camera, and light.
ren = vtk.vtkRenderer()
ren.SetViewport(0, 0, 0.5, 1.0)
ren.SetActiveCamera(camera)
ren.AddLight(light)
ren2 = vtk.vtkRenderer()
ren2.SetViewport(0.5, 0, 1.0, 1.0)
ren2.SetActiveCamera(camera)
ren2.AddLight(light)

# Create the RenderWindow and RenderWindowInteractor.
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:cubeAxes.py


示例12: FringeSimulator

    def FringeSimulator(self, file_name, file_output):
        
 
        reader = vtk.vtkPLYReader()
        reader.SetFileName(file_name)
        reader.Update()

        smooth = vtk.vtkWindowedSincPolyDataFilter()   
        smooth.SetInput(reader.GetOutput())
        smooth.Update()
  
        normals = vtk.vtkPolyDataNormals()
        normals.SetInput(smooth.GetOutput())
        normals.SetComputePointNormals(1)
        normals.SetComputeCellNormals(1)
        normals.Update()

        mapper=vtk.vtkDataSetMapper()
        mapper.SetInput(smooth.GetOutput())
        mapper.SetScalarVisibility(1)

        actor = vtk.vtkActor()
        actor.GetProperty().SetInterpolationToFlat()
        actor.SetMapper(mapper)

        self.renderer.AddActor(actor)

        key_properties = vtk.vtkInformation()
        key_properties.Set(vtk.vtkShadowMapBakerPass.OCCLUDER(),0) #// dummy val.
        key_properties.Set(vtk.vtkShadowMapBakerPass.RECEIVER(),0) #// dummy val.

        actor.SetPropertyKeys(key_properties)
        actor.SetVisibility(1)

        self.renderer.ResetCamera()
        cam = self.renderer.GetActiveCamera()

        cam_pos = cam.GetPosition()
        cam_f =  cam.GetFocalPoint()

        vcam_pos = numpy.array([float(cam_pos[0]), float(cam_pos[1]), float(cam_pos[2])])
        vcam_f = numpy.array([float(cam_f[0]),float(cam_f[1]),float(cam_f[2])])

        v = vcam_f - vcam_pos 
        d = numpy.linalg.norm(v)
        vn = v/d

        ap = vtk.vtkAppendPolyData()
        dist_fringes = cam_pos - vn * -250

        for x in xrange(-220, 220):
            cube_source= vtk.vtkCubeSource()
            cube_source.SetXLength(0.20)
            cube_source.SetYLength(80)
            cube_source.SetZLength(0.1)

            xfm = vtk.vtkTransform()
            xfm.Translate(float(x) * 0.40, 0, 0) 

            xfmPd = vtk.vtkTransformPolyDataFilter()
            xfmPd.SetInput(cube_source.GetOutput())
            xfmPd.SetTransform(xfm)

            ap.AddInput(xfmPd.GetOutput())

        ap.Update()


        xfm = vtk.vtkTransform()
        xfm.Translate(200, dist_fringes[1], dist_fringes[2])

        xfmPd = vtk.vtkTransformPolyDataFilter()
        xfmPd.SetInput(ap.GetOutput())
        xfmPd.SetTransform(xfm)

        cube_mapper=vtk.vtkPolyDataMapper()
        cube_mapper.SetInput(xfmPd.GetOutput())


        fringes_actor = vtk.vtkActor()
        fringes_actor.SetMapper(cube_mapper)
        fringes_actor.GetProperty().SetColor(1,0,0)

        fringesKeyProperties=vtk.vtkInformation()
        fringesKeyProperties.Set(vtk.vtkShadowMapBakerPass.OCCLUDER(),0) #// dummy val.
        fringesKeyProperties.Set(vtk.vtkShadowMapBakerPass.RECEIVER(),0) #// dummy val.
        fringes_actor.SetPropertyKeys(fringesKeyProperties)

        self.renderer.AddActor(fringes_actor)
        
        self.renderer.LightFollowCameraOff()
        self.renderer.AutomaticLightCreationOff()
        self.renderer.RemoveAllLights()
        self.renderer.UpdateLights()

        l = vtk.vtkLight()
        l.SetLightTypeToSceneLight()

        dist_light = cam_pos - vn * 6

#.........这里部分代码省略.........
开发者ID:paulojamorim,项目名称:fgrc-tools,代码行数:101,代码来源:fringe_projection.py


示例13:

ren.AddActor(actor)
ren.AddActor(titleActor)
ren.AddActor(outlineActor)
ren.AddActor(axes)

### need to make a camera object in pyvisi!!!
ren.ResetCamera()
cam = ren.GetActiveCamera()
cam.Azimuth(0)
cam.Elevation(-90)
cam.SetFocalPoint(centre)
ren.SetActiveCamera(cam)
ren.ResetCameraClippingRange()

# play around with lighting
light = vtk.vtkLight()
light.SetFocalPoint(centre)
light.SetPosition(centre[0]-bounds[1],
	centre[1]-bounds[3],
	centre[2]+bounds[5])
ren.AddLight(light)

light2 = vtk.vtkLight()
light2.SetFocalPoint(centre)
light2.SetPosition(centre[0]+bounds[1],
	 centre[1]+bounds[3],
	 centre[2]-bounds[5])
ren.AddLight(light2)

# set up stuff for interactive viewing
iren = vtk.vtkRenderWindowInteractor()
开发者ID:paultcochrane,项目名称:pyvisi,代码行数:31,代码来源:isosurfacePlot.py


示例14:

sphereKeyProperty = vtk.vtkInformation()
sphereKeyProperty.Set(vtk.vtkShadowMapBakerPass.OCCLUDER(),0)
sphereKeyProperty.Set(vtk.vtkShadowMapBakerPass.RECEIVER(),0)
sphereActor.SetPropertyKeys(sphereKeyProperty)
sphereActor.SetMapper(sphereMapper)

sphereActor.SetVisibility(1)
sphereActor.SetPosition(2,2,-1)
sphereActor.GetProperty().SetColor(1,1,0)

renderer.AddViewPro(rectActor)
renderer.AddViewPro(boxActor)
renderer.AddViewPro(coneActor)
renderer.AddViewPro(sphereActor)

l1 = vtk.vtkLight()
l1.SetPosition(-4,4,-1)
l1.SetFocalPOint(boxActor.GetPosition())
l1.SetColor(1,1,1)
l1.SetPositional(1)
renderer.AddLight(l1)
l1.SetSwitch(1)

l2 = vtk.vtkLight()
l2.SetPosition(-4,5,1)
l2.SetFocalPOint(sphereActor.GetPosition())
l2.SetColor(1,0,1)
l2.SetPositional(1)
renderer.AddLight(l2)
l2.SetSwitch(1)
开发者ID:Beastmaster,项目名称:itk-python-example,代码行数:30,代码来源:vtkCreateShadows.py


示例15: __init__


#.........这里部分代码省略.........
        self.sim_layout = QtGui.QVBoxLayout( self.widget )
        self.sim_layout.setObjectName( 'sim_layout' )
    
        self.logo_label = QtGui.QLabel( self.widget )
        self.logo_label.setPixmap( QtGui.QPixmap( 'icons/application_logo.png' ) )
        self.logo_label.setObjectName( 'logo_label' )
    
        self.sim_layout.addWidget( self.logo_label )
    
        self.qvtk_widget = QVTKRenderWindowInteractor.QVTKRenderWindowInteractor( self.widget )
        self.qvtk_widget.setObjectName( 'qvtk_widget' )
        
        self.sphere = vtk.vtkSphereSource()
        self.sphere.SetRadius( 1.0 )
        self.sphere.SetPhiResolution( 100 )
        self.sphere.SetThetaResolution( 100 )
        
        self.sphereMapper = vtk.vtkPolyDataMapper()
        self.sphereMapper.SetInputConnection( self.sphere.GetOutputPort() )
        
        self.sphereActor = vtk.vtkActor()
        self.sphereActor.SetMapper( self.sphereMapper )
        
        self.sphereActorCentral = vtk.vtkActor()
        self.sphereActorCentral.SetMapper( self.sphereMapper )
        
        self.sphereActorCentral.GetProperty().SetDiffuseColor(1, 1, 0)
        
        self.ren1 = vtk.vtkRenderer()
        self.ren1.AddActor( self.sphereActor )
        self.ren1.AddActor( self.sphereActorCentral )
        self.ren1.SetBackground( 0.1, 0.2, 0.4 )
        
        self.light = vtk.vtkLight()
        self.light.SetPosition( - 200, - 200, 200 )
        
        self.ren1.AddLight( self.light )
        
        self.cam = self.ren1.GetActiveCamera()
        self.cam.SetPosition( 0, - 50, 50 )
        self.cam.SetFocalPoint( 0, 0, 0 )
        self.cam.SetViewUp( 0, 1, 0 )
        self.cam.SetViewAngle( 40 )
        
        self.ren1.SetActiveCamera( self.cam )

        self.sphere.SetRadius( 2 )
        
        self.renderWindow = self.qvtk_widget.GetRenderWindow()
        self.renderWindow.AddRenderer( self.ren1 )
    
        self.sim_layout.addWidget( self.qvtk_widget )
    
        self.setCentralWidget( self.centralwidget )
        
        # ===
        # MainWindow MenuBar
        # ===
        self.menubar = QtGui.QMenuBar( self )
        self.menubar.setGeometry( QtCore.QRect( 0, 0, 800, 21 ) )
        self.menubar.setObjectName( 'menubar' )
    
        self.menu_simulation = QtGui.QMenu( self.menubar )
        self.menu_simulation.setObjectName( 'menu_simulation' )
    
        self.menu_help = QtGui.QMenu( self.menubar )
开发者ID:fatality,项目名称:hsa-repo,代码行数:67,代码来源:Client.py


示例16: main


#.........这里部分代码省略.........
  textures.append(fn4tl)
  textures.append(fn4tr)
  textures.append(fn4tb)
  
  reader = vtk.vtkXMLPolyDataReader()
  reader.SetFileName(fn4)
  reader.Update()
  
  readerc = vtk.vtkXMLPolyDataReader()
  readerc.SetFileName(fn4c)
  readerc.Update()
  
  for i in range(9):
    
    # Define organ type
    # 3 organs of each type (left, right and both)
    t = i%3
    px = int(i/3)
    
    # Add a ball
    # Visualization model
    vis_ball = vtkesqui.vtkVisualizationModel()
    vis_ball.SetName("vis_ball"+str(i))
    vis_ball.SetFileName(fn4)
    vis_ball.SetTextureFileName(textures[t])
    vis_ball.SetOpacity(1.0)
  
    # Collision model
    col_ball = vtkesqui.vtkCollisionModel()
    col_ball.SetName("col_ball_vtkbioeng"+str(i))
    col_ball.SetFileName(fn4c)
    col_ball.SetVisibility(0.0)
    col_ball.SetOpacity(0.0)

    # Organ element (ball)
    #x = -3 + i*2.0
    e_ball = vtkesqui.vtkScenarioElement()
    e_ball.SetName("e_ball"+str(i))
    e_ball.SetPosition(px-1, -2*t, -3)
    e_ball.SetOrientation(15, -0, 0)
    e_ball.SetVisualizationModel(vis_ball)
    e_ball.SetCollisionModel(col_ball)
  
    ball = vtkesqui.vtkOrgan()
    ball.SetName("ball_"+str(i)+"_"+str(t))
    ball.AddElement(e_ball)
    ball.Update()
    ball.Disable()

    scenario.AddObject(ball)
    balls.append(ball)
  
  # Scenario camera
  camera = vtk.vtkCamera()
  camera.SetPosition(0, 0, 6)
  camera.SetFocalPoint(0, 0, -6)
  camera.Yaw(0)
  camera.Elevation(20)
  camera.Pitch(-15)
  camera.ParallelProjectionOff()
  camera.SetViewAngle(70)
  camera.Dolly(1.2)
  scenario.SetCamera(camera)
  
  #/********** Lights  **********/
  headLight = vtk.vtkLight()
  headLight.SetLightTypeToHeadlight()
  headLight.PositionalOn()
  headLight.SetIntensity(0.8)
  headLight.SetConeAngle(60)
  scenario.AddLight(headLight)
  
  ambientLight = vtk.vtkLight()
  ambientLight.SetLightTypeToSceneLight()
  ambientLight.PositionalOff()
  ambientLight.SetIntensity(0.1)
  scenario.AddLight(ambientLight)

  simulation = vtkesqui.vtkSimulation()
  simulation.SetScenario(scenario)
  simulation.SetRenderTimerRate(30)
  simulation.SetSimulationTimerRate(1)
  simulation.SetInteractionTimerRate(1)
  simulation.InteractionOn()
  simulation.CollisionOn()
  simulation.Initialize()
  
  #Wait for initialization to set collision mode
  simulation.SetCollisionModeToSimple()
  
  # Sign up to receive TimerEvent
  iren = scenario.GetRenderWindowInteractor()
  cb = vtkTimerCallback()
  iren.AddObserver('TimerEvent', cb.execute)
  # 100ms timer
  timerId = iren.CreateRepeatingTimer(100);
  cb.simulation = simulation
  cb.organs = balls
  
  simulation.Run()
开发者ID:Motiva,项目名称:vtkESQui,代码行数:101,代码来源:LapPrecisionSpeed.py


示例17: main


#.........这里部分代码省略.........
    def_ball.SetTimeStep(0.001)

    # Organ element (ball)
    e_ball = vtkesqui.vtkScenarioElement()
    e_ball.SetName("ball")
    e_ball.SetPosition(0.0, 0.0, -2.0)
    e_ball.SetOrientation(0, 0, 0)
    e_ball.SetVisualizationModel(vis_ball)
    e_ball.SetCollisionModel(col_ball)
    e_ball.SetDeformationModel(def_ball)

    ball = vtkesqui.vtkOrgan()
    ball.AddElement(e_ball)

    # Add an Organ (Cavity)
    # Visualization model
    vis_cavity = vtkesqui.vtkVisualizationModel()
    vis_cavity.SetName("vis_cavity")
    vis_cavity.SetFileName(fn5)
    vis_cavity.SetTextureFileName(fn5t)
    vis_cavity.SetOpacity(1.0)

    # Collision model
    col_cavity = vtkesqui.vtkCollisionModel()
    col_cavity.SetName("col_cavity_vtkbioeng")
    col_cavity.SetFileName(fn5c)
    col_cavity.SetOpacity(0.0)

    # Deformation model
    def_cavity = vtkesqui.vtkParticleSpringSystemInterface()
    def_cavity.SetName("def_cavity_particle")
    def_cavity.SetFileName(fn5d)
    def_cavity.SetOpacity(0.0)
    def_cavity.SetSpring(150)
    def_cavity.SetDistance(1.0)
    def_cavity.SetDamping(3)
    def_cavity.SetMass(0.1)
    def_cavity.SetTimeStep(0.001)

    # Organ element (cavity)
    e_cavity = vtkesqui.vtkScenarioElement()
    e_cavity.SetName("cavity")
    e_cavity.SetPosition(0.0, 0.0, -2.0)
    e_cavity.SetOrientation(-30, 0, 0)
    e_cavity.SetVisualizationModel(vis_cavity)
    e_cavity.SetCollisionModel(col_cavity)
    e_cavity.SetDeformationModel(def_cavity)

    cavity = vtkesqui.vtkOrgan()
    cavity.AddElement(e_cavity)

    scenario = vtkesqui.vtkScenario()
    scenario.SetName("vtkESQui - Laparoscopy")

    scenario.AddObject(probe_l)
    scenario.AddObject(grasper_r)
    scenario.AddObject(ball)
    scenario.AddObject(cavity)

    # Scenario camera
    camera = vtk.vtkCamera()
    camera.SetPosition(0, 0, 6)
    camera.SetFocalPoint(0, 0, -6)
    camera.Yaw(0)
    camera.Elevation(20)
    camera.Pitch(-15)
    camera.ParallelProjectionOff()
    camera.SetViewAngle(70)
    camera.Dolly(1.2)
    scenario.SetCamera(camera)

    # /********** Lights	**********/
    headLight = vtk.vtkLight()
    headLight.SetLightTypeToHeadlight()
    headLight.PositionalOn()
    headLight.SetIntensity(0.8)
    headLight.SetConeAngle(60)
    scenario.AddLight(headLight)

    ambientLight = vtk.vtkLight()
    ambientLight.SetLightTypeToSceneLight()
    ambientLight.PositionalOff()
    ambientLight.SetPosition(0, 1, 1)
    ambientLight.SetIntensity(0.5)
    scenario.AddLight(ambientLight)

    style = vtkesqui.vtkDefaultInteractorStyle()
    style.SetScenario(scenario)

    simulation = vtkesqui.vtkSimulation()
    simulation.SetScenario(scenario)
    simulation.SetInteractorStyle(style)
    simulation.SetRenderTimerRate(50)
    simulation.SetSimulationTimerRate(50)
    simulation.SetInteractionTimerRate(50)
    simulation.InteractionOn()
    simulation.CollisionOn()
    simulation.Initialize()

    simulation.Run()
开发者ID:Motiva,项目名称:vtkESQui,代码行数:101,代码来源:Laparoscopy.py


示例18: showLayer


#.........这里部分代码省略.........
        self.dataImporterG.SetDataExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)
        #self.dataImporter.SetWholeExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)
        self.dataImporterG.SetWholeExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)
        
        
        fb=gzip.open(self.fname[:-3]+"voxb","rb")
        dataBlue=pickle.load(fb)
        self.data_matrix_blue=numpy.uint8(dataBlue)
        self.data_matrix_blue = self.data_matrix_blue[sliceInt-1:sliceInt+1,:,:] 
        self.dataImporterB = vtk.vtkImageImport()
        data_string = self.data_matrix_blue.tostring()
        self.dataImporterB.CopyImportVoidPointer(data_string, len(data_string))
        self.dataImporterB.SetDataScalarTypeToUnsignedChar()
        self.dataImporterB.SetNumberOfScalarComponents(1)
        xdim,ydim,zdim=self.data_matrix_blue.shape
        #self.dataImporter.SetDataExtent(0, zdim-1, 0, vtkPiecewiseFunctionb-1, 0, xdim-1)
        self.dataImporterB.SetDataExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)
        #self.dataImporter.SetWholeExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)
        self.dataImporterB.SetWholeExtent(0, zdim-1, 0, ydim-1, 0, xdim-1)

        
        self.append = vtk.vtkImageAppendComponents() 
        self.append.SetInputConnection(self.dataImporterR.GetOutputPort()) 
        self.append.AddInputConnection(self.dataImporterG.GetOutputPort()) 
        self.append.AddInputConnection(self.dataImporterB.GetOutputPort()) 
        self.append.Update() 
        
        volumeMapper = vtk.vtkSmartVolumeMapper()
        volumeMapper.SetInputConnection(self.append.GetOutputPort())
        
        volumeProperty = vtk.vtkVolumeProperty() 
        volumeProperty.ShadeOff()
        volumeProperty.SetInterpolationTypeToLinear()
        volumeProperty.IndependentComponentsOn()
        
        opacityTF1 = vtk.vtkPiecewiseFunction() 
        opacityTF1.AddPoint(   0.0,  0.0 ) 
        opacityTF1.AddPoint(   1.0,  0.33)
        opacityTF1.AddPoint(   128.0, 0.33) 
        opacityTF1.AddPoint(   255.0,  0.33 ) 
        volumeProperty.SetScalarOpacity(0,opacityTF1) 
        
        colourTF1 = vtk.vtkColorTransferFunction() 
        colourTF1.AddRGBPoint(   0.0,  0.0, 0.0, 0.0 ) 
        colourTF1.AddRGBPoint(   1.0,  0.0, 0.0, 0.1 )
        colourTF1.AddRGBPoint(   128.0, 0.0, 0.0, 0.5 ) 
        colourTF1.AddRGBPoint(   255.0, 0.0, 0.0, 1.0 ) 
        volumeProperty.SetColor(0,colourTF1)
        
        opacityTF2 = vtk.vtkPiecewiseFunction() 
        opacityTF2.AddPoint(   0.0,  0.0 ) 
        opacityTF2.AddPoint(   1.0,  0.33 ) 
        opacityTF2.AddPoint(   128.0, 0.33)
        opacityTF2.AddPoint(   255.0,  0.33 ) 
        volumeProperty.SetScalarOpacity(1,opacityTF2) 
        
        colourTF2 = vtk.vtkColorTransferFunction() 
        colourTF2.AddRGBPoint(   0.0,  0.0, 0.0, 0.0 ) 
        colourTF2.AddRGBPoint(   1.0,  0.0, 0.1, 0.0 )
        colourTF2.AddRGBPoint(   128.0, 0.0, 0.5, 0.0 ) 
        colourTF2.AddRGBPoint(   255.0, 0.0, 1.0, 0.0 ) 
        volumeProperty.SetColor(1,colourTF2)
        
        opacityTF3 = vtk.vtkPiecewiseFunction() 
        opacityTF3.AddPoint(   0.0,  0.0 ) 
        opacityTF3.AddPoint(   1.0,  0.33 ) 
        opacityTF3.AddPoint(   128.0, 0.33)
        opacityTF3.AddPoint(   255.0,  0.33 ) 
        volumeProperty.SetScalarOpacity(2,opacityTF3) 
        
        colourTF3 = vtk.vtkColorTransferFunction() 
        colourTF3.AddRGBPoint(   0.0,  0.0, 0.0, 0.0 ) 
        colourTF3.AddRGBPoint(   1.0,  0.1, 0.0, 0.0 )
        colourTF3.AddRGBPoint(   128.0, 0.5, 0.0, 0.0 ) 
        colourTF3.AddRGBPoint(   255.0, 1.0, 0.0, 0.0 ) 
        volumeProperty.SetColor(2,colourTF3)
   
        self.volume.SetMapper(volumeMapper)
        self.volume.SetProperty(volumeProperty)
                    
        #self.ren.RemoveActor(self.actor)
                    
        self.ren.AddVolume(self.volume)
        self.ren.SetBackground(0, 0, 0)
        # A simple function to be called when the user decides to quit the application.
        def exitCheck(obj, event):
            if obj.GetEventPending() != 0:
                obj.SetAbortRender(1)
                                     
            # Tell the application to use the function as an exit check.
        light = vtk.vtkLight()
        #light.SetColor(1, 1, 1)
        light.SwitchOff()
        self.ren.AddLight(light)
        
        renderWin = self.vtkWidget.GetRenderWindow()
        renderWin.AddObserver("AbortCheckEvent", exitCheck)
                    
        self.iren.Initialize()
        self.iren.Start()
开发者ID:JonathanWang1,项目名称:somethingMyOwn,代码行数:101,代码来源:layerView.py


示例19: Lighting

sphereMapper = vtk.vtkPolyDataMapper()
sphereMapper.SetInputConnection(sphere.GetOutputPort())

sphereActor = vtk.vtkActor()
sphereActor.SetMapper(sphereMapper)
sphereActor.GetProperty().SetColor(1, 0, 0)
sphereActor.GetProperty().SetAmbient(0.3)
sphereActor.GetProperty().SetDiffuse(0.0)
sphereActor.GetProperty().SetSpecular(0.5)

ren1 = vtk.vtkRenderer()
ren1.AddActor(sphereActor)
ren1.SetBackground(0.1, 0.2, 0.4)

light1 = vtk.vtkLight()
light1.SetFocalPoint(0, 0, 0)
light1.SetPosition(-0.8, 0.8, 1)
ren1.AddLight(light1)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.SetSize(300, 300)

# for i in xrange(334):
#     sphereActor.GetProperty().SetAmbient(i * 0.03)
#     renWin.Render()

def Lighting(obj, ev):
    global i
    i += 1
开发者ID:sulei1324,项目名称:3Dswc,代码行数:30,代码来源:light.py


示例20: __init__

    def __init__(self,parent = None):
        super(robotWindow,self).__init__(parent = None)
        self.setupUi(self)
        
        self.robot = palmModel()
               
        self.vtkWidget = QVTKRenderWindowInteractor(self.robotWidget)
        self.ren = vtk.vtkRenderer()
        
        lightPosition = [0,0,1]
        lightFocalPoint = [0,0,0]
        light = vtk.vtkLight()
        light.SetLightTypeToSceneLight()
        light.SetPosition(lightPosition[0], lightPosition[1], lightPosition[2])
        light.SetPositional(True) 
        light.SetConeAngle(10)
        light.SetFocalPoint(lightFocalPoint[0], lightFocalPoint[1], lightFocalPoint[2])
        light.SetDiffuseColor(1,0,0)
        light.SetAmbientColor(0,1,0)
        light.SetSpecularColor(0,0,1)
       

        lightActor = vtk.vtkLightActor()
        lightActor.SetLight(light)
        self.ren.AddViewProp(lightActor)
    
        self.ren.SetBackground(0, 0.6, 0.9)
        self.renderWindow = self.vtkWidget.GetRenderWindow()
        self.renderWindow.AddRenderer(self.ren)
        self.style = vtk.vtkInteractorStyleTrackballCamera()  
        self.vtkWidget.SetInteractorStyle(self.style)
        
        self.checkBox = [self.thumbChectBox,self.foreCheckBox,self.middleCheckBox,
                         self.ringCheckBox,self.littleCheckBox]

        if not self.thumbChectBox.isChecked():
       

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkLine函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkLabeledDataMapper函数代码示例发布时间: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