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


Python vtk.vtkTexture函数代码示例

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


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

示例1: __init_renderer

    def __init_renderer(self, list_of_planets):

        for planet in list_of_planets:
            actor = vtk.vtkActor()
            #sphere = vtk.vtkSphereSource()
            sphere = vtk.vtkTexturedSphereSource()
            mapper = vtk.vtkPolyDataMapper()
            sphere.SetPhiResolution(20)
            sphere.SetThetaResolution(20)
            scaled_radius = planet.get_radius() * self.__scale_planet_radius 
            if(planet.id == 0):
                scaled_radius = planet.get_radius() * self.__scale_sun_radius
            
            sphere.SetRadius(scaled_radius)
            mapper.SetInput(sphere.GetOutput())
            graphic_name = "../textures/"+planet.get_name()+".jpg"
            graphic_reader = vtk.vtkJPEGReader()
            graphic_reader.SetFileName(graphic_name)
            graphic_texture = vtk.vtkTexture()
            graphic_texture.SetInputConnection(graphic_reader.GetOutputPort())
            graphic_texture.InterpolateOn()
            actor.SetTexture(graphic_texture)
            actor.SetMapper(mapper)
            actor.SetScale(1,1,1)
            actor.SetPosition(int(self.__scale_planet_orbit_inner*planet.get_posVector_x()), 
                              int(self.__scale_planet_orbit_inner*planet.get_posVector_y()), 
                              int(self.__scale_planet_orbit_inner*planet.get_posVector_z()))
            self.__renderer.AddActor(actor)
            self.__list_of_actors.append(actor)
开发者ID:fuesika,项目名称:ts-py-planet-sim,代码行数:29,代码来源:planetSim.py

示例2: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkTexture(), 'Processing.',
         ('vtkImageData',), (),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkTexture.py

示例3: showTexture

 def showTexture(self):
     self.reader  = vtk.vtkJPEGReader()
     self.reader.SetFileName(os.path.join(os.path.split(__file__)[0], 'earth.jpg'))
     self.texture = vtk.vtkTexture()
     self.texture.SetInput(self.reader.GetOutput())
     self.sphere._actor.GetProperty().SetColor(1.0, 1.0, 1.0)
     self.sphere._actor.SetTexture(self.texture)
开发者ID:jraedler,项目名称:SimuVis4,代码行数:7,代码来源:Objects.py

示例4: addCube

    def addCube(self,pos,tam,img=False):
        jpegfile = "struct.jpg"
        
        # Read the image data from a file
        reader = vtk.vtkJPEGReader()
        reader.SetFileName(jpegfile)
         
        (x,y,z) = pos
        (i,j,k) = tam

        cubito = vtk.vtkCubeSource()
        cubito.SetXLength(0.2*i)
        cubito.SetYLength(0.2*j)
        cubito.SetZLength(0.2*k)
        cubito.SetCenter((x,y,z)) 
        if img == True:
            
            # Create texture object
            texture = vtk.vtkTexture()
            if vtk.VTK_MAJOR_VERSION <= 5:
                texture.SetInput(reader.GetOutput())
            else:
                texture.SetInputConnection(reader.GetOutputPort())
            # Map texture coordinates
            map_to_sphere = vtk.vtkTextureMapToPlane()
            if vtk.VTK_MAJOR_VERSION <= 5:
                map_to_sphere.SetInput(cubito.GetOutput())
            else:
                map_to_sphere.SetInputConnection(cubito.GetOutputPort())
            #map_to_sphere.PreventSeamOn()
             
            # Create mapper and set the mapped texture as input
            mapper = vtk.vtkPolyDataMapper()
            if vtk.VTK_MAJOR_VERSION <= 5:
                mapper.SetInput(map_to_sphere.GetOutput())
            else:
                mapper.SetInputConnection(map_to_sphere.GetOutputPort())
            
        

        planeMapper = vtk.vtkPolyDataMapper()
        planeMapper.SetInputConnection(cubito.GetOutputPort())
        planeActor = (vtk.vtkActor())
        if (img == True):
            planeActor.SetMapper(mapper)
        else:
            planeActor.SetMapper(planeMapper)# mapper planeMapper
        planeActor.DragableOn()
        planeActor.SetDragable(1)
        if (img== True):
            planeActor.SetTexture(texture)
        else:
            planeActor.GetProperty().SetColor(.0,.3,.6)
            planeActor.GetProperty().SetOpacity(0.95)
        #planeActor.GetProperty().SetAmbient(0)
        #planeActor.GetProperty().SetDiffuse(0.9)
        #planeActor.GetProperty().SetSpecular(0.1)
        self.render.AddActor(planeActor)
        
        return planeActor
