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

Python vtk.vtkAppendPolyData函数代码示例

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

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



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

示例1: CreateCrossSections

def CreateCrossSections(files, outputAreas, outputGeometryFile, outputOutlineFile):
  areaFile = open(outputAreas, 'w')

  planeAppender = vtk.vtkAppendPolyData()
  outlineAppender = vtk.vtkAppendPolyData()
  for idx in range(len(files)):
    print 'Processing contour %d' % idx
    file = files[idx]
    (plane, outline) = CreatePlanarCrossSectionPolyDataFromFile(file)
    areaFile.write(str(ComputePolyDataArea(plane)))
    areaFile.write('\n')
    planeAppender.AddInputData(plane)
    outlineAppender.AddInputData(outline)
    
  planeWriter = vtk.vtkXMLPolyDataWriter()
  planeWriter.SetFileName(outputGeometryFile)
  planeWriter.SetInputConnection(planeAppender.GetOutputPort())
  planeWriter.Update()
  
  outlineWriter = vtk.vtkXMLPolyDataWriter()
  outlineWriter.SetFileName(outputOutlineFile)
  outlineWriter.SetInputConnection(outlineAppender.GetOutputPort())
  outlineWriter.Update()

  areaFile.close()
开发者ID:PediatricAirways,项目名称:PediatricAirwaysScripts,代码行数:25,代码来源:CreatePlanarCrossSections.py


示例2: CreatePlanarCrossSectionPolyDataFromFile

def CreatePlanarCrossSectionPolyDataFromFile(file):

  with open(file, 'r') as f:
    read_data = f.read()

  tokens = string.split(read_data)

  offset = 2
  
  planeAppender = vtk.vtkAppendPolyData()
  outlineAppender = vtk.vtkAppendPolyData()

  # Iterate over separate pieces in the file
  while True:
    if (offset >= len(tokens)):
      break
    pointsInPiece = int(tokens[offset])
    
    newPoints = vtk.vtkPoints()
    newPoints.SetNumberOfPoints(pointsInPiece)
    
    for ptId in xrange(pointsInPiece):
      x = float(tokens[ptId*3 + 0 + offset + 1])
      y = float(tokens[ptId*3 + 1 + offset + 1])
      z = float(tokens[ptId*3 + 2 + offset + 1])
      newPoints.SetPoint(ptId, x, y, z)
    
    offset = offset + 3*pointsInPiece + 1
    
    polygon = vtk.vtkPolyData()
    polygon.SetPoints(newPoints)
    polygon.Allocate(pointsInPiece)
    polygon.InsertNextCell(vtk.VTK_POLYGON, pointsInPiece, range(pointsInPiece))

    triFilter = vtk.vtkTriangleFilter()
    triFilter.SetInputData(polygon)
   
    planeAppender.AddInputConnection(triFilter.GetOutputPort())
    
    outline = vtk.vtkPolyData()
    outline.SetPoints(newPoints)
    outline.Allocate(pointsInPiece)
    outline.InsertNextCell(vtk.VTK_POLY_LINE, pointsInPiece, range(pointsInPiece))
    outlineAppender.AddInputData(outline)
    
  planeAppender.Update()
  outlineAppender.Update()

  return (planeAppender.GetOutput(), outlineAppender.GetOutput())
开发者ID:PediatricAirways,项目名称:PediatricAirwaysScripts,代码行数:49,代码来源:CreatePlanarCrossSections.py


示例3: __build_actor

    def __build_actor(self):
        """
        Function to plot the circle
        """

        r = self.radius
        t = 0
        
        self.posc_a = 0
        self.posc_b = 0
        
        self.segment = vtk.vtkAppendPolyData()
        
        self.xa = self.posc_a + r * cos(t)
        self.ya = self.posc_a + r * sin(t)
                    
        while(t <= 2 * pi):
            self.GenerateCicleSegment(t)
            t = t + 0.05

        self.GenerateCicleSegment(0)
        
        self.mapper.SetInputConnection(self.segment.GetOutputPort())
        self.actor.SetMapper(self.mapper)
        self.actor.PickableOff()
开发者ID:151706061,项目名称:invesalius,代码行数:25,代码来源:cursor_actors.py


示例4: Merge5

def Merge5 ():
    reader = vtk.vtkPolyDataReader()
    reader.SetFileName('test10.vtk')

    reader2 = vtk.vtkPolyDataReader()
    reader2.SetFileName('test12.vtk')

    reader3 = vtk.vtkPolyDataReader()
    reader3.SetFileName('test13.vtk')

    app = vtk.vtkAppendPolyData()

    app.AddInputConnection(reader.GetOutputPort())

    tr = vtk.vtkTransform()
    tr.Translate(-50.916666, -1.083333, 0)
    tr.RotateZ(90)

    tp = vtk.vtkTransformPolyDataFilter()
    tp.SetTransform(tr)
    tp.SetInputConnection(reader2.GetOutputPort())

    app.AddInputConnection(tp.GetOutputPort())

    tr2 = vtk.vtkTransform()
    tr2.Translate(-50.916666, -1.083333, 0)

    tp2 = vtk.vtkTransformPolyDataFilter()
    tp2.SetTransform(tr2)
    tp2.SetInputConnection(reader3.GetOutputPort())

    app.AddInputConnection(tp2.GetOutputPort())

    return app
开发者ID:zippy84,项目名称:vtkbool,代码行数:34,代码来源:merge_all.py


示例5: __init__

 def __init__( self ):
   PerkEvaluatorMetric.__init__( self )
   
   self.outputPolyData = vtk.vtkAppendPolyData()
   
   self.planeSource = vtk.vtkPlaneSource()
   self.planePolyData = self.planeSource.GetOutput()
开发者ID:PerkTutor,项目名称:PythonMetrics,代码行数:7,代码来源:ShowUltrasoundSweep.py


示例6: _draw_line

    def _draw_line(self):
        line1 = vtk.vtkLineSource()
        line1.SetPoint1(self.points[0])
        line1.SetPoint2(self.points[1])

        line2 = vtk.vtkLineSource()
        line2.SetPoint1(self.points[1])
        line2.SetPoint2(self.points[2])

        arc = self.DrawArc()

        line = vtk.vtkAppendPolyData()
        line.AddInput(line1.GetOutput())
        line.AddInput(line2.GetOutput())
        line.AddInput(arc.GetOutput())

        c = vtk.vtkCoordinate()
        c.SetCoordinateSystemToWorld()

        m = vtk.vtkPolyDataMapper2D()
        m.SetInputConnection(line.GetOutputPort())
        m.SetTransformCoordinate(c)

        a = vtk.vtkActor2D()
        a.SetMapper(m)
        a.GetProperty().SetColor(self.colour)
        self.line_actor = a
开发者ID:RuanAragao,项目名称:invesalius3,代码行数:27,代码来源:measures.py


示例7: appendPolyData

def appendPolyData(polyDataList):
    assert len(polyDataList)
    append = vtk.vtkAppendPolyData()
    for polyData in polyDataList:
        append.AddInput(polyData)
    append.Update()
    return shallowCopy(append.GetOutput())
开发者ID:RobotLocomotion,项目名称:Pigeon,代码行数:7,代码来源:convertCollada.py


示例8: main

def main(opts, args):
  appender = vtk.vtkAppendPolyData()
  for f in args:
    o = nu.readVTK(f)
    appender.AddInput(o)
  appender.Update()
  nu.writeVTK(opts.output, appender.GetOutput())
开发者ID:fayhot,项目名称:gradworks,代码行数:7,代码来源:appendPolydata.py


示例9: grid_create

def grid_create(
		arg_grid_delta,
		arg_grid_color,
		arg_grid_width,
		arg_projection,
		arg_ratioxy):

	gridpolydata=vtk.vtkAppendPolyData()
	for i in range(0,int(90*arg_ratioxy),int(arg_grid_delta*arg_ratioxy)) :
		latpolydata=latitude_create(i,arg_projection)
		gridpolydata.AddInputData(latpolydata)
	for i in range(0,int(-90*arg_ratioxy),int(-arg_grid_delta*arg_ratioxy)) :
		latpolydata=latitude_create(i,arg_projection)
		gridpolydata.AddInputData(latpolydata)
	if arg_projection == 'linear' :
		for i in range(-180,540,arg_grid_delta) :
			lonpolydata=longitude_create(i,arg_projection,arg_ratioxy)
			gridpolydata.AddInputData(lonpolydata)
	else:
		for i in range(0,180,arg_grid_delta) :
			lonpolydata=longitude_create(i,arg_projection)
			gridpolydata.AddInputData(lonpolydata)

	gridpolygonmapper=vtk.vtkDataSetMapper()
	gridpolygonmapper.SetInputConnection(gridpolydata.GetOutputPort())

	gridpolygonactor=vtk.vtkActor()
	gridpolygonactor.SetMapper(gridpolygonmapper)
	gridpolygonactor.GetProperty().SetColor(arg_grid_color)
	gridpolygonactor.GetProperty().SetLineWidth(arg_grid_width)
	gridpolygonactor.GetProperty().SetAmbient(1)
	gridpolygonactor.GetProperty().SetDiffuse(0)
	gridpolygonactor.PickableOff()

	return(gridpolygonactor)
开发者ID:PBrockmann,项目名称:VTK_Mapper,代码行数:35,代码来源:mylib_grid.py


示例10: __init__

	def __init__(self, amt, radius):
		Model.__init__(self)
		self.source = vtk.vtkAppendPolyData()
		for i in range(amt):
			opX = 1.0
			opY = 1.0
			opZ = 1.0
			if random() > 0.5:
				opX *= -1.0
			if random() > 0.5:
				opY *= -1.0
			if random() > 0.5:
				opZ *= -1.0
			sRad = 0.25 + ( random() * 0.25 )
			x = float(random() * radius) * opX
			y = float(random() * radius) * opY
			z = float(random() * radius) * opZ
			s = vtk.vtkSphereSource()
			s.SetCenter(x,y,z)
			s.SetRadius(float(sRad))
			s.Update()
			self.source.AddInput(s.GetOutput())
		#add center
		s = vtk.vtkSphereSource()
		s.SetCenter(0.0, 0.0, 0.0)
		s.SetRadius(0.5)
		s.Update()
		self.source.AddInput(s.GetOutput())
		self.Update()
开发者ID:aglowacki,项目名称:ScanSimulator,代码行数:29,代码来源:PrimitiveModels.py


示例11: __init__

    def __init__(self):

        # Creates a cube image of height 0, thus creating a plane.
        cube = vtk.vtkCubeSource()
        cube.SetXLength(120)
        cube.SetYLength(120)
        cube.SetZLength(0)

        #cubeTransform = vtk.vtkTransform()
        #cubeTransform.Translate(0, 0, 0)
        
        cubeMapper = vtk.vtkPolyDataMapper()
        cubeMapper.SetInputConnection(cube.GetOutputPort())
        
        cubeTransformFilter = vtk.vtkTransformPolyDataFilter()
        cubeTransformFilter.SetInputConnection(cube.GetOutputPort())
        #cubeTransformFilter.SetTransform(cubeTransform)
        
        appendFilter = vtk.vtkAppendPolyData()
        #appendFilter.AddInputConnection(line.GetOutputPort())
        appendFilter.AddInputConnection(cubeTransformFilter.GetOutputPort())
       
        # gets the location of the tablet
        self.x = GlobalVariables.imageXDist/2.0 # @UndefinedVariable
        self.y = GlobalVariables.imageYDist/2.0 # @UndefinedVariable
        self.z = GlobalVariables.imageZDist/2.0 # @UndefinedVariable
        
        # moves the cube actor which is what moves the cursor
        self.cubeActor = vtk.vtkActor()
        self.cubeActor.SetMapper(cubeMapper)
        self.cubeActor.GetProperty().SetColor(0.2, 0.6, 0.8)
        self.cubeActor.SetPosition(self.x,self.y,self.z)#(self.sampleSpacing[0]/2,self.sampleSpacing[1]/2,self.sampleSpacing[2]/2)#(-30, -30, -150) #(70,90,50)
开发者ID:rcockbur,项目名称:3DMedicalVisualizationTool,代码行数:32,代码来源:PlaneGenerator.py


示例12: appendfilter

def appendfilter(polydatas):
    """Append list of polydata objects."""
    appender = vtk.vtkAppendPolyData()
    for polydata in polydatas:
        appender.AddInput(polydata)
    appender.Update()
    return appender.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:7,代码来源:vtklib.py


示例13: Create_Topo

def Create_Topo(Slope,Plane):
	ugrid = vtk.vtkUnstructuredGrid()
	gridreader=vtk.vtkUnstructuredGridReader()
	gridreader.SetFileName(Slope)
	gridreader.Update()
	ugrid = gridreader.GetOutput()
	GeomFilt1 = vtk.vtkGeometryFilter()
	GeomFilt1.SetInput(ugrid)
	GeomFilt1.Update()
	x = GeomFilt1.GetOutput()

	u = vtk.vtkUnstructuredGrid()
	bgridreader=vtk.vtkXMLUnstructuredGridReader()
	bgridreader.SetFileName(Plane)
	bgridreader.Update()
	u = bgridreader.GetOutput() 
	GeomFilt2 = vtk.vtkGeometryFilter()
	GeomFilt2.SetInput(u)
	GeomFilt2.Update()
	y = GeomFilt2.GetOutput()

	append = vtk.vtkAppendPolyData()
	append.AddInput(x)
	append.AddInput(y)
	data = append.GetOutput()

	d = vtk.vtkDelaunay3D()
	d.SetInput(data)
	d.Update
	d.BoundingTriangulationOff()  
	d.SetTolerance(0.00001)
	d.SetAlpha(0)
	d.Update()
	z = d.GetOutput()
	return z
开发者ID:Norrisa,项目名称:open-stratigraphy-model,代码行数:35,代码来源:Geom.py


示例14: merge_polydata

def merge_polydata(pds):
    f = vtk.vtkAppendPolyData()
    for pd in pds:
        f.AddInput(pd)
    f.Update()

    return f.GetOutput()
开发者ID:dasaderi,项目名称:SWDB-2015,代码行数:7,代码来源:tube.py


示例15: makeCylinderPtsVTP

def makeCylinderPtsVTP(locXYZ,radius=50,height=50,res=10):
    # Load the file
    if type(locXYZ) == np.ndarray:
        loc = locXYZ
    elif type(locXYZ) == str:
        loc = np.genfromtxt(locXYZ)
    # Make append poly filter
    appPoly = vtk.vtkAppendPolyData()
    # Loop through all the locations
    for pt in loc[:,0:3]:
    	# Make the cylinters
        cyl = vtk.vtkCylinderSource()
        cyl.SetCenter(pt)
        cyl.SetRadius(radius)
        cyl.SetHeight(height)
        cyl.SetResolution(res)
        # Rotate to be vertical
        rot = vtk.vtkTransform()
        rot.Translate(-pt)
        rot.PostMultiply()
        rot.RotateX(90)
        rot.Translate(pt)
        tranFor = vtk.vtkTransformPolyDataFilter()
        tranFor.SetInputConnection(cyl.GetOutputPort())
        tranFor.SetTransform(rot)
        tranFor.Update()
        # Append
        appPoly.AddInputConnection(tranFor.GetOutputPort())
    # Update and return.
    appPoly.Update()
    return appPoly.GetOutput()
开发者ID:grosenkj,项目名称:telluricpy,代码行数:31,代码来源:XYZtools.py


示例16: __init__

    def __init__(self, slice3dVWRThingy, sliceGrid):
        self.slice3dVWR = slice3dVWRThingy
        self._grid = sliceGrid
        self._sliceDirectionsDict = {}

        # this same picker is used on all new IPWS of all sliceDirections
        self.ipwPicker = vtk.vtkCellPicker()

        self.currentCursor = None

        # configure the grid from scratch
        self._initialiseGrid()

        self._initUI()

        # bind all events
        self._bindEvents()

        # fill out our drop-down menu
        self._disableMenuItems = self._appendGridCommandsToMenu(
            self.slice3dVWR.controlFrame.slicesMenu,
            self.slice3dVWR.controlFrame, disable=True)

        self.overlayMode = 'greenOpacityRange'
        self.fusionAlpha = 0.4

        # this will make all ipw slice polydata available at the output
        self.ipwAppendPolyData = vtk.vtkAppendPolyData()

        # this append filter will make all slice data available at the output
        self.ipwAppendFilter = vtk.vtkAppendFilter()

        # create the first slice
        self._createSlice('Axial')
开发者ID:fvpolpeta,项目名称:devide,代码行数:34,代码来源:sliceDirections.py


示例17: main

def main(argv=None):
    dimension = 2
    numprocs = 2
    level = 0  # startlevel

    no_multigridlevels = 0

    # check how many processors generated aggregation output
    # while check_files_for_next_level(0,numprocs, "aggs_level%LEVEL_proc%PROC.out") == True:
    #  numprocs = numprocs + 1
    # numprocs = numprocs - 1
    # print "Aggregtaion information for " + str(numprocs) + " processors found"

    # process all multigrid levels
    while check_files_for_next_level(level, numprocs, "aggs_level%LEVEL_proc%PROC.out"):
        global_nodecoords = []

        print "Level " + str(level)

        if level == 0:  # read in coordinates (finest level
            global_nodecoords, dimension = read_finelevel_nodecoords_from_file("example.txt")
        else:
            global_nodecoords, dimension = read_nodecoords_from_file("nodes" + str(level) + ".txt")

        # read aggregates
        aggid2nodes, aggid2procs = readin_aggregates("aggs_level%LEVEL_proc%PROC.out", numprocs, level)

        # vtk polygon for output
        aggpolygons = vtk.vtkAppendPolyData()

        # collect all aggregates
        for aggid, agg_nodes in aggid2nodes.iteritems():
            # build an aggregate
            if dimension == 2:
                prepareDelaunayData(
                    dimension, agg_nodes, global_nodecoords, aggpolygons, aggid, aggid2nodes, aggid2procs
                )
            else:
                prepareDelaunayData3d(
                    dimension, agg_nodes, global_nodecoords, aggpolygons, aggid, aggid2nodes, aggid2procs
                )

                # aggpolygons.GetOutput().GetPointData().SetVectors(vtkDisplacementVector)
                # aggpolygons.Update()

        writer = vtk.vtkXMLPolyDataWriter()
        fname = "aggs" + str(level) + ".vtp"
        writer.SetFileName(fname)
        writer.SetInput(aggpolygons.GetOutput())
        writer.Write()

        write_nodes_file("nodes" + str(level + 1) + ".txt", aggid2nodes, global_nodecoords, dimension)

        # increment number of multigrid levels that have been found in the files
        if no_multigridlevels < level:
            no_multigridlevels = level

        print "VTK Export for level " + str(level) + " finished...\r\n"

        level = level + 1
开发者ID:hcedwar,项目名称:Trilinos,代码行数:60,代码来源:MueLu_Agg2VTK.py


示例18: __create_vtk_rep

  def __create_vtk_rep(self, p1, p2):
    cone = self.__create_cone(p1, p2)
    line = self.__create_connecting_line(p1, p2)

    append_filter = vtk.vtkAppendPolyData()
    append_filter.AddInputData(cone);
    append_filter.AddInputData(line);
    append_filter.Update()
    return append_filter.GetOutput()
开发者ID:zibneuro,项目名称:brainvispy,代码行数:9,代码来源:visneuralconnection.py


示例19: Execute

    def Execute(self):

        if (self.Surface == None):
            self.PrintError('Error: no Surface.')

        appendFilter = vtk.vtkAppendPolyData()
        appendFilter.AddInputData(self.Surface)
        appendFilter.AddInputData(self.Surface2)
        appendFilter.Update()

        self.Surface = appendFilter.GetOutput()
开发者ID:samsmu,项目名称:vmtk,代码行数:11,代码来源:vmtksurfaceappend.py


示例20: Merge

def Merge(polydata_list):
    append = vtk.vtkAppendPolyData()

    for polydata in polydata_list:
        triangle = vtk.vtkTriangleFilter()
        triangle.SetInputData(polydata)
        append.AddInputData(triangle.GetOutput())

    clean = vtk.vtkCleanPolyData()
    clean.SetInputData(append.GetOutput())

    return append.GetOutput()
开发者ID:Houssk,项目名称:invesalius3,代码行数:12,代码来源:polydata_utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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