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

Python vtk.vtkTransform函数代码示例

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

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



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

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


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


示例3: __init__

    def __init__(self):
        EventHandler.EventHandler.__init__(self)

        # default name is the class name, minus the "Factory"
        self._Name = self.__class__.__name__
        if self._Name[-7:] == 'Factory':
            self._Name = self._Name[0:-7]

        # Store the modified time
        self._MTime = vtk.vtkObject()
        self._RenderTime = vtk.vtkObject()

        # list of renderers the actors are displayed in
        self._Renderers = []
        # dictionary of actors for each renderer
        self._ActorDict = {}

        # ActorFactories which are children of this one
        self._Children = []

        # the transform for all of the actors
        self._Transform = vtk.vtkTransform()

        # this transform is used as a spare
        self._DummyTransform = vtk.vtkTransform()
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:25,代码来源:ActorFactory.py


示例4: __init__

 def __init__(self):
     # ODE initialization
     self.world = ode.World()
     self.world.setGravity(GRAVITY)
     self.world.setERP(ERP)
     self.world.setCFM(CFM)
     self.space = ode.Space()
     self.floor = ode.GeomPlane(self.space, (0.0,1.0,0.0), 0.0)
     self.jointGroup = ode.JointGroup()
     self.time = 0.0
     # VTK initialization
     self.renderer = vtk.vtkRenderer()
     self.renderer.SetBackground(102.0/255.0,204/255.0,1.0)
     self.window = vtk.vtkRenderWindow()
     self.window.SetSize(WINDOW_WIDTH,WINDOW_HEIGHT)
     self.window.AddRenderer(self.renderer)
     self.interactor = vtk.vtkRenderWindowInteractor()
     self.interactor.SetRenderWindow(self.window)
     self.axes = vtk.vtkAxesActor()
     self.axes.SetAxisLabels(0)
     transform = vtk.vtkTransform()
     transform.Scale(0.1,0.1,0.1)
     self.axes.SetUserTransform(transform)
     self.renderer.AddActor(self.axes)
     # Create ground plane visualization
     self.floorVisual = vtk.vtkPlaneSource()
     self.floorVisual.SetNormal((0.0,1.0,0.0))
     self.floorVisual.SetResolution(10,10)
     self.floorReader = vtk.vtkJPEGReader()
     self.floorReader.SetFileName(FLOOR_IMAGE)
     self.floorTexture = vtk.vtkTexture()
     transform = vtk.vtkTransform()
     transform.Scale(50.0,50.0,50.0)
     self.floorTexture.SetTransform(transform)
     self.floorTexture.SetInput(self.floorReader.GetOutput())
     self.floorMap = vtk.vtkTextureMapToPlane()
     self.floorMap.SetInput(self.floorVisual.GetOutput())
     self.floorMapper = vtk.vtkPolyDataMapper()
     self.floorMapper.SetInput(self.floorMap.GetOutput())
     self.floorActor = vtk.vtkActor()
     transform = vtk.vtkTransform()
     transform.Scale(100.0,100.0,100.0)
     self.floorActor.SetUserTransform(transform)
     self.floorActor.SetMapper(self.floorMapper)
     self.floorActor.SetTexture(self.floorTexture)
     self.renderer.AddActor(self.floorActor)
     # VTK camera setup
     self.camera = vtk.vtkCamera()
     self.renderer.SetActiveCamera(self.camera)
     self.cameraFocus = [0.0, 0.0, 0.0]
     self.cameraPos = [4.0, 2.5, 1.5]
     self.cameraOffset = [0.0,1.0,3.0]
     self.cameraRoll = 0.0
     # Keep track of the simulated bodies and robots
     self.bodies = []
     self.robots = []
     self.controllers = []
开发者ID:tioguerra,项目名称:pyrobosim,代码行数:57,代码来源:sim.py