开发者ID:Jovior85,项目名称:NavEsp,代码行数:60,代码来源:Renderer.py

示例5: getSphericalMap

    def getSphericalMap( self, **args ):
        thetaResolution = args.get( "thetaRes", 32 )
        phiResolution = args.get( "phiRes", 32 )
        radius = args.get( "radius", 100 )
        if self.sphereActor == None: 
            self.sphere = vtk.vtkSphereSource()
            self.sphere.SetThetaResolution( thetaResolution )
            self.sphere.SetPhiResolution( phiResolution )
            self.sphere.SetRadius( radius )   
            self.sphere.SetEndTheta( 359.999 )    
            mesh = self.sphere.GetOutput()
            
            self.sphereTexmapper = vtk.vtkTextureMapToSphere()
            if vtk.VTK_MAJOR_VERSION <= 5:  self.sphereTexmapper.SetInput(mesh)
            else:                           self.sphereTexmapper.SetInputData(mesh)        
            self.sphereTexmapper.PreventSeamOff()
            
            self.sphereMapper = vtk.vtkPolyDataMapper()
            self.sphereMapper.SetInputConnection(self.sphereTexmapper.GetOutputPort())
                                   
            imageFlipper = vtk.vtkImageFlip()
            if vtk.VTK_MAJOR_VERSION <= 5:  imageFlipper.SetInput(self.sphericalBaseImage)
            else:                           imageFlipper.SetInputData(self.sphericalBaseImage)        
            imageFlipper.SetFilteredAxis( 1 ) 
            
            self.sphereTexture = vtk.vtkTexture()
            self.sphereTexture.SetInputConnection( imageFlipper.GetOutputPort()  )
            
            self.sphereActor = vtk.vtkActor()
            self.sphereActor.SetMapper(self.sphereMapper)
            self.sphereActor.SetTexture(self.sphereTexture)
#            self.sphereActor.GetProperty().SetOpacity( self.map_opacity )
            self.sphereActor.SetVisibility( False )  

        return self.sphereActor
开发者ID:ThomasMaxwell,项目名称:UVIS_DV3D,代码行数:35,代码来源:MapManager.py

示例6: Texture

    def Texture(self, currentElement):
        self.logger.debug('  inside a <Texture> element: "%s"' % currentElement.get('name'))
        texture = vtk.vtkTexture()

        # Datatype(s) I need for input: ImageReader
        ImageReaderNode = ''
        for childElement in currentElement.getchildren():
            if childElement.tag in vtkTypes['ImageReader']:
                ImageReaderNode = childElement
        if ImageReaderNode != '':
            imageReader = self.namesToFunctions[ImageReaderNode.tag](ImageReaderNode)
            try:
                texture.SetInputConnection(imageReader.GetOutputPort())
            except:
                self.logger.error('  .. <Texture> failed to SetInputConnection')
        else:
            self.logger.error('  .. <Texture> needs an ImageReader-type childElement.')

        if 'SetRepeat' in currentElement.keys():
            try:
                texture.SetRepeat(int( currentElement.get('SetRepeat')))
            except:
                self.logger.error('  .. <Texture> failed to SetRepeat')
        if 'SetInterpolate' in currentElement.keys():
            try:
                texture.SetInterpolate(int( currentElement.get('SetInterpolate')))
            except:
                self.logger.error('  .. <Texture> failed to SetInterpolate')
        return texture
开发者ID:mfassler,项目名称:jaivis,代码行数:29,代码来源:xmlReader.py

示例7: __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

