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

Python vtk.vtkGlyph3D函数代码示例

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

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



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

示例1: Glyph3D

    def Glyph3D(self, currentElement):
        glyph = vtk.vtkGlyph3D()
        # Datatype(s) I need for input: Algorithm
        AlgorithmElement = ''
        for childElement in currentElement.getchildren():
            if childElement.tag in vtkTypes['Algorithm']:
                AlgorithmElement = childElement
        if AlgorithmElement != '':
            dataset = self.namesToFunctions[AlgorithmElement.tag](AlgorithmElement)
            try:
                glyph.SetInputConnection(dataset.GetOutputPort())
            except:
                self.logger.error('  .. <Glyph3D> failed to SetInputConnection')
        else:
            self.logger.error('  .. <Glyph3D> needs an Algorithm-type childElement')
        if 'SetSource' in currentElement.keys():
            gsourceName = currentElement.get('SetSource')
            try:
                self.logger.debug('  .. <Glyph3D> SetSource(%s)' % gsourceName)
                glyph.SetSource( self.glyphsources[gsourceName].GetOutput() )
            except:
                self.logger.error('  .. <Glyph3D> failed to SetSource')
        glyph.SetScaleModeToScaleByVector ()
        glyph.SetColorModeToColorByVector ()
        glyph.SetRange(0.0, 0.11445075055913652)
        glyph.SetScaleFactor(3.0)

        return glyph
开发者ID:mfassler,项目名称:jaivis,代码行数:28,代码来源:xmlReader.py


示例2: __init__

    def __init__(self, profile=0, radius=2):

        if not radius:
            self.radius = Globals.renderProps["sphereSize"] * 1.1
        else: self.radius = radius
        self.z = 0

        self.data = vtk.vtkPolyData()


        self.sphere = vtk.vtkSphereSource()
        self.sphere.SetRadius( Globals.referenceSize * self.radius )
        self.sphere.SetPhiResolution( Globals.renderProps["spherePhiResolution"] )
        self.sphere.SetThetaResolution( Globals.renderProps["sphereThetaResolution"] )

        self.glyphPoints = vtk.vtkGlyph3D()
        self.glyphPoints.SetInput( self.data )
        self.glyphPoints.SetSource( self.sphere.GetOutput() )

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputConnection( self.glyphPoints.GetOutputPort() )

        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper)
        if profile:
            self.actor.GetProperty().SetColor(0,0,1)
        else:
            self.actor.GetProperty().SetColor(1,1,0)

        Globals.ren.AddActor(self.actor)
开发者ID:ewong718,项目名称:freesurfer,代码行数:30,代码来源:CrossHair.py


示例3: __init__

 def __init__(self,ext_actors=None): #ext_actors is a list of any external vtkActors.
     #initializations:
     self.renderer  = vtk.vtkRenderer()
     self.window    = vtk.vtkRenderWindow()
     self.window.SetSize(1000,1000)
     self.mapper    = vtk.vtkPolyDataMapper()
     self.points    = vtk.vtkPoints()
     self.poly_data = vtk.vtkPolyData()
     self.glyph3d   = vtk.vtkGlyph3D()
     self.actor     = vtk.vtkActor()
     self.point_s   = vtk.vtkPointSource()
     self.sphere    = vtk.vtkSphereSource() 
     self.interactor= vtk.vtkRenderWindowInteractor()
     self.inter_sty = PdbInteractorStyle()
     self.axes_actor= vtk.vtkAxesActor()
     #configurations:
     self.point_s.SetNumberOfPoints(1)
     self.sphere.SetRadius(1.0)
     self.interactor.SetInteractorStyle(self.inter_sty)
     self.interactor.SetRenderWindow(self.window)
     self.axes_actor.SetTotalLength(100,100,100)
     if ext_actors:
         self.ex_actors = ext_actors
     else:
         self.ex_actors=[]
开发者ID:alinar,项目名称:Molar,代码行数:25,代码来源:pdb_viewer.py


