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

Python vtk.vtkTubeFilter函数代码示例

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

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



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

示例1: _build_scene_tube

 def _build_scene_tube(self, shape):
     positions = shape.convert_to_positions_sizes()
     joint_count = len(positions)
     pts = vtk.vtkPoints()
     lines = vtk.vtkCellArray()
     lines.InsertNextCell(joint_count)
     for j in range(joint_count):
         pts.InsertPoint(j, positions[j])
         lines.InsertCellPoint(j)
     td = vtk.vtkPolyData()
     td.SetPoints(pts)
     td.SetLines(lines)
     tf = vtk.vtkTubeFilter()
     tf.SetInput(td)
     tf.SetRadius(TUBE_RADIUS)
     # tf.SetVaryRadiusToVaryRadiusOff()
     tf.SetCapping(1)
     tf.SetNumberOfSides(50)
     tf.Update()
     tm = vtk.vtkPolyDataMapper()
     tm.SetInput(tf.GetOutput())
     ta = vtk.vtkActor()
     ta.SetMapper(tm)
     #ta.GetProperty().SetDiffuse(0.8)
     ta.GetProperty().SetAmbient(0.25)
     self.vtkrenderer.AddActor(ta)
开发者ID:gokererdogan,项目名称:Infer3DShape,代码行数:26,代码来源:vision_forward_model.py


示例2: __init__

    def __init__(self, centers, vectors, radii, alpha=1, cmap=None):
        tails = centers - np.divide(vectors, 2.)
        heads = centers + np.divide(vectors, 2.)
        points = np.vstack(zip(tails, heads))
        pairs = np.arange(len(centers)*2).reshape(-1, 2)
        radii = np.repeat(radii, 2)

        assert (points.size/3. == pairs.size)
        assert (pairs.size == radii.size)

        self.polydata = vtk.vtkPolyData()
        self.set_points(points)
        self.set_lines(pairs)
        self.set_scalars(radii)

        self.tubeFilter = vtk.vtkTubeFilter()
        self.tubeFilter.SetInput(self.polydata)
        self.tubeFilter.SetVaryRadiusToVaryRadiusByAbsoluteScalar()
        self.tubeFilter.SetNumberOfSides(10)
        # self.tubeFilter.CappingOn()

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputConnection(self.tubeFilter.GetOutputPort())
        self.mapper.ScalarVisibilityOff()
        self.SetMapper(self.mapper)

        self.GetProperty().SetOpacity(alpha)

        self.script = [0]
开发者ID:RodericDay,项目名称:MiniPNM,代码行数:29,代码来源:graphics.py


示例3: add_bonds

    def add_bonds(self, neighbors, center):
        """
        Adds bonds for a site.

        Args:
            neighbors:
                Neighbors of the site.
            center:
                The site in the center for all bonds.
        """
        points = vtk.vtkPoints()
        points.InsertPoint(0, center.x, center.y, center.z)
        n = len(neighbors)
        lines = vtk.vtkCellArray()
        for i in range(n):
            points.InsertPoint(i + 1, neighbors[i].coords)
            lines.InsertNextCell(2)
            lines.InsertCellPoint(0)
            lines.InsertCellPoint(i + 1)
        pd = vtk.vtkPolyData()
        pd.SetPoints(points)
        pd.SetLines(lines)

        tube = vtk.vtkTubeFilter()
        tube.SetInput(pd)
        tube.SetRadius(0.1)

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(tube.GetOutputPort())

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
        self.ren.AddActor(actor)
开发者ID:jesuansito,项目名称:pymatgen,代码行数:33,代码来源:structure_vtk.py


示例4: __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