示例8: _MakeXYActors

    def _MakeXYActors(self, reduce=1):
        # get a texture-mapped actor
        extent = self._ImageReslice.GetOutputExtent()
        origin = self._ImageReslice.GetOutputOrigin()
        spacing = self._ImageReslice.GetOutputSpacing()

        bounds = [origin[0] + spacing[0] * (extent[0] - 0.5),
                  origin[0] + spacing[0] * (extent[1] + 0.5),
                  origin[1] + spacing[1] * (extent[2] - 0.5),
                  origin[1] + spacing[1] * (extent[3] + 0.5),
                  origin[2] + spacing[2] * (extent[4] - 0.5),
                  origin[2] + spacing[2] * (extent[5] + 0.5)]

        for sliceNumber in range(extent[4], old_div((extent[5] + 1), reduce)):
            # the z position of the slice
            z = origin[2] + reduce * sliceNumber * spacing[2]

            plane = vtk.vtkPlaneSource()
            plane.SetXResolution(1)
            plane.SetYResolution(1)
            plane.SetOrigin(bounds[0], bounds[2], z)
            plane.SetPoint1(bounds[1], bounds[2], z)
            plane.SetPoint2(bounds[0], bounds[3], z)

            imageClip = vtk.vtkExtractVOI()
            imageClip.SetInput(self._ImageToStructuredPoints.GetOutput())
            imageClip.SetVOI(extent[0], extent[1],
                             extent[2], extent[3],
                             reduce * sliceNumber, reduce * sliceNumber)
            imageClip.ReleaseDataFlagOn()

            texture = vtk.vtkTexture()
            texture.SetQualityTo32Bit()
            texture.SetInput(imageClip.GetOutput())
            texture.RepeatOff()
            texture.InterpolateOn()
            texture.MapColorScalarsThroughLookupTableOff()

            for i in range(3):
                mapper = vtk.vtkPolyDataMapper()
                mapper.SetInput(plane.GetOutput())
                mapper.SetClippingPlanes(self._ClippingPlanes[i])

                actor = vtk.vtkActor()
                actor.SetMapper(mapper)
                actor.SetTexture(texture)
                actor.PickableOff()
                actor.SetProperty(self._PropertyXY)

                self._PlanesXY.append(plane)
                self._ImageClipsXY.append(imageClip)
                self._ActorsXY.append(actor)

        numberOfPlanes = (extent[5] - extent[4] + 1) / reduce * 3
        return self._ActorsXY[-numberOfPlanes:]
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:55,代码来源:VolumePlanesFactory.py

示例9: create_textured_plane

def create_textured_plane(**kwargs):
    """
    create a plane with correct size and texture it with a map
    """
    image_reader = vtk.vtkPNGReader()
    image_reader.SetFileName(kwargs['map'])

    plane = vtk.vtkPlaneSource()
    size = kwargs['size']
    z_level = 0.0
    plane.SetOrigin(-0.5*size[0], -0.5*size[1], z_level)
    plane.SetPoint1(+0.5*size[0], -0.5*size[1], z_level)
    plane.SetPoint2(-0.5*size[0], +0.5*size[1], z_level)

    texture = vtk.vtkTexture()
    texture.SetInputConnection(image_reader.GetOutputPort())

    texture_plane = vtk.vtkTextureMapToPlane()
    texture_plane.SetInputConnection(plane.GetOutputPort())
    return texture_plane, texture
开发者ID:capitalaslash,项目名称:radcal-gui,代码行数:20,代码来源:map.py

示例10: make_texture_overly_object

    def make_texture_overly_object(self):
        input_image = self.session.overlay_image_fname
        reader = vtk.vtkJPEGReader()
        reader.SetFileName(input_image)
        texture = vtk.vtkTexture()
        texture.SetInput(reader.GetOutput())
        texture.SetInputConnection(reader.GetOutputPort())
        texture.InterpolateOn()

        plane = vtk.vtkPlaneSource()
        plane.SetOrigin((0, 0, 0))
        plane.SetPoint1(self.bounds.lat_max_distance)
        plane.SetPoint2(self.bounds.long_max_distance)

        planeMapper = vtk.vtkPolyDataMapper()
        planeMapper.SetInputConnection(plane.GetOutputPort())
        self.overlayActor = vtk.vtkActor()
        self.overlayActor.SetMapper(planeMapper)
        self.overlayActor.SetTexture(texture)
        self.actors.append(self.overlayActor)
开发者ID:hardbyte,项目名称:QuakeCloud,代码行数:20,代码来源:mulitview_beta.py

