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

Python vtk.vtkLabeledDataMapper函数代码示例

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

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



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

示例1: VtkDibujaIdsCells

def VtkDibujaIdsCells(uGrid, setToDraw, entTypeName, renderer):
  ids= vtk.vtkIdFilter()
  ids.SetInput(uGrid)
  ids.CellIdsOff()
  ids.PointIdsOff()

  VtkCargaIdsCells(uGrid,setToDraw,entTypeName)
    
  # Dibuja las etiquetas de las líneas.
  cc= vtk.vtkCellCenters()
  cc.SetInputConnection(ids.GetOutputPort()) #  Centroides de las celdas. 
        
  visCells= vtk.vtkSelectVisiblePoints()
  visCells.SetInputConnection(cc.GetOutputPort())
  visCells.SetRenderer(renderer)
  visCells.SelectionWindowOff()

  #Create the mapper to display the cell ids.  Specify the format to
  # use for the labels.  Also create the associated actor.
  cellMapper= vtk.vtkLabeledDataMapper()
  cellMapper.SetInputConnection(visCells.GetOutputPort())
  cellMapper.GetLabelTextProperty().SetColor(0,0,0.9)

  cellLabels= vtk.vtkActor2D()
  cellLabels.SetMapper(cellMapper)
       
  renderer.AddActor2D(cellLabels)
开发者ID:lcpt,项目名称:xc,代码行数:27,代码来源:cad_mesh.py


示例2: VtkDibujaIdsKPts

def VtkDibujaIdsKPts(uGrid, setToDraw, renderer):
  '''Draw the point labels.'''
  numKPtsDI= setToDraw.getPoints.size
  if(numKPtsDI>0):
    ids= vtk.vtkIdFilter()
    ids.SetInput(uGrid)
    ids.CellIdsOff()
    ids.PointIdsOff()

    VtkCargaIdsKPts(uGrid,setToDraw)
            
    visPts= vtk.vtkSelectVisiblePoints()
    visPts.SetInputConnection(ids.GetOutputPort())
    visPts.SetRenderer(renderer)
    visPts.SelectionWindowOff()

    #Create the mapper to display the point ids.  Specify the format to
    #  use for the labels.  Also create the associated actor.
    ldm= vtk.vtkLabeledDataMapper()
    ldm.SetInputConnection(visPts.GetOutputPort())
    ldm.GetLabelTextProperty().SetColor(0.1,0.1,0.1)

    pointLabels= vtk.vtkActor2D()
    pointLabels.SetMapper(ldm)

    renderer.AddActor2D(pointLabels)
  else:
    print "El conjunto: '",setToDraw,"' no tiene KPts."
开发者ID:lcpt,项目名称:xc,代码行数:28,代码来源:cad_mesh.py


示例3: Execute

    def Execute(self):
 
        if not self.Centerlines:
            self.PrintError('Error: No input centerlines.')
            return
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self) 

        if self.CellDataArrayName:
            cellCenters = vtk.vtkCellCenters()
            cellCenters.SetInput(self.Centerlines)
            cellCenters.Update()
            cellCenters.GetOutput().GetPointData().SetActiveScalars(self.CellDataArrayName)
            labelsMapper = vtk.vtkLabeledDataMapper();
            labelsMapper.SetInput(cellCenters.GetOutput())
            labelsMapper.SetLabelModeToLabelScalars()
            labelsActor = vtk.vtkActor2D()
            labelsActor.SetMapper(labelsMapper)
            self.vmtkRenderer.Renderer.AddActor(labelsActor)

        centerlineMapper = vtk.vtkPolyDataMapper()
        centerlineMapper.SetInput(self.Centerlines)
        if self.CellDataArrayName and not self.PointDataArrayName:
            centerlineMapper.ScalarVisibilityOn()
            centerlineMapper.SetScalarModeToUseCellData()
            self.Centerlines.GetCellData().SetActiveScalars(self.CellDataArrayName)
            centerlineMapper.SetScalarRange(self.Centerlines.GetCellData().GetScalars().GetRange(0))
        elif self.PointDataArrayName:
            centerlineMapper.ScalarVisibilityOn()
            centerlineMapper.SetScalarModeToUsePointData()
            self.Centerlines.GetPointData().SetActiveScalars(self.PointDataArrayName)
            centerlineMapper.SetScalarRange(self.Centerlines.GetPointData().GetScalars().GetRange(0))
        else:
            centerlineMapper.ScalarVisibilityOff()
        centerlineActor = vtk.vtkActor()
        centerlineActor.SetMapper(centerlineMapper)
        self.vmtkRenderer.Renderer.AddActor(centerlineActor)

        scalarBarActor = None
        if self.Legend and centerlineActor and self.PointDataArrayName:
            scalarBarActor = vtk.vtkScalarBarActor()
            scalarBarActor.SetLookupTable(centerlineActor.GetMapper().GetLookupTable())
            scalarBarActor.GetLabelTextProperty().ItalicOff()
            scalarBarActor.GetLabelTextProperty().BoldOff()
            scalarBarActor.GetLabelTextProperty().ShadowOff()
            scalarBarActor.SetLabelFormat('%.2f')
            scalarBarActor.SetTitle(self.PointDataArrayName)
            self.vmtkRenderer.Renderer.AddActor(scalarBarActor)
	
	if self.Display:
            self.vmtkRenderer.Render()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
开发者ID:SaraZanchi,项目名称:vmtk,代码行数:59,代码来源:vmtkcenterlineviewer.py


示例4: add_actors

 def add_actors(self, list_of_actors, label=False):
     for actor in list_of_actors:
         self.ren.AddActor(actor)
         if label:
             labelMapper = vtk.vtkLabeledDataMapper()
             labelMapper.SetInput(actor.polydata)
             labelActor = vtk.vtkActor2D()
             labelActor.SetMapper(labelMapper)
             self.ren.AddActor(labelActor)
