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

Python vtk.vtkPoints函数代码示例

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

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



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

示例1: computeSphericalPoints

    def computeSphericalPoints( self, **args ):
        lon_data = self.np_points_data[0::3]
        lat_data = self.np_points_data[1::3]
        z_data = self.np_points_data[2::3]
        radian_scaling = math.pi / 180.0 
        theta =  ( 90.0 - lat_data ) * radian_scaling
        phi = lon_data * radian_scaling
        
        r = z_data * self.spherical_scaling + self.earth_radius
        self.np_sp_grid_data = numpy.dstack( ( r, theta, phi ) ).flatten()
        vtk_sp_grid_data = numpy_support.numpy_to_vtk( self.np_sp_grid_data ) 

#         if self.grid == PlotType.List:
# #             r = numpy.empty( lon_data.shape, lon_data.dtype )      
# #             r.fill(  self.earth_radius )
#             r = z_data * self.spherical_scaling + self.earth_radius
#             self.np_sp_grid_data = numpy.dstack( ( r, theta, phi ) ).flatten()
#             vtk_sp_grid_data = numpy_support.numpy_to_vtk( self.np_sp_grid_data ) 
#         elif self.grid == PlotType.Grid:
#             thetaB = theta.reshape( [ theta.shape[0], 1 ] )  
#             phiB = phi.reshape( [ 1, phi.shape[0] ] )
#             grid_data = numpy.array( [ ( self.earth_radius, t, p ) for (t,p) in numpy.broadcast(thetaB,phiB) ] )
#             self.np_sp_grid_data = grid_data.flatten() 
#             vtk_sp_grid_data = numpy_support.numpy_to_vtk( self.np_sp_grid_data ) 
#         else:
#             print>>sys.stderr, "Unrecognized grid type: %s " % str( self.grid )
#             return        
        size = vtk_sp_grid_data.GetSize()                    
        vtk_sp_grid_data.SetNumberOfComponents( 3 )
        vtk_sp_grid_data.SetNumberOfTuples( size/3 )   
        vtk_sp_grid_points = vtk.vtkPoints()
        vtk_sp_grid_points.SetData( vtk_sp_grid_data )
        self.vtk_spherical_points = vtk.vtkPoints()
        self.shperical_to_xyz_trans.TransformPoints( vtk_sp_grid_points, self.vtk_spherical_points ) 
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:34,代码来源:DistributedPointCollections.py


示例2: DeleteCallback

    def DeleteCallback(self, obj):
        delId = -1
        sourceValid = False
        if self.CurrentSourcePointId != -1:
            delId = self.CurrentSourcePointId
            sourceValid = True
        elif self.CurrentTargetPointId != -1:
            delId = self.CurrentTargetPointId
        else:
            return
        savedSources = vtk.vtkPoints()
        savedSources.DeepCopy(self.SourcePoints)
        savedTargets = vtk.vtkPoints()
        savedTargets.DeepCopy(self.TargetPoints)
        self.InitializeSpheres()

        for i in range(savedSources.GetNumberOfPoints()):
            if i != delId:
                self.AddDisplacement(savedSources.GetPoint(i), savedTargets.GetPoint(i))

        nPoints = self.SourcePoints.GetNumberOfPoints()

        if nPoints == 0:
            self.SelectSource(-1)
        elif sourceValid:
            self.SelectSource((delId - 1) % nPoints)
        else:
            self.SelectTarget((delId - 1) % nPoints)

        self.SourceSpheres.Modified()
        self.TargetSpheres.Modified()

        self.vmtkRenderer.RenderWindow.Render()
开发者ID:tangui,项目名称:vmtk,代码行数:33,代码来源:vmtkthinplatesplinedeformation.py


示例3: latitude_create