示例5: render

    def render(self, pointsData, scalarsArray, radiusArray, nspecies, colouringOptions, atomScaleFactor, lut):
        """
        Render the given antisites (wire frame).
        
        """
        self._logger.debug("Rendering antisites: colour by '%s'", colouringOptions.colourBy)

        # points
        points = vtk.vtkPoints()
        points.SetData(pointsData.getVTK())

        # poly data
        polydata = vtk.vtkPolyData()
        polydata.SetPoints(points)
        polydata.GetPointData().AddArray(scalarsArray.getVTK())
        polydata.GetPointData().SetScalars(radiusArray.getVTK())

        # source
        cubeSource = vtk.vtkCubeSource()
        edges = vtk.vtkExtractEdges()
        edges.SetInputConnection(cubeSource.GetOutputPort())
        glyphSource = vtk.vtkTubeFilter()
        glyphSource.SetInputConnection(edges.GetOutputPort())
        glyphSource.SetRadius(0.05)
        glyphSource.SetVaryRadius(0)
        glyphSource.SetNumberOfSides(5)
        glyphSource.UseDefaultNormalOn()
        glyphSource.SetDefaultNormal(0.577, 0.577, 0.577)

        # glyph
        glyph = vtk.vtkGlyph3D()
        if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
            glyph.SetSource(glyphSource.GetOutput())
            glyph.SetInput(polydata)
        else:
            glyph.SetSourceConnection(glyphSource.GetOutputPort())
            glyph.SetInputData(polydata)
        glyph.SetScaleFactor(atomScaleFactor * 2.0)
        glyph.SetScaleModeToScaleByScalar()
        glyph.ClampingOff()

        # mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(glyph.GetOutputPort())
        mapper.SetLookupTable(lut)
        mapper.SetScalarModeToUsePointFieldData()
        mapper.SelectColorArray("colours")
        utils.setMapperScalarRange(mapper, colouringOptions, nspecies)

        # actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        # store attributes
        self._actor = utils.ActorObject(actor)
        self._data["Points"] = pointsData
        self._data["Scalars"] = scalarsArray
        self._data["Radius"] = radiusArray
        self._data["LUT"] = lut
        self._data["Scale factor"] = atomScaleFactor
开发者ID:chrisdjscott,项目名称:Atoman,代码行数:60,代码来源:antisiteRenderer.py


示例6: __init__

    def __init__(self, dataShape, interactor):
        self.dataShape = dataShape
        self.planes = []
        self.coordinate = [0,0,0]
        self.lastChangedAxis = -1
        for i in range(3):
            p = vtkImplicitPlaneRepresentation()
            p.SetPlaceFactor(1.0)
            p.OutsideBoundsOn()
            p.ScaleEnabledOff()
            p.SetOrigin(0.25,0.25,0.25)
            p.PlaceWidget([0.1,dataShape[0],0.1,dataShape[1],0.1,dataShape[2]])

            args = [0, 0, 0]
            args[i] = 1
            p.SetNormal(*args)
            p.GetSelectedPlaneProperty().SetColor(*args)
            p.GetEdgesProperty().SetColor(*args) #bug in VTK

            p.GetPlaneProperty().SetOpacity(0.001)
            #do not draw outline
            p.GetOutlineProperty().SetColor(0,0,0)
            p.GetOutlineProperty().SetOpacity(0.0)
            #do not draw normal
            p.GetSelectedNormalProperty().SetOpacity(0.0)
            p.GetNormalProperty().SetOpacity(0.0)
            p.OutlineTranslationOff()
            p.TubingOff()
            
            self.cross = vtkPolyData()
            points = vtkPoints()
            polys = vtkCellArray()
            points.SetNumberOfPoints(6)
            for i in range(3):
                polys.InsertNextCell(2)
                polys.InsertCellPoint(2*i); polys.InsertCellPoint(2*i+1)
            self.cross.SetPoints(points)
            self.cross.SetLines(polys)
            
            pw = vtkImplicitPlaneWidget2()
            pw.SetRepresentation(p)
            pw.SetInteractor(interactor)
            pw.AddObserver("InteractionEvent", self.__PlanePositionCallback)
            
            self.planes.append(pw)
            
        tubes = vtkTubeFilter()
        tubes.SetNumberOfSides(16)
        tubes.SetInput(self.cross)
        tubes.SetRadius(1.0)
        
        crossMapper = vtkPolyDataMapper()
        crossMapper.SetInput(self.cross)
        crossActor = vtkActor()
        crossActor.SetMapper(crossMapper)
        crossActor.GetProperty().SetColor(0,0,0)
        self.AddPart(crossActor)
        
        #initially invoke the event!
        self.InvokeEvent("CoordinatesEvent")
