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


Python vtk.vtkTransform方法代码示例

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


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

示例1: getDepthMapData

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def getDepthMapData(self, viewId):

        mapId = self.reader.GetCurrentMapId(viewId)
        if mapId < 0:
            return None, None

        depthImage = vtk.vtkImageData()
        transform = vtk.vtkTransform()
        self.reader.GetDataForMapId(viewId, mapId, depthImage, transform)

        dims = depthImage.GetDimensions()
        d = vnp.getNumpyFromVtk(depthImage, 'ImageScalars')
        d = d.reshape(dims[1], dims[0])
        t = np.array([[transform.GetMatrix().GetElement(r, c) for c in range(4)] for r in range(4)])

        return d, t 
开发者ID:RobotLocomotion,项目名称:director,代码行数:18,代码来源:perception.py

示例2: set_scale

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def set_scale(self, xscale=None, yscale=None, zscale=None, reset_camera=True):
        """Scale all the datasets in the scene.

        Scaling in performed independently on the X, Y and Z axis.
        A scale of zero is illegal and will be replaced with one.

        """
        if xscale is None:
            xscale = self.scale[0]
        if yscale is None:
            yscale = self.scale[1]
        if zscale is None:
            zscale = self.scale[2]
        self.scale = [xscale, yscale, zscale]

        # Update the camera's coordinate system
        transform = vtk.vtkTransform()
        transform.Scale(xscale, yscale, zscale)
        self.camera.SetModelTransformMatrix(transform.GetMatrix())
        self.parent.render()
        if reset_camera:
            self.update_bounds_axes()
            self.reset_camera()
        self.Modified() 
开发者ID:pyvista,项目名称:pyvista,代码行数:26,代码来源:renderer.py

示例3: CameraModeToObjectAxis

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def CameraModeToObjectAxis(self, axis):
        camera = self._parent._vtkren.GetActiveCamera()
        transform = vtk.vtkTransform()
        transform.Identity()
        (pt, center) = self.ComputeDisplayCenter()
        transform.Translate(center[0], center[1], center[2])
        dx = self._parent._iren.GetLastEventPosition()[0] - self._parent._iren.GetEventPosition()[0]
        dy = self._parent._iren.GetLastEventPosition()[1] - self._parent._iren.GetEventPosition()[1]
        camera.OrthogonalizeViewUp()
        size = self._parent._vtkren.GetSize()
        transform.RotateWXYZ(360.0 * dx / size[0], axis[0], axis[1], axis[2])
        transform.RotateWXYZ(360.0 * dy / size[1], axis[0], axis[1], axis[2])
        transform.Translate(-center[0], -center[1], -center[2])
        camera.ApplyTransform(transform)
        camera.OrthogonalizeViewUp()
        self._parent._vtkren.ResetCameraClippingRange()
        self._parent._vtkren.GetRenderWindow().Render() 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:19,代码来源:wvtk.py

示例4: CameraModeToObjectAllAxis

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def CameraModeToObjectAllAxis(self):
        camera = self._parent._vtkren.GetActiveCamera()
        transform = vtk.vtkTransform()
        transform.Identity()
        (pt, center) = self.ComputeDisplayCenter()
        transform.Translate(center[0], center[1], center[2])
        dx = self._parent._iren.GetLastEventPosition()[0] - self._parent._iren.GetEventPosition()[0]
        dy = self._parent._iren.GetLastEventPosition()[1] - self._parent._iren.GetEventPosition()[1]
        camera.OrthogonalizeViewUp()
        viewUp = camera.GetViewUp()
        size = self._parent._vtkren.GetSize()
        transform.RotateWXYZ(360.0 * dx / size[0], viewUp[0], viewUp[1], viewUp[2])
        v2 = [0, 0, 0]
        vtk.vtkMath().Cross(camera.GetDirectionOfProjection(), viewUp, v2)
        transform.RotateWXYZ(-360.0 * dy / size[1], v2[0], v2[1], v2[2])
        transform.Translate(-center[0], -center[1], -center[2])
        camera.ApplyTransform(transform)
        camera.OrthogonalizeViewUp()
        self._parent._vtkren.ResetCameraClippingRange()
        self._parent._vtkren.GetRenderWindow().Render() 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:22,代码来源:wvtk.py

