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

Python vtk.vtkOutlineFilter函数代码示例

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

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



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

示例1: build_bbox

    def build_bbox(self, basis_vector):
        
        cell = numpy.array(basis_vector).astype(numpy.float32)
        Xmax,Ymax,Zmax =  numpy.array([cell[0,0], cell[1,1], cell[2,2]], dtype = numpy.float32)
        bbox_points = vtk.vtkPoints()
        
        self.cell_bounds_coords = numpy.array([-Xmax/2. , Xmax/2.,  -Ymax/2., Ymax/2.,  -Zmax/2., Zmax/2.])
        
        bbox_points.InsertNextPoint(-Xmax/2. , -Ymax/2., -Zmax/2.)
        bbox_points.InsertNextPoint(Xmax/2. , Ymax/2., Zmax/2.)
         
        BBox_poly = vtk.vtkPolyData()
        BBox_poly.SetPoints(bbox_points)
         
        outline = vtk.vtkOutlineFilter()
        if vtk.vtkVersion.GetVTKMajorVersion()<6:
            outline.SetInput(BBox_poly)
        else:
            outline.SetInputData(BBox_poly)

        outline_mapper = vtk.vtkPolyDataMapper()
        outline_mapper.SetInputConnection(outline.GetOutputPort())
        
        outline_actor = vtk.vtkActor()
        outline_actor.SetMapper(outline_mapper)
        outline_actor.GetProperty().SetColor(1,1,1)
        outline_actor.GetProperty().SetLineWidth(3)
        
        return outline_actor
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:29,代码来源:MolecularViewerPlugin.py


示例2: __init__

 def __init__(self,viewer, selection_color):
     self.viewer = viewer
     self.selection_color = selection_color
     outline = vtk.vtkOutlineFilter()
     if vtk.vtkVersion.GetVTKMajorVersion()<6:
         outline.SetInput(self.viewer._polydata)
     else:
         outline.SetInputData(self.viewer._polydata)
                 
     outlineMapper = vtk.vtkPolyDataMapper()
     outlineMapper.SetInputConnection(outline.GetOutputPort())
     self.box=vtk.vtkActor()
     self.box.SetMapper( outlineMapper )
     self.box.GetProperty().SetColor(1,1,1)
     self.box.PickableOff()
     
     self.SetProp3D(self.box)
     self.planes=vtk.vtkPlanes()
     self.SetInteractor(viewer.iren)
     if vtk.vtkVersion.GetVTKMajorVersion()<6:
         self.SetInput(self.viewer._polydata)
     else:
         self.SetInputData(self.viewer._polydata)
         
     self.SetPlaceFactor(1)
     self.PlaceWidget()
     self.InsideOutOn()
     self.SetRotationEnabled(0)
     self.GetPlanes(self.planes)
     self.AddObserver("EndInteractionEvent",self.on_select_atoms)
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:30,代码来源:MolecularViewerPlugin.py


示例3: SetInput

  def SetInput(self, input) :
    img = image(input)
    self.__input__ = img
    if img :
      # Update to try to avoid to exit if a c++ exception is throwed
      # sadely, it will not prevent the program to exit later...
      # a real fix would be to wrap c++ exception in vtk
      img.UpdateOutputInformation()
      img.Update()
      import itk
      self.__flipper__ = itk.FlipImageFilter[img].New(Input=img)
      axes = self.__flipper__.GetFlipAxes()
      axes.SetElement(1, True)
      self.__flipper__.SetFlipAxes(axes)
      self.__itkvtkConverter__ = itk.ImageToVTKImageFilter[img].New(self.__flipper__)
      self.__volumeMapper__.SetInput(self.__itkvtkConverter__.GetOutput())
      # needed to avoid warnings
      # self.__itkvtkConverter__.GetOutput() must be callable
      import vtk
      if not self.__outline__ :
	  self.__outline__ = vtk.vtkOutlineFilter()
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())
	  self.__outlineMapper__ = vtk.vtkPolyDataMapper()
	  self.__outlineMapper__.SetInput(self.__outline__.GetOutput())
	  self.__outlineActor__ = vtk.vtkActor()
	  self.__outlineActor__.SetMapper(self.__outlineMapper__)
	  self.__ren__.AddActor(self.__outlineActor__)
      else :
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())

    self.Render()
开发者ID:glehmann,项目名称:WrapITK-old,代码行数:31,代码来源:__init__.py