开发者ID:JensNRAD,项目名称:volumina,代码行数:60,代码来源:slicingPlanesWidget.py


示例7: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)

        self._tubeFilter = vtk.vtkTubeFilter()
        
        module_utils.setup_vtk_object_progress(self, self._tubeFilter,
                                           'Generating tubes.')
                                           
        self._config.NumberOfSides = 3
        self._config.Radius = 0.01

        configList = [
            ('Number of sides:', 'NumberOfSides', 'base:int', 'text',
             'Number of sides that the tube should have.'),
            ('Tube radius:', 'Radius', 'base:float', 'text',
             'Radius of the generated tube.')]
        ScriptedConfigModuleMixin.__init__(self, configList)        
        
        self._viewFrame = self._createWindow(
            {'Module (self)' : self,
             'vtkTubeFilter' : self._tubeFilter})

        # pass the data down to the underlying logic
        self.config_to_logic()
        # and all the way up from logic -> config -> view to make sure
        self.syncViewWithLogic()
开发者ID:fvpolpeta,项目名称:devide,代码行数:27,代码来源:myTubeFilter.py


示例8: add_edge

 def add_edge(self, start, end, colour=Colours.BASE0):
     """Appends an edge to the edges list."""
     # Line
     line = vtkLineSource()
     line.SetPoint1(start)
     line.SetPoint2(end)
     # Line Mapper
     line_mapper = vtkPolyDataMapper()
     line_mapper.SetInputConnection(line.GetOutputPort())
     self.edge_colours.append(colour)
     self.line_mappers.append(line_mapper)
     # Bar
     bar = vtkTubeFilter()
     bar.SetInputConnection(line.GetOutputPort())
     bar.SetRadius(2.5)
     self.bar_data.append(bar)
     # Bar Mapper
     # Tried this, but mapping the ribbon caused beaucoup errors,
     # debugging would take a week.There must be some kind of way
     # out of here.
     # Said the joker to the thief
     # There's too much confusion
     # I can't get no relief
     # No reason to get excited, the thief he kindly spoke
     # But you and I have been through that
     # And this is not our fate
     # So let us not talk falsely now, the hour is getting late.
     # (2011-08-12)
     bar_mapper = vtkPolyDataMapper()
     bar_mapper.SetInputConnection(bar.GetOutputPort())
     self.bar_mappers.append(bar_mapper)
开发者ID:TomRegan,项目名称:synedoche,代码行数:31,代码来源:Graphics.py


示例9: draw_line

    def draw_line(self, l):
        """
        """

        if l in self.lines:
            return
        self.lines.append(l)

        line = vtk.vtkLineSource()
        line.SetPoint1(l.p1.x, l.p1.y, l.p1.z)
        line.SetPoint2(l.p2.x, l.p2.y, l.p2.z)

        # lineMapper = vtk.vtkPolyDataMapper()
        # lineMapper.SetInputConnection(line.GetOutputPort())
        # lineActor = vtk.vtkActor()
        # lineActor.SetMapper(lineMapper)

        tubeFilter = vtk.vtkTubeFilter()
        tubeFilter.SetInputConnection(line.GetOutputPort())
        tubeFilter.SetRadius(l.radius)
        tubeFilter.SetNumberOfSides(10)
        tubeFilter.Update()

        tubeMapper = vtk.vtkPolyDataMapper()
        tubeMapper.SetInputConnection(tubeFilter.GetOutputPort())
        
        tubeActor = vtk.vtkActor()
        tubeActor.SetMapper(tubeMapper)
        tubeActor.GetProperty().SetColor(l.color[0], l.color[1], l.color[2])

        self.rend.AddActor(tubeActor)
        self.tubeActors.append(tubeActor)