示例5: __init__

	def __init__(self):
		super(RenderWidget, self).__init__()

		# Default volume renderer
		self.renderer = vtkRenderer()
		self.renderer.SetBackground2(0.4, 0.4, 0.4)
		self.renderer.SetBackground(0.1, 0.1, 0.1)
		self.renderer.SetGradientBackground(True)
		self.renderer.SetLayer(0)

		# Overlay renderer which is synced with the default renderer
		self.rendererOverlay = vtkRenderer()
		self.rendererOverlay.SetLayer(1)
		self.rendererOverlay.SetInteractive(0)
		self.renderer.GetActiveCamera().AddObserver("ModifiedEvent", self._syncCameras)

		self.rwi = QVTKRenderWindowInteractor(parent=self)
		self.rwi.SetInteractorStyle(vtkInteractorStyleTrackballCamera())
		self.rwi.GetRenderWindow().AddRenderer(self.renderer)
		self.rwi.GetRenderWindow().AddRenderer(self.rendererOverlay)
		self.rwi.GetRenderWindow().SetNumberOfLayers(2)
		self.rwi.SetDesiredUpdateRate(0)

		self.imagePlaneWidgets = [vtkImagePlaneWidget() for i in range(3)]
		for index in range(3):
			self.imagePlaneWidgets[index].DisplayTextOn()
			self.imagePlaneWidgets[index].SetInteractor(self.rwi)
			# Disable the margin for free rotation
			self.imagePlaneWidgets[index].SetMarginSizeX(0.0)
			self.imagePlaneWidgets[index].SetMarginSizeY(0.0)

		self.mapper = vtkOpenGLGPUVolumeRayCastMapper()
		self.mapper.SetAutoAdjustSampleDistances(1)
		self.volume = None
		self.imageData = None
		self.VolumeVisualization = None
		self.shouldResetCamera = False
		self.gridItems = []
		self.orientationGridItems = []

		self.clippingBox = ClippingBox()
		self.clippingBox.setWidget(self)

		# Keep track of the base and user transforms
		self.baseTransform = vtkTransform()
		self.userTransform = vtkTransform()

		self.setMinimumWidth(340)
		self.setMinimumHeight(340)

		layout = QGridLayout(self)
		layout.setSpacing(0)
		layout.setContentsMargins(0, 0, 0, 0)
		layout.addWidget(self.rwi, 0, 0)
		self.setLayout(layout)
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:55,代码来源:RenderWidget.py


示例6: DeformSurface

    def DeformSurface(self):
        # interpolate and sample the displacement norms over the surface
        rbf = vtkvmtkcontrib.vtkvmtkRBFInterpolation2()
        rbf.SetSource(self.SourceSpheres)
        rbf.SetRBFTypeToBiharmonic()
        rbf.ComputeCoefficients()
        sampler = vtkvmtkcontrib.vtkvmtkPolyDataSampleFunction()
        sampler.SetInput(self.Surface)
        sampler.SetImplicitFunction(rbf)
        sampler.SetSampleArrayName("DisplacementNorms")
        sampler.Update()

        sampArray = sampler.GetOutput().GetPointData().GetArray("DisplacementNorms")

        ##Clamp the negative values to 0 and the positive values to one in a weight array
        calculator = vtk.vtkArrayCalculator()
        calculator.SetInput(sampler.GetOutput())
        calculator.AddScalarArrayName("DisplacementNorms")
        calculator.SetFunction("if( DisplacementNorms > 0 , iHat, jHat)")
        calculator.SetResultArrayName("Weights")
        calculator.SetResultArrayType(vtk.VTK_FLOAT)
        calculator.Update()

        # Create the transform
        thinPlateSplineTransform = vtk.vtkThinPlateSplineTransform()
        thinPlateSplineTransform.SetBasisToR()
        thinPlateSplineTransform.SetSourceLandmarks(self.SourcePoints)
        thinPlateSplineTransform.SetTargetLandmarks(self.TargetPoints)

        transform = vtk.vtkTransform()
        transform.Identity()
        transform2 = vtk.vtkTransform()
        transform2.Identity()

        # Apply weighted transform
        transformFilter = vtk.vtkWeightedTransformFilter()
        transformFilter.SetInput(calculator.GetOutput())
        transformFilter.SetNumberOfTransforms(3)
        transformFilter.SetWeightArray("Weights")
        transformFilter.SetTransform(thinPlateSplineTransform, 0)
        transformFilter.SetTransform(transform, 1)
        transformFilter.SetTransform(transform2, 2)
        transformFilter.Update()

        normalsFilter = vtk.vtkPolyDataNormals()
        normalsFilter.SetInput(transformFilter.GetOutput())
        normalsFilter.Update()

        # FIXME: the normal filter apparently introduced some holes in some meshes (wtf?). This filter cleans the mesh
        cleanFilter = vtk.vtkCleanPolyData()
        cleanFilter.SetInput(normalsFilter.GetOutput())
        cleanFilter.Update()

        self.DeformedSurface = cleanFilter.GetOutput()
