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

Python vtk.vtkPointSource函数代码示例

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

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



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

示例1: load_config

 def load_config (self, file):
     debug ("In PointStreamer::load_config ()")
     self.setup_pipeline ()
     val = file.readline ()
     try:
         self.n_pnt, self.strmln_mode, self.integration_mode = eval (val)
     except ValueError: # old format
         self.n_pnt, self.strmln_mode = eval (val)
     # For backward compatibility - the dummy is actually unused.
     dummy_seed = vtk.vtkPointSource ()        
     p = vtkPipeline.vtkMethodParser.VtkPickler ()
     for i in (self.sphere_src, self.sphere_map, self.sphere_act,
               self.sphere_act.GetProperty (),
               dummy_seed, self.strmln, self.ribbonf, self.tubef, 
               self.stream_map, self.stream_act,
               self.stream_act.GetProperty ()):
         p.load (i, file)
     self.setup_stream_pipeline ()
     self.radius = self.sphere_src.GetRadius ()
     self.cen = list (self.sphere_src.GetCenter ())
     self.color_mode = self.strmln.GetSpeedScalars ()
     if self.stream_map.GetScalarVisibility () == 0:
         self.color_mode = -1
     self.do_color_mode ()
     self.update ()
     self.update_integration_mode ()
开发者ID:sldion,项目名称:DNACC,代码行数:26,代码来源:Streamlines.py


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


示例3: create_stream_line

    def create_stream_line(self,y1,y2,y3,n,r=10):

        seeds = vtk.vtkPointSource()
        seeds.SetNumberOfPoints(n)
        seeds.SetCenter(y1, y2, y3)
        seeds.SetRadius(r)
        seeds.SetDistributionToShell()



        integ = vtk.vtkRungeKutta4()
        streamline = vtk.vtkStreamLine()
        streamline.SetInputConnection(self.vec_reader.GetOutputPort())
        streamline.SetSourceConnection(seeds.GetOutputPort())
        streamline.SetMaximumPropagationTime(220)
        streamline.SetIntegrationStepLength(0.05)
        streamline.SetStepLength(0.5)
        streamline.SpeedScalarsOn()
        streamline.SetNumberOfThreads(1)
        streamline.SetIntegrationDirectionToIntegrateBothDirections()

        streamline.SetIntegrator(integ)
        streamline.SetSpeedScalars(220);

        streamlineMapper = vtk.vtkPolyDataMapper()
        streamlineMapper.SetInputConnection(streamline.GetOutputPort())
        streamlineMapper.SetLookupTable(self.arrowColor)


        streamline_actor = vtk.vtkActor()
        streamline_actor.SetMapper(streamlineMapper)
        streamline_actor.VisibilityOn()

        return streamline_actor
开发者ID:svelezsaffon,项目名称:vector_field_visualization_vtk,代码行数:34,代码来源:streamlines.py


示例4: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create source
        source = vtk.vtkPointSource()
        source.SetCenter(0, 0, 0)
        source.SetNumberOfPoints(50)
        source.SetRadius(5.0)
        source.Update()
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:32,代码来源:pointsource.py


示例5: pointsource

def pointsource(center=[0, 0, 0], radius=1.0, numberofpoints=100):
    """Create a random cloud of points"""
    points = vtk.vtkPointSource()
    points.SetNumberOfPoints(numberofpoints)
    points.SetCenter(center)
    points.SetRadius(radius)
    points.Update()
    return points.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:8,代码来源:vtklib.py


示例6: __init__

    def __init__(self, center=(0,0,0), color=(1,2,3) ):   
        """ create point """
        self.src = vtk.vtkPointSource()
        self.src.SetCenter(center)
        self.src.SetRadius(0)
        self.src.SetNumberOfPoints(1)

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInput(self.src.GetOutput())
        self.SetMapper(self.mapper)
        self.SetColor(color)
开发者ID:aewallin,项目名称:randompolygon,代码行数:11,代码来源:ovdvtk.py


示例7: save_config

 def save_config (self, file):
     debug ("In PointStreamer::save_config ()")
     file.write ("%d, %d, %d\n"%(self.n_pnt, self.strmln_mode,
                                 self.integration_mode))
     # For backward compatibility - the dummy is actually unused.
     dummy_seed = vtk.vtkPointSource ()
     p = vtkPipeline.vtkMethodParser.VtkPickler ()
     for i in (self.sphere_src, self.sphere_map, self.sphere_act, 
               self.sphere_act.GetProperty (),
               dummy_seed, self.strmln, self.ribbonf, self.tubef, 
               self.stream_map, self.stream_act,
               self.stream_act.GetProperty ()):
         p.dump (i, file)