开发者ID:hadim,项目名称:lsysdrawer,代码行数:32,代码来源:vviewer.py


示例10: __init__

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


示例11: __init__

    def __init__(self, centers, vectors, radii, alpha=1, cmap=None):
        tails = centers - vectors/2.
        heads = centers + vectors/2.
        points = np.vstack(zip(tails, heads))
        pairs = np.arange(len(centers)*2).reshape(-1, 2)
        radii = radii.repeat(2)

        assert (points.size/3. == pairs.size)
        assert (pairs.size == radii.size)

        self.polydata = vtk.vtkPolyData()
        self.polydata.SetPoints(self.pointArray(points))
        self.polydata.SetLines(self.lineArray(pairs))
        self.polydata.GetPointData().SetScalars(self.floatArray(radii))

        self.tubeFilter = vtk.vtkTubeFilter()
        self.tubeFilter.SetInput(self.polydata)
        self.tubeFilter.SetVaryRadiusToVaryRadiusByAbsoluteScalar()
        self.tubeFilter.SetNumberOfSides(10)
        self.tubeFilter.CappingOn()

        self.mapper = vtk.vtkPolyDataMapper()
        self.mapper.SetInputConnection(self.tubeFilter.GetOutputPort())
        self.mapper.ScalarVisibilityOff()
        self.SetMapper(self.mapper)

        self.GetProperty().SetOpacity(alpha)
开发者ID:Maggie1988,项目名称:OpenPNM,代码行数:27,代码来源:Graphics.py


示例12: _createCylinder

 def _createCylinder(self, endPt1, endPt2, res=20):
     """
     Create a cylinder oriented to have the given end points.
     
     :@type endPt1: Vec3f
     :@param endPt1: The first end point to align the cylinder with.
     :@type endPt2: Vec3f
     :@param endPt2: The second end point to align the cylinder with.
     :@type radius: float
     :@param radius: The radius of the cylinder.
     :@type res: int
     :@param res: The circular resolution of the cylinder (number of sides). 
                  Must be at least 3.
                  
     :@rtype: vtk.vtkActor
     :@return: A renderable actor representing a cylinder.
     """
     res = 3 if res < 3 else res
     line = vtk.vtkLineSource()
     line.SetPoint1(endPt1.x,endPt1.y,endPt1.z)
     line.SetPoint2(endPt2.x,endPt2.y,endPt2.z)
     # Create a tube filter to represent the line as a cylinder.
     tube = vtk.vtkTubeFilter()
     tube.SetInput(line.GetOutput())
     tube.SetRadius(self.actor_radius)
     tube.SetNumberOfSides(res)
     mapper = vtk.vtkPolyDataMapper()
     mapper.SetInputConnection(tube.GetOutputPort())
     actor = vtk.vtkActor()
     actor.SetMapper(mapper)
     
     return actor    
开发者ID:smdabdoub,项目名称:ProkaryMetrics,代码行数:32,代码来源:bacteria.py


示例13: update_model

    def update_model( self, render=True ):
        model = self.pca.mean_.copy()
        for i in range(self.pca.components_.shape[0]):
            model += self.weights[i] * self.pca.components_[i]
        print model
        for i,s in enumerate(self.sources):
            s.SetCenter( model[3*i],
                         model[3*i+1],
                         model[3*i+2] )
            self.poly.GetPoints().SetPoint(i,
                                 model[3*i],
                                  model[3*i+1],
                                  model[3*i+2])

        # get a new tube filter
        self.tubes = vtk.vtkTubeFilter()
        self.tubes.SetInput(self.poly)
        self.tubes.SetRadius(0.1)
        self.tubes.SetNumberOfSides(6)
        self.mappers.append( vtk.vtkPolyDataMapper() )
        self.mappers[0].SetInputConnection(self.tubes.GetOutputPort())
        self.actors[0].SetMapper(self.mappers[0])
        
        if render:
            self.vtkWidget.Render()
        return
