本文整理汇总了Python中vtk.vtkActor函数的典型用法代码示例。如果您正苦于以下问题:Python vtkActor函数的具体用法?Python vtkActor怎么用?Python vtkActor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkActor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, reader):
self.reader = reader
sg = self.src_glyph = vtk.vtkSphereSource()
sg.SetRadius(0.5)
sg.SetCenter(0.5, 0.0, 0.0)
g = self.glyph = vtk.vtkTensorGlyph()
g.SetInputConnection(self.reader.GetOutputPort())
g.SetSource(self.src_glyph.GetOutput())
g.SetScaleFactor(0.25)
# The normals are needed to generate the right colors and if
# not used some of the glyphs are black.
self.normals = vtk.vtkPolyDataNormals()
self.normals.SetInputConnection(g.GetOutputPort())
self.map = vtk.vtkPolyDataMapper()
self.map.SetInputConnection(self.normals.GetOutputPort())
self.act = vtk.vtkActor()
self.act.SetMapper(self.map)
# An outline.
self.of = vtk.vtkOutlineFilter()
self.of.SetInputConnection(self.reader.GetOutputPort())
self.out_map = vtk.vtkPolyDataMapper()
self.out_map.SetInputConnection(self.of.GetOutputPort())
self.out_act = vtk.vtkActor()
self.out_act.SetMapper(self.out_map)
示例2: plotvtk
def plotvtk(mesh,boundary):
meshMapper = vtk.vtkPolyDataMapper()
meshMapper.SetInputConnection(mesh.GetOutputPort())
meshActor = vtk.vtkActor()
meshActor.SetMapper(meshMapper)
meshActor.GetProperty().SetEdgeColor(0, 0, 1)
meshActor.GetProperty().SetInterpolationToFlat()
meshActor.GetProperty().SetRepresentationToWireframe()
boundaryMapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
boundaryMapper.SetInputConnection(boundary.GetProducerPort())
else:
boundaryMapper.SetInputData(boundary)
boundaryActor = vtk.vtkActor()
boundaryActor.SetMapper(boundaryMapper)
boundaryActor.GetProperty().SetColor(1, 0, 0)
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(meshActor)
renderer.AddActor(boundaryActor)
renderer.SetBackground(.3, .6, .3)
renderWindowInteractor.Initialize()
renderWindow.Render()
renderWindowInteractor.Start()
示例3: __init__
def __init__(self):
self.files = []
self.timestep = -1
self.geometry = vtk.vtkUnstructuredGridReader()
self.geometry_mapper = vtk.vtkDataSetMapper()
self.geometry_actor = vtk.vtkActor()
self.positions = vtk.vtkUnstructuredGridReader()
self.positions_mapper = vtk.vtkDataSetMapper()
self.positions_actor = vtk.vtkActor()
self.geometry_mapper.SetInput(self.geometry.GetOutput())
self.positions_mapper.SetInput(self.positions.GetOutput())
self.positions_mapper.ScalarVisibilityOff()
self.geometry_actor.SetMapper(self.geometry_mapper)
self.geometry_actor.GetProperty().SetOpacity(0.2)
self.positions_actor.SetMapper(self.positions_mapper)
self.positions_actor.GetProperty().SetColor(light_grey)
self.ren = vtk.vtkRenderer()
self.ren_win = GtkGLExtVTKRenderWindow()
self.ren_win.GetRenderWindow().AddRenderer(self.ren)
self.ren.AddActor(self.geometry_actor)
self.ren.AddActor(self.positions_actor)
self.ren.SetBackground(0.1, 0.2, 0.4)
示例4: __init__
def __init__(self):
# Central dot
self.dot = vtk.vtkSphereSource()
self.dot.SetThetaResolution(20)
self.dot.SetRadius(.5)
self.dotMapper = vtk.vtkPolyDataMapper()
self.dotMapper.SetInputConnection(self.dot.GetOutputPort())
self.dotActor = vtk.vtkActor()
self.dotActor.SetMapper(self.dotMapper)
# Circular halo around dot
self.halo = vtk.vtkSphereSource()
self.halo.SetThetaResolution(20)
self.halo.SetRadius(2)
self.haloMapper = vtk.vtkPolyDataMapper()
self.haloMapper.SetInputConnection(self.halo.GetOutputPort())
self.haloActor = vtk.vtkActor()
self.haloActor.SetMapper(self.haloMapper)
self.dotActor.GetProperty().SetColor(red)
self.haloActor.GetProperty().SetColor(white)
self.haloActor.GetProperty().SetOpacity(0.1)
self.haloActor.GetProperty().SetSpecular(0.6)
self.actor = vtk.vtkAssembly()
self.actor.AddPart(self.dotActor)
self.actor.AddPart(self.haloActor)
示例5: plotContinents
def plotContinents(self,x1,x2,y1,y2,projection,wrap,tmpl):
contData = vcs2vtk.prepContinents(self.canvas._continents)
contMapper = vtk.vtkPolyDataMapper()
contMapper.SetInputData(contData)
contActor = vtk.vtkActor()
contActor.SetMapper(contMapper)
contActor.GetProperty().SetColor(0.,0.,0.)
contActor = vcs2vtk.doWrap(contActor,[x1,x2,y1,y2],wrap)
if projection.type!="linear":
contData=contActor.GetMapper().GetInput()
cpts = contData.GetPoints()
geo, gcpts = vcs2vtk.project(cpts,projection,[x1,x2,y1,y2])
contData.SetPoints(gcpts)
contMapper = vtk.vtkPolyDataMapper()
contMapper.SetInputData(contData)
contActor = vtk.vtkActor()
contActor.SetMapper(contMapper)
contActor.GetProperty().SetColor(0.,0.,0.)
else:
geo=None
ren = vtk.vtkRenderer()
self.renWin.AddRenderer(ren)
self.setLayer(ren,tmpl.data.priority)
vcs2vtk.fitToViewport(contActor,ren,[tmpl.data.x1,tmpl.data.x2,tmpl.data.y1,tmpl.data.y2],wc=[x1,x2,y1,y2],geo=geo)
if tmpl.data.priority!=0:
ren.AddActor(contActor)
示例6: initPicker
def initPicker(self):
coneSource = vtk.vtkConeSource()
coneSource.CappingOn()
coneSource.SetHeight(2)
coneSource.SetRadius(1)
coneSource.SetResolution(10)
coneSource.SetCenter(1,0,0)
coneSource.SetDirection(-1,0,0)
coneMapper = vtk.vtkDataSetMapper()
coneMapper.SetInputConnection(coneSource.GetOutputPort())
self.redCone = vtk.vtkActor()
self.redCone.PickableOff()
self.redCone.SetMapper(coneMapper)
self.redCone.GetProperty().SetColor(1,0,0)
self.greenCone = vtk.vtkActor()
self.greenCone.PickableOff()
self.greenCone.SetMapper(coneMapper)
self.greenCone.GetProperty().SetColor(0,1,0)
# Add the two cones (or just one, if you want)
self.renderer.AddViewProp(self.redCone)
self.renderer.AddViewProp(self.greenCone)
self.picker = vtk.vtkVolumePicker()
self.picker.SetTolerance(1e-6)
self.picker.SetVolumeOpacityIsovalue(0.1)
示例7: render_image
def render_image(pointset):
delaunay = vtk.vtkDelaunay2D()
delaunay.SetTolerance(0.001)
delaunay.SetAlpha(18)
delaunay.SetInput(pointset);
delaunay.Update();
meshMapper = vtk.vtkPolyDataMapper()
meshMapper.SetInput(delaunay.GetOutput())
meshMapper.SetScalarRange(0,255)
meshActor = vtk.vtkActor()
meshActor.SetMapper(meshMapper)
boundaryMapper = vtk.vtkPolyDataMapper()
boundaryMapper.SetInput(delaunay.GetOutput())
boundaryActor = vtk.vtkActor()
boundaryActor.SetMapper(boundaryMapper);
boundaryActor.GetProperty().SetColor(0,0.55,0);
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(meshActor)
renderer.AddActor(boundaryActor)
renderer.SetBackground(.5, .5, .5)
renderWindow.SetSize(600, 600)
renderWindow.Render()
renderWindowInteractor.Start()
示例8: test
def test(points, springs1, springs2):
app = QApplication(sys.argv)
window = Viewer3D.SimpleView()
polydata1 = GeneratePolydata.generateLinePolydata(points, springs1)
polydata2 = GeneratePolydata.generateLinePolydata(points, springs2)
mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputData(polydata1)
actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInputData(polydata2)
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)
actor1.GetProperty().SetColor(1,0,0)
actor2.GetProperty().SetColor(0,1,0.5)
window.ren.AddActor(actor1)
window.ren.AddActor(actor2)
window.start(app)
return
示例9: make_sphere
def make_sphere():
global renderer
# ---------------------------------------------------------------
# The following code is identical to render_demo.py...
# ---------------------------------------------------------------
# create a sphere
sphere_src = vtk.vtkSphereSource()
sphere_src.SetRadius(1.0)
sphere_src.SetCenter(0.0, 0.0, 0.0)
sphere_src.SetThetaResolution(20)
sphere_src.SetPhiResolution(20)
# extract the edges
edge_extractor = vtk.vtkExtractEdges()
edge_extractor.SetInputConnection(sphere_src.GetOutputPort())
# map sphere and edges separately
sphere_mapper = vtk.vtkPolyDataMapper()
sphere_mapper.SetInputConnection(sphere_src.GetOutputPort())
edge_mapper = vtk.vtkPolyDataMapper()
edge_mapper.SetInputConnection(edge_extractor.GetOutputPort())
# define different rendering styles for sphere and edges
sphere_actor = vtk.vtkActor()
sphere_actor.SetMapper(sphere_mapper)
sphere_actor.GetProperty().SetColor(1, 0.5, 0)
edge_actor = vtk.vtkActor()
edge_actor.SetMapper(edge_mapper)
edge_actor.GetProperty().SetColor(0, 0.5, 0)
edge_actor.GetProperty().SetLineWidth(3)
# add resulting primitives to renderer
renderer.AddActor(sphere_actor)
renderer.AddActor(edge_actor)
示例10: Execute
def Execute(self):
if (self._Surface == None):
self.PrintError('vmtkPickPointSeedSelector Error: Surface not set.')
return
self._SourceSeedIds.Initialize()
self._TargetSeedIds.Initialize()
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
glyphs = vtk.vtkGlyph3D()
glyphSource = vtk.vtkSphereSource()
glyphs.SetInput(self.PickedSeeds)
glyphs.SetSource(glyphSource.GetOutput())
glyphs.SetScaleModeToDataScalingOff()
glyphs.SetScaleFactor(self._Surface.GetLength()*0.01)
glyphMapper = vtk.vtkPolyDataMapper()
glyphMapper.SetInput(glyphs.GetOutput())
self.SeedActor = vtk.vtkActor()
self.SeedActor.SetMapper(glyphMapper)
self.SeedActor.GetProperty().SetColor(1.0,0.0,0.0)
self.SeedActor.PickableOff()
self.vmtkRenderer.Renderer.AddActor(self.SeedActor)
self.vmtkRenderer.RenderWindowInteractor.AddObserver("KeyPressEvent", self.KeyPressed)
surfaceMapper = vtk.vtkPolyDataMapper()
surfaceMapper.SetInput(self._Surface)
surfaceMapper.ScalarVisibilityOff()
surfaceActor = vtk.vtkActor()
surfaceActor.SetMapper(surfaceMapper)
surfaceActor.GetProperty().SetOpacity(1.0)
self.vmtkRenderer.Renderer.AddActor(surfaceActor)
self.OutputText('Please position the mouse and press space to add source points, \'u\' to undo\n')
any = 0
while any == 0:
self.InitializeSeeds()
self.vmtkRenderer.Render()
any = self.PickedSeedIds.GetNumberOfIds()
self._SourceSeedIds.DeepCopy(self.PickedSeedIds)
self.OutputText('Please position the mouse and press space to add target points, \'u\' to undo\n')
any = 0
while any == 0:
self.InitializeSeeds()
self.vmtkRenderer.Render()
any = self.PickedSeedIds.GetNumberOfIds()
self._TargetSeedIds.DeepCopy(self.PickedSeedIds)
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
示例11: visQuadFunc
def visQuadFunc():
""" vtk sample scene with iso contours """
# VTK supports implicit functions of the form f(x,y,z)=constant. These
# functions can represent things spheres, cones, etc. Here we use a
# general form for a quadric to create an elliptical data field.
quadric = vtk.vtkQuadric()
quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)
# vtkSampleFunction samples an implicit function over the x-y-z range
# specified (here it defaults to -1,1 in the x,y,z directions).
sample = vtk.vtkSampleFunction()
sample.SetSampleDimensions(30, 30, 30)
sample.SetImplicitFunction(quadric)
# Create five surfaces F(x,y,z) = constant between range specified. The
# GenerateValues() method creates n isocontour values between the range
# specified.
contours = vtk.vtkContourFilter()
contours.SetInputConnection(sample.GetOutputPort())
contours.GenerateValues(8, 0.0, 1.2)
contMapper = vtk.vtkPolyDataMapper()
contMapper.SetInputConnection(contours.GetOutputPort())
contMapper.SetScalarRange(0.0, 1.2)
contActor = vtk.vtkActor()
contActor.SetMapper(contMapper)
# We'll put a simple outline around the data.
outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(sample.GetOutputPort())
outlineMapper = vtk.vtkPolyDataMapper()
outlineMapper.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(outlineMapper)
outlineActor.GetProperty().SetColor(1, 0.5, 0)
# extract data from the volume
extract = vtk.vtkExtractVOI()
extract.SetInputConnection(sample.GetOutputPort())
extract.SetVOI(0, 29, 0, 29, 15, 15)
extract.SetSampleRate(1, 2, 3)
contours2 = vtk.vtkContourFilter()
contours2.SetInputConnection(extract.GetOutputPort())
contours2.GenerateValues(8, 0.0, 1.2)
contMapper2 = vtk.vtkPolyDataMapper()
contMapper2.SetInputConnection(contours2.GetOutputPort())
contMapper2.SetScalarRange(0.0, 1.2)
contActor2 = vtk.vtkActor()
contActor2.SetMapper(contMapper2)
return contActor, contActor2, outlineActor, contours, contours2
示例12: BuildBackdrop
def BuildBackdrop (minX, maxX, minY, maxY, minZ, maxZ, thickness):
global basePlane
global baseMapper
global base
global backPlane
global backMapper
global back
global left
global leftPlane
global leftMapper
if not basePlane:
basePlane = vtk.vtkCubeSource()
basePlane.SetCenter( (maxX + minX)/2.0, minY, (maxZ + minZ)/2.0)
basePlane.SetXLength(maxX-minX)
basePlane.SetYLength(thickness)
basePlane.SetZLength(maxZ - minZ)
if not baseMapper:
baseMapper = vtk.vtkPolyDataMapper()
baseMapper.SetInput(basePlane.GetOutput())
if not base:
base = vtk.vtkActor()
base.SetMapper(baseMapper)
if not backPlane:
backPlane = vtk.vtkCubeSource()
backPlane.SetCenter( (maxX + minX)/2.0, (maxY + minY)/2.0, minZ)
backPlane.SetXLength(maxX-minX)
backPlane.SetYLength(maxY - minY)
backPlane.SetZLength(thickness)
if not backMapper:
backMapper = vtk.vtkPolyDataMapper()
backMapper.SetInput(backPlane.GetOutput())
if not back:
back = vtk.vtkActor()
back.SetMapper(backMapper)
if not leftPlane:
leftPlane = vtk.vtkCubeSource()
leftPlane.SetCenter( minX, (maxY+minY)/2.0, (maxZ+minZ)/2.0)
leftPlane.SetXLength(thickness)
leftPlane.SetYLength(maxY-minY)
leftPlane.SetZLength(maxZ-minZ)
if not leftMapper:
leftMapper = vtk.vtkPolyDataMapper()
leftMapper.SetInput(leftPlane.GetOutput())
if not left:
left = vtk.vtkActor()
left.SetMapper(leftMapper)
return [base, back, left]
示例13: build_constelation
def build_constelation(self,mol):
if mol.acteur == None :
MB.showwarning('Info','Select a molecule in the list')
return
if mol.symobs !=None:
mol.acteur.RemoveObserver(mol.symobs)
if mol.lsm!=[]:
for sm in mol.lsm:
self.gfx.renderer.RemoveActor(sm)
mol.lsm=[]
(xmin, xmax, ymin, ymax, zmin, zmax)= self.bounds
sym=open(self.symlistfile,'r')
for l in sym:
ms = l.split()
nbl = int(ms[6][1:])
if nbl not in mol.lnbsm:
continue
ang = [float(ms[0]),float(ms[1]),float(ms[2])]
tra = array([float(ms[3]),float(ms[4]),float(ms[5])])
sm=symmate() #on cree un symmate vide
sm.SetPosition(mol.acteur.GetPosition()) #on assigne la partie translationelle des pv
sm.SetOrientation(mol.acteur.GetOrientation()) #on assigne la partie rotationelle des pv
self.RotaEuler(sm.ut,ang[0],ang[1],ang[2]) #on defini la partie rotationelle de la transformation
sm.ut.Translate(tra[0],tra[1],tra[2]) #on defini la partie translationelle de la transformation
sm.SetUserTransform(sm.ut) #on assigne la transformation a notre symmate
pip = [sm.GetMatrix().GetElement(0,3),sm.GetMatrix().GetElement(1,3),sm.GetMatrix().GetElement(2,3)]#on recupere la partie translationelle de la combinaison de pv et de la transformation (ut)
if (xmin + self.mdbe < pip[0]) and (pip[0] < xmax - self.mdbe) and (ymin + self.mdbe < pip[1]) and (pip[1] < ymax - self.mdbe) and (zmin + self.mdbe < pip[2]) and (pip[2] < zmax - self.mdbe):# on test si pip est dans la boite
sm.nbsym=nbl
if mol.acteur.GetClassName()=='vtkAssembly':# dans le cas ou la molecule independante est un assembly
for i in range(mol.acteur.GetNumberOfPaths()):
tmp=vtk.vtkActor()
tmp.SetMapper(mol.acteur.GetParts().GetItemAsObject(i).GetMapper())
p=vtk.vtkProperty()
#p.SetColor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor())
p.SetColor(Map.invcolor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor()))
tmp.SetProperty(p)
if mol.mod.type=='mol':
tmp.GetProperty().SetLineWidth(4)
tmp.DragableOff()
tmp.PickableOff()
sm.AddPart(tmp)
else:#cas simple ou la mol ind est composer d un seul objet
tmp=vtk.vtkActor()
tmp.SetMapper(mol.acteur.GetMapper())
p=vtk.vtkProperty()
#p.SetColor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor())
p.SetColor(Map.invcolor(mol.acteur.GetProperty().GetColor()))
tmp.SetProperty(p)
if mol.mod.type=='mol':
tmp.GetProperty().SetLineWidth(4)
tmp.DragableOff()
tmp.PickableOff()
sm.AddPart(tmp)
mol.lsm+=[sm]# on ajoute le symmate a la liste des symmate
sym.close()
self.move_sym(mol)
示例14: Execute
def Execute(self):
self._SourceSeedIds.Initialize()
if not self.vmtkRenderer:
self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
self.vmtkRenderer.Initialize()
self.OwnRenderer = 1
glyphs = vtk.vtkGlyph3D()
glyphSource = vtk.vtkSphereSource()
glyphs.SetInputData(self.PickedSeeds)
glyphs.SetSourceConnection(glyphSource.GetOutputPort())
glyphs.SetScaleModeToDataScalingOff()
glyphs.SetScaleFactor(self._Surface.GetLength()*0.01)
glyphMapper = vtk.vtkPolyDataMapper()
glyphMapper.SetInputConnection(glyphs.GetOutputPort())
self.SeedActor = vtk.vtkActor()
self.SeedActor.SetMapper(glyphMapper)
self.SeedActor.GetProperty().SetColor(1.0,0.0,0.0)
self.SeedActor.PickableOff()
self.vmtkRenderer.Renderer.AddActor(self.SeedActor)
self.vmtkRenderer.AddKeyBinding('u','Undo.',self.UndoCallback)
self.vmtkRenderer.AddKeyBinding('space','Add points.',self.PickCallback)
surfaceMapper = vtk.vtkPolyDataMapper()
surfaceMapper.SetInputData(self._Surface)
surfaceMapper.ScalarVisibilityOff()
surfaceActor = vtk.vtkActor()
surfaceActor.SetMapper(surfaceMapper)
surfaceActor.GetProperty().SetOpacity(1)
self.vmtkRenderer.Renderer.AddActor(surfaceActor)
# create a text actor
txt = vtk.vtkTextActor()
info = "Position mouse and press space. "
info += "Select seeds in this order: RSpv, RIpv, LIpv, LSpv. "
info += "Fifth seed requires --use_laa_seed command."
txt.SetInput(info)
txtprop=txt.GetTextProperty()
txtprop.SetFontFamilyToArial()
txtprop.SetFontSize(13)
txtprop.SetColor(1, 1, 1)
txt.SetDisplayPosition(0, 10)
self.vmtkRenderer.Renderer.AddActor(txt)
any = 0
while any == 0:
self.InitializeSeeds()
self.vmtkRenderer.Render()
any = self.PickedSeedIds.GetNumberOfIds()
self._SourceSeedIds.DeepCopy(self.PickedSeedIds)
if self.OwnRenderer:
self.vmtkRenderer.Deallocate()
示例15: SetInputActor
def SetInputActor(self):
self.inputActor1 = vtk.vtkActor()
self.inputActor1.SetMapper(self.inputMapper1)
self.inputActor1.GetProperty().SetInterpolationToFlat()
self.inputActor2 = vtk.vtkActor()
self.inputActor2.SetMapper(self.inputMapper2)
self.inputActor3 = vtk.vtkActor()
self.inputActor3.SetMapper(self.inputMapper3)
self.inputActor4 = vtk.vtkActor()
self.inputActor4.SetMapper(self.inputMapper4)