示例5: Roll

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def Roll(self, *args):
        camera = self._parent._vtkren.GetActiveCamera()
        transform = vtk.vtkTransform()
        pos = camera.GetPosition()
        fp = camera.GetFocalPoint()
        axis = [fp[i] - pos[i] for i in range(3)]
        (DisplayCenter, Center) = self.ComputeDisplayCenter()
        x1 = self._parent._iren.GetLastEventPosition()[0] - int(DisplayCenter[0])
        x2 = self._parent._iren.GetEventPosition()[0] - int(DisplayCenter[0])
        y1 = self._parent._iren.GetLastEventPosition()[1] - int(DisplayCenter[1])
        y2 = self._parent._iren.GetEventPosition()[1] - int(DisplayCenter[1])
        zCross = x1 * y2 - y1 * x2
        zCross = float(zCross)
        angle = vtk.vtkMath().DegreesFromRadians(zCross / (math.sqrt(float(x1 * x1 + y1 * y1)) *
                                                           math.sqrt(float(x2 * x2 + y2 * y2))))
        transform.Identity()
        transform.Translate(Center[0], Center[1], Center[2])
        transform.RotateWXYZ(angle, axis[0], axis[1], axis[2])
        transform.Translate(-Center[0], -Center[1], -Center[2])
        camera.ApplyTransform(transform)
        camera.OrthogonalizeViewUp()
        self._parent._vtkren.ResetCameraClippingRange()
        self._parent._iren.Render()

        # ----------------------------------------------------------------------------- 
开发者ID:pyCGNS,项目名称:pyCGNS,代码行数:27,代码来源:wvtk.py

示例6: RequestData

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def RequestData(self, request, inInfo, outInfo):
        """Used by pipeline to generate output"""
        # Get input/output of Proxy
        pdi = self.GetInputData(inInfo, 0, 0)
        # Get number of points
        pdo = self.GetOutputData(outInfo, 0)
        #### Perfrom task ####
        filt = vtk.vtkTransformFilter()
        trans = vtk.vtkTransform()
        trans.Scale(self.get_conversion(), self.get_conversion(), self.get_conversion())
        filt.SetTransform(trans)
        filt.SetInputDataObject(pdi)
        filt.Update()
        scaled = filt.GetOutputDataObject(0)
        pdo.DeepCopy(scaled)
        return 1 
开发者ID:OpenGeoVis,项目名称:PVGeo,代码行数:18,代码来源:xyz.py

示例7: getFootFramesFromReferenceFrame

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def getFootFramesFromReferenceFrame(referenceFrame, stanceWidth, stanceRotation, stanceOffset):

    footHeight=0.0745342

    ref = vtk.vtkTransform()
    ref.SetMatrix(referenceFrame.GetMatrix())

    stanceFrame = vtk.vtkTransform()
    stanceFrame.PostMultiply()
    stanceFrame.RotateZ(stanceRotation)
    stanceFrame.Translate(stanceOffset)
    stanceFrame.Concatenate(ref)

    lfootFrame = vtk.vtkTransform()
    lfootFrame.PostMultiply()
    lfootFrame.Translate(0, stanceWidth/2.0, footHeight)
    lfootFrame.Concatenate(stanceFrame)

    rfootFrame = vtk.vtkTransform()
    rfootFrame.PostMultiply()
    rfootFrame.Translate(0, -stanceWidth/2.0, footHeight)
    rfootFrame.Concatenate(stanceFrame)

    return stanceFrame, lfootFrame, rfootFrame 
开发者ID:RobotLocomotion,项目名称:director,代码行数:26,代码来源:segmentation.py

示例8: getDrillMesh

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def getDrillMesh(applyBitOffset=False):

    button = np.array([0.007, -0.035, -0.06])
    drillMesh = ioUtils.readPolyData(os.path.join(app.getDRCBase(), 'software/models/otdf/dewalt_button.obj'))

    if applyBitOffset:
        t = vtk.vtkTransform()
        t.Translate(0.01, 0.0, 0.0)
        drillMesh = transformPolyData(drillMesh, t)

    d = DebugData()
    d.addPolyData(drillMesh)
    d.addSphere(button, radius=0.005, color=[0,1,0])
    d.addLine([0.0,0.0,0.155], [0.0, 0.0, 0.14], radius=0.001, color=[0,1,0])

    return shallowCopy(d.getPolyData()) 
开发者ID:RobotLocomotion,项目名称:director,代码行数:18,代码来源:segmentation.py

示例9: test_translate_should_match_vtk_transformation

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def test_translate_should_match_vtk_transformation(rotate_amounts, translate_amounts, grid):
    trans = vtk.vtkTransform()
    trans.RotateWXYZ(0, *rotate_amounts)
    trans.Translate(translate_amounts)
    trans.Update()

    grid_a = grid.copy()
    grid_b = grid.copy()
    grid_c = grid.copy()
    grid_a.transform(trans)
    grid_b.transform(trans.GetMatrix())
    grid_c.transform(pyvista.trans_from_matrix(trans.GetMatrix()))
    assert np.allclose(grid_a.points, grid_b.points, equal_nan=True)
    assert np.allclose(grid_a.points, grid_c.points, equal_nan=True) 
开发者ID:pyvista,项目名称:pyvista,代码行数:16,代码来源:test_common.py