开发者ID:kevin-keraudren,项目名称:fetus-detector,代码行数:26,代码来源:show_simple_edges.py


示例14: __init__

 def __init__(self, pos, radius, rgb=[0.62, 0, 0.77]):
     self.source = vtk.vtkCubeSource()
     self.mapper = vtk.vtkPolyDataMapper()
     
     # length of sides
     self.source.SetXLength(radius)
     self.source.SetYLength(radius)
     self.source.SetZLength(radius)
     
     # centre
     self.source.SetCenter(pos)
     
     # edges filter
     edges = vtk.vtkExtractEdges()
     edges.SetInputConnection(self.source.GetOutputPort())
     
     # tube filter
     tubes = vtk.vtkTubeFilter()
     tubes.SetInputConnection(edges.GetOutputPort())
     tubes.SetRadius(0.15)
     tubes.SetNumberOfSides(5)
     tubes.UseDefaultNormalOn()
     tubes.SetDefaultNormal(.577, .577, .577)
     
     # mapper
     self.mapper.SetInputConnection(tubes.GetOutputPort())
     
     # actor
     self.SetMapper(self.mapper)
     self.GetProperty().SetColor(rgb)
开发者ID:brunoduran,项目名称:Atoman,代码行数:30,代码来源:highlight.py


示例15: make_cylinderActor

def make_cylinderActor (r, x0, x1, rgb, opacity):
    points = vtk.vtkPoints()
    lines  = vtk.vtkCellArray()
    lines.InsertNextCell(2)
    # point 0
    points.InsertNextPoint(x0[0], x0[1], x0[2])
    lines.InsertCellPoint(0)
    # point 1
    points.InsertNextPoint(x1[0], x1[1], x1[2])
    lines.InsertCellPoint(1)

    cData = vtk.vtkPolyData()
    cData.SetPoints(points)
    cData.SetLines(lines)

    c = vtk.vtkTubeFilter()
    c.SetNumberOfSides(8)
    c.SetInput(cData)
    c.SetRadius(r)

    cMapper = vtk.vtkPolyDataMapper()
    cMapper.SetInput(c.GetOutput())

    cActor = vtk.vtkActor()
    cActor.SetMapper(cMapper)
    cActor.GetProperty().SetColor(rgb[0], rgb[1], rgb[2])
    cActor.GetProperty().SetOpacity(opacity)

    return cActor
开发者ID:kichiki,项目名称:stokes,代码行数:29,代码来源:stvis-vtk.py


示例16: CreateAxes