开发者ID:RodericDay,项目名称:MiniPNM,代码行数:9,代码来源:graphics.py


示例5: polyShowCellIds

def polyShowCellIds(ren,obj):

  #@c Show the cell ids of a given poly object in a renderer
  #@a ren: renderer
  #@a obj: object name
  if isinstance(obj,list):
      tag = "%s_%s" % (ren[0],obj[0])
  elif isinstance(obj,str):
      tag = "%s_%s" % (ren[0],obj)
  else:
      raise ValueError("Argument type unsupported.")
  
  try:
      vis.polyUnshowCellIds(ren,obj)
  except:
      pass
    
  lmap = [None]*2
  lmap[0] = "p_lmapc_"+tag
  labels = [None]*2
  labels[0] = "p_labelsc_"+tag  
  ids = [None]*2
  ids[0] = "p_cellids_"+tag
  
  filt = vtk.vtkCellCenters()
  if isinstance(obj,list):
        filt.SetInputDataObject(obj[1])
  else:
        vtkPoly = Repository.ExportToVtk(obj)
        filt.SetInputDataObject(vtkPoly)
  filt.Update()
  ids[1] = filt.GetOutput()
  
  lmap[1] = vtk.vtkLabeledDataMapper()
  lmap[1].SetLabelModeToLabelIds()
  lmap[1].SetInputDataObject(ids[1])
  lmap[1].SetLabelFormat("%g")
  labels[1] = vtk.vtkActor2D()
  labels[1].SetMapper(lmap[1])
  ren[1].AddActor2D(labels[1])
  
  vis.render(ren)
  setattr(vis,lmap[0],lmap)
  setattr(vis,labels[0],labels)
  return 
开发者ID:osmsc,项目名称:SimVascular,代码行数:45,代码来源:poly.py


示例6: polyShowScalarValues

def polyShowScalarValues(ren,obj):

  #@c Show the scalar values for object in renderer
  #@a ren: renderer
  #@a obj: object name
  if isinstance(obj,list):
      tag = "%s_%s" % (ren[0],obj[0])
  elif isinstance(obj,str):
      tag = "%s_%s" % (ren[0],obj)
  else:
      raise ValueError("Argument type unsupported.")
  
  try:
      vis.polyUnshowScalarValues(ren,obj)
  except:
      pass
      
  lmap = [None]*2
  lmap[0] = "p_lmap_"+tag
  labels = [None]*2
  labels[0] = "p_labels_"+tag  
  
  lmap[1] = vtk.vtkLabeledDataMapper()
  lmap[1].SetLabelModeToLabelScalars()
  if isinstance(obj,list):
        lmap[1].SetInputDataObject(obj[1])
  else:
        vtkPoly = Repository.ExportToVtk(obj)
        lmap[1].SetInputDataObject(vtkPoly)
  lmap[1].SetLabelFormat("%g")
  
  labels[1] = vtk.vtkActor2D()
  labels[1].SetMapper(lmap[1])
  ren[1].AddActor2D(labels[1])
  
  vis.render(ren)
  setattr(vis,lmap[0],lmap)
  setattr(vis,labels[0],labels)
  return
开发者ID:osmsc,项目名称:SimVascular,代码行数:39,代码来源:poly.py


示例7: Execute

    def Execute(self):

        if (self._Surface == None):
            self.PrintError('vmtkOpenProfilesSeedSelector Error: Surface not set.')
            return
        
        if (self._SeedIds == None):
            self.PrintError('vmtkOpenProfilesSeedSelector Error: SeedIds not set.')
            return

        self._SourceSeedIds.Initialize()
        self._TargetSeedIds.Initialize()

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        seedPoints = vtk.vtkPoints()
        for i in range(self._SeedIds.GetNumberOfIds()):
            seedPoints.InsertNextPoint(self._Surface.GetPoint(self._SeedIds.GetId(i)))
        seedPolyData = vtk.vtkPolyData()
        seedPolyData.SetPoints(seedPoints)
        seedPolyData.Update()
        labelsMapper = vtk.vtkLabeledDataMapper();
        labelsMapper.SetInput(seedPolyData)
        labelsMapper.SetLabelModeToLabelIds()
        labelsActor = vtk.vtkActor2D()
        labelsActor.SetMapper(labelsMapper)

        self.vmtkRenderer.Renderer.AddActor(labelsActor)

        surfaceMapper = vtk.vtkPolyDataMapper()
        surfaceMapper.SetInput(self._Surface)
        surfaceMapper.ScalarVisibilityOff()
        surfaceActor = vtk.vtkActor()
        surfaceActor.SetMapper(surfaceMapper)
        surfaceActor.GetProperty().SetOpacity(0.25)

        self.vmtkRenderer.Renderer.AddActor(surfaceActor)

        self.vmtkRenderer.Render()
        
        self.vmtkRenderer.Renderer.RemoveActor(labelsActor)
        self.vmtkRenderer.Renderer.RemoveActor(surfaceActor)

        seedIdString = self.InputText("Please input list of inlet profile ids: ")
        separator = ' '
        if seedIdString.find(',') != -1:
            separator = ','
        seedIdList = seedIdString.split(separator)
        for seedIdString in seedIdList:
            self._SourceSeedIds.InsertNextId(int(seedIdString.strip()))

        seedIdString = self.InputText("Please input list of outlet profile ids (leave empty for all available profiles): ")
        if seedIdString.strip() == '':
            self.OutputText("Selected outlets: ")
            for i in range(seedPoints.GetNumberOfPoints()):
                if self._SourceSeedIds.IsId(i) == -1:
                    self._TargetSeedIds.InsertNextId(i)
                    self.OutputText("%d " % i)
            self.OutputText("\n")
        else:
            seedIdList = seedIdString.split(separator)
            for seedIdString in seedIdList:
                self._TargetSeedIds.InsertNextId(int(seedIdString.strip()))
        
        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:69,代码来源:vmtkcenterlines.py


