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


Python vtk.vtkArrowSource方法代码示例

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


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

示例1: update

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def update(self):
        # Source for the glyph filter
        arrow = vtkArrowSource()
        arrow.SetTipResolution(8)
        arrow.SetTipLength(0.3)
        arrow.SetTipRadius(0.1)

        glyph = vtkGlyph3D()
        glyph.SetSourceConnection(arrow.GetOutputPort())
        glyph.SetInput(self.input_)
        glyph.SetVectorModeToUseNormal()
        glyph.SetScaleFactor(0.1)
        #glyph.SetColorModeToColorByVector()
        #glyph.SetScaleModeToScaleByVector()
        glyph.OrientOn()
        glyph.Update()

        self.output_ = glyph.GetOutput() 
开发者ID:mmolero,项目名称:pcloudpy,代码行数:20,代码来源:DisplayNormals.py

示例2: applyArrowGlyphs

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def applyArrowGlyphs(polyData, computeNormals=True, voxelGridLeafSize=0.03, normalEstimationSearchRadius=0.05, arrowSize=0.02):

    if computeNormals:
        polyData = applyVoxelGrid(polyData, leafSize=0.02)
        voxelData = applyVoxelGrid(polyData, leafSize=voxelGridLeafSize)
        polyData = normalEstimation(polyData, searchRadius=normalEstimationSearchRadius, searchCloud=voxelData)
        polyData = removeNonFinitePoints(polyData, 'normals')
        flipNormalsWithViewDirection(polyData, SegmentationContext.getGlobalInstance().getViewDirection())

    assert polyData.GetPointData().GetNormals()

    arrow = vtk.vtkArrowSource()
    arrow.Update()

    glyph = vtk.vtkGlyph3D()
    glyph.SetScaleFactor(arrowSize)
    glyph.SetSourceData(arrow.GetOutput())
    glyph.SetInputData(polyData)
    glyph.SetVectorModeToUseNormal()
    glyph.Update()

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

示例3: __init__

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def __init__(self, positions: np.ndarray, vectors: np.ndarray):
        self.num_vectors = 0

        # VTK position representation
        self._positions = vtk.vtkPoints()

        # VTK vector representation
        self._vectors = vtk.vtkFloatArray()
        self._vectors.SetName("Vector Field")
        self._vectors.SetNumberOfComponents(3)

        # Visualization Pipeline
        # - Data source
        position_data = vtk.vtkPolyData()
        position_data.SetPoints(self._positions)
        position_data.GetPointData().AddArray(self._vectors)
        position_data.GetPointData().SetActiveVectors("Vector Field")

        # - Add the vector arrays as 3D Glyphs
        arrow_source = vtk.vtkArrowSource()

        add_arrows = vtk.vtkGlyph3D()
        add_arrows.SetInputData(position_data)
        add_arrows.SetSourceConnection(arrow_source.GetOutputPort())
        add_arrows.Update()

        # - Map the data representation to graphics primitives
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(add_arrows.GetOutputPort())

        super().__init__(mapper)

        self.add_vectors(positions, vectors) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:35,代码来源:vtkVisualization.py

示例4: add_arrows

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def add_arrows(self, cent, direction, mag=1, **kwargs):
        """Add arrows to plotting object."""
        direction = direction.copy()
        if cent.ndim != 2:
            cent = cent.reshape((-1, 3))

        if direction.ndim != 2:
            direction = direction.reshape((-1, 3))

        direction[:,0] *= mag
        direction[:,1] *= mag
        direction[:,2] *= mag

        pdata = pyvista.vector_poly_data(cent, direction)
        # Create arrow object
        arrow = vtk.vtkArrowSource()
        arrow.Update()
        glyph3D = vtk.vtkGlyph3D()
        glyph3D.SetSourceData(arrow.GetOutput())
        glyph3D.SetInputData(pdata)
        glyph3D.SetVectorModeToUseVector()
        glyph3D.Update()

        arrows = wrap(glyph3D.GetOutput())

        return self.add_mesh(arrows, **kwargs) 
开发者ID:pyvista,项目名称:pyvista,代码行数:28,代码来源:plotting.py

示例5: Arrow

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def Arrow(start=(0.,0.,0.), direction=(1.,0.,0.), tip_length=0.25,
          tip_radius=0.1, tip_resolution=20, shaft_radius=0.05,
          shaft_resolution=20, scale=None):
    """Create a vtk Arrow.

    Parameters
    ----------
    start : np.ndarray
        Start location in [x, y, z]

    direction : list or np.ndarray
        Direction the arrow points to in [x, y, z]

    tip_length : float, optional
        Length of the tip.

    tip_radius : float, optional
        Radius of the tip.

    tip_resolution : int, optional
        Number of faces around the tip.

    shaft_radius : float, optional
        Radius of the shaft.

    shaft_resolution : int, optional
        Number of faces around the shaft.

    scale : float or str, optional
        Scale factor of the entire object, default is None (i.e. scale of 1).
        'auto' scales to length of direction array.

    Return
    ------
    arrow : pyvista.PolyData
        Arrow surface.

    """
    # Create arrow object
    arrow = vtk.vtkArrowSource()
    arrow.SetTipLength(tip_length)
    arrow.SetTipRadius(tip_radius)
    arrow.SetTipResolution(tip_resolution)
    arrow.SetShaftRadius(shaft_radius)
    arrow.SetShaftResolution(shaft_resolution)
    arrow.Update()
    surf = pyvista.PolyData(arrow.GetOutput())

    if scale == 'auto':
        scale = float(np.linalg.norm(direction))
    if isinstance(scale, float) or isinstance(scale, int):
        surf.points *= scale
    elif scale is not None:
        raise TypeError("Scale must be either float, int or 'auto'.")

    translate(surf, start, direction)
    return surf 
开发者ID:pyvista,项目名称:pyvista,代码行数:59,代码来源:geometric_objects.py

示例6: MakeGlyphs

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkArrowSource [as 别名]
def MakeGlyphs(src, reverseNormals):
    """
    Glyph the normals on the surface.

    You may need to adjust the parameters for maskPts, arrow and glyph for a
    nice appearance.

    :param: src - the surface to glyph.
    :param: reverseNormals - if True the normals on the surface are reversed.
    :return: The glyph object.

    """
    # Sometimes the contouring algorithm can create a volume whose gradient
    # vector and ordering of polygon (using the right hand rule) are
    # inconsistent. vtkReverseSense cures this problem.
    reverse = vtk.vtkReverseSense()

    # Choose a random subset of points.
    maskPts = vtk.vtkMaskPoints()
    maskPts.SetOnRatio(5)
    maskPts.RandomModeOn()
    if reverseNormals:
        reverse.SetInputData(src)
        reverse.ReverseCellsOn()
        reverse.ReverseNormalsOn()
        maskPts.SetInputConnection(reverse.GetOutputPort())
    else:
        maskPts.SetInputData(src)

    # Source for the glyph filter
    arrow = vtk.vtkArrowSource()
    arrow.SetTipResolution(16)
    arrow.SetTipLength(0.3)
    arrow.SetTipRadius(0.1)

    glyph = vtk.vtkGlyph3D()
    glyph.SetSourceConnection(arrow.GetOutputPort())
    glyph.SetInputConnection(maskPts.GetOutputPort())
    glyph.SetVectorModeToUseNormal()
    glyph.SetScaleFactor(1)
    glyph.SetColorModeToColorByVector()
    glyph.SetScaleModeToScaleByVector()
    glyph.OrientOn()
    glyph.Update()
    return glyph 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:47,代码来源:test_code_vasp_01.py


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