def CreateAxes():
    global xAxis, yAxis, zAxis, popSplatter

    # Create axes.
    popSplatter.Update()
    bounds = popSplatter.GetOutput().GetBounds()
    axes = vtk.vtkAxes()
    axes.SetOrigin(bounds[0], bounds[2], bounds[4])
    axes.SetScaleFactor(popSplatter.GetOutput().GetLength()/5.0)

    axesTubes = vtk.vtkTubeFilter()
    axesTubes.SetInputConnection(axes.GetOutputPort())
    axesTubes.SetRadius(axes.GetScaleFactor()/25.0)
    axesTubes.SetNumberOfSides(6)

    axesMapper = vtk.vtkPolyDataMapper()
    axesMapper.SetInputConnection(axesTubes.GetOutputPort())

    axesActor = vtk.vtkActor()
    axesActor.SetMapper(axesMapper)

    # Label the axes.
    XText = vtk.vtkVectorText()
    XText.SetText(xAxis)

    XTextMapper = vtk.vtkPolyDataMapper()
    XTextMapper.SetInputConnection(XText.GetOutputPort())

    XActor = vtk.vtkFollower()
    XActor.SetMapper(XTextMapper)
    XActor.SetScale(0.02, .02, .02)
    XActor.SetPosition(0.35, -0.05, -0.05)
    XActor.GetProperty().SetColor(0, 0, 0)

    YText = vtk.vtkVectorText()
    YText.SetText(yAxis)

    YTextMapper = vtk.vtkPolyDataMapper()
    YTextMapper.SetInputConnection(YText.GetOutputPort())

    YActor = vtk.vtkFollower()
    YActor.SetMapper(YTextMapper)
    YActor.SetScale(0.02, .02, .02)
    YActor.SetPosition(-0.05, 0.35, -0.05)
    YActor.GetProperty().SetColor(0, 0, 0)

    ZText = vtk.vtkVectorText()
    ZText.SetText(zAxis)

    ZTextMapper = vtk.vtkPolyDataMapper()
    ZTextMapper.SetInputConnection(ZText.GetOutputPort())

    ZActor = vtk.vtkFollower()
    ZActor.SetMapper(ZTextMapper)
    ZActor.SetScale(0.02, .02, .02)
    ZActor.SetPosition(-0.05, -0.05, 0.35)
    ZActor.GetProperty().SetColor(0, 0, 0)
    return axesActor, XActor, YActor, ZActor
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:58,代码来源:FinancialField.py


示例17: generate

 def generate(self):
     if self.actor is not None:
         self.frame.ren.RemoveActor(self.actor)
     self.pts = vtk.vtkPoints()
     self.radii = vtk.vtkFloatArray()
     self.radii.SetName('radii')
     self.colors = vtk.vtkUnsignedCharArray()
     self.colors.SetNumberOfComponents(3)
     self.colors.SetName('colors')
     # nodes
     for k, node in self.K.items():
         self.pts.InsertPoint(k, *node.pos)
         self.radii.InsertTuple1(k, node.radius)
         if self.color_tips_in_yellow and not node.children:
             self.colors.InsertTuple3(k, *name_to_rgb('yellow'))
         else:
             self.colors.InsertTuple3(k, *name_to_rgb(self.base_color))
     # edges
     lines = vtk.vtkCellArray()
     for k, node in self.K.items():
         if node.parent is None: continue
         lines.InsertNextCell(2)
         lines.InsertCellPoint(k)
         lines.InsertCellPoint(node.parent)
     self.polydata = vtk.vtkPolyData()
     self.polydata.SetPoints(self.pts)
     self.polydata.SetLines(lines)
     self.polydata.GetPointData().AddArray(self.radii)
     self.polydata.GetPointData().AddArray(self.colors)
     self.polydata.GetPointData().SetActiveScalars('radii')
     self.tubes = vtk.vtkTubeFilter()
     self.tubes.SetNumberOfSides(10)
     if USING_VTK6:
         self.tubes.SetInputData(self.polydata)
     else:
         self.tubes.SetInput(self.polydata)
     self.tubes.SetVaryRadiusToVaryRadiusByAbsoluteScalar()
     self.tubes.CappingOn()
     self.mapper = vtk.vtkPolyDataMapper()
     if self.show_volume:
         if USING_VTK6:
             self.mapper.SetInputConnection(self.tubes.GetOutputPort())
         else:
             self.mapper.SetInput(self.tubes.GetOutput())
     else:
         if USING_VTK6:
             self.mapper.SetInputData(self.polydata)
         else:
             self.mapper.SetInput(self.polydata)
     self.mapper.ScalarVisibilityOn()
     self.mapper.SetScalarModeToUsePointFieldData()
     self.mapper.SelectColorArray('colors')
     self.actor = vtk.vtkActor()
     self.actor.GetProperty().SetColor(name_to_rgb_float(self.base_color))
     self.actor.SetMapper(self.mapper)
     self.frame.ren.AddActor(self.actor)
     self.frame.ren_win.Render()
开发者ID:cjauvin,项目名称:pypetree,代码行数:57,代码来源:world.py


