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


Python vtk.vtkStringArray函数代码示例

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


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

示例1: testMultiTreeOutputs

    def testMultiTreeOutputs(self):
        outputs = vtk.vtkStringArray()
        outputs.SetNumberOfComponents(1)
        outputs.SetNumberOfTuples(2)
        outputs.SetValue(0, "tree1")
        outputs.SetValue(1, "tree2")
        rcal = vtk.vtkRCalculatorFilter()


        rcal.SetRscript("library(ape)\n\
                         tree1 = read.tree(text=\"" + tree_data + "\")\n\
                         tree2 = read.tree(text=\"" + tree_data + "\")\n")

        rcal.GetTrees(outputs)

        input = vtk.vtkTable()
        rcal.SetInputData(input)

        rcal.Update()

        compo = rcal.GetOutput()
        tree1 = compo.GetPieceAsDataObject(0)
        self.assertTrue(tree1.IsA('vtkTree'))
        tree2 = compo.GetPieceAsDataObject(1)
        self.assertTrue(tree2.IsA('vtkTree'))
开发者ID:0004c,项目名称:VTK,代码行数:25,代码来源:TestRCalculatorFilter.py

示例2: testReturnByReference

 def testReturnByReference(self):
     """Return a string by reference."""
     a = vtk.vtkStringArray()
     s = "hello"
     a.InsertNextValue(s)
     t = a.GetValue(0)
     self.assertEqual(t, s)
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:TestStrings.py

示例3: getRAWReader

	def getRAWReader(self, Series_Info, Channel):
		"""
		create a tiff reader that reads then given channel of the given series
		"""
		XYDim = Series_Info['Resolution_X'] - 1
		NumSect = Series_Info['Number_Sections'] - 1
		XSpace = Series_Info['Voxel_Width_X']
		YSpace = Series_Info['Voxel_Height_Y']
		ZSpace = Series_Info['Voxel_Depth_Z']
		
		RAWReader = vtk.vtkImageReader2()
		if self.progressCallback:
			RAWReader.AddObserver("ProgressEvent", lib.messenger.send)
			lib.messenger.connect(RAWReader, 'ProgressEvent', self.progressCallback)
		arr = vtk.vtkStringArray()
		for i in Channel:
			arr.InsertNextValue(os.path.join(self.path, i))
		RAWReader.SetFileNames(arr)
	
		if Series_Info['Bit_Depth'] == 8:
			RAWReader.SetDataScalarTypeToUnsignedChar()
		elif Series_Info['Bit_Depth'] == 12:
			RAWReader.SetDataScalarTypeToUnsignedShort()
		RAWReader.FileLowerLeftOff()

		spacingX,spacingY,spacingZ = 1.0,1.0,1.0
		if XSpace != 0.0 and YSpace != 0.0:
			spacingY = YSpace / XSpace
		if XSpace != 0.0 and ZSpace != 0.0:
			spacingZ = ZSpace / XSpace
		
		RAWReader.SetDataExtent(0, XYDim, 0, XYDim, 0, NumSect)
		RAWReader.SetDataSpacing(spacingX, spacingY, spacingZ)
		RAWReader.Update()
		return RAWReader
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:35,代码来源:LeicaDataSource.py

示例4: computeStatistics

  def computeStatistics(self, segmentationNode, grayscaleNode, visibleSegmentsOnly = True):
    import vtkSegmentationCorePython as vtkSegmentationCore

    self.reset()

    self.segmentationNode = segmentationNode
    self.grayscaleNode = grayscaleNode

    # Get segment ID list
    visibleSegmentIds = vtk.vtkStringArray()
    if visibleSegmentsOnly:
      self.segmentationNode.GetDisplayNode().GetVisibleSegmentIDs(visibleSegmentIds)
    else:
      self.segmentationNode.GetSegmentation().GetSegmentIDs(visibleSegmentIds)
    if visibleSegmentIds.GetNumberOfValues() == 0:
      logging.debug("computeStatistics will not return any results: there are no visible segments")
    # Initialize self.statistics with segment IDs and names
    for segmentIndex in range(visibleSegmentIds.GetNumberOfValues()):
      segmentID = visibleSegmentIds.GetValue(segmentIndex)
      segment = self.segmentationNode.GetSegmentation().GetSegment(segmentID)
      self.statistics["SegmentIDs"].append(segmentID)
      self.statistics[segmentID,"Segment"] = segment.GetName()

    self.addSegmentLabelmapStatistics()
    self.addGrayscaleVolumeStatistics()
    self.addSegmentClosedSurfaceStatistics()