示例4: __init__

    def __init__(self,data_reader):
        self.lut=vtk.vtkLookupTable()
        self.lut.SetNumberOfColors(256)

        self.lut.SetTableRange(data_reader.get_scalar_range())
        self.lut.SetHueRange(0,1)
        self.lut.SetRange(data_reader.get_scalar_range())
        self.lut.SetRange(data_reader.get_scalar_range())
        self.lut.Build()

        self.arrow=vtk.vtkArrowSource()
        self.arrow.SetTipResolution(6)
        self.arrow.SetTipRadius(0.1)
        self.arrow.SetTipLength(0.35)
        self.arrow.SetShaftResolution(6)
        self.arrow.SetShaftRadius(0.03)
        
        self.glyph=vtk.vtkGlyph3D()

        self.glyph.SetInput(data_reader.get_data_set())
        self.glyph.SetSource(self.arrow.GetOutput())
        self.glyph.SetVectorModeToUseVector()
        self.glyph.SetColorModeToColorByScalar()
        self.glyph.SetScaleModeToScaleByVector()
        self.glyph.OrientOn()
        self.glyph.SetScaleFactor(0.002)
		
        mapper=vtk.vtkPolyDataMapper()
        mapper.SetInput(self.glyph.GetOutput())
        mapper.SetLookupTable(self.lut)
        mapper.ScalarVisibilityOn()
        mapper.SetScalarRange(data_reader.get_scalar_range())
        self.actor=vtk.vtkActor()
        self.actor.SetMapper(mapper)	
开发者ID:bitcoinsoftware,项目名称:3D-Scientific-Visualization,代码行数:34,代码来源:Vector_Field.py


示例5: __init__

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


示例6: get_actor

    def get_actor(self):

        # cone.SetResolution(5)
        # cone.SetHeight(2)


        self.glyphs = vtk.vtkGlyph3D()
        self.glyphs.SetSourceConnection(self.e_glyph_shape.GetOutputPort())
        self.glyphs.SetColorModeToColorByScalar()

        self.centroidsPD = vtk.vtkPolyData()
        self.centroidsPD.SetPoints(self.electrode_points)
        self.centroidsPD.GetPointData().SetScalars(self.electrode_colors)

        if vtk_major_version == 5:

            self.glyphs.SetInput(self.centroidsPD)


        else:
            self.glyphs.SetInputData(self.centroidsPD)

        self.glyphsMapper = vtk.vtkPolyDataMapper()
        self.glyphsMapper.SetInputConnection(self.glyphs.GetOutputPort())

        self.glyphs.ScalingOff()  # IMPORTANT
        self.glyphs.Update()

        self.electrodes_actor = vtk.vtkActor()
        self.electrodes_actor.SetMapper(self.glyphsMapper)

        return self.electrodes_actor
开发者ID:maciekswat,项目名称:ram_plots,代码行数:32,代码来源:brain_plot_utils.py


示例7: get_electrode_glyphs

def get_electrode_glyphs(e_pts, e_colors):
    e_glyph_shape = vtk.vtkSphereSource()

    # cone.SetResolution(5)
    # cone.SetHeight(2)
    e_glyph_shape.SetRadius(3.0)

    glyphs = vtk.vtkGlyph3D()
    glyphs.SetSourceConnection(e_glyph_shape.GetOutputPort())
    glyphs.SetColorModeToColorByScalar()

    centroidsPD = vtk.vtkPolyData()
    centroidsPD.SetPoints(e_pts)
    centroidsPD.GetPointData().SetScalars(e_colors)

    if vtk_major_version == 5:

        glyphs.SetInput(centroidsPD)


    else:
        glyphs.SetInputData(centroidsPD)

    glyphs.ScalingOff()  # IMPORTANT
    glyphs.Update()

    glyphs.ScalingOff()  # IMPORTANT
    glyphs.Update()

    return glyphs
开发者ID:maciekswat,项目名称:ram_plots,代码行数:30,代码来源:brain_plot_utils.py


示例8: VtkDefineActorKPoint

def VtkDefineActorKPoint(recordGrid, renderer, radius):
  '''Returns a vtkActor to represent key-points in a rendering scene.
  It defines the scale, orientation, rendering properties, textures, ...
  
  :ivar recordGrid: unstructured grid (generic data set) to which incorporate
                    the actor KPoint
  :ivar renderer:   name of the renderer (lights, views, ...) to be used in the
                    display
  :ivar radius:     radius of the spheres to be employed in the KPoints 
                    representation
  '''
  sphereSource= vtk.vtkSphereSource()
  sphereSource.SetRadius(radius)
  sphereSource.SetThetaResolution(5)
  sphereSource.SetPhiResolution(5)
  
  markKPts= vtk.vtkGlyph3D()
  markKPts.SetInputData(recordGrid.uGrid) 
  markKPts.SetSourceData(sphereSource.GetOutput())
  markKPts.ScalingOff()
  markKPts.OrientOff()
    
  mappKPts= vtk.vtkPolyDataMapper()
  mappKPts.SetInputData(markKPts.GetOutput())

  visKPts= vtk.vtkActor()
  visKPts.SetMapper(mappKPts)
  visKPts.GetProperty().SetColor(.7, .5, .5)
    
  renderer.AddActor(visKPts)
