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


Python vtk.vtkVersion函数代码示例

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


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

示例1: createAllModules

def createAllModules(g):
    """ createAllModules(g: ClassTree) -> None
    Traverse the VTK class tree and add all modules into the module registry
    
    """
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        assert len(g.tree[0]) == 1
        base = g.tree[0][0]
        assert base.name == 'vtkObjectBase'
    
    vtkObjectBase = new_module(vtkBaseModule, 'vtkObjectBase')
    vtkObjectBase.vtkClass = vtk.vtkObjectBase
    registry = get_module_registry()
    registry.add_module(vtkObjectBase)
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        for child in base.children:
            if child.name in disallowed_classes:
                continue
            createModule(vtkObjectBase, child)
    else:
        for base in g.tree[0]:
            for child in base.children:
                if child.name in disallowed_classes:
                    continue
                createModule(vtkObjectBase, child)
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:25,代码来源:init.py

示例2: PlotEdges

def PlotEdges(mesh, angle):
    featureEdges = vtk.vtkFeatureEdges()
    if vtk.vtkVersion().GetVTKMajorVersion() >5:
        featureEdges.SetInputData(mesh)
    else:
        featureEdges.SetInput(mesh)
    featureEdges.FeatureEdgesOn()
    featureEdges.BoundaryEdgesOff()
    featureEdges.NonManifoldEdgesOff()
    featureEdges.ManifoldEdgesOff()
    featureEdges.SetFeatureAngle(angle)
    
    
    edgeMapper = vtk.vtkPolyDataMapper();
    edgeMapper.SetInputConnection(featureEdges.GetOutputPort());
    
    edgeActor = vtk.vtkActor();
    edgeActor.GetProperty().SetLineWidth(5);
    edgeActor.SetMapper(edgeMapper)
    
    
    mapper = vtk.vtkDataSetMapper()
    if vtk.vtkVersion().GetVTKMajorVersion() >5:
        mapper.SetInputData(mesh)
    else:
        mapper.SetInput(mesh)

    
    # Actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().LightingOff()    
        
    ###############################
    # Display
    ###############################
    
    # Render
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)
    
    # Allow user to interact
    istyle = vtk.vtkInteractorStyleTrackballCamera()
    iren.SetInteractorStyle(istyle)
    
    ren.AddActor(actor)
    ren.AddActor(edgeActor)
    
        
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:akaszynski,项目名称:PyACVD,代码行数:55,代码来源:VTK_Plotting.py

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

示例4: write_polydata

def write_polydata(polydata, filename):
    """Write polydata as vtkPolyData format, according to extension."""

    if VERBOSE:
        print "Writing ", filename, "..."

    basename, extension = os.path.splitext(filename)

    if   (extension == '.vtk'):
        writer = vtk.vtkPolyDataWriter()
        writer.SetFileTypeToBinary()
    elif (extension == '.vtp'):
        writer = vtk.vtkXMLPolyDataWriter()
        writer.SetDataModeToBinary()
    else:
        print 'Cannot recognize model file format'
        return None

    writer.SetFileName(filename)
    if (vtk.vtkVersion().GetVTKMajorVersion() >= 6.0):
        writer.SetInputData(polydata)
    else:
        writer.SetInput(polydata)
    writer.Update()

    del writer

    if VERBOSE:
        print "Done writing ", filename
        print "Number of lines found:", outpd.GetNumberOfLines()
开发者ID:RuizhiLiao,项目名称:whitematteranalysis,代码行数:30,代码来源:io.py

