当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkIdList函数代码示例

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


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

示例1: Frechet_distances_2

def Frechet_distances_2(input_vtk_polydata_n, input_vtk_polydata_m):
    # compute Frechet distance from an array of fibers to another array

    number_of_lines_m = input_vtk_polydata_m.GetNumberOfLines()
    number_of_lines_n = input_vtk_polydata_n.GetNumberOfLines()
    all_fibers_m = range(0,number_of_lines_m)
    all_fibers_n = range(0,number_of_lines_n)
    distances = numpy.zeros([number_of_lines_m,number_of_lines_n])
    
    #input_vtk_polydata2 = input_vtk_polydata
    
    input_vtk_polydata_m.GetLines().InitTraversal()
    line1_ptids = vtk.vtkIdList()
    
    inpoints1 = input_vtk_polydata_m.GetPoints()
    inpoints2 = input_vtk_polydata_n.GetPoints()
    
    for lidx1 in all_fibers_m:
        input_vtk_polydata_m.GetLines().GetNextCell(line1_ptids)
        
        input_vtk_polydata_n.GetLines().InitTraversal()
        line2_ptids = vtk.vtkIdList()
        
        for lidx2 in all_fibers_n:
            input_vtk_polydata_n.GetLines().GetNextCell(line2_ptids)

            distances[lidx1,lidx2] = _frechet_distance_internal_use(inpoints1,inpoints2,line1_ptids,line2_ptids)

    return distances
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:29,代码来源:similarity.py

示例2: createGlyph

  def createGlyph(self):
    self.polyData = vtk.vtkPolyData()
    points = vtk.vtkPoints()
    lines = vtk.vtkCellArray()
    self.polyData.SetPoints( points )
    self.polyData.SetLines( lines )
    prevPoint = None
    firstPoint = None

    for x,y in ((0,0),)*4:
      p = points.InsertNextPoint( x, y, 0 )
      if prevPoint is not None:
        idList = vtk.vtkIdList()
        idList.InsertNextId( prevPoint )
        idList.InsertNextId( p )
        self.polyData.InsertNextCell( vtk.VTK_LINE, idList )
      prevPoint = p
      if firstPoint is None:
        firstPoint = p

    # make the last line in the polydata
    idList = vtk.vtkIdList()
    idList.InsertNextId( p )
    idList.InsertNextId( firstPoint )
    self.polyData.InsertNextCell( vtk.VTK_LINE, idList )
开发者ID:Slicer,项目名称:Slicer,代码行数:25,代码来源:RectangleEffect.py

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

示例4: getNumberOfPointsSharedByTwoCells

def getNumberOfPointsSharedByTwoCells( pd, iCell1, iCell2 ):
    '''Compute the number of shared points between iCell1 and iCell2 in the vtkPolyData pd.'''
    cell1_points = vtk.vtkIdList()
    pd.GetCellPoints( iCell1, cell1_points )
    cell2_points = vtk.vtkIdList()
    pd.GetCellPoints( iCell2, cell2_points )
    cell1_points.IntersectWith( cell2_points )
    return cell1_points.GetNumberOfIds()
开发者ID:timhutton,项目名称:klein-quartic,代码行数:8,代码来源:math_functions.py

示例5: __init__

 def __init__(self):
     self._Surface = None
     self._SeedIds = None
     self._SourceSeedIds = vtk.vtkIdList()
     self._TargetSeedIds = vtk.vtkIdList()
     self.PrintError = None
     self.PrintLog = None
     self.InputText = None
     self.OutputText = None
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:9,代码来源:vmtkcenterlines.py

示例6: createGlyph

  def createGlyph(self, polyData):
    """
    create a brush circle of the right radius in XY space
    - assume uniform scaling between XY and RAS which
      is enforced by the view interactors
    """
    sliceNode = self.sliceWidget.sliceLogic().GetSliceNode()
    self.rasToXY.DeepCopy(sliceNode.GetXYToRAS())
    self.rasToXY.Invert()
    maximum, maxIndex = 0,0
    for index in range(3):
      if abs(self.rasToXY.GetElement(0, index)) > maximum:
        maximum = abs(self.rasToXY.GetElement(0, index))
        maxIndex = index
    point = [0, 0, 0, 0]
    point[maxIndex] = self.radius
    xyRadius = self.rasToXY.MultiplyPoint(point)
    import math
    xyRadius = math.sqrt( xyRadius[0]**2 + xyRadius[1]**2 + xyRadius[2]**2 )

    if self.pixelMode:
      xyRadius = 0.01

    # make a circle paint brush
    points = vtk.vtkPoints()
    lines = vtk.vtkCellArray()
    polyData.SetPoints(points)
    polyData.SetLines(lines)
    PI = 3.1415926
    TWOPI = PI * 2
    PIoverSIXTEEN = PI / 16
    prevPoint = -1
    firstPoint = -1
    angle = 0
    while angle <= TWOPI:
      x = xyRadius * math.cos(angle)
      y = xyRadius * math.sin(angle)
      p = points.InsertNextPoint( x, y, 0 )
      if prevPoint != -1:
        idList = vtk.vtkIdList()
        idList.InsertNextId(prevPoint)
        idList.InsertNextId(p)
        polyData.InsertNextCell( vtk.VTK_LINE, idList )
      prevPoint = p
      if firstPoint == -1:
        firstPoint = p
      angle = angle + PIoverSIXTEEN

    # make the last line in the circle
    idList = vtk.vtkIdList()
    idList.InsertNextId(p)
    idList.InsertNextId(firstPoint)
    polyData.InsertNextCell( vtk.VTK_LINE, idList )