开发者ID:lcpt,项目名称:xc,代码行数:30,代码来源:cad_mesh.py


示例9: __init__

    def __init__(self, scale=0.01, **kwargs):
        kwargs["scale"] = scale

        self.poly_data = vtk.vtkPolyData()

        self.arrow_source = vtk.vtkArrowSource()

        self.transform = vtk.vtkTransform()
        
        self.transform_poly_data_filter = vtk.vtkTransformPolyDataFilter()
        self.transform_poly_data_filter.SetTransform(self.transform)
        self.transform_poly_data_filter.SetInputConnection(self.arrow_source.GetOutputPort())

        self.glyph = vtk.vtkGlyph3D()
        self.glyph.OrientOn()
        self.glyph.SetVectorModeToUseNormal()
        self.glyph.SetInput(self.poly_data)
        self.glyph.SetSourceConnection(self.transform_poly_data_filter.GetOutputPort())

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputConnection(self.glyph.GetOutputPort())

        self.actor = vtk.vtkActor()
        self.actor.SetMapper(self.mapper)

        self._process_kwargs(**kwargs)
开发者ID:gbaydin,项目名称:autodiff,代码行数:26,代码来源:troupe.py


示例10: create_glyph

    def create_glyph(self,plane_mapper):
        #in here we do the arrows
        arrows = vtk.vtkArrowSource()


        ptMask = vtk.vtkMaskPoints()
        ptMask.SetInputConnection(plane_mapper.GetOutputPort())
        ptMask.SetOnRatio(10)
        ptMask.RandomModeOn()

        #in here we do the glyohs
        glyph = vtk.vtkGlyph3D()
        glyph.SetSourceConnection(arrows.GetOutputPort())
        glyph.SetInputConnection(ptMask.GetOutputPort())
        glyph.SetColorModeToColorByVector()
        glyph.SetScaleFactor(20)


        #Glyph mapper
        gly_mapper = vtk.vtkPolyDataMapper()
        gly_mapper.SetInputConnection(glyph.GetOutputPort())
        gly_mapper.SetLookupTable(self.arrowColor)


        #glyph actor
        gly_actor = vtk.vtkActor()
        gly_actor.SetMapper(gly_mapper)

        return gly_actor
开发者ID:svelezsaffon,项目名称:vector_field_visualization_vtk,代码行数:29,代码来源:three_planes.py


示例11: create_glyphs

    def create_glyphs (self, poly):    
        if self.glyph_type == 'sphere':
            glyph = vtk.vtkSphereSource()
            glyph.SetRadius(1)
            glyph.SetPhiResolution(8)
            glyph.SetThetaResolution(8)
        elif self.glyph_type == 'cylinder':
            glyph = vtk.vtkCylinderSource()
            glyph.SetHeight(self.height)
            glyph.SetRadius(self.radius)
            glyph.SetCenter(0,0,0)
            glyph.SetResolution(10)
            glyph.CappingOn()

        tt = vtk.vtkTransform()
        tt.RotateZ(90)
        tf = vtk.vtkTransformPolyDataFilter()
        tf.SetInput(glyph.GetOutput())
        tf.SetTransform(tt)
        tf.Update()

        glypher = vtk.vtkGlyph3D()
        glypher.SetInput(poly)
        glypher.SetSource(tf.GetOutput())
        glypher.SetVectorModeToUseNormal()
        glypher.SetScaleModeToScaleByScalar()
        glypher.SetScaleFactor(self.glyph_scale_factor)
        glypher.Update()

        return glypher
开发者ID:151706061,项目名称:ChestImagingPlatform,代码行数:30,代码来源:display_particles.py