示例8: Execute

    def Execute(self):

        if not self.Centerlines:
            self.PrintError("Error: No input centerlines.")
            return

        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        self.vmtkRenderer.RegisterScript(self)

        if self.CellDataArrayName:
            cellCenters = vtk.vtkCellCenters()
            cellCenters.SetInputData(self.Centerlines)
            cellCenters.Update()
            cellCenters.GetOutput().GetPointData().SetActiveScalars(self.CellDataArrayName)
            labelsMapper = vtk.vtkLabeledDataMapper()
            labelsMapper.SetInputConnection(cellCenters.GetOutputPort())
            labelsMapper.SetLabelModeToLabelScalars()
            labelsActor = vtk.vtkActor2D()
            labelsActor.SetMapper(labelsMapper)
            self.vmtkRenderer.Renderer.AddActor(labelsActor)

        centerlineMapper = vtk.vtkPolyDataMapper()
        centerlineMapper.SetInputData(self.Centerlines)
        if self.CellDataArrayName and not self.PointDataArrayName:
            centerlineMapper.ScalarVisibilityOn()
            centerlineMapper.SetScalarModeToUseCellData()
            self.Centerlines.GetCellData().SetActiveScalars(self.CellDataArrayName)
            centerlineMapper.SetScalarRange(self.Centerlines.GetCellData().GetScalars().GetRange(0))
        elif self.PointDataArrayName:
            centerlineMapper.ScalarVisibilityOn()
            centerlineMapper.SetScalarModeToUsePointData()
            self.Centerlines.GetPointData().SetActiveScalars(self.PointDataArrayName)
            centerlineMapper.SetScalarRange(self.Centerlines.GetPointData().GetScalars().GetRange(0))
        else:
            centerlineMapper.ScalarVisibilityOff()

        if self.ColorMap == "grayscale":
            lut = centerlineMapper.GetLookupTable()
            lut.SetNumberOfTableValues(self.NumberOfColors)
            lut.SetValueRange(0.0, 1.0)
            lut.SetSaturationRange(0.0, 0.0)
            lut.Build()
            centerlineMapper.SetLookupTable(lut)

        if self.ColorMap == "rainbow":
            lut = centerlineMapper.GetLookupTable()
            lut.SetHueRange(0.666667, 0.0)
            lut.SetSaturationRange(0.75, 0.75)
            lut.SetValueRange(1.0, 1.0)
            lut.SetAlphaRange(1.0, 1.0)
            lut.SetNumberOfColors(self.NumberOfColors)
            lut.Build()
            centerlineMapper.SetLookupTable(lut)

        if self.ColorMap == "blackbody":
            lut = centerlineMapper.GetLookupTable()
            lut.SetNumberOfTableValues(self.NumberOfColors)
            colorTransferFunction = vtk.vtkColorTransferFunction()
            colorTransferFunction.SetColorSpaceToRGB()
            colorTransferFunction.AddRGBPoint(0, 0.0, 0.0, 0.0)
            colorTransferFunction.AddRGBPoint(0.4, 0.901961, 0.0, 0.0)
            colorTransferFunction.AddRGBPoint(0.8, 0.901961, 0.901961, 0.0)
            colorTransferFunction.AddRGBPoint(1.0, 1.0, 1.0, 1.0)
            for ii, ss in enumerate([float(xx) / float(self.NumberOfColors) for xx in range(self.NumberOfColors)]):
                cc = colorTransferFunction.GetColor(ss)
                lut.SetTableValue(ii, cc[0], cc[1], cc[2], 1.0)
            lut.Build()
            centerlineMapper.SetLookupTable(lut)

        if self.ColorMap == "cooltowarm":
            lut = centerlineMapper.GetLookupTable()
            lut.SetNumberOfTableValues(self.NumberOfColors)
            colorTransferFunction = vtk.vtkColorTransferFunction()
            colorTransferFunction.SetColorSpaceToDiverging()
            colorTransferFunction.AddRGBPoint(0, 0.231373, 0.298039, 0.752941)
            colorTransferFunction.AddRGBPoint(0.5, 0.865003, 0.865003, 0.865003)
            colorTransferFunction.AddRGBPoint(1.0, 0.705882, 0.0156863, 0.14902)
            for ii, ss in enumerate([float(xx) / float(self.NumberOfColors) for xx in range(self.NumberOfColors)]):
                cc = colorTransferFunction.GetColor(ss)
                lut.SetTableValue(ii, cc[0], cc[1], cc[2], 1.0)
            lut.Build()
            centerlineMapper.SetLookupTable(lut)

        centerlineActor = vtk.vtkActor()
        centerlineActor.SetMapper(centerlineMapper)
        self.vmtkRenderer.Renderer.AddActor(centerlineActor)

        scalarBarActor = None
        if self.Legend and centerlineActor and self.PointDataArrayName:
            scalarBarActor = vtk.vtkScalarBarActor()
            scalarBarActor.SetLookupTable(centerlineActor.GetMapper().GetLookupTable())
            scalarBarActor.GetLabelTextProperty().ItalicOff()
            scalarBarActor.GetLabelTextProperty().BoldOff()
            scalarBarActor.GetLabelTextProperty().ShadowOff()
            scalarBarActor.SetLabelFormat("%.2f")
            scalarBarActor.SetTitle(self.PointDataArrayName)
#.........这里部分代码省略.........
开发者ID:aabdulwahed,项目名称:vmtk,代码行数:101,代码来源:vmtkcenterlineviewer.py


示例9: Execute