开发者ID:tangui,项目名称:vmtk,代码行数:54,代码来源:vmtkthinplatesplinedeformation.py


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


示例8: get_cylinder

def get_cylinder(upper, height, radius,
                 direction,
                 resolution=10):

    src = vtk.vtkCylinderSource()
    src.SetCenter((0, height/2, 0))
    src.SetHeight(height + radius/2.0)
    src.SetRadius(radius)
    src.SetResolution(resolution)

    rot1 = vtk.vtkTransform()
    fi = nm.arccos(direction[1])

    rot1.RotateWXYZ(-nm.rad2deg(fi), 0.0, 0.0, 1.0)
    u = nm.abs(nm.sin(fi))
    rot2 = vtk.vtkTransform()
    if u > 1.0e-6:

        # sometimes d[0]/u little bit is over 1
        d0_over_u = direction[0] / u
        if d0_over_u > 1:
            psi = 0
        elif d0_over_u < -1:
            psi = 2 * nm.pi
        else:
            psi = nm.arccos(direction[0] / u)

        logger.debug('d0 '+str(direction[0])+'  u '+str(u)+' psi '+str(psi))
        if direction[2] < 0:
            psi = 2 * nm.pi - psi

        rot2.RotateWXYZ(-nm.rad2deg(psi), 0.0, 1.0, 0.0)

    tl = vtk.vtkTransform()
    tl.Translate(upper)

    tr1a = vtk.vtkTransformFilter()
    tr1a.SetInput(src.GetOutput())
    tr1a.SetTransform(rot1)

    tr1b = vtk.vtkTransformFilter()
    tr1b.SetInput(tr1a.GetOutput())
    tr1b.SetTransform(rot2)

    tr2 = vtk.vtkTransformFilter()
    tr2.SetInput(tr1b.GetOutput())
    tr2.SetTransform(tl)

    tr2.Update()

    return tr2.GetOutput()
开发者ID:Trineon,项目名称:lisa,代码行数:51,代码来源:gen_vtk_tree.py


示例9: test_Segmentation

  def test_Segmentation(self):
    """ Test the GetRASBounds & GetBounds method on a segmentation.
    """
    #self.delayDisplay("Starting test_Segmentation")
    cubeSource = vtk.vtkCubeSource()
    cubeSource.SetXLength(500)
    cubeSource.SetYLength(200)
    cubeSource.SetZLength(300)
    cubeSource.SetCenter(10, -85, 0.7)

    rotation = vtk.vtkTransform()
    rotation.RotateX(15.0)
    rotation.RotateZ(78)

    applyTransform = vtk.vtkTransformPolyDataFilter()
    applyTransform.SetTransform(rotation)
    applyTransform.SetInputConnection(cubeSource.GetOutputPort())
    applyTransform.Update()

    modelNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLModelNode())
    modelNode.SetPolyDataConnection(applyTransform.GetOutputPort())

    segmentationNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLSegmentationNode())
    segmentationLogic = slicer.modules.segmentations.logic()
    segmentationLogic.ImportModelToSegmentationNode(modelNode, segmentationNode)

    # Testing
    bounds = range(6)
    segmentationNode.GetRASBounds(bounds)
    untransformedBounds = [-65.0710220336914, 235.9289779663086, -304.413391113281, 288.586608886719, -216.427032470703, 213.572967529297]
    self.assertListAlmostEquals(bounds, untransformedBounds)

    segmentationNode.GetBounds(bounds)
    self.assertListAlmostEquals(bounds, untransformedBounds)

    transform = vtk.vtkTransform()
    transform.Translate([-5.0, +42.0, -0.1])
    transform.RotateWXYZ(41, 0.7, 0.6, 75)
    transform.Scale(2, 3, 10)
    transformNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLTransformNode())
    transformNode.ApplyTransform(transform)

    segmentationNode.SetAndObserveTransformNodeID(transformNode.GetID())
    transformedBounds = [-200.70776329131795, 479.54290966330126, -723.6172978253361, 996.0765602877555, -2171.2883672792996, 2141.1537548033725]
    segmentationNode.GetRASBounds(bounds)
    self.assertListAlmostEquals(bounds, transformedBounds)

    segmentationNode.GetBounds(bounds)
    self.assertListAlmostEquals(bounds, untransformedBounds)