开发者ID:sldion,项目名称:DNACC,代码行数:13,代码来源:Streamlines.py


示例8: main

def main():
    pointSource = vtk.vtkPointSource()
    pointSource.SetNumberOfPoints(20)
    pointSource.Update()

    idFilter = vtk.vtkIdFilter()
    idFilter.SetInputConnection(pointSource.GetOutputPort())
    idFilter.SetIdsArrayName("OriginalIds")
    idFilter.Update()

    surfaceFilter = vtk.vtkDataSetSurfaceFilter()
    surfaceFilter.SetInputConnection(idFilter.GetOutputPort())
    surfaceFilter.Update()

    poly_input = surfaceFilter.GetOutput()

    # Create a mapper and actor
    mapper = vtk.vtkPolyDataMapper()

    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInputConnection(poly_input.GetProducerPort())
    else:
        mapper.SetInputData(poly_input)
    mapper.ScalarVisibilityOff()

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

    # Visualize
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)

    areaPicker = vtk.vtkAreaPicker()
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetPicker(areaPicker)
    renderWindowInteractor.SetRenderWindow(renderWindow)

    renderer.AddActor(actor)
    #renderer.SetBackground(1,1,1) # Background color white

    renderWindow.Render()

    style = vtk.vtkRenderWindowInteractor()
    #style = myInteractorStyle()
    #style = InteractorStyle()
    #style = QVTKRenderWindowInteractor()
    #style.SetPoints(poly_input)
    renderWindowInteractor.SetInteractorStyle(style)

    renderWindowInteractor.Start()
开发者ID:FrankNaets,项目名称:pyNastran,代码行数:51,代码来源:highlight_selected_points.py


示例9: getpsactor

def getpsactor(ps):   # ps 是点云映射到Grid的空间坐标
    # create source
    """
    # vtkPointSource用来创建围绕特定中心点,特定直径的和特定数量点集合组成的球体。
    # 默认点是随机分布在球体里面。也可以生产的点只分布在球面上。
    # 基本用法:
    # SetRadius()设置球体半径
    # SetCenter()设置球体中心点
    # SetNumberOfPoints()设置球中的点的个数
    # SetDistributionToUniform()设置点的分布在球体内
    # SetDistributionToShell()设置点分布在球面上。

    """
    src = vtk.vtkPointSource()
    src.SetCenter(0, 0, 0)       # 设置圆心
    src.SetNumberOfPoints(50)    # 设置点的个数
    src.SetRadius(5)             # 设置半径
    src.Update()                 # ???????
    # ps = [[1,1,1],[2,2,2]]
    # print src.GetOutput()
    points = vtk.vtkPoints()
    vertices = vtk.vtkCellArray()  # 创建一个cell对象
    for p in ps:
    # Create the topology of the point (a vertex)
        id = points.InsertNextPoint(p)
        vertices.InsertNextCell(1)  # 将cell的容量增加1
        vertices.InsertCellPoint(id)  # 将 id所指的点插入cell

    # Create a polydata object  # polydata : 多边形数据
    point = vtk.vtkPolyData()

    # vertex : 顶点  topology:拓扑
    # Set the points and vertices we created as the geometry and topology of the polydata
    point.SetPoints(points)
    point.SetVerts(vertices)
    # mapper
    # mapper = vtk.vtkPolyDataMapper()
    # Visualize
    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInput(point)
    else:
        mapper.SetInputData(point)

    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    # actor.GetProperty().SetPointSize(2)
    # assign actor to the renderer
    return actor
开发者ID:David-webb,项目名称:python_homework,代码行数:50,代码来源:visu.py