开发者ID:Slicer,项目名称:Slicer,代码行数:53,代码来源:PaintEffect.py

示例7: create_cylinder

def create_cylinder(r=.5, h=1., res=30):
    pts = vtk.vtkPoints()
    pts.SetNumberOfPoints(10*res)

    pd = vtk.vtkPolyData()
    pd.Allocate(3*res, 1)

    ang = 2*math.pi/res

    ind = 0

    for sign in [-1, 1]:
        y = sign*h/2
        for i in range(res):
            c0, s0 = math.cos(i*ang), math.sin(i*ang)
            c1, s1 = math.cos((i+1)*ang), math.sin((i+1)*ang)

            x0, z0 = round(r*c0, 6), round(r*s0, 6)
            x1, z1 = round(r*c1, 6), round(r*s1, 6)

            pts.InsertPoint(ind, 0, y, 0)
            pts.InsertPoint(ind+1, x0, y, z0)
            pts.InsertPoint(ind+2, x1, y, z1)

            tri = vtk.vtkIdList()
            [ tri.InsertNextId(ind+j) for j in range(3) ]

            t = pd.InsertNextCell(vtk.VTK_TRIANGLE, tri)

            ind += 3

            if sign == 1:
                pd.ReverseCell(t)

                pts.InsertPoint(ind, x0, -h/2, z0)
                pts.InsertPoint(ind+1, x0, y, z0)

                pts.InsertPoint(ind+2, x1, y, z1)
                pts.InsertPoint(ind+3, x1, -h/2, z1)

                poly = vtk.vtkIdList()
                [ poly.InsertNextId(ind+j) for j in range(4) ]

                pd.InsertNextCell(vtk.VTK_POLYGON, poly)

                ind += 4

    pd.SetPoints(pts)

    prod = vtk.vtkTrivialProducer()
    prod.SetOutput(pd)

    return prod
开发者ID:zippy84,项目名称:vtkbool,代码行数:53,代码来源:brick.py

示例8: VtkLoadElemMesh

    def VtkLoadElemMesh(self,field,defFScale=0.0,eigenMode=None):
        '''Load the element mesh

        :param field: scalar field to be represented
        :param defFScale: factor to apply to current displacement of nodes 
                  so that the display position of each node equals to
                  the initial position plus its displacement multiplied
                  by this factor. In case of modal analysis, the displayed 
                  position of each node equals to the initial position plus
                  its eigenVector multiplied by this factor.
                  (Defaults to 0.0, i.e. display of initial/undeformed shape)
        :param eigenMode: eigenvibration mode if we want to display the deformed 
                 shape associated with it when a modal analysis has been carried out. 
                 Defaults to None: no modal analysis.

        '''
        # Define grid
        self.nodes= vtk.vtkPoints()
        self.gridRecord.uGrid= vtk.vtkUnstructuredGrid()
        self.gridRecord.uGrid.SetPoints(self.nodes)
        eSet= self.gridRecord.xcSet
        eSet.numerate()
        self.gridRecord.uGrid.name= eSet.name+'_grid'
        # Scalar values.
        nodeSet= eSet.getNodes
        if(field):
            arr= field.fillArray(nodeSet)
            field.creaLookUpTable()      
        # Load nodes in vtk
        setNodes= eSet.getNodes
        if eigenMode==None:
            for n in setNodes:
                pos= n.getCurrentPos3d(defFScale)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
        else:
            for n in setNodes:
                pos= n.getEigenPos3d(defFScale,eigenMode)
                self.nodes.InsertPoint(n.getIdx,pos.x,pos.y,pos.z)
         # Load elements in vtk
        setElems= eSet.getElements
        for e in setElems:
            vertices= xc_base.vector_int_to_py_list(e.getIdxNodes)
            vtx= vtk.vtkIdList()
            for vIndex in vertices:
                vtx.InsertNextId(vIndex)
            if(e.getVtkCellType!= vtk.VTK_VERTEX):
                self.gridRecord.uGrid.InsertNextCell(e.getVtkCellType,vtx)
        setConstraints= eSet.getConstraints
        for c in setConstraints:
            vtx= vtk.vtkIdList()
            vtx.InsertNextId(c.getNodeIdx)
            if(c.getVtkCellType!= vtk.VTK_LINE):
                self.gridRecord.uGrid.InsertNextCell(c.getVtkCellType,vtx)