示例5: build_vtk_renderer

    def build_vtk_renderer(self):

        # offscreen rendering
        if (vtk.vtkVersion().GetVTKMajorVersion() == 5.0):
            graphics_factory = vtk.vtkGraphicsFactory()
            graphics_factory.SetOffScreenOnlyMode( 1);
            graphics_factory.SetUseMesaClasses( 1 );
            imaging_factory = vtk.vtkImagingFactory()
            imaging_factory.SetUseMesaClasses( 1 );
  
        self.renderer = vtk.vtkRenderer()
        self.renderer.SetBackground(1, 1, 1)
        self.render_window = vtk.vtkRenderWindow()
        # offscreen rendering
        self.render_window.SetOffScreenRendering(1)

        self.render_window.AddRenderer(self.renderer)
        # create a renderwindowinteractor
        #if self.interact:
        #self.iren = vtk.vtkRenderWindowInteractor()
        #self.iren.SetRenderWindow(self.render_window)

        # scalar bar        
        self.scalarbar = vtk.vtkScalarBarActor()
        # To avoid uninitialized warning in VTK 6
        self.scalarbar.SetTitle("") 
        # black text since background is white for printing
        self.scalarbar.GetLabelTextProperty().SetColor(0, 0, 0)
        self.scalarbar.GetTitleTextProperty().SetColor(0, 0, 0)
开发者ID:SlicerDMRI,项目名称:whitematteranalysis,代码行数:29,代码来源:render.py

示例6: __init__

    def __init__(self):
        ActorFactory.ActorFactory.__init__(self)

        # Create a green line
        self._Points = vtk.vtkPoints()
        self._Lines = vtk.vtkCellArray()
        self._Poly = vtk.vtkPolyData()

        self._Poly.SetPoints(self._Points)
        self._Poly.SetLines(self._Lines)

        self._PathProperty = vtk.vtkProperty()
        self._PathProperty.SetColor(0, 1, 0)
        self._PathProperty.SetOpacity(0.0)

        # turn the line into a cylinder
        self._tube = vtk.vtkTubeFilter()

        # VTK-6
        if vtk.vtkVersion().GetVTKMajorVersion() > 5:
            self._tube.SetInputData(self._Poly)
        else:
            self._tube.SetInput(self._Poly)

        self._tube.SetNumberOfSides(3)
        self._tube.SetRadius(2.5)
开发者ID:parallaxinnovations,项目名称:MicroView,代码行数:26,代码来源:PathFactory.py

示例7: SetRenderWindow

    def SetRenderWindow(self,w):
        """ SetRenderWindow(w: vtkRenderWindow)        
        Set a new render window to QVTKWidget and initialize the
        interactor as well
        
        """
        if w == self.mRenWin:
            return
        
        if self.mRenWin:
            if system.systemType!='Linux':
                self.mRenWin.SetInteractor(None)
            if self.mRenWin.GetMapped():
                self.mRenWin.Finalize()
            
        self.mRenWin = w

        if self.mRenWin:
            self.mRenWin.Register(None)
            if self.mRenWin.GetMapped():
                self.mRenWin.Finalize()
            if system.systemType=='Linux':
                display = None
                try:
                    display = int(QtGui.QX11Info.display())
                except TypeError:
                    # This was changed for PyQt4.2
                    if isinstance(QtGui.QX11Info.display(), QtGui.Display):
                        display = sip.unwrapinstance(QtGui.QX11Info.display())
                if display is not None:
                    v = vtk.vtkVersion()
                    version = [v.GetVTKMajorVersion(),
                               v.GetVTKMinorVersion(),
                               v.GetVTKBuildVersion()]
                    display = hex(display)[2:]
                    if version < [5, 7, 0]:
                        vp = ('_%s_void_p\0x00' % display)
                    elif version < [6, 2, 0]:
                        vp = ('_%s_void_p' % display)
                    else:
                        vp = ('_%s_p_void' % display)
                    self.mRenWin.SetDisplayId(vp)
                self.resizeWindow(1,1)
            self.mRenWin.SetWindowInfo(str(int(self.winId())))
            if self.isVisible():
                self.mRenWin.Start()

            if not self.mRenWin.GetInteractor():
                #iren = vtk.vtkRenderWindowInteractor()
                iren = QVTKRenderWindowInteractor()