def latitude_create(
                arg_lat,
		arg_projection):

	if arg_projection == 'linear' :
		n_polypoints=2
        	polygonpoints=vtk.vtkPoints()
        	polygonpoints.SetNumberOfPoints(n_polypoints)
		polygonpoints.InsertPoint(0,-180,arg_lat,0)
		polygonpoints.InsertPoint(1,540,arg_lat,0)
	else:
        	n_polypoints=360
        	polygonpoints=vtk.vtkPoints()
        	polygonpoints.SetNumberOfPoints(n_polypoints)
        	deg2rad=numpy.pi/180.
        	for n in range(n_polypoints) :
                	theta=2*numpy.pi*n/(n_polypoints-1)
                	x=numpy.cos(arg_lat*deg2rad)*numpy.cos(theta)
                	y=numpy.cos(arg_lat*deg2rad)*numpy.sin(theta)
                	z=numpy.sin(arg_lat*deg2rad)
                	polygonpoints.InsertPoint(n,x,y,z)

        polygonlines=vtk.vtkCellArray()
        polygonlines.InsertNextCell(n_polypoints)
        for n in range(n_polypoints) :
                polygonlines.InsertCellPoint(n)
        latpolydata=vtk.vtkPolyData()
        latpolydata.SetPoints(polygonpoints)
        latpolydata.SetLines(polygonlines)

        return latpolydata
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:31,代码来源:mylib_grid.py


示例4: setPointHeights

    def setPointHeights( self, ptheights ):
        try:
            if self.topo == PlotType.Planar:   
                self.np_points_data[2::3] =  ptheights
                vtk_points_data = numpy_support.numpy_to_vtk( self.np_points_data ) 
                vtk_points_data.SetNumberOfComponents( 3 )
                vtk_points_data.SetNumberOfTuples( len( self.np_points_data ) / 3 ) 
                self.vtk_planar_points.SetData( vtk_points_data )
                self.polydata.SetPoints( self.vtk_planar_points )  
                self.vtk_planar_points.Modified()
            elif self.topo == PlotType.Spherical:
                self.np_sp_grid_data[0::3] =  self.spherical_scaling * ptheights + self.earth_radius
                vtk_sp_grid_data = numpy_support.numpy_to_vtk( self.np_sp_grid_data ) 
                size = vtk_sp_grid_data.GetSize()                    
                vtk_sp_grid_data.SetNumberOfComponents( 3 )
                vtk_sp_grid_data.SetNumberOfTuples( size/3 )   
                vtk_sp_grid_points = vtk.vtkPoints()
                vtk_sp_grid_points.SetData( vtk_sp_grid_data )
                self.vtk_spherical_points = vtk.vtkPoints()
                self.shperical_to_xyz_trans.TransformPoints( vtk_sp_grid_points, self.vtk_spherical_points ) 
#                pt0 = self.vtk_spherical_points.GetPoint(0)
    #            print "VTK Set point Heights, samples: %s %s %s " % ( str( ptheights[0] ), str( self.np_sp_grid_data[0] ), str( pt0 ) )
                self.polydata.SetPoints( self.vtk_spherical_points ) 
                self.vtk_spherical_points.Modified()
            self.polydata.Modified()
        except Exception, err:
            self.printLogMessage( "Processing point heights: %s " % str( err ), error=True )
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:27,代码来源:DistributedPointCollections.py


示例5: __init__

  def __init__(self, sliceWidget):

    # keep a flag since events such as sliceNode modified
    # may come during superclass construction, which will
    # invoke our processEvents method
    self.initialized = False

    super(DrawEffectTool,self).__init__(sliceWidget)

    # create a logic instance to do the non-gui work
    self.logic = DrawEffectLogic(self.sliceWidget.sliceLogic())

    # interaction state variables
    self.activeSlice = None
    self.lastInsertSLiceNodeMTime = None
    self.actionState = None

    # initialization
    self.xyPoints = vtk.vtkPoints()
    self.rasPoints = vtk.vtkPoints()
    self.polyData = self.createPolyData()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    self.mapper.SetInputData(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )

    self.initialized = True
开发者ID:LucasGandel,项目名称:Slicer,代码行数:33,代码来源:DrawEffect.py


示例6: genTextActor