#.........这里部分代码省略.........
        self.ActiveSegment = vtk.vtkPolyData()
        self.ActiveSegmentPoints = vtk.vtkPoints()
        self.ActiveSegmentCellArray = vtk.vtkCellArray()
        self.ActiveSegmentRadiusArray = vtk.vtkDoubleArray()
        self.ActiveSegmentRadiusArray.SetName(self.RadiusArrayName)
        self.ActiveSegment.SetPoints(self.ActiveSegmentPoints)
        self.ActiveSegment.SetLines(self.ActiveSegmentCellArray)
        self.ActiveSegment.GetPointData().AddArray(self.ActiveSegmentRadiusArray)
        self.ActiveSegment.GetPointData().SetActiveScalars(self.RadiusArrayName)

        activeSegmentMapper = vtk.vtkPolyDataMapper()
        activeSegmentMapper.ScalarVisibilityOff()
        if self.SplineInterpolation and self.Image != None:
            splineFilter = vtk.vtkSplineFilter()
            splineFilter.SetInputData(self.ActiveSegment)
            splineFilter.SetSubdivideToLength()
            splineFilter.SetLength(2.0*min(self.Image.GetSpacing()))
            activeSegmentMapper.SetInputConnection(splineFilter.GetOutputPort())
        else:
            activeSegmentMapper.SetInputData(self.ActiveSegment)

        self.ActiveSegmentActor = vtk.vtkActor()
        self.ActiveSegmentActor.SetMapper(activeSegmentMapper)
        self.ActiveSegmentActor.GetProperty().SetColor(1.0,1.0,1.0)
        self.ActiveSegmentActor.GetProperty().SetLineWidth(3.0)
        self.ActiveSegmentActor.PickableOff()
        self.vmtkRenderer.Renderer.AddActor(self.ActiveSegmentActor)

        activeTube = vtk.vtkTubeFilter()
        activeTube.SetInputConnection(activeSegmentMapper.GetInputPort())
        activeTube.SetVaryRadiusToVaryRadiusByAbsoluteScalar()
        activeTube.SetNumberOfSides(20)
        activeTubeMapper = vtk.vtkPolyDataMapper()
        activeTubeMapper.SetInputConnection(activeTube.GetOutputPort())
        activeTubeMapper.ScalarVisibilityOff()
        activeTubeActor = vtk.vtkActor()
        activeTubeActor.SetMapper(activeTubeMapper)
        activeTubeActor.PickableOff()
        activeTubeActor.GetProperty().SetOpacity(0.6)
        self.vmtkRenderer.Renderer.AddActor(activeTubeActor)

        self.NetworkLabelsArray = vtk.vtkStringArray.SafeDownCast(self.Network.GetCellData().GetAbstractArray(self.LabelsArrayName))
        if not self.NetworkLabelsArray:
            self.NetworkLabelsArray = vtk.vtkStringArray()
            self.NetworkLabelsArray.SetName(self.LabelsArrayName)
            self.NetworkLabelsArray.SetNumberOfValues(self.Network.GetNumberOfCells())
            for i in range(self.Network.GetNumberOfCells()):
                self.NetworkLabelsArray.SetValue(i,'')
            self.Network.GetCellData().AddArray(self.NetworkLabelsArray)
        self.CellCenters = vtk.vtkCellCenters()
        self.CellCenters.SetInputData(self.Network)
        self.CellCenters.VertexCellsOff()
        self.CellCenters.Update()

        labeledMapper = vtk.vtkLabeledDataMapper()
        labeledMapper.SetInputConnection(self.CellCenters.GetOutputPort())
        labeledMapper.SetLabelModeToLabelFieldData()
        labeledMapper.SetFieldDataName(self.LabelsArrayName)
        labeledMapper.GetLabelTextProperty().SetFontFamilyToArial()
        labeledMapper.GetLabelTextProperty().BoldOff()
        labeledMapper.GetLabelTextProperty().ItalicOff()
        labeledMapper.GetLabelTextProperty().ShadowOff()
        
        self.LabelsActor = vtk.vtkActor2D()
        self.LabelsActor.SetMapper(labeledMapper)
        self.LabelsActor.VisibilityOff()
        self.vmtkRenderer.Renderer.AddActor(self.LabelsActor)

        self.CellPicker = vtk.vtkCellPicker()
        self.CellPicker.SetTolerance(1E-2)
        self.CellPicker.InitializePickList()
        self.CellPicker.AddPickList(self.NetworkActor)
        self.CellPicker.PickFromListOn()

        self.vmtkRenderer.AddKeyBinding('a','Add mode.',self.AddCallback)
        self.vmtkRenderer.AddKeyBinding('d','Delete mode.',self.DeleteCallback)
        self.vmtkRenderer.AddKeyBinding('m','Merge mode.',self.MergeCallback)
        self.vmtkRenderer.AddKeyBinding('s','Split mode.',self.SplitCallback)
        self.vmtkRenderer.AddKeyBinding('l','Label mode.',self.LabelCallback)
        self.vmtkRenderer.AddKeyBinding('Tab','Show labels.',self.ShowLabelCallback)
        self.vmtkRenderer.RenderWindowInteractor.AddObserver("KeyReleaseEvent", self.KeyReleaseCallback)
        self.vmtkRenderer.RenderWindowInteractor.AddObserver("LeftButtonPressEvent", self.LeftButtonPressCallback)
        self.vmtkRenderer.RenderWindowInteractor.AddObserver("MouseMoveEvent", self.MouseMoveCallback)

        if self.PlaneWidgetX:
            self.PlaneWidgetX.UseContinuousCursorOn()
            self.PlaneWidgetX.AddObserver("StartInteractionEvent", self.PlaneStartInteractionCallback)
        if self.PlaneWidgetY:
            self.PlaneWidgetY.UseContinuousCursorOn()
            self.PlaneWidgetY.AddObserver("StartInteractionEvent", self.PlaneStartInteractionCallback)
        if self.PlaneWidgetZ:
            self.PlaneWidgetZ.UseContinuousCursorOn()
            self.PlaneWidgetZ.AddObserver("StartInteractionEvent", self.PlaneStartInteractionCallback)

        self.FirstRender()

        self.Surface = self.NetworkTube.GetOutput()

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()
开发者ID:samsmu,项目名称:vmtk,代码行数:101,代码来源:vmtknetworkeditor.py