示例4: build_real_bbox

    def build_real_bbox(self, molecule):
        
        Xmin,Xmax,Ymin, Ymax, Zmin, Zmax = molecule.GetBounds()
        bbox_points = vtk.vtkPoints()
         
        bbox_points.InsertNextPoint(Xmin, Ymin, Zmin)
        bbox_points.InsertNextPoint(Xmax , Ymax, Zmax)
         
        BBox_poly = vtk.vtkPolyData()
        BBox_poly.SetPoints(bbox_points)
         
        outline = vtk.vtkOutlineFilter()
        if vtk.vtkVersion.GetVTKMajorVersion()<6:
            outline.SetInput(BBox_poly)
        else:
            outline.SetInputData(BBox_poly)

        outline_mapper = vtk.vtkPolyDataMapper()
        outline_mapper.SetInputConnection(outline.GetOutputPort())
        
        outline_actor = vtk.vtkActor()
        outline_actor.SetMapper(outline_mapper)
        outline_actor.GetProperty().SetColor(1,0,0)
        outline_actor.GetProperty().SetLineWidth(3)
        
        self._renderer.AddActor(outline_actor)
        self._iren.Render()
开发者ID:mark-johnson-1966,项目名称:MDANSE,代码行数:27,代码来源:MolecularViewerPlugin.py


示例5: add_outline

 def add_outline(self):
     outline = vtk.vtkOutlineFilter()
     outline.SetInputData(self.data.grid[self.current_timestep])
     outline_mapper = vtk.vtkDataSetMapper()
     outline_mapper.SetInputConnection(outline.GetOutputPort())
     self.outline_actor.SetMapper(outline_mapper)
     self.ren.AddActor(self.outline_actor)
开发者ID:capitalaslash,项目名称:radcal-gui,代码行数:7,代码来源:vtkgui.py