示例11: __init__

 def __init__(self, renderer, parent, screenDistance, width, height, isActiveCamera = False):
     '''
     Initialize the CameraScreen model.
     If you are going to stream data to it, set isActiveCamera to true in the constructor parameters and pass jpeg data to the update method.
     '''
     # Call the parent constructor
     super(CameraScreen,self).__init__(renderer, parent)
     
     # Create a plane for the camera 
     # Ref: http://www.vtk.org/doc/nightly/html/classvtkPlaneSource.html
     planeSource = vtk.vtkPlaneSource()
     # Defaults work for this, so just push it out a bit
     #planeSource.Push(screenDistance)
     
     # Transform scale it to the right size
     trans = vtk.vtkTransform()
     trans.Scale(width, height, 1)
     trans.Translate(0, 0, screenDistance)
     trans.RotateY(180) # Effectively flipping the UV (texture) mapping so that the video isn't left/right flipped
     transF = vtk.vtkTransformPolyDataFilter()
     transF.SetInputConnection(planeSource.GetOutputPort())
     transF.SetTransform(trans)
     
     # Create a test picture and assign it to the screen for now...
     # Ref: http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/Rendering/Python/TPlane.py
     if not isActiveCamera:
         self.__textReader = vtk.vtkPNGReader()
         self.__textReader.SetFileName("../scene/media/semisortedcameralogo.png")
     else:
         self.__textReader = vtk.vtkJPEGReader()
     self.cameraVtkTexture = vtk.vtkTexture()
     self.cameraVtkTexture.SetInputConnection(self.__textReader.GetOutputPort())
     self.cameraVtkTexture.InterpolateOn()        
     
     # Finally assign the mapper and the actor
     planeMapper = vtk.vtkPolyDataMapper()
     planeMapper.SetInputConnection(transF.GetOutputPort())
      
     self.vtkActor.SetMapper(planeMapper)
     self.vtkActor.SetTexture(self.cameraVtkTexture)
开发者ID:GearsAD,项目名称:semisorted_arnerve,代码行数:40,代码来源:CameraScreen.py

示例12: _createOrthoPipelineForNewIPW

    def _createOrthoPipelineForNewIPW(self, ipw):
        """This will create and append all the necessary constructs for a
        single new layer (ipw) to the self._orthoPipeline.

        Make sure you only call this method if the orthoView exists!
        After having done this, you still need to call _syncOrthoView() or
        _resetOrthoView() if you've added a new primary.
        """

        _ps = vtk.vtkPlaneSource()
        _pa = vtk.vtkActor()
        _tm2p = vtk.vtkTextureMapToPlane()
        self._orthoPipeline.append(
            {'planeSource' : _ps,
             'planeActor' : _pa,
             'textureMapToPlane': _tm2p})

        _tm2p.AutomaticPlaneGenerationOff()
        _tm2p.SetInput(_ps.GetOutput())
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(_tm2p.GetOutput())
        _pa.SetMapper(mapper)

        otherTexture = ipw.GetTexture()

        # we don't just use the texture, else VTK goes mad re-uploading
        # the same texture unnecessarily... let's just make use of the
        # same input, we get much more effective use of the
        # host->GPU bus
        texture = vtk.vtkTexture()
        texture.SetInterpolate(otherTexture.GetInterpolate())
        texture.SetQuality(otherTexture.GetQuality())
        texture.MapColorScalarsThroughLookupTableOff()
        texture.RepeatOff()
        texture.SetInput(otherTexture.GetInput())

        _pa.SetTexture(texture)

        self._renderer.AddActor(_pa)
开发者ID:fvpolpeta,项目名称:devide,代码行数:39,代码来源:sliceDirection.py

示例13: __init__

    def __init__( self, color, plane, reslice, range ):
        
        self._color = color
    
        self._source = plane
                
        self._mapper = vtk.vtkPolyDataMapper()
        self._mapper.SetInput( self._source.GetOutput() )
        self.SetMapper( self._mapper )

        self._lut = vtk.vtkWindowLevelLookupTable()
        self._lut.SetNumberOfColors( 256 )
        self._lut.SetTableRange( range[0], range[1] )
        self._lut.SetHueRange( 0.0, 0.0 )
        self._lut.SetSaturationRange( 0.0, 0.0 )
        self._lut.SetValueRange( 0.0, 1.0 )
        self._lut.SetAlphaRange( 0.0, 1.0 )
        self._lut.Build()

        self._colormap = vtk.vtkImageMapToColors()
        self._colormap.SetInputConnection( reslice.GetOutputPort() )
        self._colormap.SetLookupTable( self._lut )
        self._colormap.SetOutputFormatToRGBA()
        self._colormap.PassAlphaToOutputOn()

        self._texture = vtk.vtkTexture()
        self._texture.SetInterpolate( True )
        self._texture.SetQualityTo32Bit()
        self._texture.MapColorScalarsThroughLookupTableOff()
        self._texture.RepeatOff()
        self._texture.SetInput( self._colormap.GetOutput() )
        self._texture.SetLookupTable( self._lut )
        self.SetTexture( self._texture )

        self._property = vtk.vtkProperty()
        self._property.SetOpacity( 0.9 )
        self._property.EdgeVisibilityOn()
        self._property.SetEdgeColor( self._color[0], self._color[1], self._color[2] )
        self.SetProperty( self._property )
开发者ID:aevum,项目名称:moonstone,代码行数:39,代码来源:sliceplanewidget.py

示例14: __init__

 def __init__(self, sim, pos, dims, density, fixed=False):
     # ODE initialization
     x, y, z = pos # initial pos
     lx, ly, lz = dims # dimensions
     self.sim = sim # link to the sim object
     self.body = ode.Body(self.sim.world) # ode body
     mass = ode.Mass() # mass object
     mass.setBox(density, lx, ly, lz) # calculate mass
     self.body.setMass(mass) # link mass to body
     self.body.setPosition(pos) # set the initial pos
     self.geom = ode.GeomBox(self.sim.space, lengths=dims) # geometry
     self.geom.setBody(self.body) # link geometry and body
     if fixed:
         self.fixedJoint = ode.FixedJoint(self.sim.world)
         self.fixedJoint.attach(self.body,self.sim.space.getBody())
         self.fixedJoint.setFixed()
     # VTK initialization
     self.math = vtk.vtkMath()
     self.cube = vtk.vtkCubeSource()
     self.cube.SetXLength(lx)
     self.cube.SetYLength(ly)
     self.cube.SetZLength(lz)
     self.cube.SetCenter((0.0,0.0,0.0))
     self.reader = vtk.vtkJPEGReader()
     self.reader.SetFileName(ROBOT_IMAGE)
     self.texture = vtk.vtkTexture()
     transform = vtk.vtkTransform()
     transform.Scale(1.0,1.0,1.0)
     self.texture.SetTransform(transform)
     self.texture.SetInput(self.reader.GetOutput())
     self.mapper = vtk.vtkPolyDataMapper()
     self.mapper.SetInput(self.cube.GetOutput())
     self.actor = vtk.vtkActor()
     self.actor.SetMapper(self.mapper)
     self.actor.SetTexture(self.texture)
     sim.renderer.AddActor(self.actor)
     # Self-include in the bodies for visualization
     sim.bodies.append(self)
开发者ID:fuesika,项目名称:pyrobosim,代码行数:38,代码来源:robot.py

示例15: showRender

    def showRender(self):
        
        jpegfile = "/home/jose/Documentos/PFC/PFC/sphere.jpg"
        # Read the image data from a file
        reader = vtk.vtkJPEGReader()
        reader.SetFileName(jpegfile)
        reader.Update()
                # Create texture object
        texture = vtk.vtkTexture()
        
        if vtk.VTK_MAJOR_VERSION <= 5:
            texture.SetInput(reader.GetOutput())
        else:
            texture.SetInputConnection(reader.GetOutputPort())
        #self.render.SetTexturedBackground(True)
        
        #self.render.SetBackgroundTexture(texture)
        self.render.GradientBackgroundOn()
        self.render.SetBackground2(0.4,0.5,0.9)
        self.render.SetBackground(0.3,0.3,0.3)

        self.pantalla.Initialize()
        self.pantalla.Start()
开发者ID:Jovior85,项目名称:NavEsp,代码行数:23,代码来源:Renderer.py


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