示例10:

ids.CellIdsOn()
ids.FieldDataOn()

# Create the renderer here because vtkSelectVisiblePoints needs it.
ren = vtk.vtkRenderer()

# Create labels for points
visPts = vtk.vtkSelectVisiblePoints()
visPts.SetInputConnection(ids.GetOutputPort())
visPts.SetRenderer(ren)
visPts.SelectionWindowOn()
visPts.SetSelection(xmin, xmin + xLength, ymin, ymin + yLength)

# Create the mapper to display the point ids.  Specify the format to
# use for the labels.  Also create the associated actor.
ldm = vtk.vtkLabeledDataMapper()
# ldm.SetLabelFormat("%g")
ldm.SetInputConnection(visPts.GetOutputPort())
ldm.SetLabelModeToLabelFieldData()
pointLabels = vtk.vtkActor2D()
pointLabels.SetMapper(ldm)

# Create labels for cells
cc = vtk.vtkCellCenters()
cc.SetInputConnection(ids.GetOutputPort())
visCells = vtk.vtkSelectVisiblePoints()
visCells.SetInputConnection(cc.GetOutputPort())
visCells.SetRenderer(ren)
visCells.SelectionWindowOn()
visCells.SetSelection(xmin, xmin + xLength, ymin, ymin + yLength)
开发者ID:0004c,项目名称:VTK,代码行数:30,代码来源:labeledMesh.py


示例11: Execute

    def Execute(self):

        if self.Surface == None:
            self.PrintError('Error: No input surface.')

        if self.ExtensionMode == "centerlinedirection" and self.Centerlines == None:
            self.PrintError('Error: No input centerlines.')

        boundaryIds = vtk.vtkIdList()

        if self.Interactive:
            if not self.vmtkRenderer:
                import vmtkrenderer
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1
 
            boundaryExtractor = vtkvmtk.vtkvmtkPolyDataBoundaryExtractor()
            boundaryExtractor.SetInput(self.Surface)
            boundaryExtractor.Update()
            boundaries = boundaryExtractor.GetOutput()
            numberOfBoundaries = boundaries.GetNumberOfCells()
            seedPoints = vtk.vtkPoints()
            for i in range(numberOfBoundaries):
                barycenter = [0.0, 0.0, 0.0]
                vtkvmtk.vtkvmtkBoundaryReferenceSystems.ComputeBoundaryBarycenter(boundaries.GetCell(i).GetPoints(),barycenter)
                seedPoints.InsertNextPoint(barycenter)
            seedPolyData = vtk.vtkPolyData()
            seedPolyData.SetPoints(seedPoints)
            seedPolyData.Update()
            labelsMapper = vtk.vtkLabeledDataMapper();
            labelsMapper.SetInput(seedPolyData)
            labelsMapper.SetLabelModeToLabelIds()
            labelsActor = vtk.vtkActor2D()
            labelsActor.SetMapper(labelsMapper)
    
            self.vmtkRenderer.Renderer.AddActor(labelsActor)
    
            surfaceMapper = vtk.vtkPolyDataMapper()
            surfaceMapper.SetInput(self.Surface)
            surfaceMapper.ScalarVisibilityOff()
            surfaceActor = vtk.vtkActor()
            surfaceActor.SetMapper(surfaceMapper)
            surfaceActor.GetProperty().SetOpacity(0.25)
    
            self.vmtkRenderer.Renderer.AddActor(surfaceActor)
    
            self.vmtkRenderer.Render()
    
            self.vmtkRenderer.Renderer.RemoveActor(labelsActor)
            self.vmtkRenderer.Renderer.RemoveActor(surfaceActor)
            
            ok = False
            while not ok:
                labelString = self.InputText("Please input boundary ids: ",self.LabelValidator)
                labels = [int(label) for label in labelString.split()]
                ok = True
                for label in labels:
                    if label not in range(numberOfBoundaries):
                        ok = False

            for label in labels:
                boundaryIds.InsertNextId(label)

        flowExtensionsFilter = vtkvmtk.vtkvmtkPolyDataFlowExtensionsFilter()
        flowExtensionsFilter.SetInput(self.Surface)
        flowExtensionsFilter.SetCenterlines(self.Centerlines)
        flowExtensionsFilter.SetSigma(self.Sigma)
        flowExtensionsFilter.SetAdaptiveExtensionLength(self.AdaptiveExtensionLength)
        flowExtensionsFilter.SetAdaptiveExtensionRadius(self.AdaptiveExtensionRadius)
        flowExtensionsFilter.SetAdaptiveNumberOfBoundaryPoints(self.AdaptiveNumberOfBoundaryPoints)
        flowExtensionsFilter.SetExtensionLength(self.ExtensionLength)
        flowExtensionsFilter.SetExtensionRatio(self.ExtensionRatio)
        flowExtensionsFilter.SetExtensionRadius(self.ExtensionRadius)
        flowExtensionsFilter.SetTransitionRatio(self.TransitionRatio)
        flowExtensionsFilter.SetCenterlineNormalEstimationDistanceRatio(self.CenterlineNormalEstimationDistanceRatio)
        flowExtensionsFilter.SetNumberOfBoundaryPoints(self.TargetNumberOfBoundaryPoints)
        if self.ExtensionMode == "centerlinedirection":
            flowExtensionsFilter.SetExtensionModeToUseCenterlineDirection()
        elif self.ExtensionMode == "boundarynormal":
            flowExtensionsFilter.SetExtensionModeToUseNormalToBoundary()
        if self.InterpolationMode == "linear":
            flowExtensionsFilter.SetInterpolationModeToLinear()
        elif self.InterpolationMode == "thinplatespline":
            flowExtensionsFilter.SetInterpolationModeToThinPlateSpline()
        if self.Interactive:
            flowExtensionsFilter.SetBoundaryIds(boundaryIds)
        flowExtensionsFilter.Update()

        self.Surface = flowExtensionsFilter.GetOutput()

        if self.Surface.GetSource():
            self.Surface.GetSource().UnRegisterAllOutputs()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:93,代码来源:vmtkflowextensions.py