def genTextActor(renderer,string=None,x=None,y=None,to='default',tt='default',cmap=None):
  if isinstance(to,str):
    to = vcs.elements["textorientation"][to]
  if isinstance(tt,str):
    tt = vcs.elements["texttable"][tt]
  if tt.priority==0:
    return []
  if string is None:
    string = tt.string
  if x is None:
    x = tt.x
  if y is None:
    y = tt.y
  if x is None or y is None or string in [['',],[]]:
    return []

  n = max(len(x),len(y),len(string))
  for a in [x,y,string]:
    while len(a)<n:
      a.append(a[-1])

  sz = renderer.GetRenderWindow().GetSize()
  actors=[]
  pts = vtk.vtkPoints()
  geo = None
  if vcs.elements["projection"][tt.projection].type!="linear":
      # Need to figure out new WC
      Npts = 20
      for i in range(Npts+1):
          X = tt.worldcoordinate[0]+float(i)/Npts*(tt.worldcoordinate[1]-tt.worldcoordinate[0])
          for j in range(Npts+1):
              Y = tt.worldcoordinate[2]+float(j)/Npts*(tt.worldcoordinate[3]-tt.worldcoordinate[2])
              pts.InsertNextPoint(X,Y,0.)
      geo,pts = project(pts,tt.projection,tt.worldcoordinate,geo=None)
      wc = pts.GetBounds()[:4]
      #renderer.SetViewport(tt.viewport[0],tt.viewport[2],tt.viewport[1],tt.viewport[3])
      renderer.SetWorldPoint(wc)


  for i in range(n):
    t = vtk.vtkTextActor()
    p=t.GetTextProperty()
    prepTextProperty(p,sz,to,tt,cmap)
    pts = vtk.vtkPoints()
    pts.InsertNextPoint(x[i],y[i],0.)
    if geo is not None:
        geo,pts = project(pts,tt.projection,tt.worldcoordinate,geo=geo)
        X,Y,tz=pts.GetPoint(0)
        X,Y = world2Renderer(renderer,X,Y,tt.viewport,wc)
    else:
        X,Y = world2Renderer(renderer,x[i],y[i],tt.viewport,tt.worldcoordinate)
    t.SetPosition(X,Y)
    t.SetInput(string[i])
    #T=vtk.vtkTransform()
    #T.Scale(1.,sz[1]/606.,1.)
    #T.RotateY(to.angle)
    #t.SetUserTransform(T)
    renderer.AddActor(t)
    actors.append(t)
  return actors
开发者ID:UNESCO-IHE,项目名称:uvcdat,代码行数:60,代码来源:vcs2vtk.py


示例7: __init__

  def __init__(self, sliceWidget):
    super(LevelTracingEffectTool,self).__init__(sliceWidget)

    # create a logic instance to do the non-gui work
    self.logic = LevelTracingEffectLogic(self.sliceWidget.sliceLogic())

    # instance variables
    self.actionState = ''

    # initialization
    self.xyPoints = vtk.vtkPoints()
    self.rasPoints = vtk.vtkPoints()
    self.polyData = vtk.vtkPolyData()

    self.tracingFilter = vtkITK.vtkITKLevelTracingImageFilter()
    self.ijkToXY = vtk.vtkGeneralTransform()

    self.mapper = vtk.vtkPolyDataMapper2D()
    self.actor = vtk.vtkActor2D()
    property_ = self.actor.GetProperty()
    property_.SetColor( 107/255., 190/255., 99/255. )
    property_.SetLineWidth( 1 )
    if vtk.VTK_MAJOR_VERSION <= 5:
      self.mapper.SetInput(self.polyData)
    else:
      self.mapper.SetInputData(self.polyData)
    self.actor.SetMapper(self.mapper)
    property_ = self.actor.GetProperty()
    property_.SetColor(1,1,0)
    property_.SetLineWidth(1)
    self.renderer.AddActor2D( self.actor )
    self.actors.append( self.actor )
开发者ID:kingofpanda,项目名称:Slicer,代码行数:32,代码来源:LevelTracingEffect.py


示例8: getRigidTransform

def getRigidTransform(fix, mov): # In real resolution
    LandmarkTransform = vtk.vtkLandmarkTransform()
    LandmarkTransform.SetModeToRigidBody()
    
    n = fix.shape[0]
    fix_point = vtk.vtkPoints()
    fix_point.SetNumberOfPoints(n)
    mov_point = vtk.vtkPoints()
    mov_point.SetNumberOfPoints(n)

    for i in range(n):
        fix_point.SetPoint(i, fix[i, 0], fix[i, 1], fix[i, 2])
        mov_point.SetPoint(i, mov[i, 0], mov[i, 1], mov[i, 2])

    LandmarkTransform.SetSourceLandmarks(mov_point)
    LandmarkTransform.SetTargetLandmarks(fix_point)
    LandmarkTransform.Update()

    matrix = LandmarkTransform.GetMatrix()
    T = ml.zeros([4, 4], dtype = npy.float32)
    for i in range(4):
        for j in range(4):
            T[i, j] = matrix.GetElement(j, i)

    p1 = mov[0, :].tolist()
    p2 = [0.0, 0, 0]
    LandmarkTransform.InternalTransformPoint(p1, p2)
    
    return T, npy.array(p2)
开发者ID:guohengkai,项目名称:MIRVAP,代码行数:29,代码来源:ElastixUtil.py


示例9: display

def display(data, data2=None, data3=None):
    # Generate some random points

    math = vtk.vtkMath()
    points = vtk.vtkPoints()
    
    [data, scalefactor]=scaledata(data)
    for i in range(len(data)):
        points.InsertNextPoint( data[i,0],data[i,1], data[i,2]);
    ballActor = vtksetup(points, color=red, radius=.001)
    [ren,renWin,iren]=vtkwindow()
    ren.AddActor(ballActor) # Add the actors to the renderer, set the background and size
    
    if data2 != None:
        data=data2*scalefactor
        points = vtk.vtkPoints()
        for i in range(len(data)):
            points.InsertNextPoint( data[i,0],data[i,1], data[i,2]);
        ballActor = vtksetup(points, color=blue)
        ren.AddActor(ballActor)
    
    if data3 != None:
        data=data3*scalefactor
        points = vtk.vtkPoints()
        for i in range(len(data)):
            points.InsertNextPoint( data[i,0],data[i,1], data[i,2]);
        ballActor = vtksetup(points, color=green, radius=.007)
        ren.AddActor(ballActor)



    # Interact with the data.
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:badbytes,项目名称:pymeg,代码行数:35,代码来源:plotvtksurface.py


示例10: __init__

    def __init__(self):

        pypes.pypeScript.__init__(self)

        self.Surface = None
        self.DeformedSurface = None
        self.SourcePoints = vtk.vtkPoints()
        self.TargetPoints = vtk.vtkPoints()
        self.DisplacementNorms = vtk.vtkDoubleArray()
        self.Displacements = vtk.vtkDoubleArray()
        self.Displacements.SetNumberOfComponents(3)
        self.SourceSpheres = vtk.vtkPolyData()
        self.TargetSpheres = vtk.vtkPolyData()
        self.SourceSpheres.SetPoints(self.SourcePoints)
        self.TargetSpheres.SetPoints(self.TargetPoints)
        self.SourceSpheres.GetPointData().SetScalars(self.DisplacementNorms)
        self.SourceSpheres.GetPointData().SetVectors(self.Displacements)
        self.vmtkRenderer = None
        self.OwnRenderer = 0
        self.DisplayDeformed = False
        self.SurfaceMapper = None
        self.Opacity = 1.0
        self.SourceSpheresActor = None
        self.TargetSpheresActor = None

        self.SetScriptName("vmtkthinplatesplinedeformation")
        self.SetInputMembers(
            [
                ["Surface", "i", "vtkPolyData", 1, "", "the input surface", "vmtksurfacereader"],
                ["Opacity", "opacity", "float", 1, "(0.0,1.0)", "object opacities in the scene"],
                ["vmtkRenderer", "renderer", "vmtkRenderer", 1, "", "external renderer"],
            ]
        )
        self.SetOutputMembers([["DeformedSurface", "o", "vtkPolyData", 1, "", "", "vmtksurfacewriter"]])
开发者ID:tangui,项目名称:vmtk,代码行数:34,代码来源:vmtkthinplatesplinedeformation.py


示例11: KeyPressCallback

 def KeyPressCallback(self, obj, event):
     ch = self.window_interactor.GetKeySym()
     if ch == 'Return':
         trans = loadTransform()
         num = 0
         for transform in trans:
             self.point_data_result = applyTransform(self.tmp_data_move, transform)
             self.point_data_result[:, :3] /= self.tmp_space
             for cnt in range(3, 6):
                 point_result = self.point_data_result[npy.where(npy.round(self.point_data_result[:, -1]) == cnt - 3)]
                 point_move = self.point_data_move[npy.where(npy.round(self.point_data_move[:, -1]) == cnt - 3)]
                 if not point_result.shape[0]:
                     continue
                     
                 self.cells = vtk.vtkCellArray()
                 self.points = vtk.vtkPoints()
                 l = 0
                 for i in range(self.zmin, self.zmax + 1):
                     data = point_result[npy.where(npy.round(point_move[:, 2]) == i)]
                     if data is not None:
                         if data.shape[0] == 0:
                             continue
                         count = data.shape[0]
                         points = vtk.vtkPoints()
                         for j in range(count):
                             points.InsertPoint(j, data[j, 0], data[j, 1], data[j, 2])
                         
                         para_spline = vtk.vtkParametricSpline()
                         para_spline.SetXSpline(vtk.vtkKochanekSpline())
                         para_spline.SetYSpline(vtk.vtkKochanekSpline())
                         para_spline.SetZSpline(vtk.vtkKochanekSpline())
                         para_spline.SetPoints(points)
                         para_spline.ClosedOn()
                         
                         # The number of output points set to 10 times of input points
                         numberOfOutputPoints = count * 10
                         self.cells.InsertNextCell(numberOfOutputPoints)
                         for k in range(0, numberOfOutputPoints):
                             t = k * 1.0 / numberOfOutputPoints
                             pt = [0.0, 0.0, 0.0]
                             para_spline.Evaluate([t, t, t], pt, [0] * 9)
                             if pt[0] != pt[0]:
                                 print pt
                                 continue
                             self.points.InsertPoint(l, pt[0], pt[1], pt[2])
                             self.cells.InsertCellPoint(l)
                             l += 1
     
                 self.contours[cnt].SetPoints(self.points)
                 self.contours[cnt].SetPolys(self.cells)
                 self.contours[cnt].Update()
                 
             self.render_window.Render()
             saveGif(self.render_window, num)
             num += 1
开发者ID:guohengkai,项目名称:MIRVAP,代码行数:55,代码来源:SurfaceGifView.py


示例12: method

        def method(self):

            # multiblock += contact points
            output_a = self._contact_source_a.GetPolyDataOutput()
            output_b = self._contact_source_b.GetPolyDataOutput()

            id_f = numpy.where(
                abs(self._data[:, 0] - self._time) < 1e-15)[0]

            self.cpa_export = self._data[
                id_f, 2:5].copy()

            self.cpb_export = self._data[
                id_f, 5:8].copy()

            self.cn_export = self._data[
                id_f, 8:11].copy()

            self.cf_export = self._data[
                id_f, 11:14].copy()

            self.cpa_ = numpy_support.numpy_to_vtk(
                self.cpa_export)
            self.cpa_.SetName('contact_positions_A')

            self.cpb_ = numpy_support.numpy_to_vtk(
                self.cpb_export)
            self.cpb_.SetName('contact_positions_B')

            self.cn_ = numpy_support.numpy_to_vtk(
                self.cn_export)
            self.cn_.SetName('contact_normals')

            self.cf_ = numpy_support.numpy_to_vtk(
                self.cf_export)
            self.cf_.SetName('contact_forces')

            output_a.Allocate(len(self.cpa_export), 1)

            cpa_points = vtk.vtkPoints()
            cpa_points.SetNumberOfPoints(len(self.cpa_export))
            cpa_points.SetData(self.cpa_)
            output_a.SetPoints(cpa_points)

            # normal and forces are attached to A points
            output_a.GetPointData().AddArray(self.cn_)
            output_a.GetPointData().AddArray(self.cf_)

            output_b.Allocate(len(self.cpb_export), 1)

            cpb_points = vtk.vtkPoints()
            cpb_points.SetNumberOfPoints(len(self.cpb_export))
            cpb_points.SetData(self.cpb_)

            output_b.SetPoints(cpb_points)
开发者ID:radarsat1,项目名称:siconos,代码行数:55,代码来源:vexport.py


示例13: vtk_ellipsoid_topomesh

def vtk_ellipsoid_topomesh(ellipsoid_radius=50.0, ellipsoid_scales=[1,1,1], ellipsoid_axes=np.diag(np.ones(3)), ellipsoid_center=np.zeros(3)):
    """
    """      
    import vtk
    from openalea.cellcomplex.property_topomesh.utils.image_tools import vtk_polydata_to_triangular_mesh

    ico = vtk.vtkPlatonicSolidSource()
    ico.SetSolidTypeToIcosahedron()
    ico.Update()

    subdivide = vtk.vtkLoopSubdivisionFilter()
    subdivide.SetNumberOfSubdivisions(3)
    subdivide.SetInputConnection(ico.GetOutputPort())
    subdivide.Update()

    scale_transform = vtk.vtkTransform()
    scale_factor = ellipsoid_radius/(np.sqrt(2)/2.)
    scale_transform.Scale(scale_factor,scale_factor,scale_factor)

    ellipsoid_sphere = vtk.vtkTransformPolyDataFilter()
    ellipsoid_sphere.SetInput(subdivide.GetOutput())
    ellipsoid_sphere.SetTransform(scale_transform)
    ellipsoid_sphere.Update()

    ellipsoid_transform = vtk.vtkTransform()
    axes_transform = vtk.vtkLandmarkTransform()
    source_points = vtk.vtkPoints()
    source_points.InsertNextPoint([1,0,0])
    source_points.InsertNextPoint([0,1,0])
    source_points.InsertNextPoint([0,0,1])
    target_points = vtk.vtkPoints()
    target_points.InsertNextPoint(ellipsoid_axes[0])
    target_points.InsertNextPoint(ellipsoid_axes[1])
    target_points.InsertNextPoint(ellipsoid_axes[2])
    axes_transform.SetSourceLandmarks(source_points)
    axes_transform.SetTargetLandmarks(target_points)
    axes_transform.SetModeToRigidBody()
    axes_transform.Update()
    ellipsoid_transform.SetMatrix(axes_transform.GetMatrix())
    ellipsoid_transform.Scale(ellipsoid_scales[0],ellipsoid_scales[1],ellipsoid_scales[2])
    center_transform = vtk.vtkTransform()
    center_transform.Translate(ellipsoid_center[0],ellipsoid_center[1],ellipsoid_center[2])
    center_transform.Concatenate(ellipsoid_transform)
    ellipsoid_ellipsoid = vtk.vtkTransformPolyDataFilter()
    ellipsoid_ellipsoid.SetInput(ellipsoid_sphere.GetOutput())
    ellipsoid_ellipsoid.SetTransform(center_transform)
    ellipsoid_ellipsoid.Update()

    ellipsoid_mesh = vtk_polydata_to_triangular_mesh(ellipsoid_ellipsoid.GetOutput())

    topomesh = triangle_topomesh(ellipsoid_mesh.triangles.values(),ellipsoid_mesh.points)

    return topomesh
开发者ID:VirtualPlants,项目名称:cellcomplex,代码行数:53,代码来源:example_topomesh.py


示例14: draw_lines

def draw_lines(nodes, color):
    colors = vtk.vtkUnsignedCharArray()
    colors.SetNumberOfComponents(3)
    colors.SetName("Colors")
    cnt = 0
    noderange = 100
    mod = 1
    edges = nodes[0].getedges()
    points = vtk.vtkPoints()
    lines = vtk.vtkCellArray()
    nodecnt = 0

    while cnt < len(nodes):
        node = nodes[cnt]
        cnt += 1
        edges = node.getedges()
        for edge in edges:
            x0,y0,z0 = edge[0]
            x1,y1,z1 = edge[1]

            points.InsertNextPoint(edge[0])
            points.InsertNextPoint(edge[1])

            line = vtk.vtkLine()
            line.GetPointIds().SetId(0,nodecnt)
            line.GetPointIds().SetId(1,nodecnt+1)
            lines.InsertNextCell(line)
            nodecnt += 2
            colors.InsertNextTupleValue(color)

        if cnt % mod == 0:
            print "noderange", noderange, "cnt", cnt, "mod",mod
            # Create a polydata to store everything in
            linesPolyData = vtk.vtkPolyData()
            # Add the points to the dataset
            linesPolyData.SetPoints(points)
            # Add the lines to the dataset
            linesPolyData.SetLines(lines)
            linesPolyData.GetCellData().SetScalars(colors)

            mapper = vtk.vtkPolyDataMapper()
            mapper.SetInput(linesPolyData)
            actor = vtk.vtkActor()
            actor.SetMapper(mapper)
            renderer.AddActor(actor)
            points = vtk.vtkPoints()
            lines = vtk.vtkCellArray()
            nodecnt = 0    
            renderWindow.Render()
            camera = renderer.GetActiveCamera()
            camera.Azimuth(0.1)

    print "done!"
开发者ID:squeakus,项目名称:octree,代码行数:53,代码来源:animatetree.py


示例15: InitializeSeeds

    def InitializeSeeds(self):
        if (self.InteractionMode==0):
	    self.SeedIds.Initialize()
	    self.SeedPoints.Initialize()
	    seedPoints = vtk.vtkPoints()
	    self.SeedPoints.SetPoints(seedPoints)
	else:
	    self.ExamineSpheres.Initialize()
	    spherePoints = vtk.vtkPoints()
	    self.ExamineSpheres.SetPoints(spherePoints)
	    self.ExamineSpheres.GetPointData().Initialize()
	    sphereRadii = vtk.vtkDoubleArray()
	    self.ExamineSpheres.GetPointData().SetScalars(sphereRadii)
开发者ID:ChaliZhg,项目名称:vmtk,代码行数:13,代码来源:vmtkdijkstradistancetopoints.py


示例16: MakePyramid

def MakePyramid():
    '''
      Make a regular square pyramid.
    '''
    numberOfVertices = 5
 
    points = vtk.vtkPoints()
 
    p = [
         [1.0, 1.0, 0.0],
         [-1.0, 1.0, 0.0],
         [-1.0, -1.0, 0.0],
         [1.0, -1.0, 0.0],
         [0.0, 0.0, 1.0]
         ]
    for pt in p:
        points.InsertNextPoint(pt)
 
    pyramid = vtk.vtkPyramid()
    for i in range(0, numberOfVertices):
        pyramid.GetPointIds().SetId(i, i)
 
    ug = vtk.vtkUnstructuredGrid()
    ug.SetPoints(points)
    ug.InsertNextCell(pyramid.GetCellType(), pyramid.GetPointIds())
 
    return ug
开发者ID:IsaiahKing,项目名称:MiscRecord,代码行数:27,代码来源:Cell3DDemonstration.py


示例17: copyFirstNLines

  def copyFirstNLines(self, sourcePolyData, lineCount):
    """make a polydata with only the first N polylines"""

    polyData = vtk.vtkPolyData()
    points = vtk.vtkPoints()
    polyData.SetPoints(points)

    lines = vtk.vtkCellArray()
    polyData.SetLines(lines)

    sourcePoints = sourcePolyData.GetPoints()
    sourceLines = sourcePolyData.GetLines()
    sourceIdList = vtk.vtkIdList()
    sourceLines.InitTraversal()
    while sourceLines.GetNextCell(sourceIdList):
        pointCount = sourceIdList.GetNumberOfIds()
        idList = vtk.vtkIdList()
        for idIndex in range(pointCount):
            sourceId = sourceIdList.GetId(idIndex)
            point = sourcePoints.GetPoint(sourceId)
            id = points.InsertNextPoint(point)
            idList.InsertNextId(id)
        lines.InsertNextCell(idList)
        if lines.GetNumberOfCells() > lineCount:
            break

    return polyData
开发者ID:pieper,项目名称:SlicerWeb,代码行数:27,代码来源:glTF.py


示例18: array2vtkPoints

def array2vtkPoints(num_array, vtk_points=None):
    """Converts a numpy array/Python list to a vtkPoints object.

    Unless a Python list/tuple or a non-contiguous array is given, no
    copy of the data is made.  Thus the function is very efficient.

    Parameters
    ----------

    - num_array : numpy array or Python list/tuple

      The input array must be 2D with `shape[1] == 3`.

    - vtk_points : `vtkPoints` (default: `None`)

      If an optional `vtkPoints` instance, is passed as an argument
      then a new array is not created and returned.  The passed array
      is itself modified and returned.

    """
    if vtk_points:
        points  = vtk_points
    else:
        points = vtk.vtkPoints()

    arr = numpy.asarray(num_array)
    assert len(arr.shape) == 2, "Points array must be 2 dimensional."
    assert arr.shape[1] == 3, "Incorrect shape: shape[1] must be 3."
    vtk_array = array2vtk(arr)
    points.SetData(vtk_array)
    return points
开发者ID:PerryZh,项目名称:mayavi,代码行数:31,代码来源:array_handler.py


示例19: 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


示例20: make_cylinderActor

def make_cylinderActor (r, x0, x1, rgb, opacity):
    points = vtk.vtkPoints()
    lines  = vtk.vtkCellArray()
    lines.InsertNextCell(2)
    # point 0
    points.InsertNextPoint(x0[0], x0[1], x0[2])
    lines.InsertCellPoint(0)
    # point 1
    points.InsertNextPoint(x1[0], x1[1], x1[2])
    lines.InsertCellPoint(1)

    cData = vtk.vtkPolyData()
    cData.SetPoints(points)
    cData.SetLines(lines)

    c = vtk.vtkTubeFilter()
    c.SetNumberOfSides(8)
    c.SetInput(cData)
    c.SetRadius(r)

    cMapper = vtk.vtkPolyDataMapper()
    cMapper.SetInput(c.GetOutput())

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

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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