开发者ID:lcpt,项目名称:xc,代码行数:53,代码来源:vtk_FE_graphic.py

示例9: getDual

def getDual( pd ):
    '''Get the dual of a vtkPolyData. The finite parts only.'''
    pd.BuildLinks()
    cells = vtk.vtkCellArray()
    points = vtk.vtkPoints()
    for iPt in range(pd.GetNumberOfPoints()):
        neighbor_cellIds = vtk.vtkIdList()
        pd.GetPointCells( iPt, neighbor_cellIds )
        if neighbor_cellIds.GetNumberOfIds() < 3:
            continue
        # sort the neighbor_cellIds into a ring around iPt
        sorted_neighbor_cellIds = [ neighbor_cellIds.GetId( 0 ) ]
        for it in range( neighbor_cellIds.GetNumberOfIds() - 1 ):
            for iicell in range( 1, neighbor_cellIds.GetNumberOfIds() ):
                icell = neighbor_cellIds.GetId( iicell )
                if icell in sorted_neighbor_cellIds:
                    continue
                # does this cell share exactly two vertices with the last one in the list?
                if getNumberOfPointsSharedByTwoCells( pd, sorted_neighbor_cellIds[-1], icell ) == 2:
                    sorted_neighbor_cellIds += [ icell ]
                    break
        if len( sorted_neighbor_cellIds ) < neighbor_cellIds.GetNumberOfIds():
            continue # was a boundary vertex or non-manifold
        if not getNumberOfPointsSharedByTwoCells( pd, sorted_neighbor_cellIds[-1], sorted_neighbor_cellIds[0] ) == 2:
            continue # boundary vertex, in the case where cell id 0 was on the boundary
        # make a face around this vertex: a new point at each centroid of the neighboring cells
        cells.InsertNextCell( neighbor_cellIds.GetNumberOfIds() )
        for id in sorted_neighbor_cellIds:
            # find centroid of this cell
            neighbor_verts = vtk.vtkIdList()
            pd.GetCellPoints( id, neighbor_verts )
            c = (0,0,0)
            for iiv in range(neighbor_verts.GetNumberOfIds()):
                iv = neighbor_verts.GetId(iiv)
                p = pd.GetPoint( iv )
                c = add( c, p )
            c = mul( c, 1.0 / neighbor_verts.GetNumberOfIds() )
            # insert the centroid as a point and as an index into the new face
            cells.InsertCellPoint( points.InsertNextPoint( c ) )
    dual_pd = vtk.vtkPolyData()
    dual_pd.SetPoints( points )
    dual_pd.SetPolys( cells )

    # merge duplicate points
    cleaner = vtk.vtkCleanPolyData()
    if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
        cleaner.SetInputData( dual_pd )
    else:
        cleaner.SetInput( dual_pd )
    cleaner.SetTolerance(0.0001)
    cleaner.Update()
    return cleaner.GetOutput()
开发者ID:timhutton,项目名称:klein-quartic,代码行数:52,代码来源:math_functions.py

示例10: GetConnectedVertices

 def GetConnectedVertices(self, connectedVerticesIDList, polyData, pointID):
     # Return IDs of all the vertices that compose the first neighbor.
     cellList = vtk.vtkIdList()
     connectedVerticesIDList.InsertUniqueId(pointID)
     # Get cells that vertex 'pointID' belongs to
     polyData.GetPointCells(pointID, cellList)
     numberOfIds = cellList.GetNumberOfIds()
     for i in range(0, numberOfIds):
         # Get points which compose all cells
         pointIdList = vtk.vtkIdList()
         polyData.GetCellPoints(cellList.GetId(i), pointIdList)
         for j in range(0, pointIdList.GetNumberOfIds()):
             connectedVerticesIDList.InsertUniqueId(pointIdList.GetId(j))
     return connectedVerticesIDList
开发者ID:luciemac,项目名称:PickAndPaintExtension,代码行数:14,代码来源:PickAndPaint.py

示例11: __get_common_cells

 def __get_common_cells(self,p1,p2,exclude=-1):
     """
     Get all the cells containing p1 and p2
     """
     cell_list_1 = vtk.vtkIdList()
     self.__vtk_model.GetPointCells(p1,cell_list_1)
     nb_ids = cell_list_1.GetNumberOfIds()
     cell_list_1 = [cell_list_1.GetId(j) for j in xrange(nb_ids)]
     cell_list_2 = vtk.vtkIdList()
     self.__vtk_model.GetPointCells(p2,cell_list_2)
     nb_ids = cell_list_2.GetNumberOfIds()
     cell_list_2 = [cell_list_2.GetId(j) for j in xrange(nb_ids)]
     common_cells = [cell for cell in cell_list_1 if cell in cell_list_2 and cell!=exclude]
     return common_cells