开发者ID:SlicerRt,项目名称:Slicer,代码行数:49,代码来源:SlicerBoundsTest.py


示例10: test_Segmentation

  def test_Segmentation(self):
    """ Test the GetRASBounds & GetBounds method on a segmentation.
    """
    #self.delayDisplay("Starting test_Segmentation")
    cubeSource = vtk.vtkCubeSource()
    cubeSource.SetXLength(500)
    cubeSource.SetYLength(200)
    cubeSource.SetZLength(300)
    cubeSource.SetCenter(10, -85, 0.7)

    rotation = vtk.vtkTransform()
    rotation.RotateX(15.0)
    rotation.RotateZ(78)

    applyTransform = vtk.vtkTransformPolyDataFilter()
    applyTransform.SetTransform(rotation)
    applyTransform.SetInputConnection(cubeSource.GetOutputPort())
    applyTransform.Update()

    modelNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLModelNode())
    modelNode.SetPolyDataConnection(applyTransform.GetOutputPort())

    segmentationNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLSegmentationNode())
    segmentationLogic = slicer.modules.segmentations.logic()
    segmentationLogic.ImportModelToSegmentationNode(modelNode, segmentationNode)

    # Testing
    bounds = range(6)
    segmentationNode.GetRASBounds(bounds)
    untransformedBounds = [-65.4164152220677, 237.23434621664234, -305.4495706784099, 289.7072339384947, -217.46321203583187, 213.68731403607347]
    self.assertListAlmostEquals(bounds, untransformedBounds)

    segmentationNode.GetBounds(bounds)
    self.assertListAlmostEquals(bounds, untransformedBounds)

    transform = vtk.vtkTransform()
    transform.Translate([-5.0, +42.0, -0.1])
    transform.RotateWXYZ(41, 0.7, 0.6, 75)
    transform.Scale(2, 3, 10)
    transformNode = slicer.mrmlScene.AddNode(slicer.vtkMRMLTransformNode())
    transformNode.ApplyTransform(transform)

    segmentationNode.SetAndObserveTransformNodeID(transformNode.GetID())
    transformedBounds = [-690.2701685073098, 970.3186946284741, -744.3124542486084, 1018.260811721817, -2183.4639807718822, 2144.107746300856]
    segmentationNode.GetRASBounds(bounds)
    self.assertListAlmostEquals(bounds, transformedBounds)

    segmentationNode.GetBounds(bounds)
    self.assertListAlmostEquals(bounds, untransformedBounds)
开发者ID:pieper,项目名称:Slicer,代码行数:49,代码来源:SlicerBoundsTest.py


示例11: drawFrameInCamera

    def drawFrameInCamera(self, t, frameName='new frame',visible=True):

        imageView = self.cameraView.views[self.imageViewName]
        v = imageView.view
        q = self.cameraView.imageManager.queue
        localToCameraT = vtk.vtkTransform()
        q.getTransform('local', self.imageViewName, localToCameraT)

        res = vis.showFrame( vtk.vtkTransform() , 'temp', view=v, visible=True, scale = 0.2)
        om.removeFromObjectModel(res)
        pd = res.polyData
        pd = filterUtils.transformPolyData(pd, t)
        pd = filterUtils.transformPolyData(pd, localToCameraT)
        q.projectPoints(self.imageViewName, pd )
        vis.showPolyData(pd, ('overlay ' + frameName), view=v, colorByName='Axes',parent='camera overlay',visible=visible)
开发者ID:rdeits,项目名称:director,代码行数:15,代码来源:pfgrasp.py


示例12: rotateMesh

def rotateMesh(mesh, axis=1, angle=0):
    try:
        print("Rotating surface: axis=", axis, "angle=", angle)
        matrix = vtk.vtkTransform()
        if axis == 0:
            matrix.RotateX(angle)
        if axis == 1:
            matrix.RotateY(angle)
        if axis == 2:
            matrix.RotateZ(angle)
        tfilter = vtk.vtkTransformPolyDataFilter()
        tfilter.SetTransform(matrix)
        if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
            tfilter.SetInputData(mesh)
        else:
            tfilter.SetInput(mesh)
        tfilter.Update()
        mesh2 = tfilter.GetOutput()
        return mesh2
    except:
        print("Surface rotating failed")
        exc_type, exc_value, exc_traceback = sys.exc_info()
        traceback.print_exception(
            exc_type, exc_value, exc_traceback, limit=2, file=sys.stdout)
    return None
开发者ID:dave3d,项目名称:dicom2stl,代码行数:25,代码来源:vtkutils.py


示例13: SetInlet

 def SetInlet(self, inlet):
     """Create a vtkTransform which will rotate the coordinates such that
     inlet.Normal is oriented in the z-direction and origin is inlet.Centre
     """
     n = inlet.Normal
     n = np.array([n.x, n.y, n.z])
     
     minInd = n.argsort()[0]
     axis = np.zeros(3)
     axis[minInd] = 1
     
     transmat = np.eye(4)
     transmat[0, 0:3] = np.cross(n, axis)
     transmat[0, 0:3] /= np.sqrt(np.sum(transmat[0, 0:3]**2))
     transmat[1, 0:3] = np.cross(n, transmat[0, 0:3])
     transmat[2, 0:3] = n
     
     trans = vtkTransform()
     trans.Scale(1., 1., 0.)
     trans.Concatenate(transmat.flatten())
     r = inlet.Centre
     trans.Translate(r.x, r.y, r.z)
     
     self.trans = trans
     self.transformer.SetTransform(self.trans)
     return
开发者ID:uschille,项目名称:hemelb,代码行数:26,代码来源:TesselateFace.py


示例14: select_point_cloud

 def select_point_cloud(self):
     if not self.scene.get_active_point_cloud(): return
     self.unselect_point_cloud()
     transform = vtk.vtkTransform()
     transform.SetMatrix(self.actor.GetMatrix())
     transform_filter = vtk.vtkTransformPolyDataFilter()
     transform_filter.SetInputConnection(self.src.GetOutputPort())
     transform_filter.SetTransform(transform)
     enclosed_pts = vtk.vtkSelectEnclosedPoints()
     if USING_VTK6:
         enclosed_pts.SetInputData(self.scene.get_active_point_cloud().polydata)
         enclosed_pts.SetSurfaceConnection(transform_filter.GetOutputPort())
     else:
         enclosed_pts.SetInput(self.scene.get_active_point_cloud().polydata)
         enclosed_pts.SetSurface(transform_filter.GetOutput())
     enclosed_pts.Update()
     inside_arr = enclosed_pts.GetOutput().GetPointData().\
       GetArray('SelectedPoints')
     self.selected_pts = []
     for i in range(inside_arr.GetNumberOfTuples()):
         if inside_arr.GetComponent(i, 0):
             self.scene.get_active_point_cloud().colors.\
               SetTuple3(i, *name_to_rgb('blue'))
             self.selected_pts.append(i)
             self.scene.get_active_point_cloud().selected_pts[i] += 1
     self.scene.get_active_point_cloud().colors.Modified()
     self.frame.ren_win.Render()
开发者ID:cjauvin,项目名称:pypetree,代码行数:27,代码来源:world.py


示例15: test_3D_interactionDefaults

  def test_3D_interactionDefaults(self):
    """ Test that the interaction widget exists in the 3D view.
    """
    logic = SlicerTransformInteractionTest1Logic()

    #self.delayDisplay("Starting test_3D_interactionDefaults")
    logic = SlicerTransformInteractionTest1Logic()
    tNode, tdNode = logic.addTransform()
    self.assertFalse(tdNode.GetEditorVisibility())
    self.assertFalse(tdNode.GetEditorSliceIntersectionVisibility())

    slicer.app.layoutManager().layout = slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView
    manager = logic.getModel3DDisplayableManager()
    self.assertIsNotNone(manager)

    # Check when nothing is on
    widget = manager.GetWidget(tdNode)
    self.assertFalse(widget.GetEnabled())

    # Check when interactive is on
    tdNode.SetEditorVisibility(True)
    self.assertTrue(widget.GetEnabled())

    # Check default widget tranform values
    representation = widget.GetRepresentation()
    defaultTransform = vtk.vtkTransform()
    representation.GetTransform(defaultTransform)

    expectedDefaultTransform = [
      [100.0,   0.0,    0.0,    0.0],
      [0.0,   100.0,    0.0,    0.0],
      [0.0,     0.0,  100.0,    0.0],
      [0.0,     0.0,    0.0,    1.0],
      ]
    self.assertTransform(defaultTransform, expectedDefaultTransform)
开发者ID:andrewfzheng,项目名称:Slicer,代码行数:35,代码来源:SlicerTransformInteractionTest1.py


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


示例17: create_glyphs

    def create_glyphs (self, poly):    
        if self.glyph_type == 'sphere':
            glyph = vtk.vtkSphereSource()
            glyph.SetRadius(1)
            glyph.SetPhiResolution(8)
            glyph.SetThetaResolution(8)
        elif self.glyph_type == 'cylinder':
            glyph = vtk.vtkCylinderSource()
            glyph.SetHeight(self.height)
            glyph.SetRadius(self.radius)
            glyph.SetCenter(0,0,0)
            glyph.SetResolution(10)
            glyph.CappingOn()

        tt = vtk.vtkTransform()
        tt.RotateZ(90)
        tf = vtk.vtkTransformPolyDataFilter()
        tf.SetInput(glyph.GetOutput())
        tf.SetTransform(tt)
        tf.Update()

        glypher = vtk.vtkGlyph3D()
        glypher.SetInput(poly)
        glypher.SetSource(tf.GetOutput())
        glypher.SetVectorModeToUseNormal()
        glypher.SetScaleModeToScaleByScalar()
        glypher.SetScaleFactor(self.glyph_scale_factor)
        glypher.Update()

        return glypher
开发者ID:151706061,项目名称:ChestImagingPlatform,代码行数:30,代码来源:display_particles.py


示例18: Execute

    def Execute(self):

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

        if not self.Matrix4x4:
            self.Matrix4x4 = vtk.vtkMatrix4x4()
            if self.MatrixCoefficients != []:
                self.PrintLog('Setting up transform matrix using specified coefficients')
                self.Matrix4x4.DeepCopy(self.MatrixCoefficients)
            elif self.Translation != [0.0,0.0,0.0] or self.Rotation != [0.0,0.0,0.0] or self.Scaling != [1.0,1.0,1.0]:
                self.PrintLog('Setting up transform matrix using specified translation, rotation and/or scaling')
                transform = vtk.vtkTransform()
                transform.RotateX(self.Rotation[0])
                transform.RotateY(self.Rotation[1])
                transform.RotateZ(self.Rotation[2])                       
                transform.Translate(self.Translation[0], self.Translation[1], self.Translation[2])
                transform.Scale(self.Scaling[0], self.Scaling[1], self.Scaling[2])
                self.Matrix4x4.DeepCopy(transform.GetMatrix())

        if self.InvertMatrix:
            self.Matrix4x4.Invert()

        transform = vtk.vtkMatrixToLinearTransform()
        transform.SetInput(self.Matrix4x4)

        transformFilter = vtk.vtkTransformFilter()
        transformFilter.SetInputData(self.Mesh)
        transformFilter.SetTransform(transform)
        transformFilter.Update()

        self.Mesh = transformFilter.GetOutput()
开发者ID:samsmu,项目名称:vmtk,代码行数:32,代码来源:vmtkmeshtransform.py


示例19: addContourObject

    def addContourObject(self, contourObject, prop3D):
        """Activate contouring for the contourObject.  The contourObject
        is usually a tdObject and specifically a vtkPolyData.  We also
        need the prop3D that represents this polydata in the 3d scene.
        """
        if self._contourObjectsDict.has_key(contourObject):
            # we already have this, thanks
            return

        try:
            contourable = contourObject.IsA('vtkPolyData')
        except:
            contourable = False

        if contourable:
            # we need a cutter to calculate the contours and then a stripper
            # to string them all together
            cutter = vtk.vtkCutter()
            plane = vtk.vtkPlane()
            cutter.SetCutFunction(plane)
            trfm = vtk.vtkTransform()
            trfm.SetMatrix(prop3D.GetMatrix())
            trfmFilter = vtk.vtkTransformPolyDataFilter()
            trfmFilter.SetTransform(trfm)
            trfmFilter.SetInput(contourObject)
            cutter.SetInput(trfmFilter.GetOutput())
            stripper = vtk.vtkStripper()
            stripper.SetInput(cutter.GetOutput())
            
            #
            #tubef = vtk.vtkTubeFilter()
            #tubef.SetNumberOfSides(12)
            #tubef.SetRadius(0.5)
            #tubef.SetInput(stripper.GetOutput())

            # and create the overlay at least for the 3d renderer
            mapper = vtk.vtkPolyDataMapper()
            mapper.SetInput(stripper.GetOutput())
            mapper.ScalarVisibilityOff()
            actor = vtk.vtkActor()
            actor.SetMapper(mapper)
            c = self.sliceDirections.slice3dVWR._tdObjects.getObjectColour(
                contourObject)
            actor.GetProperty().SetColor(c)
            actor.GetProperty().SetInterpolationToFlat()

            # add it to the renderer
            self.sliceDirections.slice3dVWR._threedRenderer.AddActor(actor)
            
            # add all necessary metadata to our dict
            contourDict = {'contourObject' : contourObject,
                           'contourObjectProp' : prop3D,
                           'trfmFilter' : trfmFilter,
                           'cutter' : cutter,
                           'tdActor' : actor}
                           
            self._contourObjectsDict[contourObject] = contourDict

            # now sync the bugger
            self.syncContourToObject(contourObject)
开发者ID:fvpolpeta,项目名称:devide,代码行数:60,代码来源:sliceDirection.py


示例20: __init__

 def __init__(self, color=(1,1,1), center=(0,0,0), text="hello", scale=1, camera=[]):
     """ create text """
     self.src = vtk.vtkVectorText()
     self.SetText(text)
     #self.SetCamera(camera)
     transform = vtk.vtkTransform()
     
     transform.Translate(center[0], center[1], center[2])
     transform.Scale(scale, scale, scale)
     #transform.RotateY(90)
     #transform2 = vtk.vtkTransform()
     #transform.Concatenate(transform2)
     #transformFilter=vtk.vtkTransformPolyDataFilter()
     #transformFilter.SetTransform(transform)
     #transformFilter.SetInputConnection(self.src.GetOutputPort())
     #transformFilter.Update()
     
     #follower = vtk.vtkFollower()
     #follower.SetMapper
     
     self.SetUserTransform(transform)
     self.mapper = vtk.vtkPolyDataMapper()
     self.mapper.SetInputConnection(self.src.GetOutputPort())
     self.SetMapper(self.mapper)
     self.SetColor(color)
开发者ID:aewallin,项目名称:randompolygon,代码行数:25,代码来源:ovdvtk.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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