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


Python vtk.vtkTransformPolyDataFilter函数代码示例

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


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

示例1: __draw_sample_as_cylinder

    def __draw_sample_as_cylinder(self,sample,color,warning_color):
        a = self.__cylinder_actors.get(sample)
        if a is not None:
            a.SetVisibility(1)
            return
        p1 = sample.coil_center
        p2 = sample.sphere_intersection
        p3 = p1+(p2-p1)*1.2  # an extra 20% to guarantee it goes into the sphere
        #height = self.COIL_HEIGHT*1.2
        height = self.COIL_HEIGHT*500
        source = vtk.vtkCylinderSource()
        source.SetCenter(0,0,0)
        #source.SetRadius(self.SAMPLE_RADIUS)
        source.SetRadius(2)
        source.SetHeight(height)
        source.SetResolution(8)

        trans = vtk.vtkTransform()
        trans.Identity()

        v1 = p1-p2
        v1 /= np.linalg.norm(v1)

        v2 = (0,1,0)
        vp = np.cross(v2,v1)
        angle = np.arcsin(np.linalg.norm(vp))
        angle_deg = 180*angle/np.pi

        trans.Translate(p3)
        trans.RotateWXYZ(angle_deg,vp)
        trans.Translate((0,height/2,0))

        trans_filter = vtk.vtkTransformPolyDataFilter()
        trans_filter.SetInputConnection(source.GetOutputPort())
        trans_filter.SetTransform(trans)

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

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

        self.ren.AddActor(actor)
        self.__cylinder_actors[sample]=actor

        prop = actor.GetProperty()
        if sample.timing_error > 1:
            if warning_color is None:
                warning_color = self.SAMPLE_CYLINDER_WARNING_COLOR
            prop.SetColor(warning_color)
        else:
            if color is None:
                color = self.SAMPLE_CYLINDER_COLOR
            prop.SetColor(color)
        info = vtk.vtkInformation()
        info.Set(vtk.vtkShadowMapBakerPass.RECEIVER(),0)
        info.Set(vtk.vtkShadowMapBakerPass.OCCLUDER(),0)
        #prop.SetAmbient(0.8)
        actor.SetPropertyKeys(info)
开发者ID:deherinu,项目名称:TmsViewer,代码行数:59,代码来源:vtk_tms_widget.py

示例2: add_stud

def add_stud(prev, x, y):
    cylA = create_cylinder(r=2.5, h=2.)

    trA = vtk.vtkTransform()
    trA.Translate(x, y, 10.6)
    trA.RotateX(90)

    tfA = vtk.vtkTransformPolyDataFilter()
    tfA.SetTransform(trA)
    tfA.SetInputConnection(cylA.GetOutputPort())

    bA = vtkboolPython.vtkPolyDataBooleanFilter()
    bA.SetInputConnection(prev.GetOutputPort())
    bA.SetInputConnection(1, tfA.GetOutputPort())
    bA.SetOperModeToUnion()
    bA.DecPolysOff()

    cylB = create_cylinder(r=1.5, h=1.)

    trB = vtk.vtkTransform()
    trB.Translate(x, y, 9.1)
    trB.RotateX(90)

    tfB = vtk.vtkTransformPolyDataFilter()
    tfB.SetTransform(trB)
    tfB.SetInputConnection(cylB.GetOutputPort())

    bB = vtkboolPython.vtkPolyDataBooleanFilter()
    bB.SetInputConnection(bA.GetOutputPort())
    bB.SetInputConnection(1, tfB.GetOutputPort())
    bB.SetOperModeToDifference()
    bB.DecPolysOff()

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

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

示例4: vtk_ellipsoid_topomesh

def vtk_ellipsoid_topomesh(ellipsoid_radius=50.0, ellipsoid_scales=[1,1,1], ellipsoid_axes=np.diag(np.ones(3)), ellipsoid_center=np.zeros(3)):
    """
    """      
    import vtk
    from openalea.cellcomplex.property_topomesh.utils.image_tools import vtk_polydata_to_triangular_mesh

    ico = vtk.vtkPlatonicSolidSource()
    ico.SetSolidTypeToIcosahedron()
    ico.Update()

    subdivide = vtk.vtkLoopSubdivisionFilter()
    subdivide.SetNumberOfSubdivisions(3)
    subdivide.SetInputConnection(ico.GetOutputPort())
    subdivide.Update()

    scale_transform = vtk.vtkTransform()
    scale_factor = ellipsoid_radius/(np.sqrt(2)/2.)
    scale_transform.Scale(scale_factor,scale_factor,scale_factor)

    ellipsoid_sphere = vtk.vtkTransformPolyDataFilter()
    ellipsoid_sphere.SetInput(subdivide.GetOutput())
    ellipsoid_sphere.SetTransform(scale_transform)
    ellipsoid_sphere.Update()

    ellipsoid_transform = vtk.vtkTransform()
    axes_transform = vtk.vtkLandmarkTransform()
    source_points = vtk.vtkPoints()
    source_points.InsertNextPoint([1,0,0])
    source_points.InsertNextPoint([0,1,0])
    source_points.InsertNextPoint([0,0,1])
    target_points = vtk.vtkPoints()
    target_points.InsertNextPoint(ellipsoid_axes[0])
    target_points.InsertNextPoint(ellipsoid_axes[1])
    target_points.InsertNextPoint(ellipsoid_axes[2])
    axes_transform.SetSourceLandmarks(source_points)
    axes_transform.SetTargetLandmarks(target_points)
    axes_transform.SetModeToRigidBody()
    axes_transform.Update()
    ellipsoid_transform.SetMatrix(axes_transform.GetMatrix())
    ellipsoid_transform.Scale(ellipsoid_scales[0],ellipsoid_scales[1],ellipsoid_scales[2])
    center_transform = vtk.vtkTransform()
    center_transform.Translate(ellipsoid_center[0],ellipsoid_center[1],ellipsoid_center[2])
    center_transform.Concatenate(ellipsoid_transform)
    ellipsoid_ellipsoid = vtk.vtkTransformPolyDataFilter()
    ellipsoid_ellipsoid.SetInput(ellipsoid_sphere.GetOutput())
    ellipsoid_ellipsoid.SetTransform(center_transform)
    ellipsoid_ellipsoid.Update()

    ellipsoid_mesh = vtk_polydata_to_triangular_mesh(ellipsoid_ellipsoid.GetOutput())

    topomesh = triangle_topomesh(ellipsoid_mesh.triangles.values(),ellipsoid_mesh.points)

    return topomesh