开发者ID:MayeulChassagnard,项目名称:Slicer,代码行数:26,代码来源:SegmentStatistics.py

示例5: VtkCreaStrArraySetData

def VtkCreaStrArraySetData(setToDraw, entTypeName, attr):
  '''Creates an array of strings with information associated 
  to the points and cells.
  Parameters:
    setToDraw:   set of entities to be displayed
    entTypeName: type of entities to be displayed 
                 ("pnts", "lines", "nodes", "elementos")
    attr:        attribute to be stored in the array
  '''
  # Define matrix
  arr= vtk.vtkStringArray()
  arr.SetName(attr)
  container= None
  if(entTypeName=="pnts"):
    container= setToDraw.getPoints
  elif(entTypeName=="lines"):
    container= setToDraw.getLines
  elif(entTypeName=="nodes"):
    container= setToDraw.getNodes
  elif(entTypeName=="elementos"):
    container= setToDraw.getElements
  else:
    lmsg.error("error: "+entTypeName+" not implemented.")
  for e in container:
    tmp= str(getattr(e,attr))
    arr.InsertValue(e.getIdx,tmp)
  return arr
开发者ID:lcpt,项目名称:xc,代码行数:27,代码来源:create_array_set_data.py

示例6: examineForImport

  def examineForImport(self,fileLists):
    """ Returns a list of qSlicerDICOMLoadable
    instances corresponding to ways of interpreting the 
    fileLists parameter.
    """
    # Create loadables for each file list
    loadables = []
    for fileList in fileLists: # Each file list corresponds to one series, so do loadables
      # Convert file list to VTK object to be able to pass it for examining
      # (VTK class cannot have Qt object as argument, otherwise it is not python wrapped)
      vtkFileList = vtk.vtkStringArray()
      for file in fileList:
        vtkFileList.InsertNextValue(slicer.util.toVTKString(file))

      # Examine files
      loadablesCollection = vtk.vtkCollection()
      slicer.modules.dicomrtimportexport.logic().ExamineForLoad(vtkFileList, loadablesCollection)

      for loadableIndex in xrange(0,loadablesCollection.GetNumberOfItems()):
        vtkLoadable = loadablesCollection.GetItemAsObject(loadableIndex)
        # Create Qt loadable if confidence is greater than 0
        if vtkLoadable.GetConfidence() > 0:
          # Convert to Qt loadable to pass it back
          qtLoadable = slicer.qSlicerDICOMLoadable()
          qtLoadable.copyFromVtkLoadable(vtkLoadable)
          qtLoadable.tooltip = 'Valid RT object in selection'
          qtLoadable.selected = True
          loadables.append(qtLoadable)

    return loadables
开发者ID:Sunderlandkyl,项目名称:SlicerRT,代码行数:30,代码来源:DicomRtImportExportPlugin.py

示例7: DICOMReaderToNumpy

def DICOMReaderToNumpy(directory):
    file_list = glob.glob(directory + os.sep + "*")
    file_list = sorted(file_list)

    ipp = gdcm.IPPSorter()
    ipp.SetComputeZSpacing(True)
    ipp.Sort(file_list)

    file_list = ipp.GetFilenames()

    array = vtk.vtkStringArray()

    for x in xrange(len(file_list)):
        array.InsertValue(x, file_list[x])

    read = vtkgdcm.vtkGDCMImageReader()
    read.SetFileNames(array)
    read.Update()

    img = vtk.vtkImageData()
    img.DeepCopy(read.GetOutput())
    img.SetSpacing(1, 1, 1)
    img.Update()

    ex = img.GetExtent()
    image = vtk.util.numpy_support.vtk_to_numpy(img.GetPointData().GetScalars())
    image = image.reshape((ex[5] + 1, ex[1] + 1, ex[3] + 1))

    return ApplyWindowLevel(image, 2000, 300)
开发者ID:paulojamorim,项目名称:simple_python_volume_rendering,代码行数:29,代码来源:reader.py

示例8: GenerateVTKGraph