开发者ID:ymerillac,项目名称:Optim_INSA_5GMM,代码行数:14,代码来源:apame_mesh.py

示例12: __init__

 def __init__(self):
     vmtkSeedSelector.__init__(self)
     self.PickedSeedIds = vtk.vtkIdList()
     self.PickedSeeds = vtk.vtkPolyData()
     self.vmtkRenderer = None
     self.OwnRenderer = 0
     self.Script = None
开发者ID:samsmu,项目名称:vmtk,代码行数:7,代码来源:vmtksurfaceendclipper.py

示例13: compute_max_array_along_lines

def compute_max_array_along_lines(pd, array_name, output_array_name):
    lines = pd.GetLines()
    point_array = pd.GetPointData().GetArray(array_name)
    
    point_array_max = vtk.vtkFloatArray()
    point_array_lines_list = list()
    point_array_max_list = list()
    lines.InitTraversal()
    for lidx in range(0, pd.GetNumberOfLines()):
        if (lidx % 100) == 0:
            print lidx, '/', pd.GetNumberOfLines()
        pts = vtk.vtkIdList()       
        lines.GetNextCell(pts)
        # compute mean POINT_ARRAY for this line
        if pts.GetNumberOfIds():
            point_array_list = list()
            for pidx in range(0, pts.GetNumberOfIds()):
                point_array_list.append(point_array.GetTuple1(pts.GetId(pidx)))
            point_array_max.InsertNextTuple1(numpy.max(numpy.array(point_array_list)))
            #fa_max.InsertNextTuple1(numpy.median(numpy.array(fa_list)))
        else:
            point_array_max.InsertNextTuple1(0.0)
            
    point_array_max.SetName(output_array_name)

    outpd = pd
    outpd.GetCellData().AddArray(point_array_max)
    outpd.GetCellData().SetActiveScalars(output_array_name)

    return outpd
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:30,代码来源:test_compute_FA.py

示例14: createCurtain

 def createCurtain( self, **args ):
     trajectory_points = self.getTrajectoryPoints( **args )
     extent =  self.input().GetExtent() 
     spacing =  self.input().GetSpacing() 
     nStrips = extent[5] - extent[4] 
     zmax = spacing[2] * nStrips
     z_inc = zmax / nStrips
     polydata = vtk.vtkPolyData()
     stripArray = vtk.vtkCellArray()
     stripData = [ vtk.vtkIdList() for ix in range(nStrips) ] 
     points = vtk.vtkPoints() 
     for iPt in range( trajectory_points.GetNumberOfPoints() ):
         pt_coords = trajectory_points.GetPoint( iPt )
         z = 0.0
         for iLevel in range( nStrips ):
             vtkId = points.InsertNextPoint( pt_coords[0], pt_coords[1], z )
             sd = stripData[ iLevel ]
             sd.InsertNextId( vtkId )               
             sd.InsertNextId( vtkId+1 )
             z = z + z_inc 
         points.InsertNextPoint( pt_coords[0], pt_coords[1], z )
                    
     for strip in stripData:
         stripArray.InsertNextCell(strip)
         
     polydata.SetPoints( points )
     polydata.SetStrips( stripArray )
     return polydata
开发者ID:painter1,项目名称:vistrails,代码行数:28,代码来源:CurtainPlotModule.py

示例15: cpnonzerocolor

def cpnonzerocolor(data):
    CellIdList = vtk.vtkIdList()
    CellIdList.Reset()
    colors = data.GetCellData().GetScalars()
    count = 0
    # Get indices from nonzero colored cells
    for i in range(data.GetNumberOfCells()):
        if ( colors.GetTuple(i) != (0.0, 0.0, 0.0, 0.0) ):
            CellIdList.InsertId(count, i)
            count = count + 1
#            print "Number Of cell:\t",i
#            print "Number of cell added:\t",count
        else:
            pass
    # Extract cells with nonzero color from data
    extractor = vtk.vtkExtractCells()
    extractor.SetInputData(data)
    extractor.SetCellList(CellIdList)
    extractor.Modified()
    extractor.Update()
    print "Number of nodes in clipped subvolume:\t",extractor.GetOutput().GetNumberOfPoints()
    print "Number of egdes in clipped subvolume:\t",extractor.GetOutput().GetNumberOfCells()
    # rearrange the id's of the cells and points - consecutive increasing ids

    print "...extracted zerocolor cells."
    
    return extractor.GetOutput()
开发者ID:mastricker,项目名称:DDDutils,代码行数:27,代码来源:conv.py


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