#                if system.systemType=='Darwin':
#                    iren.InstallMessageProcOff()
                iren.SetRenderWindow(self.mRenWin)
                iren.Initialize()
#                if system.systemType=='Linux':
#                    system.XDestroyWindow(self.mRenWin.GetGenericDisplayId(),
#                                          self.mRenWin.GetGenericWindowId())
                self.mRenWin.SetWindowInfo(str(int(self.winId())))
                self.resizeWindow(self.width(), self.height())
                self.mRenWin.SetPosition(self.x(), self.y())
开发者ID:hjanime,项目名称:VisTrails,代码行数:60,代码来源:vtkcell.py

示例8: transform_polydata_from_disk

def transform_polydata_from_disk(in_filename, transform_filename, out_filename):
    # Read it in.
    print "<io.py> Transforming ", in_filename, "->", out_filename, "..."

    # Read the transform from disk because we cannot pickle it
    (root, ext) = os.path.splitext(transform_filename)
    print root, ext
    if ext == '.xfm':
        reader = vtk.vtkMNITransformReader()
        reader.SetFileName(transform_filename)
        reader.Update()
        transform = reader.GetTransform()
    elif ext == '.img':
        reader = vtk.vtkImageReader()
        reader.SetFileName(transform_filename)
        reader.Update()
        coeffs = reader.GetOutput()
        transform = vtk.vtkBSplineTransform()
        transform.SetCoefficients(coeffs)
        print coeffs
        print transform
    else:
        f = open(transform_filename, 'r')
        transform = vtk.vtkTransform()
        matrix = vtk.vtkMatrix4x4()
        for i in range(0,4):
            for j in range(0,4):
                matrix_val = float(f.readline())
                matrix.SetElement(i,j, matrix_val)
        transform.SetMatrix(matrix)
        del matrix

    start_time = time.time()
    pd = read_polydata(in_filename)
    elapsed_time = time.time() - start_time
    print "READ:", elapsed_time
    # Transform it.
    start_time = time.time()
    transformer = vtk.vtkTransformPolyDataFilter()
    if (vtk.vtkVersion().GetVTKMajorVersion() >= 6.0):
        transformer.SetInputData(pd)
    else:
        transformer.SetInput(pd)
    transformer.SetTransform(transform)
    transformer.Update()
    elapsed_time = time.time() - start_time
    print "TXFORM:", elapsed_time

    # Write it out.
    start_time = time.time()
    pd2 = transformer.GetOutput()
    write_polydata(pd2, out_filename)
    elapsed_time = time.time() - start_time
    print "WRITE:", elapsed_time

    # Clean up.
    del transformer
    del pd2
    del pd
    del transform
开发者ID:SlicerDMRI,项目名称:whitematteranalysis,代码行数:60,代码来源:io.py

示例9: SetHistogramStencil

    def SetHistogramStencil(self, stencil_data):

        # VTK-6
        if vtk.vtkVersion().GetVTKMajorVersion() > 5:
            self.__histogram_stats.SetStencilData(stencil_data)
        else:
            self.__histogram_stats.SetStencil(stencil_data)
开发者ID:parallaxinnovations,项目名称:vtkMultiIO,代码行数:7,代码来源:MVImage.py

示例10: transform_polydata_from_disk_using_transform_object

def transform_polydata_from_disk_using_transform_object(in_filename, transform, out_filename):
    # Read it in.
    print "<io.py> Transforming ", in_filename, "->", out_filename, "..."
    start_time = time.time()
    pd = read_polydata(in_filename)
    elapsed_time = time.time() - start_time
    print "READ:", elapsed_time
    # Transform it.
    start_time = time.time()
    transformer = vtk.vtkTransformPolyDataFilter()
    if (vtk.vtkVersion().GetVTKMajorVersion() >= 6.0):
        transformer.SetInputData(pd)
    else:
        transformer.SetInput(pd)
    transformer.SetTransform(transform)
    transformer.Update()
    elapsed_time = time.time() - start_time
    print "TXFORM:", elapsed_time

    # Write it out.
    start_time = time.time()
    pd2 = transformer.GetOutput()
    write_polydata(pd2, out_filename)
    elapsed_time = time.time() - start_time
    print "WRITE:", elapsed_time

    # Clean up.
    del transformer
    del pd2
    del pd