示例6: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkOutlineFilter(), 'Processing.',
         ('vtkDataSet',), ('vtkPolyData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkOutlineFilter.py


示例7: setup_renderer

def setup_renderer(renderer, actors, bboxpolydata=None):
    ren = renderer
    for actor in actors:
        # assign actor to the renderer
        ren.AddActor(actor)
    ############################################
    # Create a vtkOutlineFilter to draw the bounding box of the data set.
    # Also create the associated mapper and actor.
    if bboxpolydata is not None:
        outline = vtk.vtkOutlineFilter()
        outline.SetInput(bboxpolydata.GetOutput())
        mapOutline = vtk.vtkPolyDataMapper()
        mapOutline.SetInputConnection(outline.GetOutputPort())
        outlineActor = vtk.vtkActor()
        outlineActor.SetMapper(mapOutline)
        outlineActor.GetProperty().SetColor(100, 100, 100)
        ren.AddViewProp(outlineActor)
        ren.AddActor(outlineActor)
    

    # Create a vtkLight, and set the light parameters.
    light = vtk.vtkLight()
    light.SetFocalPoint(0.21406, 1.5, 0)
    light.SetPosition(8.3761, 4.94858, 4.12505)
    ren.AddLight(light)
    return ren
开发者ID:HerrMuellerluedenscheid,项目名称:seismerize,代码行数:26,代码来源:vtk_focmec.py


示例8: __init__

    def __init__(self, reader):
        self.reader = reader
        sg = self.src_glyph = vtk.vtkSphereSource()
        sg.SetRadius(0.5)
        sg.SetCenter(0.5, 0.0, 0.0)
        g = self.glyph = vtk.vtkTensorGlyph()        
        g.SetInputConnection(self.reader.GetOutputPort())
        g.SetSource(self.src_glyph.GetOutput())
        g.SetScaleFactor(0.25)
        
        # The normals are needed to generate the right colors and if
        # not used some of the glyphs are black.        
        self.normals = vtk.vtkPolyDataNormals()
        self.normals.SetInputConnection(g.GetOutputPort())
        self.map = vtk.vtkPolyDataMapper()
        self.map.SetInputConnection(self.normals.GetOutputPort())        
        self.act = vtk.vtkActor()
        self.act.SetMapper(self.map)

        # An outline.
        self.of = vtk.vtkOutlineFilter()
        self.of.SetInputConnection(self.reader.GetOutputPort())
        self.out_map = vtk.vtkPolyDataMapper()
        self.out_map.SetInputConnection(self.of.GetOutputPort())
        self.out_act = vtk.vtkActor()
        self.out_act.SetMapper(self.out_map)        
开发者ID:Armand0s,项目名称:homemade_vtk,代码行数:26,代码来源:TestTensorGlyph.py


示例9: __init__

	def __init__(self, parent, visualizer, **kws):
		"""
		Initialization
		"""     
		self.x, self.y, self.z = -1, -1, -1
		VisualizationModule.__init__(self, parent, visualizer, **kws)
		self.on = 0
		self.renew = 1
		self.mapper = vtk.vtkPolyDataMapper()
		self.eventDesc = "Rendering orthogonal slices"
		self.outline = vtk.vtkOutlineFilter()
		self.outlineMapper = vtk.vtkPolyDataMapper()
		self.outlineActor = vtk.vtkActor()
		self.outlineActor.SetMapper(self.outlineMapper)
		
		self.picker = vtk.vtkCellPicker()
		self.picker.SetTolerance(0.005)
		
		self.planeWidgetX = vtk.vtkImagePlaneWidget()
		self.planeWidgetX.DisplayTextOn()
		self.planeWidgetX.SetPicker(self.picker)
		self.planeWidgetX.SetKeyPressActivationValue("x")
		#self.planeWidgetX.UserControlledLookupTableOn()
		self.prop1 = self.planeWidgetX.GetPlaneProperty()
		#self.prop1.SetColor(1, 0, 0)
		self.planeWidgetX.SetResliceInterpolateToCubic()

		self.planeWidgetY = vtk.vtkImagePlaneWidget()
		self.planeWidgetY.DisplayTextOn()
		self.planeWidgetY.SetPicker(self.picker)
		self.planeWidgetY.SetKeyPressActivationValue("y")
		self.prop2 = self.planeWidgetY.GetPlaneProperty()
		self.planeWidgetY.SetResliceInterpolateToCubic()
		#self.planeWidgetY.UserControlledLookupTableOn()
		#self.prop2.SetColor(1, 1, 0)


		# for the z-slice, turn off texture interpolation:
		# interpolation is now nearest neighbour, to demonstrate
		# cross-hair cursor snapping to pixel centers
		self.planeWidgetZ = vtk.vtkImagePlaneWidget()
		self.planeWidgetZ.DisplayTextOn()
		self.planeWidgetZ.SetPicker(self.picker)
		self.planeWidgetZ.SetKeyPressActivationValue("z")
		self.prop3 = self.planeWidgetZ.GetPlaneProperty()
		#self.prop3.SetColor(1, 0, 1)
		#self.planeWidgetZ.UserControlledLookupTableOn()
		self.planeWidgetZ.SetResliceInterpolateToCubic()
		self.renderer = self.parent.getRenderer()
		self.renderer.AddActor(self.outlineActor)
		self.useOutline = 1
		
		iactor = self.wxrenwin.GetRenderWindow().GetInteractor()
		self.planeWidgetX.SetInteractor(iactor)
		self.planeWidgetY.SetInteractor(iactor)
		self.planeWidgetZ.SetInteractor(iactor)
		
		lib.messenger.connect(None, "zslice_changed", self.setZ)
		self.filterDesc = "View orthogonal slices"
开发者ID:chalkie666,项目名称:bioimagexd-svn-import-from-sourceforge,代码行数:59,代码来源:Orthogonal.py


示例10: outline

def outline(source):
    outline_filter = vtk.vtkOutlineFilter()
    outline_filter.SetInput(source.GetOutput())
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(outline_filter.GetOutput())
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    return actor
开发者ID:151706061,项目名称:IRTK,代码行数:8,代码来源:vtkTools.py


示例11: __init__

    def __init__(self,reader):
		self.outline=vtk.vtkOutlineFilter()
		self.outline.SetInput(reader.get_data_set())
		self.outlinemapper=vtk.vtkPolyDataMapper()
		self.outlinemapper.SetInput(self.outline.GetOutput())
		self.actor=vtk.vtkActor()
		self.actor.SetMapper(self.outlinemapper)
		self.actor.GetProperty().SetColor(0,0,0)
开发者ID:bitcoinsoftware,项目名称:3D-Scientific-Visualization,代码行数:8,代码来源:Outline.py


示例12: visQuadFunc

def visQuadFunc():
    """ vtk sample scene with iso contours """

    # VTK supports implicit functions of the form f(x,y,z)=constant. These
    # functions can represent things spheres, cones, etc. Here we use a
    # general form for a quadric to create an elliptical data field.
    quadric = vtk.vtkQuadric()
    quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)

    # vtkSampleFunction samples an implicit function over the x-y-z range
    # specified (here it defaults to -1,1 in the x,y,z directions).
    sample = vtk.vtkSampleFunction()
    sample.SetSampleDimensions(30, 30, 30)
    sample.SetImplicitFunction(quadric)

    # Create five surfaces F(x,y,z) = constant between range specified. The
    # GenerateValues() method creates n isocontour values between the range
    # specified.
    contours = vtk.vtkContourFilter()
    contours.SetInputConnection(sample.GetOutputPort())
    contours.GenerateValues(8, 0.0, 1.2)

    contMapper = vtk.vtkPolyDataMapper()
    contMapper.SetInputConnection(contours.GetOutputPort())
    contMapper.SetScalarRange(0.0, 1.2)

    contActor = vtk.vtkActor()
    contActor.SetMapper(contMapper)

    # We'll put a simple outline around the data.
    outline = vtk.vtkOutlineFilter()
    outline.SetInputConnection(sample.GetOutputPort())

    outlineMapper = vtk.vtkPolyDataMapper()
    outlineMapper.SetInputConnection(outline.GetOutputPort())

    outlineActor = vtk.vtkActor()
    outlineActor.SetMapper(outlineMapper)
    outlineActor.GetProperty().SetColor(1, 0.5, 0)

    # extract data from the volume
    extract = vtk.vtkExtractVOI()
    extract.SetInputConnection(sample.GetOutputPort())
    extract.SetVOI(0, 29, 0, 29, 15, 15)
    extract.SetSampleRate(1, 2, 3)

    contours2 = vtk.vtkContourFilter()
    contours2.SetInputConnection(extract.GetOutputPort())
    contours2.GenerateValues(8, 0.0, 1.2)

    contMapper2 = vtk.vtkPolyDataMapper()
    contMapper2.SetInputConnection(contours2.GetOutputPort())
    contMapper2.SetScalarRange(0.0, 1.2)

    contActor2 = vtk.vtkActor()
    contActor2.SetMapper(contMapper2)

    return contActor, contActor2, outlineActor, contours, contours2