示例10: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create source
        pointSource = vtk.vtkPointSource()
        pointSource.SetNumberOfPoints(5)
        pointSource.Update()

        points = pointSource.GetOutput().GetPoints()
        xSpline = vtk.vtkKochanekSpline()
        ySpline = vtk.vtkKochanekSpline()
        zSpline = vtk.vtkKochanekSpline()

        spline = vtk.vtkParametricSpline()
        spline.SetXSpline(xSpline)
        spline.SetYSpline(ySpline)
        spline.SetZSpline(zSpline)
        spline.SetPoints(points)

        functionSource = vtk.vtkParametricFunctionSource()
        functionSource.SetParametricFunction(spline)
        functionSource.Update()
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(functionSource.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:45,代码来源:kochanekspline.py


示例11: initialize

    def initialize (self, valid_coord):        
        """ Initializes the seed given an array of valid co-ordinate
        directions. [x-axis, y-axis, z_axis] is the format.  For
        instance if x-axis == 0 then the data is along the YZ plane.
        This method is responsible for actually creating the seed. """

        debug ("In SeedManager::initialize ()")
        assert len (valid_coord) == 3
        self.dim = reduce (lambda x, y: x+y, valid_coord)
        if self.dim == 3:
            self.seed = vtk.vtkPointSource ()
        else:
            self.seed = vtk.vtkDiskSource ()
            self.seed.SetRadialResolution (1)
            self.seed.SetInnerRadius (0.0)
            self.transform = vtk.vtkTransformFilter ()
            self.transform.SetTransform (vtk.vtkTransform ())
            self.transform.SetInput (self.seed.GetOutput ())
            self.orient_2d (valid_coord)
开发者ID:sldion,项目名称:DNACC,代码行数:19,代码来源:Streamlines.py


示例12: create_stream_line

    def create_stream_line(self,y1,y2,y3,n,r=10,tr=2):

        seeds = vtk.vtkPointSource()
        seeds.SetNumberOfPoints(n)
        seeds.SetCenter(y1, y2, y3)
        seeds.SetRadius(r)
        seeds.SetDistributionToShell()


        integ = vtk.vtkRungeKutta4()
        streamline = vtk.vtkStreamLine()
        streamline.SetInputConnection(self.vec_reader.GetOutputPort())
        streamline.SetSourceConnection(seeds.GetOutputPort())
        streamline.SetMaximumPropagationTime(220)
        streamline.SetIntegrationStepLength(0.05)
        streamline.SetStepLength(0.5)
        streamline.SpeedScalarsOn()
        streamline.SetNumberOfThreads(1)
        streamline.SetIntegrationDirectionToIntegrateBothDirections()
        streamline.SetIntegrator(integ)
        streamline.SetSpeedScalars(220);


        streamline_mapper = vtk.vtkPolyDataMapper()
        streamline_mapper.SetInputConnection(streamline.GetOutputPort())


        streamTube = vtk.vtkTubeFilter()
        streamTube.SetInputConnection(streamline.GetOutputPort())
        streamTube.SetRadius(tr)
        streamTube.SetNumberOfSides(12)
        streamTube.SetVaryRadiusToVaryRadiusByVector()
        mapStreamTube = vtk.vtkPolyDataMapper()
        mapStreamTube.SetInputConnection(streamTube.GetOutputPort())
        mapStreamTube.SetLookupTable(self.arrowColor)

        streamTubeActor = vtk.vtkActor()
        streamTubeActor.SetMapper(mapStreamTube)
        streamTubeActor.GetProperty().BackfaceCullingOn()

        return streamTubeActor
开发者ID:svelezsaffon,项目名称:vector_field_visualization_vtk,代码行数:41,代码来源:streamtubes.py


示例13: getpsactor

def getpsactor(ps):

    # create source
    src = vtk.vtkPointSource()
    src.SetCenter(0, 0, 0)
    src.SetNumberOfPoints(50)
    src.SetRadius(5)
    src.Update()
    # ps = [[1,1,1],[2,2,2]]
    # print src.GetOutput()
    points = vtk.vtkPoints()
    vertices = vtk.vtkCellArray()
    for p in ps:
        # Create the topology of the point (a vertex)
        if len(p) == 2:
            p = [p[0], p[1], 0]
        id = points.InsertNextPoint(p)
        vertices.InsertNextCell(1)
        vertices.InsertCellPoint(id)

    # Create a polydata object
    point = vtk.vtkPolyData()

    # Set the points and vertices we created as the geometry and topology of the polydata
    point.SetPoints(points)
    point.SetVerts(vertices)
    # mapper
    # mapper = vtk.vtkPolyDataMapper()
    # Visualize
    mapper = vtk.vtkPolyDataMapper()
    if vtk.VTK_MAJOR_VERSION <= 5:
        mapper.SetInput(point)
    else:
        mapper.SetInputData(point)

    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    # actor.GetProperty().SetPointSize(2)
    # assign actor to the renderer
    return actor
开发者ID:predictwise,项目名称:3DModelSegmentation,代码行数:41,代码来源:visu.py


示例14: make_stream_actors

def make_stream_actors(position, color):
    """Create a stream and use two mappers. One to represent velocity with
    the default colour, and the other to change the colour.
    """
    seed = vtk.vtkPointSource()
    seed.SetRadius(15)
    seed.SetNumberOfPoints(100)
    seed.SetCenter(*position)

    stream_tracer = vtk.vtkStreamTracer()
    stream_tracer.SetInputConnection(mixer.GetOutputPort())
    stream_tracer.SetMaximumPropagation(500)
    stream_tracer.SetIntegrator(vtk.vtkRungeKutta45())
    stream_tracer.SetIntegrationDirectionToBoth()
    stream_tracer.SetTerminalSpeed(0.0001)
    stream_tracer.SetSource(seed.GetOutput())

    stream_tube = vtk.vtkTubeFilter()
    stream_tube.SetInputConnection(stream_tracer.GetOutputPort())
    stream_tube.SetRadius(.2)
    stream_tube.SetNumberOfSides(12)

    # Solid transparent colour
    stream_mapper1 = vtk.vtkPolyDataMapper()
    stream_mapper1.SetInputConnection(stream_tube.GetOutputPort())
    stream_mapper1.ScalarVisibilityOff()

    stream_actor1 = vtk.vtkActor()
    stream_actor1.GetProperty().SetColor(*color)
    stream_actor1.SetMapper(stream_mapper1)
    stream_actor1.GetProperty().SetOpacity(0.4)

    # opaque velocity colour
    stream_mapper2 = vtk.vtkPolyDataMapper()
    stream_mapper2.SetInputConnection(stream_tube.GetOutputPort())

    stream_actor2 = vtk.vtkActor()
    stream_actor2.SetMapper(stream_mapper2)
    stream_actor2.GetProperty().SetOpacity(1.)
    return [stream_actor1, stream_actor2]
开发者ID:chielk,项目名称:beautiful_data,代码行数:40,代码来源:mix.py


示例15:

import vtk

points = vtk.vtkPointSource()
points.SetCenter(0.0, 0.0, 0.0)
points.SetNumberOfPoints(500)
points.SetRadius(50.0)

m = vtk.vtkPolyDataMapper()
m.SetInput(points.GetOutput())

a = vtk.vtkActor()
a.SetMapper(m)
r = vtk.vtkRenderer()
r.AddActor(a)
w = vtk.vtkRenderWindow()
w.AddRenderer(r)
i = vtk.vtkRenderWindowInteractor()
i.SetRenderWindow(w)

i.Initialize()
i.Start()
开发者ID:sulei1324,项目名称:lab_codes,代码行数:21,代码来源:test7.py


示例16: use

maxVelocity =reader.GetOutput().GetPointData().GetVectors().GetMaxNorm()
maxTime = 35.0*length/maxVelocity

# Now we will generate multiple streamlines in the data. We create a
# random cloud of points and then use those as integration seeds. We
# select the integration order to use (RungeKutta order 4) and
# associate it with the streamer. The start position is the position
# in world space where we want to begin streamline integration; and we
# integrate in both directions. The step length is the length of the
# line segments that make up the streamline (i.e., related to
# display). The IntegrationStepLength specifies the integration step
# length as a fraction of the cell size that the streamline is in.

# Create source for streamtubes
seeds = vtk.vtkPointSource()
seeds.SetRadius(0.15)
seeds.SetCenter(0.1, 2.1, 0.5)
seeds.SetNumberOfPoints(6)

integ = vtk.vtkRungeKutta4()
streamer = vtk.vtkStreamLine()
streamer.SetInputConnection(reader.GetOutputPort())
streamer.SetSource(seeds.GetOutput())
streamer.SetMaximumPropagationTime(500)
streamer.SetStepLength(0.5)
streamer.SetIntegrationStepLength(0.05)
streamer.SetIntegrationDirectionToIntegrateBothDirections()
streamer.SetIntegrator(integ)

# The tube is wrapped around the generated streamline. By varying the
开发者ID:Buddington,项目名称:omegalib-evl-apps,代码行数:30,代码来源:OfficeTubes.py


示例17: vtkGetDataRoot

VTK_DATA_ROOT = vtkGetDataRoot()

# Test label reading from an MNI tag file
#

# The current directory must be writeable.
#
try:
    fname = "mni-tagtest.tag"
    channel = open(fname, "wb")
    channel.close()

    # create some random points in a sphere
    #
    sphere1 = vtk.vtkPointSource()
    sphere1.SetNumberOfPoints(13)

    xform = vtk.vtkTransform()
    xform.RotateWXYZ(20, 1, 0, 0)

    xformFilter = vtk.vtkTransformFilter()
    xformFilter.SetTransform(xform)
    xformFilter.SetInputConnection(sphere1.GetOutputPort())

    labels = vtk.vtkStringArray()
    labels.InsertNextValue("0")
    labels.InsertNextValue("1")
    labels.InsertNextValue("2")
    labels.InsertNextValue("3")
    labels.InsertNextValue("Halifax")
开发者ID:RCBiczok,项目名称:VTK,代码行数:30,代码来源:TestMNITagPoints.py


示例18: test_map_source_object

def test_map_source_object():
    "Returns actor -> mapper -> object."
    obj = vtk.vtkPointSource()
    m, a = map_source_object(obj)
    assert isinstance(m.GetInput(), vtk.vtkObject)
    assert m is a.GetMapper()
开发者ID:agravier,项目名称:pycogmo,代码行数:6,代码来源:visualisation_tests.py


示例19:

#!/usr/bin/env python
# Sanjaya Gajurel, Computational Scientist, Case Western Reserve University, April 2015
import sys
import vtk
import os
#------------------------------------------------------------------------------
# Script Entry Point
#------------------------------------------------------------------------------
if __name__ == "__main__":

    print "vtkGraph: Building a graph using Unstructured Grid & dumping it in a vtk file, vertex.vtu, to be visualized using ParaView"

    pointSource = vtk.vtkPointSource()
    pointSource.Update()

    # Create an integer array to store vertex id data & link it with its degree value as a scalar.
    degree  = vtk.vtkIntArray()
    degree.SetNumberOfComponents(1)
    degree.SetName("degree")
    degree.SetNumberOfTuples(7)
    degree.SetValue(0,2)
    degree.SetValue(1,1)
    degree.SetValue(2,3)
    degree.SetValue(3,3)
    degree.SetValue(4,4)
    degree.SetValue(5,2)
    degree.SetValue(6,1)

    pointSource.GetOutput().GetPointData().AddArray(degree)

   # Assign co-ordinates for vertices
开发者ID:auroua,项目名称:test,代码行数:31,代码来源:vtk_test3.py


示例20: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create a set of points
        fixedPointSource = vtk.vtkPointSource()
        fixedPointSource.SetNumberOfPoints(2)

        # Calculate the distance to the camera of each point
        distanceToCamera = vtk.vtkDistanceToCamera()
        distanceToCamera.SetInputConnection(fixedPointSource.GetOutputPort())
        distanceToCamera.SetScreenSize(100.0)

        # Glyph each point with an arrow
        arrow = vtk.vtkArrowSource()
        fixedGlyph = vtk.vtkGlyph3D()
        fixedGlyph.SetInputConnection(distanceToCamera.GetOutputPort())
        fixedGlyph.SetSourceConnection(arrow.GetOutputPort())

        # Scale each point
        fixedGlyph.SetScaleModeToScaleByScalar()
        fixedGlyph.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS, 
                "DistanceToCamera")

        # Create a mapper
        fixedMapper = vtk.vtkPolyDataMapper()
        fixedMapper.SetInputConnection(fixedGlyph.GetOutputPort())
        fixedMapper.SetScalarVisibility(False)
 
        # Create an actor
        fixedActor = vtk.vtkActor()
        fixedActor.SetMapper(fixedMapper)
        fixedActor.GetProperty().SetColor(0, 1, 1)

        #............................................................
        # Draw some spheres that get bigger when zooming in.
        # Create a set of points
        pointSource = vtk.vtkPointSource()
        pointSource.SetNumberOfPoints(4)

        # Glyph each point with a sphere
        sphere = vtk.vtkSphereSource()
        glyph = vtk.vtkGlyph3D()
        glyph.SetInputConnection(pointSource.GetOutputPort())
        glyph.SetSourceConnection(sphere.GetOutputPort())
        glyph.SetScaleFactor(0.1)

        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(glyph.GetOutputPort())
        mapper.SetScalarVisibility(False)
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().SetColor(0, 1, 1)

        distanceToCamera.SetRenderer(self.ren)

        # Add the actors to the scene
        self.ren.AddActor(fixedActor)
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:74,代码来源:distancetocamera.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkPoints函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkPlanes函数代码示例发布时间: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