本文整理汇总了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()
示例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())
示例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)
示例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)
示例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)
示例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())
示例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