开发者ID:alexlib,项目名称:PyDataNYC2015,代码行数:58,代码来源:scenes.py


示例13: __init__

    def __init__(self, parent):
        QVTKRenderWindowInteractor.__init__(self, parent)

        self.renderer = vtk.vtkRenderer()
        self.GetRenderWindow().AddRenderer(self.renderer)
        
        interactor = vtk.vtkInteractorStyleSwitch()
        self._Iren.SetInteractorStyle(interactor)
                
        self.surface = None

        # Remainng calls set up axes.
        tprop = vtk.vtkTextProperty()
        tprop.SetColor(1,1,1)

        # Create a faint outline to go with the axes.
        self.outline = vtk.vtkOutlineFilter()

        # Initially set up with a box as input.  This will be changed
        # to a plot once the user clicks something.
        self.box = vtk.vtkBox()
        self.box.SetBounds(0,10,0,10,0,10)
        sample = vtk.vtkSampleFunction()
        sample.SetImplicitFunction(self.box)
        sample.SetSampleDimensions(2,2,2)
        sample.SetModelBounds(0,10,0,10,0,5)
        sample.ComputeNormalsOff()

        self.outline.SetInputConnection(sample.GetOutputPort())
        mapOutline = vtk.vtkPolyDataMapper()
        mapOutline.SetInputConnection(self.outline.GetOutputPort())
        self.outlineActor = vtk.vtkActor()
        self.outlineActor.SetMapper(mapOutline)
        self.outlineActor.GetProperty().SetColor(1,1,1)
        self.outlineActor.GetProperty().SetOpacity(.25)
        self.renderer.AddActor(self.outlineActor)

        self.axes = vtk.vtkCubeAxesActor2D()
        self.axes.SetCamera(self.renderer.GetActiveCamera())
        self.axes.SetFlyModeToOuterEdges()

        self.axes.SetLabelFormat("%6.4g")
        self.axes.SetFontFactor(0.8)
        self.axes.SetAxisTitleTextProperty(tprop)
        self.axes.SetAxisLabelTextProperty(tprop)
        self.axes.SetXLabel("MPI Rank")
        self.axes.SetYLabel("Progress")
        self.axes.SetZLabel("Effort")
        self.axes.SetInput(sample.GetOutput())
        self.renderer.AddViewProp(self.axes)

        # Keep original camera around in case it gets changed
        self.originalCamera = self.renderer.GetActiveCamera()

        self.renderer.GetActiveCamera().Pitch(90)     # Want effort to be vertical
        self.renderer.GetActiveCamera().OrthogonalizeViewUp()
        self.renderer.ResetCamera()
        self.renderer.GetActiveCamera().Elevation(15)  # Be slightly above the data