def GenerateVTKGraph(graph):
    '''
    Take the vertices and edge list in the graph parameter
    and return a VTK graph.
    '''
    g = vtk.vtkMutableDirectedGraph()
    # Label the vertices
    labels = vtk.vtkStringArray()
    labels.SetNumberOfComponents(1)
    labels.SetName("Labels")

    index = dict()
    l = list(graph[0])
    # Make the vertex labels and create a dictionary with the
    # keys as labels and the vertex ids as the values.
    for i in range(0, len(l)):
        # Set the vertex labels
        labels.InsertNextValue(l[i])
        index[l[i]] = g.AddVertex()
    g.GetVertexData().AddArray(labels)
    # Add edges
    l = list(graph[1])
    for i in range(0, len(l)):
        ll = list(l[i])
        g.AddGraphEdge(index[ll[0]], index[ll[1]])
#    g.Dump()
    return g
开发者ID:AmirKhooj,项目名称:VTK,代码行数:27,代码来源:VisualizeModuleDependencies.py

示例9: _init

 def _init(self):
   g = vtk.vtkMutableDirectedGraph()
   v1 = g.AddVertex()
   v2 = g.AddVertex()
   g.AddGraphEdge(v1,v2)
   G_labels = vtk.vtkStringArray()
   G_labels.SetName("VLabels")
   G_labels.InsertNextValue("One")
   G_labels.InsertNextValue("Two")
   g.GetVertexData().AddArray(G_labels)
   G_labels = vtk.vtkStringArray()
   G_labels.SetName("VLabels")
   G_labels.InsertNextValue("Three")
   G_labels.InsertNextValue("Four")
   g.GetVertexData().AddArray(G_labels)
   return g
开发者ID:lexich,项目名称:hardinv_bot_lexich,代码行数:16,代码来源:visualize.py

示例10: add_line

    def add_line(self, start, end, color=(0.5, 0.5, 0.5), width=1):
        """
        Adds a line.

        Args:
            start:
                Starting coordinates for line.
            end:
                Ending coordinates for line.
            color:
                Color for text as RGB. Defaults to grey.
            width:
                Width of line. Defaults to 1.
        """
        source = vtk.vtkLineSource()
        source.SetPoint1(start)
        source.SetPoint2(end)

        vertexIDs = vtk.vtkStringArray()
        vertexIDs.SetNumberOfComponents(1)
        vertexIDs.SetName("VertexIDs")
        # Set the vertex labels
        vertexIDs.InsertNextValue("a")
        vertexIDs.InsertNextValue("b")
        source.GetOutput().GetPointData().AddArray(vertexIDs)

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().SetColor(color)
        actor.GetProperty().SetLineWidth(width)
        self.ren.AddActor(actor)
开发者ID:akashneo,项目名称:pymatgen,代码行数:33,代码来源:structure_vtk.py

示例11: loadFolder

    def loadFolder(self):
        loader = self.folderLoader
        loader.loadFile()

        if loader.accepted:
            loader.setDir(os.path.dirname(str(loader.selectedFolder)))
            self.dicomReader = vtkgdcm.vtkGDCMImageReader()
            regex = re.compile(r'.+\.dcm')
            files = [x for x in os.listdir(loader.selectedFolder) if re.match(regex, x)]
            self.seriesSize = len(files)
            temp = vtk.vtkStringArray()
            temp.SetNumberOfValues(len(files))
            i = 0
            for file in sorted(files):
                temp.SetValue(i, os.path.join(str(loader.selectedFolder), file))
                i = i + 1
            self.dicomReader.SetFileNames(temp)
            self.dicomReader.Update()

            imageData = self.dicomReader.GetOutput()
            size = imageData.GetDimensions()
            width = size[0]
            height = size[1]
            self.vtkWidget.setMaximumSize(QtCore.QSize(width, height))
            self.vtkWidget.setMinimumSize(QtCore.QSize(width, height))
            self.viewer.SetInputConnection(self.dicomReader.GetOutputPort())
            self.iren.ReInitialize()

            self.getMedicalData()

            self.enableSlider(self.seriesSize-1)
            self.ui.dicomSlider.setFocus()
开发者ID:Nefarin,项目名称:SODM,代码行数:32,代码来源:AppWindow.py