开发者ID:SlicerDMRI,项目名称:whitematteranalysis,代码行数:30,代码来源:io.py

示例11: __getattr__

    def __getattr__(self, name):
        v = vtk.vtkVersion()
        version = [v.GetVTKMajorVersion(),
                   v.GetVTKMinorVersion(),
                   v.GetVTKBuildVersion()]
        if version < [6, 0, 0]:
            # Translate vtk6 method names to vtk5 method names
            to_vtk5_names = {'AddInputData':  'AddInput',
                          'AddDataSetInput':  'AddInput',
                             'SetInputData':  'SetInput',
                            'AddSourceData': 'AddSource',
                            'SetSourceData': 'SetSource'}
            for new, old in to_vtk5_names.iteritems():
                if name.startswith(new):
                    # Keep suffix
                    name = old + name[len(new):]
                    break
        # redirect calls to vtkInstance
        def call_wrapper(*args):
            args = list(args)
            for i in xrange(len(args)):
                if hasattr(args[i], 'vtkInstance'):
                    # Unwrap VTK objects
                    args[i] = args[i].vtkInstance
            args = tuple(args)

            #print "CALLING", name, [a.__class__.__name__ for a in args]
            result = getattr(self.vtkInstance, name)(*args)
            #print "GOT", result.__class__.__name__

            if isinstance(result, vtk.vtkObjectBase):
                # Wrap VTK objects
                result = VTKInstanceWrapper(result)
            return result
        return call_wrapper
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:35,代码来源:vtk_classes.py

示例12: GetROIImage

    def GetROIImage(self, clipDataOn=0):
        """Return ROI Image port from ROIStencil"""
        component.getUtility(ICurrentImage).Update()
        minV, maxV = component.getUtility(ICurrentImage).GetScalarRange()
        reslice = vtk.vtkImageReslice()
        reslice.SetInputConnection(
            component.getUtility(ICurrentImage).GetOutputPort())
        reslice.SetInterpolationModeToCubic()

        # 2014-12-22 this is important
        self.__stencil_data.Update()

        # VTK-6
        if vtk.vtkVersion().GetVTKMajorVersion() > 5:
            reslice.SetStencilData(self.__stencil_data)
        else:
            reslice.SetStencil(self.__stencil_data)

        reslice.SetOutputExtent(self.__stencil_data.GetWholeExtent())
        reslice.SetOutputOrigin(self._Origin)
        reslice.SetOutputSpacing(self._Spacing)
        reslice.SetBackgroundLevel(minV)
        reslice.Update()

        return reslice
开发者ID:andyTsing,项目名称:MicroView,代码行数:25,代码来源:BasicBoneAnalysis.py

示例13: render_to_image

def render_to_image(output_filename, vtk_format, renderer, w, h):
    window = vtk.vtkRenderWindow()
    window.OffScreenRenderingOn()
    window.SetSize(w, h)

    # FIXME think this may be fixed in VTK6 so we don't have this
    # dependency...
    widget = None
    if systemType=='Darwin':
        from PyQt4 import QtCore, QtGui
        widget = QtGui.QWidget(None, QtCore.Qt.FramelessWindowHint)
        widget.resize(w, h)
        widget.show()
        window.SetWindowInfo(str(int(widget.winId())))

    window.AddRenderer(renderer)
    window.Render()
    win2image = vtk.vtkWindowToImageFilter()
    win2image.SetInput(window)
    win2image.Update()
    writer = vtk_format()
    if LooseVersion(vtk.vtkVersion().GetVTKVersion()) >= \
       LooseVersion('6.0.0'):
        writer.SetInputData(win2image.GetOutput())
    else:
        writer.SetInput(win2image.GetOutput())
    writer.SetFileName(output_filename)
    writer.Write()
    window.Finalize()
    if widget!=None:
        widget.close()
