本文整理汇总了Python中vtk.vtkTexture函数的典型用法代码示例。如果您正苦于以下问题:Python vtkTexture函数的具体用法?Python vtkTexture怎么用?Python vtkTexture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkTexture函数的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: __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
示例16:
# 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()
sphereMapper.SetInputConnection(sphereStripper.GetOutputPort())
sphereMapper.ScalarVisibilityOff()
sphereTexture = vtk.vtkTexture()
sphereTexture.SetInputConnection(reader.GetOutputPort())
sphereProperty = vtk.vtkProperty()
sphereProperty.BackfaceCullingOn()
sphere = vtk.vtkActor()
sphere.SetMapper(sphereMapper)
sphere.SetTexture(sphereTexture)
sphere.SetProperty(sphereProperty)
#---------------------------------------------------------
ren.AddViewProp(sphere)
camera = ren.GetActiveCamera()
camera.SetFocalPoint(0, 0, 0)
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:SurfacePickerWithTexture.py
示例17: SetUp
def SetUp(self):
'''
Set up squadViewer
'''
def OnClosing():
self.root.quit()
def SetPhi(squad, win, phi):
squad.SetPhiRoundness(float(phi))
win.Render()
def SetTheta(squad, win, theta):
squad.SetThetaRoundness(float(theta))
win.Render()
def SetThickness(squad, win, thickness):
squad.SetThickness(float(thickness))
win.Render()
def SetTexture(actor, texture, win):
if doTexture.get():
actor.SetTexture(texture)
else:
actor.SetTexture(None)
win.Render()
def SetToroid(squad, scale, win):
squad.SetToroidal(toroid.get())
if toroid.get():
scale.config(state=NORMAL, fg='black')
else:
scale.config(state=DISABLED, fg='gray')
win.Render()
self.root = tkinter.Tk()
self.root.title("superquadric viewer")
# Define what to do when the user explicitly closes a window.
self.root.protocol("WM_DELETE_WINDOW", OnClosing)
# Create render window
self.tkrw = vtkTkRenderWidget(self.root, width=550, height=450)
self.tkrw.BindTkRenderWidget()
renWin = self.tkrw.GetRenderWindow()
# Create parameter sliders
#
prs = tkinter.Scale(self.root, from_=0, to=3.5, res=0.1,
orient=HORIZONTAL, label="phi roundness")
trs = tkinter.Scale(self.root, from_=0, to=3.5, res=0.1,
orient=HORIZONTAL, label="theta roundness")
thicks = tkinter.Scale(self.root, from_=0.01, to=1.0, res=0.01,
orient=HORIZONTAL, label="thickness")
# Create check buttons
#
toroid = tkinter.IntVar()
toroid.set(0)
doTexture = tkinter.IntVar()
doTexture.set(0)
rframe = tkinter.Frame(self.root)
torbut = tkinter.Checkbutton(rframe, text="Toroid", variable=toroid)
texbut = tkinter.Checkbutton(rframe, text="Texture", variable=doTexture)
# Put it all together
#
torbut.pack(padx=10, pady=5, ipadx=20, ipady=5, side=RIGHT, anchor=S)
texbut.pack(padx=10, pady=5, ipadx=20, ipady=5, side=RIGHT, anchor=S)
self.tkrw.grid(sticky=N+E+W+S, columnspan=2)
rframe.grid(sticky=N+E+W+S)
thicks.grid(sticky=N+S+E+W, padx=10, ipady=5, row=1, column=1)
prs.grid(sticky=N+E+W+S, padx=10, ipady=5, row = 2, column = 0)
trs.grid(sticky=N+E+W+S, padx=10, ipady=5, row = 2, column = 1)
tkinter.Pack.propagate(rframe,NO)
prs.set(1.0)
trs.set(0.7)
thicks.set(0.3)
toroid.set(1)
doTexture.set(0)
# Create pipeline
#
squad = vtk.vtkSuperquadricSource()
squad.SetPhiResolution(20)
squad.SetThetaResolution(25)
pnmReader = vtk.vtkPNMReader()
pnmReader.SetFileName(VTK_DATA_ROOT + "/Data/earth.ppm")
atext = vtk.vtkTexture()
atext.SetInputConnection(pnmReader.GetOutputPort())
atext.InterpolateOn()
appendSquads = vtk.vtkAppendPolyData()
appendSquads.AddInputConnection(squad.GetOutputPort())
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(squad.GetOutputPort())
mapper.ScalarVisibilityOff()
#.........这里部分代码省略.........
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:101,代码来源:squadViewer.py
示例18: vtkGetDataRoot
#!/usr/bin/env python
# This simple example shows how to do basic texture mapping.
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Load in the texture map. A texture is any unsigned char image. If it
# is not of this type, you will have to map it through a lookup table
# or by using vtkImageShiftScale.
bmpReader = vtk.vtkBMPReader()
bmpReader.SetFileName(VTK_DATA_ROOT + "/Data/masonry.bmp")
atext = vtk.vtkTexture()
atext.SetInputConnection(bmpReader.GetOutputPort())
atext.InterpolateOn()
# Create a plane source and actor. The vtkPlanesSource generates
# texture coordinates.
plane = vtk.vtkPlaneSource()
planeMapper = vtk.vtkPolyDataMapper()
planeMapper.SetInputConnection(plane.GetOutputPort())
planeActor = vtk.vtkActor()
planeActor.SetMapper(planeMapper)
planeActor.SetTexture(atext)
# Create the RenderWindow, Renderer and both Actors
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
开发者ID:0004c,项目名称:VTK,代码行数:31,代码来源:TPlane.py
示例19: 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
示例20: testParametricFunctions
def testParametricFunctions(self):
# ------------------------------------------------------------
# Get a texture
# ------------------------------------------------------------
textureReader = vtk.vtkJPEGReader()
textureReader.SetFileName(VTK_DATA_ROOT + "/Data/beach.jpg")
texture = vtk.vtkTexture()
texture.SetInputConnection(textureReader.GetOutputPort())
# ------------------------------------------------------------
# For each parametric surface:
# 1) Create it
# 2) Assign mappers and actors
# 3) Position the object
# 5) Add a label
# ------------------------------------------------------------
# ------------------------------------------------------------
# Create a torus
# ------------------------------------------------------------
torus = vtk.vtkParametricTorus()
torusSource = vtk.vtkParametricFunctionSource()
torusSource.SetParametricFunction(torus)
torusSource.SetScalarModeToPhase()
torusMapper = vtk.vtkPolyDataMapper()
torusMapper.SetInputConnection(torusSource.GetOutputPort())
torusMapper.SetScalarRange(0, 360)
torusActor = vtk.vtkActor()
torusActor.SetMapper(torusMapper)
torusActor.SetPosition(0, 12, 0)
torusTextMapper = vtk.vtkTextMapper()
torusTextMapper.SetInput("Torus")
torusTextMapper.GetTextProperty().SetJustificationToCentered()
torusTextMapper.GetTextProperty().SetVerticalJustificationToCentered()
torusTextMapper.GetTextProperty().SetColor(1, 0, 0)
torusTextMapper.GetTextProperty().SetFontSize(14)
torusTextActor = vtk.vtkActor2D()
torusTextActor.SetMapper(torusTextMapper)
torusTextActor.GetPositionCoordinate().SetCoordinateSystemToWorld()
torusTextActor.GetPositionCoordinate().SetValue(0, 9.5, 0)
# ------------------------------------------------------------
# Create a Klein bottle
# ------------------------------------------------------------
klein = vtk.vtkParametricKlein()
kleinSource = vtk.vtkParametricFunctionSource()
kleinSource.SetParametricFunction(klein)
kleinSource.SetScalarModeToU0V0()
kleinMapper = vtk.vtkPolyDataMapper()
kleinMapper.SetInputConnection(kleinSource.GetOutputPort())
kleinMapper.SetScalarRange(0, 3)
kleinActor = vtk.vtkActor()
kleinActor.SetMapper(kleinMapper)
kleinActor.SetPosition(8, 10.5, 0)
kleinTextMapper = vtk.vtkTextMapper()
kleinTextMapper.SetInput("Klein")
kleinTextMapper.GetTextProperty().SetJustificationToCentered()
kleinTextMapper.GetTextProperty().SetVerticalJustificationToCentered()
kleinTextMapper.GetTextProperty().SetColor(1, 0, 0)
kleinTextMapper.GetTextProperty().SetFontSize(14)
kleinTextActor = vtk.vtkActor2D()
kleinTextActor.SetMapper(kleinTextMapper)
kleinTextActor.GetPositionCoordinate().SetCoordinateSystemToWorld()
kleinTextActor.GetPositionCoordinate().SetValue(8, 9.5, 0)
# ------------------------------------------------------------
# Create a Figure-8 Klein
# ------------------------------------------------------------
klein2 = vtk.vtkParametricFigure8Klein()
klein2Source = vtk.vtkParametricFunctionSource()
klein2Source.SetParametricFunction(klein2)
klein2Source.GenerateTextureCoordinatesOn()
klein2Mapper = vtk.vtkPolyDataMapper()
klein2Mapper.SetInputConnection(klein2Source.GetOutputPort())
klein2Mapper.SetScalarRange(0, 3)
klein2Actor = vtk.vtkActor()
klein2Actor.SetMapper(klein2Mapper)
klein2Actor.SetPosition(16, 12, 0)
klein2Actor.SetTexture(texture)
fig8KleinTextMapper = vtk.vtkTextMapper()
fig8KleinTextMapper.SetInput("Fig-8.Klein")
fig8KleinTextMapper.GetTextProperty().SetJustificationToCentered()
fig8KleinTextMapper.GetTextProperty().SetVerticalJustificationToCentered()
fig8KleinTextMapper.GetTextProperty().SetColor(1, 0, 0)
fig8KleinTextMapper.GetTextProperty().SetFontSize(14)
fig8KleinTextActor = vtk.vtkActor2D()
fig8KleinTextActor.SetMapper(fig8KleinTextMapper)
fig8KleinTextActor.GetPositionCoordinate().SetCoordinateSystemToWorld()
fig8KleinTextActor.GetPositionCoordinate().SetValue(16, 9.5, 0)
#.........这里部分代码省略.........
开发者ID:timkrentz,项目名称:SunTracker,代码行数:101,代码来源:TestParametricFunctions.py
注:本文中的vtk.vtkTexture函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论