开发者ID:cmcantalupo,项目名称:libra,代码行数:58,代码来源:vtkutils.py


示例14: create_outline

 def create_outline(self):
     outline = vtk.vtkOutlineFilter()
     outline.SetInputData(self.rdr.GetOutput())
     outline_mapper = vtk.vtkPolyDataMapper()
     outline_mapper.SetInputConnection(outline.GetOutputPort())
     self.outline_actor = vtk.vtkActor()
     self.outline_actor.SetMapper(outline_mapper)
     self.outline_actor.GetProperty().SetColor(1,1,1)
     self.outline = outline
     self.renderer.AddActor(self.outline_actor)
开发者ID:lauragarciabernal,项目名称:Superprob,代码行数:10,代码来源:border.py


示例15: prepareOutlineActor

    def prepareOutlineActor(self,_dim):
        outlineData = vtk.vtkImageData()
        outlineData.SetDimensions(_dim[0], _dim[1], 1)

        outline = vtk.vtkOutlineFilter()
        outline.SetInput(outlineData)
        outlineMapper = vtk.vtkPolyDataMapper()
        outlineMapper.SetInputConnection(outline.GetOutputPort())
    
        self.outlineActor.SetMapper(outlineMapper)
        self.outlineActor.GetProperty().SetColor(1, 1, 1)        
开发者ID:odellus,项目名称:CompuCell3D,代码行数:11,代码来源:MVCDrawView2D.py


示例16: addGrid

    def addGrid(self, grid):
        nx, ny, nz = grid.shape[1:]

        self.display.append(True)

        self.grids.append(vtk.vtkStructuredGrid())

        self.grids[-1].SetExtent(0, nz-1, 0, ny-1, 0, nx-1)
        p = vtk.vtkPoints()

        shp = grid.shape
        grid.shape = (3, nx*ny*nz)
        p.SetData(vtknp.numpy_to_vtk(np.ascontiguousarray(grid.T), deep=True, array_type=vtknp.get_vtk_array_type(grid.dtype)))
        grid.shape = shp
        self.grids[-1].SetPoints(p)

        #Couleur
        color = np.random.rand(3)
        #Create a vtkOutlineFilter to draw the bounding box of the data set.
        ol = vtk.vtkOutlineFilter()
        if (vtk.vtkVersion().GetVTKMajorVersion()>=6):
          ol.SetInputData(self.grids[-1])
        else:
          ol.SetInput(self.grids[-1])      
        olm = vtk.vtkPolyDataMapper()
        olm.SetInputConnection(ol.GetOutputPort())
        ola = vtk.vtkActor()
        ola.SetMapper(olm)
        ola.GetProperty().SetColor(color)

        s=vtk.vtkShrinkFilter()
        if (vtk.vtkVersion().GetVTKMajorVersion()>=6):
          s.SetInputData(self.grids[-1])
        else:
          s.SetInput(self.grids[-1])      
        s.SetShrinkFactor(0.8)
        #
        mapper = vtk.vtkDataSetMapper()
        #map.SetInputData(data)
        mapper.SetInputConnection(s.GetOutputPort())
        act = vtk.vtkLODActor()
        act.SetMapper(mapper)
        #act.GetProperty().SetRepresentationToWireframe()
        #act.GetProperty().SetRepresentationToPoints()	
        act.GetProperty().SetColor(color)
        act.GetProperty().SetEdgeColor(color)
        act.GetProperty().EdgeVisibilityOff()	
        self.actors.append(act)
        self.setBounds()
        self.ren.SetActiveCamera(self.cam)
开发者ID:gouarin,项目名称:python_azur,代码行数:50,代码来源:vtkPlot.py


示例17: __init__

 def __init__ (self, mod_m):
     debug ("In Outline::__init__ ()")
     Common.state.busy ()
     Base.Objects.Module.__init__ (self, mod_m)
     data_src = self.mod_m.get_data_source ()
     self.type = data_src.get_grid_type ()
     self.outline = vtk.vtkOutlineFilter ()
     self.outline.SetInput (mod_m.GetOutput ())
     self.mapper = self.map = vtk.vtkPolyDataMapper ()
     self.map.SetInput (self.outline.GetOutput ())
     self.actor = self.act = vtk.vtkActor ()  
     self.act.SetMapper (self.map)
     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,代码行数:18,代码来源:Outline.py