示例12: testIgnoreBTX

    def testIgnoreBTX(self):
        """Try to call a method that is BTX'd, to ensure VTK_IGNORE_BTX=ON
        """

        stringArray = vtk.vtkStringArray()
        information = vtk.vtkInformation()
        stringArray.CopyInformation(information, 0)
开发者ID:0004c,项目名称:VTK,代码行数:7,代码来源:TestIgnoreBTX.py

示例13: onApply

  def onApply(self):
    self.delayedAutoUpdateTimer.stop()
    self.observeSegmentation(False)

    import vtkSegmentationCorePython as vtkSegmentationCore
    segmentationNode = self.scriptedEffect.parameterSetNode().GetSegmentationNode()
    segmentationDisplayNode = segmentationNode.GetDisplayNode()
    previewNode = self.getPreviewNode()

    self.scriptedEffect.saveStateForUndo()

    # Move segments from preview into current segmentation
    segmentIDs = vtk.vtkStringArray()
    previewNode.GetSegmentation().GetSegmentIDs(segmentIDs)
    for index in xrange(segmentIDs.GetNumberOfValues()):
      segmentID = segmentIDs.GetValue(index)
      previewSegment = previewNode.GetSegmentation().GetSegment(segmentID)
      previewSegmentLabelmap = previewSegment.GetRepresentation(vtkSegmentationCore.vtkSegmentationConverter.GetSegmentationBinaryLabelmapRepresentationName())
      slicer.vtkSlicerSegmentationsModuleLogic.SetBinaryLabelmapToSegment(previewSegmentLabelmap, segmentationNode, segmentID)
      if segmentationDisplayNode is not None and self.isBackgroundLabelmap(previewSegmentLabelmap):
        # Automatically hide result segments that are background (all eight corners are non-zero)
        segmentationDisplayNode.SetSegmentVisibility(segmentID, False)
      previewNode.GetSegmentation().RemoveSegment(segmentID) # delete now to limit memory usage

    self.reset()
开发者ID:andrewfzheng,项目名称:Slicer,代码行数:25,代码来源:AbstractScriptedSegmentEditorAutoCompleteEffect.py

示例14: __init__

    def __init__(self, filename, max_num_of_vertices=-1, edge_color_filename=None):
        super(VTKVisualizer, self).__init__()
        self.vertex_id_idx_map = {}
        self.next_vertex_id = 0
        self.edge_counter = 0
        self.lookup_table = vtk.vtkLookupTable()
        self.lookup_table.SetNumberOfColors(int(1e8))
        self.edge_color_tuples = {}
        self.edge_color_filename = edge_color_filename
        self.label_vertex_id_map = {}
        self.starting_vertex = None
        self.starting_vertex_index = -1
        self.filename = filename
        self.max_num_of_vertices = max_num_of_vertices
        self.g = vtk.vtkMutableDirectedGraph()

        self.vertex_ids = vtk.vtkIntArray()
        self.vertex_ids.SetNumberOfComponents(1)
        self.vertex_ids.SetName(VERTEX_ID)

        self.labels = vtk.vtkStringArray()
        self.labels.SetNumberOfComponents(1)
        self.labels.SetName(LABELS)

        self.glyph_scales = vtk.vtkFloatArray()
        self.glyph_scales.SetNumberOfComponents(1)
        self.glyph_scales.SetName(SCALES)

        self.edge_weights = vtk.vtkDoubleArray()
        self.edge_weights.SetNumberOfComponents(1)
        self.edge_weights.SetName(WEIGHTS)

        self.edge_colors = vtk.vtkIntArray()
        self.edge_colors.SetNumberOfComponents(1)
        self.edge_colors.SetName(EDGE_COLORS)
开发者ID:AlexLeSang,项目名称:NetGraph,代码行数:35,代码来源:vtkVisualizeGraph.py

示例15: getSegmentIDs

 def getSegmentIDs(segmentationNode, visibleOnly):
   if not segmentationNode:
     return []
   segmentIDs = vtk.vtkStringArray()
   segmentation = segmentationNode.GetSegmentation()
   command = segmentationNode.GetDisplayNode().GetVisibleSegmentIDs if visibleOnly else segmentation.GetSegmentIDs
   command(segmentIDs)
   return [segmentIDs.GetValue(idx) for idx in range(segmentIDs.GetNumberOfValues())]
开发者ID:QIICR,项目名称:Reporting,代码行数:8,代码来源:CustomSegmentEditor.py


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