示例12: addPoints

    def addPoints(self, points, color, thick=False, thickness=_DEFAULT_POINT_THICKNESS):
        vtkPoints = vtk.vtkPoints()
        for point in points:
            vtkPoints.InsertNextPoint(point[0], point[1], point[2])

        pointsPolyData = vtk.vtkPolyData()
        pointsPolyData.SetPoints(vtkPoints)

        if thick:
            sphereSource = vtk.vtkSphereSource()
            sphereSource.SetRadius(thickness)
            
            glyph3D = vtk.vtkGlyph3D()
            glyph3D.SetSourceConnection(sphereSource.GetOutputPort())
            glyph3D.SetInputData(pointsPolyData)
            glyph3D.Update()
 
            mapper = vtk.vtkPolyDataMapper()
            mapper.SetInputConnection(glyph3D.GetOutputPort())
        else:
            vertexFilter = vtk.vtkVertexGlyphFilter()
            vertexFilter.SetInputData(pointsPolyData)
            vertexFilter.Update()                          

            mapper = vtk.vtkPolyDataMapper()
            mapper.SetInputData(vertexFilter.GetOutput())

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().SetColor(color)

        self._rendererScene.AddActor(actor)
开发者ID:trianam,项目名称:voropath,代码行数:32,代码来源:plotter.py


示例13: make_sphereActor

def make_sphereActor (x, r, rgb, opacity):
    points = vtk.vtkPoints()
    points.InsertNextPoint(x[0], x[1], x[2])

    diameter = vtk.vtkDoubleArray()
    diameter.SetNumberOfComponents(1)
    diameter.InsertNextTuple1(2.0*r)

    pData = vtk.vtkPolyData()
    pData.SetPoints(points)
    pData.GetPointData().SetScalars(diameter)

    pSource = vtk.vtkSphereSource()
    pSource.SetPhiResolution(16)
    pSource.SetThetaResolution(16)

    pGlyph = vtk.vtkGlyph3D()
    pGlyph.SetSource(pSource.GetOutput())
    pGlyph.SetInput(pData)
    pGlyph.ScalingOn()
    pGlyph.SetScaleModeToScaleByScalar()

    pMapper = vtk.vtkPolyDataMapper()
    pMapper.ScalarVisibilityOff()
    pMapper.SetInput(pGlyph.GetOutput())

    pActor = vtk.vtkActor()
    pActor.SetMapper(pMapper)
    pActor.GetProperty().SetColor(rgb[0], rgb[1], rgb[2])
    pActor.GetProperty().SetOpacity(opacity)

    return pActor
开发者ID:kichiki,项目名称:stokes,代码行数:32,代码来源:stvis-vtk.py


示例14: setupGlyph

  def setupGlyph(self,fUnitConv= 1.0):
    self.polydata= self.getPolydata(fUnitConv)
    # Generate the arrow for the glyphs
    arrow = vtk.vtkArrowSource()
    #arrow.SetRadius(0.1)
    #arrow.SetHeight(0.5)
    self.glyph = vtk.vtkGlyph3D()
    self.glyph.SetInputData(self.polydata)
    self.glyph.SetSourceConnection(arrow.GetOutputPort())
    self.glyph.ScalingOn()
    self.glyph.SetScaleModeToScaleByScalar()
    self.glyph.SetVectorModeToUseVector()
    self.glyph.OrientOn()
    # Tell the filter to "clamp" the scalar range
    #self.glyph.ClampingOn()  
    # Set the overall (multiplicative) scaling factor
    self.glyph.SetScaleFactor(self.scaleFactor)

    # Set the Range to "clamp" the data to 
    #   -- see equations above for nonintuitive definition of "clamping"
    # The fact that I'm setting the minimum value of the range below
    #   the minimum of my data (real min=0.0) with the equations above
    #   forces a minimum non-zero glyph size.

    #self.glyph.SetRange(-10, 10)    # Change these values to see effect on cone sizes

    # Tell glyph which attribute arrays to use for what
    self.glyph.SetInputArrayToProcess(0,0,0,0,self.lenghtsName)	# scalars
    self.glyph.SetInputArrayToProcess(1,0,0,0,self.vectorsName) # vectors
    # self.glyph.SetInputArrayToProcess(2,0,0,0,'nothing')	# normals
    #self.glyph.SetInputArrayToProcess(3,0,0,0,self.lenghtsName) # colors

    # Calling update because I'm going to use the scalar range to set the color map range
    self.glyph.Update()
开发者ID:lcpt,项目名称:xc,代码行数:34,代码来源:vector_field_data.py