开发者ID:VirtualPlants,项目名称:cellcomplex,代码行数:53,代码来源:example_topomesh.py

示例5: __init__

 def __init__(self,  center=(-2,0,0), radius = 1, angle=45, height=0.4, color=(1,1,0) , resolution=60):
     """ cone"""
     self.src = vtk.vtkConeSource()
     self.src.SetResolution(resolution)
     self.src.SetRadius( radius ) 
     #self.src.SetAngle( angle )
     self.src.SetHeight( height )
     #self.src.SetCenter(center)
     
     transform = vtk.vtkTransform()
     transform.Translate(center[0], center[1], center[2] - self.src.GetHeight()/2)
     #transform.RotateX(rotXYZ[0])
     transform.RotateY( -90 )
     #transform.RotateZ(rotXYZ[2])
     transformFilter=vtk.vtkTransformPolyDataFilter()
     transformFilter.SetTransform(transform)
     transformFilter.SetInputConnection(self.src.GetOutputPort())
     transformFilter.Update()
     
     self.mapper = vtk.vtkPolyDataMapper()
     self.mapper.SetInput(transformFilter.GetOutput())
     
     
     #self.mapper = vtk.vtkPolyDataMapper()
     #self.mapper.SetInput(self.src.GetOutput())
     self.SetMapper(self.mapper)
     self.SetColor(color)
开发者ID:aewallin,项目名称:randompolygon,代码行数:27,代码来源:ovdvtk.py

示例6: transform_back

	def transform_back(self,pt,pd):
		#The reconstructed surface is transformed back to where the
		#original points are. (Hopefully) it is only a similarity
		#transformation.

		#1. Get bounding box of pt, get its minimum corner (left, bottom, least-z), at c0, pt_bounds

		#2. Get bounding box of surface pd, get its minimum corner (left, bottom, least-z), at c1, pd_bounds

		#3. compute scale as: 
		#      scale = (pt_bounds[1] - pt_bounds[0])/(pd_bounds[1] - pd_bounds[0]);

		#4. transform the surface by T := T(pt_bounds[0], [2], [4]).S(scale).T(-pd_bounds[0], -[2], -[4])

		pt_bounds=pt.GetBounds()

		pd_bounds=pd.GetBounds()

		scale = (pt_bounds[1] - pt_bounds[0])/(pd_bounds[1] - pd_bounds[0]);

		transp = vtk.vtkTransform()
		transp.Translate(pt_bounds[0], pt_bounds[2], pt_bounds[4]);
		transp.Scale(scale, scale, scale);
		transp.Translate(- pd_bounds[0], - pd_bounds[2], - pd_bounds[4]);

		tpd = vtk.vtkTransformPolyDataFilter();
		tpd.SetInput(pd);
		tpd.SetTransform(transp);
		tpd.Update();


		return tpd.GetOutput();
开发者ID:desicos,项目名称:desicos,代码行数:32,代码来源:viewer23062013.py

示例7: createCylinderActor

def createCylinderActor(color=None,
                        radius=0.25,
                        height=0.3,
                        center=None,
                        ):
  cylinder = vtk.vtkCylinderSource()
  cylinder.SetResolution(128)
  cylinder.SetRadius(radius)
  cylinder.SetHeight(height)
  cylinderMapper = vtk.vtkPolyDataMapper()
  polyDataFilter = vtk.vtkTransformPolyDataFilter()
  polyDataFilter.SetInputConnection(cylinder.GetOutputPort())

  transform = vtk.vtkTransform()
  if center is not None:
    transform.Translate(*center)
  else:
    transform.Translate(0,0,height/2)
  transform.RotateWXYZ(90, 1,0,0)
  polyDataFilter.SetTransform(transform)

  cylinderMapper.SetInputConnection(polyDataFilter.GetOutputPort())
  cylinderActor = vtk.vtkActor()
  cylinderActor.SetMapper(cylinderMapper)
  if color is not None:
    cylinderActor.GetProperty().SetColor(color)
  return cylinderActor
开发者ID:simonkolotov,项目名称:Learning,代码行数:27,代码来源:VtkPickPieces.py

示例8: TransformPolyDataFilter

 def TransformPolyDataFilter(self, currentElement):
     transFilter = vtk.vtkTransformPolyDataFilter()
     # Datatype(s) I need for input:  Algorithm, LinearTransform
     AlgorithmElement = ''
     TransformElement = ''
     for childElement in currentElement.getchildren():
         if childElement.tag in vtkTypes['Algorithm']:
             AlgorithmElement = childElement
         if childElement.tag in vtkTypes['LinearTransform']:
             TransformElement = childElement
     if AlgorithmElement != '':
         dataset = self.namesToFunctions[AlgorithmElement.tag](AlgorithmElement)
         try:
             transFilter.SetInputConnection(dataset.GetOutputPort())
         except:
             self.logger.error('  .. <TransformPolyDataFilter> failed to SetInputConnection')
     else:
         self.logger.error('  .. <TransformPolyDataFilter> needs an Algorithm-type childElement')
     if TransformElement != '':
         transform = self.namesToFunctions[TransformElement.tag](TransformElement)
         try:
             transFilter.SetTransform(transform)
         except:
             self.logger.error('  .. <TransformPolyDataFilter> failed to SetTransform')
     else:
         self.logger.error('<TransformPolyDataFilter> needs an Transform-type childElement')
     return transFilter
开发者ID:mfassler,项目名称:jaivis,代码行数:27,代码来源:xmlReader.py

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

示例10: __init__

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

示例11: __init__

 def __init__(self, renderers, name):
     '''
     Initialize the bot model.
     '''
     # Call the parent constructor
     super(RoverBot,self).__init__(renderers)
     
     filename = "../scene/media/rover.stl"
     
     self.__name = name
      
     reader = vtk.vtkSTLReader()
     reader.SetFileName(filename)
     
     # Do the internal transforms to make it look along unit-z, do it with a quick transform
     trans = vtk.vtkTransform()
     trans.Scale(0.05, 0.05, 0.05)
     trans.RotateX(-90)
     transF = vtk.vtkTransformPolyDataFilter()
     transF.SetInputConnection(reader.GetOutputPort())
     transF.SetTransform(trans)
      
     self.__mapper = vtk.vtkPolyDataMapper()
     #if vtk.VTK_MAJOR_VERSION <= 5:
     #    self.__mapper.SetInput(reader.GetOutput())
     #else:
     self.__mapper.SetInputConnection(transF.GetOutputPort())
      
     self.vtkActor.SetMapper(self.__mapper)
     
     # Set up all the children for this model
     self.__setupChildren(renderers)
     # Set it to [0,0,0] so that it updates all the children
     self.SetSceneObjectPosition([0, 0, 0])
开发者ID:GearsAD,项目名称:semisorted_arnerve,代码行数:34,代码来源:RoverBot.py

示例12: GetPolyData

    def GetPolyData(self):
        """Return a vtkPolyData that bounding the ROI."""

        trans = vtk.vtkTransformPolyDataFilter()
        trans.SetInput(self._cylinder.GetOutput())
        trans.SetTransform(self.GetTransform())
        return trans.GetOutput()
开发者ID:andyTsing,项目名称:MicroView,代码行数:7,代码来源:ROICylinderFactory.py

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

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

示例15: add_tube

def add_tube(prev, x, y):
    cylA = create_cylinder(r=3.155, h=8.6)

    cube = vtk.vtkCubeSource()
    cube.SetXLength(.75)
    cube.SetYLength(6.6)
    cube.SetZLength(13.6)
    cube.SetCenter(0, 1, 0)

    bA = vtkbool.vtkPolyDataBooleanFilter()
    bA.SetInputConnection(cylA.GetOutputPort())
    bA.SetInputConnection(1, cube.GetOutputPort())
    bA.SetOperModeToUnion()

    cylB = create_cylinder(r=2.405, h=8.6)

    bB = vtkbool.vtkPolyDataBooleanFilter()
    bB.SetInputConnection(bA.GetOutputPort())
    bB.SetInputConnection(1, cylB.GetOutputPort())
    bB.SetOperModeToDifference()

    tr = vtk.vtkTransform()
    tr.Translate(x, y, 4.3)
    tr.RotateX(90)

    tf = vtk.vtkTransformPolyDataFilter()
    tf.SetTransform(tr)
    tf.SetInputConnection(bB.GetOutputPort())

    bC = vtkbool.vtkPolyDataBooleanFilter()
    bC.SetInputConnection(prev.GetOutputPort())
    bC.SetInputConnection(1, tf.GetOutputPort())
    bC.SetOperModeToUnion()

    return bC
开发者ID:aashish24,项目名称:vtkbool,代码行数:35,代码来源:brick.py


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