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


Python vtk.vtkGlyph3D方法代码示例

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


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

示例1: update

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkGlyph3D [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 vtkGlyph3D [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 vtkGlyph3D [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: create_actor

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkGlyph3D [as 别名]
def create_actor(self):
        self.points = vtk.vtkPoints()
        self.colors = vtk.vtkUnsignedCharArray()
        self.colors.SetName("colors")
        self.colors.SetNumberOfComponents(4)

        polydata = vtk.vtkPolyData()
        polydata.SetPoints(self.points)
        polydata.GetPointData().SetScalars(self.colors)

        # create cell
        voxel = self.create_voxel()

        self.glyph3D = vtk.vtkGlyph3D()
        self.glyph3D.SetColorModeToColorByScalar()
        self.glyph3D.SetSource(voxel.GetOutput())
        self.glyph3D.SetInput(polydata)
        self.glyph3D.ScalingOff()
        self.glyph3D.Update()

        # mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.glyph3D.GetOutput())

        # actor
        self.actor = vtk.vtkActor()
        self.actor.SetMapper(mapper)
        self.actor.GetProperty().SetAmbient(0.15) 
开发者ID:maxorange,项目名称:pix2vox,代码行数:30,代码来源:gui_viewer.py

示例5: add_arrows

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkGlyph3D [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

示例6: applyDiskGlyphs

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkGlyph3D [as 别名]
def applyDiskGlyphs(polyData, computeNormals=True):

    voxelGridLeafSize = 0.03
    normalEstimationSearchRadius = 0.05
    diskRadius = 0.015
    diskResolution = 12

    if computeNormals:
        scanInput = polyData

        pd = applyVoxelGrid(scanInput, leafSize=voxelGridLeafSize)

        pd = labelOutliers(pd, searchRadius=normalEstimationSearchRadius, neighborsInSearchRadius=3)
        pd = thresholdPoints(pd, 'is_outlier', [0, 0])

        pd = normalEstimation(pd, searchRadius=normalEstimationSearchRadius, searchCloud=scanInput)
    else:
        pd = polyData

    assert polyData.GetPointData().GetNormals()

    disk = vtk.vtkDiskSource()
    disk.SetOuterRadius(diskRadius)
    disk.SetInnerRadius(0.0)
    disk.SetRadialResolution(0)
    disk.SetCircumferentialResolution(diskResolution)
    disk.Update()

    t = vtk.vtkTransform()
    t.RotateY(90)
    disk = transformPolyData(disk.GetOutput(), t)

    glyph = vtk.vtkGlyph3D()
    glyph.ScalingOff()
    glyph.OrientOn()
    glyph.SetSourceData(disk)
    glyph.SetInputData(pd)
    glyph.SetVectorModeToUseNormal()
    glyph.Update()

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

示例7: MakeGlyphs

# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkGlyph3D [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.vtkGlyph3D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。