示例15: __init__

 def __init__ (self, mod_m): 
     debug ("In VelocityVector::__init__ ()")
     Common.state.busy ()
     Base.Objects.Module.__init__ (self, mod_m)
     self.glyph2d_src = vtk.vtkGlyphSource2D ()
     self.cone = vtk.vtkConeSource ()
     self.arrow = vtk.vtkArrowSource ()
     self.glyph_src = self.cone
     self.glyph3d = vtk.vtkGlyph3D ()
     self.mapper = self.map = vtk.vtkPolyDataMapper ()
     self.actor = self.act = vtk.vtkActor ()
     # used to orient the cone properly
     self.glph_trfm = vtk.vtkTransformFilter ()
     self.glph_trfm.SetTransform (vtk.vtkTransform ())
     self.data_out = self.mod_m.GetOutput ()
     
     # Point of glyph that is attached -- -1 is tail, 0 is center,
     # 1 is head.
     self.glyph_pos = -1 
     self.scale = 1.0
     self.color_mode = 2 #2 is vector, 1 is scalar, -1 none
     self._initialize ()
     self._gui_init ()
     self.renwin.Render ()
     Common.state.idle ()
开发者ID:sldion,项目名称:DNACC,代码行数:25,代码来源:VelocityVector.py


示例16: render

    def render(self, pointsData, scalarsArray, radiusArray, nspecies, colouringOptions, atomScaleFactor, lut):
        """
        Render the given antisites (wire frame).
        
        """
        self._logger.debug("Rendering antisites: colour by '%s'", colouringOptions.colourBy)

        # points
        points = vtk.vtkPoints()
        points.SetData(pointsData.getVTK())

        # poly data
        polydata = vtk.vtkPolyData()
        polydata.SetPoints(points)
        polydata.GetPointData().AddArray(scalarsArray.getVTK())
        polydata.GetPointData().SetScalars(radiusArray.getVTK())

        # source
        cubeSource = vtk.vtkCubeSource()
        edges = vtk.vtkExtractEdges()
        edges.SetInputConnection(cubeSource.GetOutputPort())
        glyphSource = vtk.vtkTubeFilter()
        glyphSource.SetInputConnection(edges.GetOutputPort())
        glyphSource.SetRadius(0.05)
        glyphSource.SetVaryRadius(0)
        glyphSource.SetNumberOfSides(5)
        glyphSource.UseDefaultNormalOn()
        glyphSource.SetDefaultNormal(0.577, 0.577, 0.577)

        # glyph
        glyph = vtk.vtkGlyph3D()
        if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
            glyph.SetSource(glyphSource.GetOutput())
            glyph.SetInput(polydata)
        else:
            glyph.SetSourceConnection(glyphSource.GetOutputPort())
            glyph.SetInputData(polydata)
        glyph.SetScaleFactor(atomScaleFactor * 2.0)
        glyph.SetScaleModeToScaleByScalar()
        glyph.ClampingOff()

        # mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(glyph.GetOutputPort())
        mapper.SetLookupTable(lut)
        mapper.SetScalarModeToUsePointFieldData()
        mapper.SelectColorArray("colours")
        utils.setMapperScalarRange(mapper, colouringOptions, nspecies)

        # actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        # store attributes
        self._actor = utils.ActorObject(actor)
        self._data["Points"] = pointsData
        self._data["Scalars"] = scalarsArray
        self._data["Radius"] = radiusArray
        self._data["LUT"] = lut
        self._data["Scale factor"] = atomScaleFactor
开发者ID:chrisdjscott,项目名称:Atoman,代码行数:60,代码来源:antisiteRenderer.py


示例17: 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()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:59,代码来源:vmtkcenterlines.py


示例18: visualize