示例18: tubeView

 def tubeView(self, clipper, pathWidth = 1.2):
     tubes = vtk.vtkTubeFilter()
     tubes.SetInputConnection(clipper.GetOutputPort())
     tubes.SetRadius(pathWidth/2.0)
     tubes.SetNumberOfSides(4)
     tubesMapper = vtk.vtkPolyDataMapper()
     tubesMapper.SetInputConnection(tubes.GetOutputPort())
     tubesActor = vtk.vtkActor()
     tubesActor.SetMapper(tubesMapper)
     return tubesActor
开发者ID:GVallicrosa,项目名称:FabQtV2,代码行数:10,代码来源:vtkCustom.py


示例19: __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.2, 0.3, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create Spiral tube
        nV = 256 #No. of vertices
        nCyc = 5 #No. of spiral cycles
        rS = 2.0   #Spiral radius
        h = 10.0
        nTv = 8 #No. of surface elements for each tube vertex

        points = vtk.vtkPoints()
        for i in range(nV):
            vX = rS * math.cos(2 * math.pi * nCyc * i / (nV-1))
            vY = rS * math.sin(2 * math.pi * nCyc * i / (nV-1))
            vZ = h * i / nV
            points.InsertPoint(i, vX, vY, vZ)

        lines = vtk.vtkCellArray()
        lines.InsertNextCell(nV)
        for i in range(nV):
            lines.InsertCellPoint(i)

        polyData = vtk.vtkPolyData()
        polyData.SetPoints(points)
        polyData.SetLines(lines)

        tube = vtk.vtkTubeFilter()
        tube.SetInput(polyData)
        tube.SetNumberOfSides(nTv)
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(tube.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

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


示例20: _createTube

 def _createTube(self):
     logging.debug("In MultiSliceContour::createTube()")
     
     points = vtk.vtkPoints()
     for point in self._originalPoints:
         points.InsertNextPoint(point)
                
     self._parametricSpline = vtk.vtkParametricSpline()
     self._parametricSpline.SetPoints(points)
     
     self._parametricFuntionSource = vtk.vtkParametricFunctionSource()
     self._parametricFuntionSource.SetParametricFunction(self._parametricSpline)
     self._parametricFuntionSource.SetUResolution(100)
     
     self._tubeFilter = vtk.vtkTubeFilter()
     self._tubeFilter.SetNumberOfSides(10)
     self._tubeFilter.SetRadius(self._radius)
     self._tubeFilter.SetInputConnection(self._parametricFuntionSource.GetOutputPort())
     
     self._tubeActor = []
     self._cubes = []
     i = 0
     for cutter in self._cutters:
         cutter.SetInputConnection(self._tubeFilter.GetOutputPort())
         cutter.Update()
         
         cube = vtk.vtkBox()
         #TODO change imagebounds to planesourceRange
         cube.SetBounds(self._scene.slice[i].getBounds())
         clip = vtk.vtkClipPolyData()
         clip.SetClipFunction(cube)
         clip.SetInputConnection(cutter.GetOutputPort())
         clip.InsideOutOn()
         clip.Update()          
         self._cubes.append(cube)
         
         tubeMapper=vtk.vtkPolyDataMapper()
         tubeMapper.ScalarVisibilityOff()
         tubeMapper.SetInputConnection(clip.GetOutputPort())
         tubeMapper.GlobalImmediateModeRenderingOn()
         
         tubeActor = vtk.vtkActor()
         tubeActor.SetMapper(tubeMapper)
         tubeActor.GetProperty().LightingOff()
         tubeActor.GetProperty().SetColor(self.lineColor)
         tubeActor.SetUserTransform(self._scene.slice[i].resliceTransform.GetInverse())
         
         
         self._tubeActor.append(tubeActor)
         self._scene.renderer.AddActor(tubeActor)
         i = i+1                
开发者ID:aevum,项目名称:moonstone,代码行数:51,代码来源:multislicecontour.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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