示例18: prepareOutlineActor

    def prepareOutlineActor(self,_imageData):
#        print MODULENAME, '------------  prepareOutlineActor()'
        outlineDimTmp=_imageData.GetDimensions()
        # print "\n\n\n this is outlineDimTmp=",outlineDimTmp," self.outlineDim=",self.outlineDim
        if self.outlineDim[0] != outlineDimTmp[0] or self.outlineDim[1] != outlineDimTmp[1] or self.outlineDim[2] != outlineDimTmp[2]:
            self.outlineDim=outlineDimTmp
        
            outline = vtk.vtkOutlineFilter()
            outline.SetInput(_imageData)
            outlineMapper = vtk.vtkPolyDataMapper()
            outlineMapper.SetInputConnection(outline.GetOutputPort())
        
            self.outlineActor.SetMapper(outlineMapper)
            
            color = Configuration.getSetting("WindowColor")   # eventually do this smarter (only get/update when it changes)
            self.outlineActor.GetProperty().SetColor(float(color.red())/255,float(color.green())/255,float(color.blue())/255)
#            self.outlineActor.GetProperty().SetColor(1, 1, 1)        
            self.outlineDim = _imageData.GetDimensions()
开发者ID:AngeloTorelli,项目名称:CompuCell3D,代码行数:18,代码来源:MVCDrawView3D.py


示例19: SetInput

  def SetInput(self, input) :
    import itk
    img = itk.output(input)
    self.__input__ = img
    if img :
      # Update to try to avoid to exit if a c++ exception is throwed
      # sadely, it will not prevent the program to exit later...
      # a real fix would be to wrap c++ exception in vtk
      img.UpdateOutputInformation()
      img.Update()
      
      # flip the image to get the same representation than the vtk one
      self.__flipper__ = itk.FlipImageFilter[img].New(Input=img)
      axes = self.__flipper__.GetFlipAxes()
      axes.SetElement(1, True)
      self.__flipper__.SetFlipAxes(axes)
      
      # change the spacing while still keeping the ratio to workaround vtk bug
      # when spacing is very small
      spacing_ = itk.spacing(img)
      normSpacing = []
      for i in range(0, spacing_.Size()):
        normSpacing.append( spacing_.GetElement(i) / spacing_.GetElement(0) )
      self.__changeInfo__ = itk.ChangeInformationImageFilter[img].New(self.__flipper__, OutputSpacing=normSpacing, ChangeSpacing=True)
      
      # now really convert the data
      self.__itkvtkConverter__ = itk.ImageToVTKImageFilter[img].New(self.__changeInfo__)
      self.__volumeMapper__.SetInput(self.__itkvtkConverter__.GetOutput())
      # needed to avoid warnings
      # self.__itkvtkConverter__.GetOutput() must be callable
      
      import vtk
      if not self.__outline__ :
	  self.__outline__ = vtk.vtkOutlineFilter()
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())
	  self.__outlineMapper__ = vtk.vtkPolyDataMapper()
	  self.__outlineMapper__.SetInput(self.__outline__.GetOutput())
	  self.__outlineActor__ = vtk.vtkActor()
	  self.__outlineActor__.SetMapper(self.__outlineMapper__)
	  self.__ren__.AddActor(self.__outlineActor__)
      else :
	  self.__outline__.SetInput(self.__itkvtkConverter__.GetOutput())

    self.Render()
开发者ID:giacomo21,项目名称:Image-analysis,代码行数:44,代码来源:itkvtkExtras.py


示例20: __init__

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

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create source
        source = vtk.vtkConeSource()
        source.SetHeight(3.0)
        source.SetRadius(1.0)
        source.SetResolution(20)
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        self.ren.AddActor(actor)

        # outline
        outline = vtk.vtkOutlineFilter()
        outline.SetInputConnection(source.GetOutputPort())
        mapper2 = vtk.vtkPolyDataMapper()
        mapper2.SetInputConnection(outline.GetOutputPort())
        actor2 = vtk.vtkActor()
        actor2.SetMapper(mapper2)
        self.ren.AddActor(actor2)
 
        self.ren.ResetCamera()

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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