def visualize():
    A = initPoints(particleA)
    B = initPoints(particleB)
    C = initPoints(particleC)
    displayDict = {}
    # Set up the renderer and redering window
    renderer = vtk.vtkRenderer()
    renwin = vtk.vtkRenderWindow()
    renwin.SetSize(1600, 1400)
    renwin.StereoCapableWindowOn()
    renwin.StereoRenderOn()
    renwin.SetStereoTypeToCrystalEyes()
    renwin.AddRenderer(renderer)
    ptsComp = vtk.vtkPoints()
    posComp = vnp.numpy_to_vtk(np.array([[0, 0, 0]], order='C'), deep=True)
    ptsComp.SetData(posComp)
    polyDataComp = vtk.vtkPolyData()
    polyDataComp.SetPoints(ptsComp)
    sourceComp = vtk.vtkCylinderSource()
    sourceComp.SetResolution(20)
    sourceComp.SetRadius(compartment['radius'] + particleScale)
    sourceComp.SetHeight(compartment['length'] + 2 * particleScale)
    sourceComp.SetCenter(0, -compartment['length']/2, 0)
    glyphComp = vtk.vtkGlyph3D()
    glyphComp.SetSource(sourceComp.GetOutput())
    glyphComp.SetInput(polyDataComp)
    glyphComp.ScalingOff()
    # glyphComp.SetScaleModeToDefault()
    # glyphComp.SetScaleFactor(particleScale)
    mapperComp = vtk.vtkPolyDataMapper()
    mapperComp.SetInput(glyphComp.GetOutput())
    mapperComp.ImmediateModeRenderingOn()
    actorComp = vtk.vtkActor()
    actorComp.SetMapper(mapperComp)
    actorComp.GetProperty().SetOpacity(0.2)
    actorComp.GetProperty().SetColor(1, 1, 1)
    actorComp.SetOrientation(0, 90, 90)
    renderer.AddActor(actorComp)
    renderer.AddActor(A['actor'])
    renderer.AddActor(B['actor'])
    renderer.AddActor(C['actor'])
    print 'Create camera'
    camera = vtk.vtkCamera()
    camera.SetPosition(300e-6, 200.0e-6, -300.0e-6)
    camera.SetFocalPoint(0, 0, 0)
    camera.ComputeViewPlaneNormal()    
    renderer.SetActiveCamera(camera)
    renderer.ResetCamera()
    interactor = vtk.vtkRenderWindowInteractor()
    interactor.SetRenderWindow(renwin)
    callback = TimerCallback(A, B, C)
    interactor.Initialize()
    interactor.AddObserver('TimerEvent', callback.execute)
    timerId = interactor.CreateRepeatingTimer(1)
    print 'Here'
    # renwin.FullScreenOn()
    interactor.Start()
开发者ID:subhacom,项目名称:misc,代码行数:57,代码来源:molmotionvtk.py


示例19: 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()
开发者ID:catactg,项目名称:SUM,代码行数:56,代码来源:seedselector.py


示例20: render

 def render(self, pointsData, scalarsArray, radiusArray, nspecies, colouringOptions, atomScaleFactor, lut, settings):
     """
     Render the given antisites (wire frame).
     
     """
     self._logger.debug("Rendering vacancies: colour by '%s'", colouringOptions.colourBy)
     
     # points
     points = vtk.vtkPoints()
     points.SetData(pointsData.getVTK())
     
     # poly data
     polydata = vtk.vtkPolyData()
     polydata.SetPoints(points)
     polydata.GetPointData().AddArray(scalarsArray.getVTK())
     polydata.GetPointData().SetScalars(radiusArray.getVTK())
     
     # source
     glyphSource = vtk.vtkCubeSource()
     
     # glyph
     glyph = vtk.vtkGlyph3D()
     if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
         glyph.SetSource(glyphSource.GetOutput())
         glyph.SetInput(polydata)
     else:
         glyph.SetSourceConnection(glyphSource.GetOutputPort())
         glyph.SetInputData(polydata)
     scaleVacs = 2.0 * settings.getSetting("vacScaleSize")
     glyph.SetScaleFactor(atomScaleFactor * scaleVacs)
     glyph.SetScaleModeToScaleByScalar()
     glyph.ClampingOff()
       
     # mapper
     mapper = vtk.vtkPolyDataMapper()
     mapper.SetInputConnection(glyph.GetOutputPort())
     mapper.SetLookupTable(lut)
     mapper.SetScalarModeToUsePointFieldData()
     mapper.SelectColorArray("colours")
     utils.setMapperScalarRange(mapper, colouringOptions, nspecies)
     
     # actor
     actor = vtk.vtkActor()
     actor.SetMapper(mapper)
     actor.GetProperty().SetSpecular(settings.getSetting("vacSpecular"))
     actor.GetProperty().SetSpecularPower(settings.getSetting("vacSpecularPower"))
     actor.GetProperty().SetOpacity(settings.getSetting("vacOpacity"))
     
     # store attributes
     self._actor = utils.ActorObject(actor)
     self._data["Points"] = pointsData
     self._data["Scalars"] = scalarsArray
     self._data["Radius"] = radiusArray
     self._data["LUT"] = lut
     self._data["Scale factor"] = atomScaleFactor
     self._data["Vacancy opacity"] = settings.getSetting("vacOpacity")
开发者ID:Kenny-Jolley,项目名称:Atoman,代码行数:56,代码来源:vacancyRenderer.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkHexahedron函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkGeometryFilter函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap