本文整理汇总了Python中vtk.vtkJPEGReader函数的典型用法代码示例。如果您正苦于以下问题:Python vtkJPEGReader函数的具体用法?Python vtkJPEGReader怎么用?Python vtkJPEGReader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkJPEGReader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkJPEGReader(), 'Reading vtkJPEG.',
(), ('vtkJPEG',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkJPEGReader.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: __init__
def __init__(self, module_manager):
ModuleBase.__init__(self, module_manager)
self._state = STATE_INIT
self._config.filename = None
self._current_measurement = None
# pogo line first
# outline of larynx second
self._actors = []
# list of pointwidgets, first is apex, second is lm, others
# are others. :)
self._markers = []
self._pogo_line_source = None
self._area_polydata = None
self._view_frame = None
self._viewer = None
self._reader = vtk.vtkJPEGReader()
self._create_view_frame()
self._bind_events()
self.view()
# all modules should toggle this once they have shown their
# stuff.
self.view_initialised = True
self.config_to_logic()
self.logic_to_config()
self.config_to_view()
开发者ID:fvpolpeta,项目名称:devide,代码行数:33,代码来源:LarynxMeasurement.py
示例6: buildPipeline
def buildPipeline(self):
""" execute() -> None
Dispatch the vtkRenderer to the actual rendering widget
"""
module = self.getRegisteredModule()
world_map = None # wmod.forceGetInputFromPort( "world_map", None ) if wmod else None
opacity = wmod.forceGetInputFromPort( "opacity", 0.4 ) if wmod else 0.4
map_border_size = wmod.forceGetInputFromPort( "map_border_size", 20 ) if wmod else 20
self.y0 = -90.0
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
self.world_cut = wmod.forceGetInputFromPort( "world_cut", -1 ) if wmod else getFunctionParmStrValues( module, "world_cut", -1 )
roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ]
map_cut_size = [ roi_size[0] + 2*map_border_size, roi_size[1] + 2*map_border_size ]
data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = NormalizeLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
image_reader = vtk.vtkJPEGReader()
image_reader.SetFileName( self.map_file )
baseImage = image_reader.GetOutput()
new_dims = None
if dataPosition == None:
baseImage = self.RollMap( baseImage )
new_dims = baseImage.GetDimensions()
else:
baseImage, new_dims = self.getBoundedMap( baseImage, dataPosition, map_cut_size )
scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
# printArgs( " baseMap: ", extent=baseImage.GetExtent(), spacing=baseImage.GetSpacing(), origin=baseImage.GetOrigin() )
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( opacity )
# self.baseMapActor.SetDisplayExtent( -1, 0, 0, 0, 0, 0 )
#Positioning map at location %s, size = %s, roi = %s" % ( str( ( self.x0, self.y0) ), str( map_cut_size ), str( ( NormalizeLon( self.roi[0] ), NormalizeLon( self.roi[1] ), self.roi[2], self.roi[3] ) ) )
self.baseMapActor.SetPosition( self.x0, self.y0, 0.1 )
self.baseMapActor.SetInput( baseImage )
self.renderer.AddActor( self.baseMapActor )
开发者ID:imclab,项目名称:vistrails,代码行数:58,代码来源:WorldMapModule.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: FileExtensionsDescriptor
def FileExtensionsDescriptor(cls):
# cheap way
#return 'JPEG Images|*.jpg;*.jpeg;*.JPG;*.JPEG'
# dynamic way
descriptor = 'JPEG Images'
extensions = vtk.vtkJPEGReader().GetFileExtensions().split(' ')
extensions.extend([item.upper() for item in extensions])
extensions = ['*'+item for item in extensions]
return '|'.join([descriptor, ';'.join(extensions)])
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:10,代码来源:jpeg.py
示例9: build
def build( self, **args ):
if self.enableBasemap:
# print " @@@ MapManager: build "
world_map = None
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
# data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if self.roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = self.NormalizeMapLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
self.image_reader = vtk.vtkJPEGReader()
self.image_reader.SetFileName( self.map_file )
self.image_reader.Update()
world_image = self.image_reader.GetOutput()
self.sphericalBaseImage = self.RollMap( world_image )
new_dims, scale = None, None
if dataPosition == None:
self.baseImage = self.RollMap( world_image )
new_dims = self.baseImage.GetDimensions()
scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
self.width = 360.0
else:
self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition )
scale = [ self.map_cut_size[0]/new_dims[0], self.map_cut_size[1]/new_dims[1], 1 ]
self.width = self.map_cut_size[0]
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( self.map_opacity )
mapCorner = [ self.x0, self.y0 ]
self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.05 )
extent = self.baseImage.GetExtent()
# print " @@@ baseImage.GetExtent: ", str( extent )
# print " @@@ baseImage.Position: ", str( self.x0 )
# print " @@@ baseImage.Size: ", str( self.map_cut_size )
if vtk.VTK_MAJOR_VERSION <= 5: self.baseMapActor.SetInput(self.baseImage)
else: self.baseMapActor.SetInputData(self.baseImage)
self.mapCenter = [ self.x0 + self.map_cut_size[0]/2.0, self.y0 + self.map_cut_size[1]/2.0 ]
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:55,代码来源:MapManager.py
示例10: build
def build( self, **args ):
if self.enableBasemap:
world_map = None
dataPosition = None
if world_map == None:
self.map_file = defaultMapFile
self.map_cut = defaultMapCut
else:
self.map_file = world_map[0].name
self.map_cut = world_map[1]
roi_size = [ self.roi[1] - self.roi[0], self.roi[3] - self.roi[2] ]
map_cut_size = [ roi_size[0] + 2*self.map_border_size, roi_size[1] + 2*self.map_border_size ]
if map_cut_size[0] > 360.0: map_cut_size[0] = 360.0
if map_cut_size[1] > 180.0: map_cut_size[1] = 180.0
# data_origin = self.input().GetOrigin() if self.input() else [ 0, 0, 0 ]
if self.world_cut == -1:
if (self.roi <> None):
if roi_size[0] > 180:
self.ComputeCornerPosition()
self.world_cut = self.NormalizeMapLon( self.x0 )
else:
dataPosition = [ ( self.roi[1] + self.roi[0] ) / 2.0, ( self.roi[3] + self.roi[2] ) / 2.0 ]
else:
self.world_cut = self.map_cut
self.imageInfo = vtk.vtkImageChangeInformation()
self.image_reader = vtk.vtkJPEGReader()
self.image_reader.SetFileName( self.map_file )
self.image_reader.Update()
world_image = self.image_reader.GetOutput()
self.sphericalBaseImage = self.RollMap( world_image )
new_dims, scale = None, None
if dataPosition == None:
self.baseImage = self.RollMap( world_image )
new_dims = self.baseImage.GetDimensions()
scale = [ 360.0/new_dims[0], 180.0/new_dims[1], 1 ]
else:
self.baseImage, new_dims = self.getBoundedMap( world_image, dataPosition, map_cut_size, self.map_border_size )
scale = [ map_cut_size[0]/new_dims[0], map_cut_size[1]/new_dims[1], 1 ]
self.baseMapActor = vtk.vtkImageActor()
self.baseMapActor.SetOrigin( 0.0, 0.0, 0.0 )
self.baseMapActor.SetScale( scale )
self.baseMapActor.SetOrientation( 0.0, 0.0, 0.0 )
self.baseMapActor.SetOpacity( self.map_opacity )
mapCorner = [ self.x0, self.y0 ]
self.baseMapActor.SetPosition( mapCorner[0], mapCorner[1], 0.1 )
if vtk.VTK_MAJOR_VERSION <= 5: self.baseMapActor.SetInput(self.baseImage)
else: self.baseMapActor.SetInputData(self.baseImage)
self.mapCenter = [ self.x0 + map_cut_size[0]/2.0, self.y0 + map_cut_size[1]/2.0 ]
开发者ID:UV-CDAT,项目名称:UVIS_DV3D,代码行数:52,代码来源:MapManager.py
示例11: VtkRead
def VtkRead(filepath, t):
if not const.VTK_WARNING:
log_path = os.path.join(inv_paths.USER_LOG_DIR, 'vtkoutput.txt')
fow = vtk.vtkFileOutputWindow()
fow.SetFileName(log_path.encode(const.FS_ENCODE))
ow = vtk.vtkOutputWindow()
ow.SetInstance(fow)
global no_error
if t == "bmp":
reader = vtk.vtkBMPReader()
elif t == "tiff" or t == "tif":
reader = vtk.vtkTIFFReader()
elif t == "png":
reader = vtk.vtkPNGReader()
elif t == "jpeg" or t == "jpg":
reader = vtk.vtkJPEGReader()
else:
return False
reader.AddObserver("ErrorEvent", VtkErrorToPy)
reader.SetFileName(filepath)
reader.Update()
if no_error:
image = reader.GetOutput()
dim = image.GetDimensions()
if reader.GetNumberOfScalarComponents() > 1:
luminanceFilter = vtk.vtkImageLuminance()
luminanceFilter.SetInputData(image)
luminanceFilter.Update()
image = vtk.vtkImageData()
image.DeepCopy(luminanceFilter.GetOutput())
img_array = numpy_support.vtk_to_numpy(image.GetPointData().GetScalars())
img_array.shape = (dim[1], dim[0])
return img_array
else:
no_error = True
return False
开发者ID:invesalius,项目名称:invesalius3,代码行数:48,代码来源:bitmap_reader.py
示例12: createButtonRepresentation
def createButtonRepresentation(self, **args):
self.buttonRepresentation = vtk.vtkTexturedButtonRepresentation2D()
self.buttonRepresentation.SetPlaceFactor( args.get( 'scale', 1 ) )
self.numberOfImages = len( self.names )
if self.numberOfImages:
self.buttonRepresentation.SetNumberOfStates(self.numberOfImages)
for button_index in range( self.numberOfImages ):
buttonFilePath = os.path.join( ButtonDir, '.'.join( [ self.names[ button_index ], 'jpeg' ] ) )
JPEGReader = vtk.vtkJPEGReader()
JPEGReader.SetFileName ( buttonFilePath )
JPEGReader.Update()
image_data = JPEGReader.GetOutput()
if self.image_size == None: self.image_size = image_data.GetDimensions()
self.buttonRepresentation.SetButtonTexture( button_index, image_data )
self.button_files.append( buttonFilePath )
self.setToggleProps()
开发者ID:doutriaux1,项目名称:uvcdat,代码行数:16,代码来源:ButtonBarWidget.py
示例13: 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
示例14: addLogo
def addLogo(self):
if self.logoRepresentation == None:
defaultLogoFile = os.path.join(sys.prefix,"share","vcs","uvcdat.png")
reader = vtk.vtkJPEGReader()
reader.SetFileName( defaultLogoFile )
reader.Update()
logo_input = reader.GetOutput()
self.logoRepresentation = vtk.vtkLogoRepresentation()
self.logoRepresentation.SetImage(logo_input)
self.logoRepresentation.ProportionalResizeOn ()
# self.logoRepresentation.SetPosition( 0.82, 0.0 )
# self.logoRepresentation.SetPosition2( 0.18, 0.08 )
self.logoRepresentation.SetPosition( 0.82, 1.0 )
self.logoRepresentation.SetPosition2( 0.08, 0.18 )
self.logoRepresentation.GetImageProperty().SetOpacity( 0.9 )
self.logoRepresentation.GetImageProperty().SetDisplayLocationToBackground()
self.logoWidget = vtk.vtkLogoWidget()
self.logoWidget.SetInteractor( self.renderWindowInteractor )
self.logoWidget.SetRepresentation(self.logoRepresentation)
self.logoWidget.On()
self.render()
开发者ID:arulalant,项目名称:uvcdat,代码行数:21,代码来源:DV3DPlot.py
示例15: __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
示例16: __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
示例17: 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
示例18: __init__
def __init__(self, module_manager):
ModuleBase.__init__(self, module_manager)
self._reader = vtk.vtkJPEGReader()
self._reader.SetFileDimensionality(3)
module_utils.setup_vtk_object_progress(self, self._reader,
'Reading JPG images.')
self._config.filePattern = '%03d.jpg'
self._config.firstSlice = 0
self._config.lastSlice = 1
self._config.spacing = (1,1,1)
self._config.fileLowerLeft = False
configList = [
('File pattern:', 'filePattern', 'base:str', 'filebrowser',
'Filenames will be built with this. See module help.',
{'fileMode' : wx.OPEN,
'fileMask' :
'JPG files (*.jpg)|*.jpg|All files (*.*)|*.*'}),
('First slice:', 'firstSlice', 'base:int', 'text',
'%d will iterate starting at this number.'),
('Last slice:', 'lastSlice', 'base:int', 'text',
'%d will iterate and stop at this number.'),
('Spacing:', 'spacing', 'tuple:float,3', 'text',
'The 3-D spacing of the resultant dataset.'),
('Lower left:', 'fileLowerLeft', 'base:bool', 'checkbox',
'Image origin at lower left? (vs. upper left)')]
ScriptedConfigModuleMixin.__init__(
self, configList,
{'Module (self)' : self,
'vtkJPEGReader' : self._reader})
self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:36,代码来源:JPEGReader.py
示例19:
# Do picking with an actor with a texture.
# This example draws a cone at the pick point, with the color
# of the cone set from the color of the texture at the pick position.
#
# renderer and interactor
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# read the volume
reader = vtk.vtkJPEGReader()
reader.SetFileName(VTK_DATA_ROOT + "/Data/beach.jpg")
#---------------------------------------------------------
# Do the surface rendering
sphereSource = vtk.vtkSphereSource()
sphereSource.SetRadius(100)
textureSphere = vtk.vtkTextureMapToSphere()
textureSphere.SetInputConnection(sphereSource.GetOutputPort())
sphereStripper = vtk.vtkStripper()
sphereStripper.SetInputConnection(textureSphere.GetOutputPort())
sphereStripper.SetMaximumLength(5)
sphereMapper = vtk.vtkPolyDataMapper()
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:SurfacePickerWithTexture.py
示例20: main
def main():
session = Set_Render_Variables("quake(13).csv")
data = Data_Extractor(session)
bounds = Model_Bounds_Points_Maker(data, session)
events = Timed_Event_List_Maker(data.event_list, session)
# sets up the VTK session
ren = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
#renderWindow.AddRenderer(ren)
i_ren = vtk.vtkRenderWindowInteractor()
i_ren.SetRenderWindow(renderWindow)
# text / legend object
legend = vtk.vtkCornerAnnotation()
legend.SetText(0, " Quake Cloud 3d Visualiser\n Depth Markers are 25Km Apart\n"
" All other distances are relative \n\n\n Copyright 2013 Jay Gattuso\n\n")
legend.SetMaximumFontSize(15)
# handles the overlay map image
input_image = session.overlay_image_fname
reader = vtk.vtkJPEGReader()
reader.SetFileName(input_image)
texture = vtk.vtkTexture()
texture.SetInput(reader.GetOutput())
texture.SetInputConnection(reader.GetOutputPort())
texture.InterpolateOn()
ren = vtk.vtkRenderer()
renderWindow.AddRenderer(ren)
plane = vtk.vtkPlaneSource()
plane.SetOrigin((0, 0, 0))
plane.SetPoint1(bounds.lat_max_distance)
plane.SetPoint2(bounds.long_max_distance)
# Create texture object
planeMapper = vtk.vtkPolyDataMapper()
planeMapper.SetInputConnection(plane.GetOutputPort())
planeActor = vtk.vtkActor()
planeActor.SetMapper(planeMapper)
planeActor.SetTexture(texture)
pointCloud_bounds = VtkPointCloud(data.event_max_depth)
if session.plot_boundary_markers:
for bound in bounds.bounds:
pointCloud_bounds.addPoint(bound, 10) # the number is what makes the bound markers larger
if session.plot_depth_scale:
for bound in bounds.bounds_scale:
pointCloud_bounds.addPoint(bound, 10) # the number is what makes the bound markers larger
# add basic objects (bounds, overlay, background)
ren.AddActor(pointCloud_bounds.vtkActor)
ren.AddViewProp(legend)
ren.AddActor(planeActor)
ren.SetBackground(.2, .2, .2)
ren.ResetCamera()
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
# Begin Interaction
renderWindow.Render()
# Initialize must be called prior to creating timer events.
renderWindowInteractor.Initialize()
# Sign up to receive TimerEvent
cb = vtkTimerCallback(events.timed_event_dict, data.event_max_depth, ren, renderWindow, session)
cb.actor = vtk.vtkActor()
renderWindowInteractor.AddObserver('TimerEvent', cb.execute)
timerId = renderWindowInteractor.CreateRepeatingTimer(session.replay_frame_speed)
renderWindowInteractor.Start()
开发者ID:timClicks,项目名称:QuakeCloud,代码行数:77,代码来源:Single_view_render.py
注:本文中的vtk.vtkJPEGReader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论