示例12: __init__

    def __init__ (self, mod_m, module=None, n_points=25, vis_points=0):
        """Input arguments:

        mod_m -- Module manager that manages this module.

        module -- Module to label.  Can be given a module name (the
        same name as listed in the Modules GUI) or an index of the
        module (starting from 0) in the current module manager.  If
        the value is -1, then the filtered data from the module
        manager is used.  The value defaults to None where the user is
        asked to specify the module to label.

        n_points -- Number of points to label.  Defaults to 25.

        vis_points -- If 1 turns on the vtkSelectVisiblePoints filter.
        Defaults to 0.    
        """
        debug ("In Labels::__init__ ()")
        Base.Objects.Module.__init__ (self, mod_m)

        self.act = None
        self.input = None
        self.mod_num = -1
        if module is not None:
            self._set_input(module)
        if not self.input:
            res = self._get_input_gui()
            self._set_input(res)
        
        if not self.input:
            msg = "Sorry, you need to choose a valid module in order to "\
                  "use this module."
            raise Base.Objects.ModuleException, msg
        input = self.input
        
        Common.state.busy ()
        self.n_points = n_points
        self.vis_points = vis_points
        self.mask = vtk.vtkMaskPoints ()
        n = input.GetNumberOfPoints ()
        self.mask.SetInput (input)
        self.mask.SetOnRatio (max(n/n_points, 1))
        self.mask.GenerateVerticesOn()
        self.mask.RandomModeOn ()
        self.vis_pnts = vtk.vtkSelectVisiblePoints ()
        self.vis_pnts.SetRenderer(self.renwin.get_renderer())
        self.mapper = self.map = vtk.vtkLabeledDataMapper ()
        self.mapper.SetLabelModeToLabelScalars()
        self.tprop = None
        if hasattr(self.mapper, "GetLabelTextProperty"):
            self.tprop = self.mapper.GetLabelTextProperty()
            self.tprop.SetColor (*Common.config.fg_color)
            self.tprop.SetOpacity(1.0)

        if vis_points:
            self.vis_pnts.SetInput (self.mask.GetOutput ())
            self.mapper.SetInput (self.vis_pnts.GetOutput ())
        else:
            self.mapper.SetInput (self.mask.GetOutput ())
            
        self.actor = self.act = vtk.vtkActor2D ()
        self.actor.SetMapper (self.mapper)
        self.vis_pnt_gui = None
        self.act.GetProperty ().SetColor (*Common.config.fg_color)
        self.renwin.add_actors (self.act)
        # used for the pipeline browser
        self.pipe_objs = self.act
        self.renwin.Render ()
        Common.state.idle ()
开发者ID:sldion,项目名称:DNACC,代码行数:69,代码来源:Labels.py


示例13:

band_cell_edges_mapper.SetInputConnection(band_cell_edges.GetOutputPort())
band_cell_edges_actor = vtk.vtkActor()
band_cell_edges_actor.SetMapper(band_cell_edges_mapper)
band_cell_edges_actor.GetProperty().SetColor(.4,.4,.4)

# Displays the contour edges generated by the BPDCF,
# somewhat thicker than the cell edges
band_edges_mapper = vtk.vtkPolyDataMapper()
band_edges_mapper.SetInputConnection(bands.GetOutputPort(1))
band_edges_actor = vtk.vtkActor()
band_edges_actor.SetMapper(band_edges_mapper)
band_edges_actor.GetProperty().SetColor(1,1,1)
band_edges_actor.GetProperty().SetLineWidth(1.3)

# Displays the scalars of the input points of the BPDCF
scalar_value_mapper = vtk.vtkLabeledDataMapper()
scalar_value_mapper.SetInputConnection(src.GetOutputPort())
scalar_value_mapper.SetLabelModeToLabelScalars()
scalar_value_mapper.SetLabelFormat("%1.3f")
scalar_value_actor = vtk.vtkActor2D()
scalar_value_actor.SetMapper(scalar_value_mapper)

# Set up renderer and camera
r = vtk.vtkRenderer()
r.AddViewProp(bands_actor)
r.AddViewProp(band_cell_edges_actor)
r.AddViewProp(band_edges_actor)
r.AddViewProp(scalar_value_actor)
r.SetBackground(.5,.5,.5)
cam=r.GetActiveCamera()
cam.SetPosition(1.25,.5,1)
开发者ID:Kitware,项目名称:VTK,代码行数:31,代码来源:TestBandedContourFilter3.py


示例14: Execute

    def Execute(self):

        if self.Surface == None:
            self.PrintError('Error: No input surface.')