示例10: test_rotate_should_match_vtk_rotation

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def test_rotate_should_match_vtk_rotation(angle, axis, grid):
    trans = vtk.vtkTransform()
    getattr(trans, 'Rotate{}'.format(axis.upper()))(angle)
    trans.Update()

    trans_filter = vtk.vtkTransformFilter()
    trans_filter.SetTransform(trans)
    trans_filter.SetInputData(grid)
    trans_filter.Update()
    grid_a = pyvista.UnstructuredGrid(trans_filter.GetOutput())

    grid_b = grid.copy()
    getattr(grid_b, 'rotate_{}'.format(axis))(angle)
    assert np.allclose(grid_a.points, grid_b.points, equal_nan=True) 
开发者ID:pyvista,项目名称:pyvista,代码行数:16,代码来源:test_common.py

示例11: transform

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def transform(self, trans):
        """Compute a transformation in place using a 4x4 transform.

        Parameters
        ----------
        trans : vtk.vtkMatrix4x4, vtk.vtkTransform, or np.ndarray
            Accepts a vtk transformation object or a 4x4 transformation matrix.

        """
        if isinstance(trans, vtk.vtkMatrix4x4):
            t = pyvista.trans_from_matrix(trans)
        elif isinstance(trans, vtk.vtkTransform):
            t = pyvista.trans_from_matrix(trans.GetMatrix())
        elif isinstance(trans, np.ndarray):
            if trans.ndim != 2:
                raise ValueError('Transformation array must be 4x4')
            elif trans.shape[0] != 4 or trans.shape[1] != 4:
                raise ValueError('Transformation array must be 4x4')
            t = trans
        else:
            raise TypeError('Input transform must be either:\n'
                            '\tvtk.vtkMatrix4x4\n'
                            '\tvtk.vtkTransform\n'
                            '\t4x4 np.ndarray\n')

        x = (self.points*t[0, :3]).sum(1) + t[0, -1]
        y = (self.points*t[1, :3]).sum(1) + t[1, -1]
        z = (self.points*t[2, :3]).sum(1) + t[2, -1]

        # overwrite points
        self.points[:, 0] = x
        self.points[:, 1] = y
        self.points[:, 2] = z 
开发者ID:pyvista,项目名称:pyvista,代码行数:35,代码来源:common.py

示例12: getActorCircle

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def getActorCircle(radius_inner=100, radius_outer=99, color=(1,0,0)):
    """"""
    # create source
    source = vtk.vtkDiskSource()
    source.SetInnerRadius(radius_inner)
    source.SetOuterRadius(radius_outer)
    source.SetRadialResolution(100)
    source.SetCircumferentialResolution(100)

    # Transformer
    transform = vtk.vtkTransform()
    transform.RotateWXYZ(90, 1, 0, 0)
    transformFilter = vtk.vtkTransformPolyDataFilter()
    transformFilter.SetTransform(transform)
    transformFilter.SetInputConnection(source.GetOutputPort())
    transformFilter.Update()

    # mapper
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(transformFilter.GetOutputPort())

    # actor
    actor = vtk.vtkActor()
    actor.GetProperty().SetColor(color)
    actor.SetMapper(mapper)

    return actor 
开发者ID:VisualComputingInstitute,项目名称:3d-semantic-segmentation,代码行数:29,代码来源:viz.py

示例13: _repr

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def _repr(self, indent=4):
    if isinstance(self, FieldContainer):
        return _fields_repr(self, indent)
    if isinstance(self, vtk.vtkTransform):
        return _transform_repr(self, indent)
    if isinstance(self, dict):
        return _dict_repr(self, indent)
    if isinstance(self, list) and len(self) and not isinstance(self[0], (int, float)):
        return _list_repr(self, indent)
    else:
        return repr(self) 
开发者ID:RobotLocomotion,项目名称:director,代码行数:13,代码来源:fieldcontainer.py

示例14: computeAToB

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def computeAToB(a,b):

    t = vtk.vtkTransform()
    t.PostMultiply()
    t.Concatenate(b)
    t.Concatenate(a.GetLinearInverse())
    tt = vtk.vtkTransform()
    tt.SetMatrix(t.GetMatrix())
    return tt 
开发者ID:RobotLocomotion,项目名称:director,代码行数:11,代码来源:segmentation.py

示例15: lockAffordanceToHand

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkTransform [as 别名]
def lockAffordanceToHand(aff, hand='l_hand'):

    linkFrame = getLinkFrame(hand)
    affT = aff.actor.GetUserTransform()

    if not hasattr(aff, 'handToAffT') or not aff.handToAffT:
        aff.handToAffT = computeAToB(linkFrame, affT)

    t = vtk.vtkTransform()
    t.PostMultiply()
    t.Concatenate(aff.handToAffT)
    t.Concatenate(linkFrame)
    aff.actor.GetUserTransform().SetMatrix(t.GetMatrix()) 
开发者ID:RobotLocomotion,项目名称:director,代码行数:15,代码来源:segmentation.py


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