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


Python vtk.vtkTubeFilter函数代码示例

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


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


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