开发者ID:AnyarInc,项目名称:VisTrails,代码行数:31,代码来源:init.py

示例14: VertFacetoPoly

def VertFacetoPoly(new_pt, new_fc):
    """ Creates a vtk polydata object given points and triangular faces """
    
    # Convert points to vtkfloat object
    points = np.vstack(new_pt)
    vtkArray = VN.numpy_to_vtk(np.ascontiguousarray(points), deep=True)#, deep=True) 
    points = vtk.vtkPoints()
    points.SetData(vtkArray) 
    
    # Convert faces to vtk cells object
    ints = np.ones(len(new_fc), 'int')*3
    cells = np.hstack((ints.reshape(-1, 1), np.vstack(new_fc)))
    cells = np.ascontiguousarray(np.hstack(cells).astype('int64'))
    vtkcells = vtk.vtkCellArray()
    vtkcells.SetCells(cells.shape[0], VN.numpy_to_vtkIdTypeArray(cells, deep=True))

    # Create polydata object
    pdata = vtk.vtkPolyData()
    pdata.SetPoints(points)
    pdata.SetPolys(vtkcells)
    
    # Remove duplicate verticies
    clean = vtk.vtkCleanPolyData()
    clean.ConvertPolysToLinesOff()
    clean.ConvertLinesToPointsOff()
    clean.ConvertStripsToPolysOff()
    if vtk.vtkVersion().GetVTKMajorVersion() > 5:
        clean.SetInputData(pdata)
    else:
        clean.SetInput(pdata) 
    clean.Update()

    return clean.GetOutput()
开发者ID:akaszynski,项目名称:PyACVD,代码行数:33,代码来源:Clustering.py

示例15: PlotGrids_wFEM

def PlotGrids_wFEM(grids):
    """ Plots CFD structured grids with a single FEM """

    N = len(grids)
    HSV_tuples = [(x*1.0/N, 0.5, 0.5) for x in range(N)]
    RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples)
    
    actors = []
    for i in range(len(grids)):
        
        # Create mapper
        mapper = vtk.vtkDataSetMapper()
        if vtk.vtkVersion().GetVTKMajorVersion() >5:
            mapper.SetInput(grids[i])
        else:
            mapper.SetInputData(grids[i])
        
        # Create actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        actor.GetProperty().EdgeVisibilityOn()
        if i != 0:
            actor.GetProperty().SetRepresentationToWireframe()
            actor.GetProperty().SetColor(RGB_tuples[i])
        actor.GetProperty().LightingOff()
        actors.append(actor)
        
    # Add FEM Actor to renderer window
    ren = vtk.vtkRenderer()
#    ren.SetBackground(0.3, 0.3, 0.3)
    ren.SetBackground(0.8, 0.8, 0.8)
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)
    
    # Allow user to interact
    istyle = vtk.vtkInteractorStyleTrackballCamera()
    iren.SetInteractorStyle(istyle)
    

    
    # Add actor
    for actor in actors:
        ren.AddActor(actor)
    
    axes = vtk.vtkAxesActor()
    widget = vtk.vtkOrientationMarkerWidget()
#    widget.SetOutlineColor( 0.9300, 0.5700, 0.1300 )
    widget.SetOrientationMarker( axes )
    widget.SetInteractor( iren )
    widget.SetViewport( 0.0, 0.0, 0.4, 0.4 )
    widget.SetEnabled( 1 )
    widget.InteractiveOn()
    
    # Render
    iren.Initialize()
    renWin.Render()
    iren.Start()
开发者ID:akaszynski,项目名称:PyACVD,代码行数:59,代码来源:VTK_Plotting.py


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