#        cleaner = vtk.vtkCleanPolyData()
#        cleaner.SetInput(self.Surface)
#        cleaner.Update()
#
#        triangleFilter = vtk.vtkTriangleFilter()
#        triangleFilter.SetInput(cleaner.GetOutput())
#        triangleFilter.Update()
#
#        self.Surface = triangleFilter.GetOutput()

        boundaryIds = vtk.vtkIdList()

        if self.Interactive:
            if not self.vmtkRenderer:
                from vmtk import vmtkrenderer
                self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
                self.vmtkRenderer.Initialize()
                self.OwnRenderer = 1

            self.vmtkRenderer.RegisterScript(self)

            boundaryExtractor = vtkvmtk.vtkvmtkPolyDataBoundaryExtractor()
            boundaryExtractor.SetInputData(self.Surface)
            boundaryExtractor.Update()

            boundaries = boundaryExtractor.GetOutput()
            numberOfBoundaries = boundaries.GetNumberOfCells()
            seedPoints = vtk.vtkPoints()
            for i in range(numberOfBoundaries):
                barycenter = [0.0, 0.0, 0.0]
                vtkvmtk.vtkvmtkBoundaryReferenceSystems.ComputeBoundaryBarycenter(boundaries.GetCell(i).GetPoints(),barycenter)
                seedPoints.InsertNextPoint(barycenter)
            seedPolyData = vtk.vtkPolyData()
            seedPolyData.SetPoints(seedPoints)
            labelsMapper = vtk.vtkLabeledDataMapper();
            labelsMapper.SetInputData(seedPolyData)
            labelsMapper.SetLabelModeToLabelIds()
            labelsActor = vtk.vtkActor2D()
            labelsActor.SetMapper(labelsMapper)

            self.vmtkRenderer.Renderer.AddActor(labelsActor)

            surfaceMapper = vtk.vtkPolyDataMapper()
            surfaceMapper.SetInputData(self.Surface)
            surfaceMapper.ScalarVisibilityOff()
            surfaceActor = vtk.vtkActor()
            surfaceActor.SetMapper(surfaceMapper)
            surfaceActor.GetProperty().SetOpacity(0.25)

            self.vmtkRenderer.Renderer.AddActor(surfaceActor)

            #self.vmtkRenderer.Render()
            #self.vmtkRenderer.Renderer.RemoveActor(labelsActor)
            #self.vmtkRenderer.Renderer.RemoveActor(surfaceActor)

            ok = False
            while not ok:
                labelString = self.InputText("Please input boundary ids: ",self.LabelValidator)
                labels = [int(label) for label in labelString.split()]
                ok = True
                for label in labels:
                    if label not in list(range(numberOfBoundaries)):
                        ok = False

            for label in labels:
                boundaryIds.InsertNextId(label)

        if self.Method == 'simple':
            capper = vtkvmtk.vtkvmtkSimpleCapPolyData()
            capper.SetInputData(self.Surface)

        elif self.Method == 'centerpoint':
            capper = vtkvmtk.vtkvmtkCapPolyData()
            capper.SetInputData(self.Surface)
            capper.SetDisplacement(0.0)
            capper.SetInPlaneDisplacement(0.0)

        elif self.Method == 'smooth':
            triangle = vtk.vtkTriangleFilter()
            triangle.SetInputData(self.Surface)
            triangle.PassLinesOff()
            triangle.PassVertsOff()
            triangle.Update()
            capper = vtkvmtk.vtkvmtkSmoothCapPolyData()
            capper.SetInputConnection(triangle.GetOutputPort())
            capper.SetConstraintFactor(self.ConstraintFactor)
            capper.SetNumberOfRings(self.NumberOfRings)

        elif self.Method == 'annular':
            capper = vtkvmtk.vtkvmtkAnnularCapPolyData()
            capper.SetInputData(self.Surface)

        elif self.Method == 'concaveannular':
            from vmtk import vtkvmtkcontrib
            capper = vtkvmtkcontrib.vtkvmtkConcaveAnnularCapPolyData()
#.........这里部分代码省略.........
开发者ID:vmtk,项目名称:vmtk,代码行数:101,代码来源:vmtksurfacecapper.py


示例15: locals

isoMapper.SetInputConnection(iso.GetOutputPort())
isoMapper.ScalarVisibilityOn()
isoMapper.SetScalarRange(iso.GetOutput().GetScalarRange())
isoActor = vtk.vtkActor()
isoActor.SetMapper(isoMapper)
# Subsample the points and label them
mask = vtk.vtkMaskPoints()
mask.SetInputConnection(iso.GetOutputPort())
mask.SetOnRatio(expr.expr(globals(), locals(),["numPts","/","50"]))
mask.SetMaximumNumberOfPoints(50)
mask.RandomModeOn()
# Create labels for points - only show visible points
visPts = vtk.vtkSelectVisiblePoints()
visPts.SetInputConnection(mask.GetOutputPort())
visPts.SetRenderer(ren1)
ldm = vtk.vtkLabeledDataMapper()
ldm.SetInputConnection(mask.GetOutputPort())
#    ldm SetLabelFormat "%g"
ldm.SetLabelModeToLabelScalars()
tprop = ldm.GetLabelTextProperty()
tprop.SetFontFamilyToArial()
tprop.SetFontSize(10)
tprop.SetColor(1,0,0)
contourLabels = vtk.vtkActor2D()
contourLabels.SetMapper(ldm)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor2D(isoActor)
ren1.AddActor2D(contourLabels)
ren1.SetBackground(1,1,1)
renWin.SetSize(500,500)
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:labeledContours.py


示例16: draw_vtk


#.........这里部分代码省略.........
        scalars = vtk.vtkFloatArray()
        for v in values:
            scalars.InsertNextValue(v)
        poly_data.GetPointData().SetScalars(scalars)
        bcf = vtk.vtkBandedPolyDataContourFilter()
        if vtk.VTK_MAJOR_VERSION <= 5:
            bcf.SetInput(poly_data)
        else:
            bcf.SetInputData(poly_data)
        bcf.SetNumberOfContours(contours_count)
        bcf.GenerateValues(contours_count, [values.min(), values.max()])
        bcf.SetNumberOfContours(contours_count + 1)
        bcf.SetScalarModeToValue()
        bcf.GenerateContourEdgesOn()
        bcf.Update()
        bcf_mapper.ImmediateModeRenderingOn()
        if vtk.VTK_MAJOR_VERSION <= 5:
            bcf_mapper.SetInput(bcf.GetOutput())
        else:
            bcf_mapper.SetInputData(bcf.GetOutput())
        bcf_mapper.SetScalarRange(values.min(), values.max())
        bcf_mapper.SetLookupTable(lut)
        bcf_mapper.ScalarVisibilityOn()
        if use_cell_data:
            bcf_mapper.SetScalarModeToUseCellData()

        bcf_actor.SetMapper(bcf_mapper)
        renderer.AddActor(bcf_actor)
        edge_mapper = vtk.vtkPolyDataMapper()
        if vtk.VTK_MAJOR_VERSION <= 5:
            edge_mapper.SetInput(bcf.GetContourEdgesOutput())
        else:
            edge_mapper.SetInputData(bcf.GetContourEdgesOutput())
        edge_mapper.SetResolveCoincidentTopologyToPolygonOffset()
        edge_actor = vtk.vtkActor()
        edge_actor.SetMapper(edge_mapper)
        if use_gray:
            edge_actor.GetProperty().SetColor(0.0, 1.0, 0.0)
        else:
            edge_actor.GetProperty().SetColor(0.0, 0.0, 0.0)
        renderer.AddActor(edge_actor)

        if show_labels:
            mask = vtk.vtkMaskPoints()
            if vtk.VTK_MAJOR_VERSION <= 5:
                mask.SetInput(bcf.GetOutput())
            else:
                mask.SetInputData(bcf.GetOutput())
            mask.SetOnRatio(bcf.GetOutput().GetNumberOfPoints() / 20)
            mask.SetMaximumNumberOfPoints(20)
            # Create labels for points - only show visible points
            visible_points = vtk.vtkSelectVisiblePoints()
            visible_points.SetInputConnection(mask.GetOutputPort())
            visible_points.SetRenderer(renderer)
            ldm = vtk.vtkLabeledDataMapper()
            ldm.SetInputConnection(mask.GetOutputPort())
            ldm.SetLabelFormat("%.2E")
            ldm.SetLabelModeToLabelScalars()
            text_property = ldm.GetLabelTextProperty()
            text_property.SetFontFamilyToArial()
            text_property.SetFontSize(10)
            if use_gray:
                text_property.SetColor(0.0, 1.0, 0.0)
            else:
                text_property.SetColor(0.0, 0.0, 0.0)
            text_property.ShadowOff()
            text_property.BoldOff()
            contour_labels = vtk.vtkActor2D()
            contour_labels.SetMapper(ldm)
            renderer.AddActor(contour_labels)

        scalar_bar = vtk.vtkScalarBarActor()
        scalar_bar.SetOrientationToHorizontal()
        scalar_bar.SetLookupTable(lut)
        if title is not None:
            scalar_bar.SetTitle(title)
        scalar_bar_widget = vtk.vtkScalarBarWidget()
        scalar_bar_widget.SetInteractor(render_window_interactor)
        scalar_bar_widget.SetScalarBarActor(scalar_bar)
        scalar_bar_widget.On()
    else:
        if vtk.VTK_MAJOR_VERSION <= 5:
            bcf_mapper.SetInput(poly_data)
        else:
            bcf_mapper.SetInputData(poly_data)
        bcf_actor.GetProperty().SetColor(0.0, 1.0, 0.0)

    if show_mesh:
        bcf_actor.GetProperty().EdgeVisibilityOn()
        bcf_actor.GetProperty().SetEdgeColor(mesh_color)

    bcf_actor.SetMapper(bcf_mapper)
    renderer.AddActor(bcf_actor)

    if show_axes:
        axes = vtk.vtkAxesActor()
        renderer.AddActor(axes)

    render_window.Render()
    render_window_interactor.Start()
开发者ID:qzcad,项目名称:pyfem,代码行数:101,代码来源:mesh2d.py


示例17: display_annot


#.........这里部分代码省略.........
             print "Point final"
             ijk[0] = int(annots_dict['xf'])
             ijk[1] = int(annots_dict['yf'])
             print ijk
             annots_dict['pf_ijk']=ijk
             pixId = self.transformed_image.ComputePointId(ijk)
             pf_2display = self.transformed_image.GetPoint(pixId)
             annots_dict['pf_2display']=pf_2display
             print pf_2display
             
             # Create a graphial line between the two points
             annot_pts = vtk.vtkPoints()
             annot_pts.InsertNextPoint(pi_2display)
             annot_pts.InsertNextPoint(pf_2display)
   
             annot_ln = vtk.vtkLine()
             annot_ln.GetPointIds().SetId(0,0)
             annot_ln.GetPointIds().SetId(1,1)
             note_lines = vtk.vtkCellArray()
             note_lines.InsertNextCell(annot_ln)
             
             annot_poly = vtk.vtkPolyData()
             annot_poly.SetPoints(annot_pts)
             annot_poly.SetLines(note_lines)
             annot_poly.Update()
 
             # Create mappers and actors
             annot_mapper_mesh = vtk.vtkPolyDataMapper()
             annot_mapper_mesh.SetInput( annot_poly )
                         
             self.annot_actor = vtk.vtkActor()
             self.annot_actor.SetMapper(annot_mapper_mesh)
             self.annot_actor.GetProperty().SetColor(color_list[a_count])
             self.annot_actor.GetProperty().SetLineWidth(3)
             self.annot_actor.GetProperty().SetOpacity(0.6)
             self.annot_actor.GetProperty().SetPointSize(7.0)
             self.annot_actor.GetProperty().SetRepresentationToWireframe()
             
             ############
             # Generate data arrays containing label ids
             annot_pts_lbl.InsertPoint(a_count, pi_2display)
                                
             # add annotation to scene
             print annots_dict
             self.renderer1.AddActor(self.annot_actor)
                     
             # Initizalize
             self.renWin1. 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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