本文整理汇总了Python中vtk.vtkArrowSource函数的典型用法代码示例。如果您正苦于以下问题:Python vtkArrowSource函数的具体用法?Python vtkArrowSource怎么用?Python vtkArrowSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkArrowSource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__ (self, mod_m):
debug ("In VelocityVector::__init__ ()")
Common.state.busy ()
Base.Objects.Module.__init__ (self, mod_m)
self.glyph2d_src = vtk.vtkGlyphSource2D ()
self.cone = vtk.vtkConeSource ()
self.arrow = vtk.vtkArrowSource ()
self.glyph_src = self.cone
self.glyph3d = vtk.vtkGlyph3D ()
self.mapper = self.map = vtk.vtkPolyDataMapper ()
self.actor = self.act = vtk.vtkActor ()
# used to orient the cone properly
self.glph_trfm = vtk.vtkTransformFilter ()
self.glph_trfm.SetTransform (vtk.vtkTransform ())
self.data_out = self.mod_m.GetOutput ()
# Point of glyph that is attached -- -1 is tail, 0 is center,
# 1 is head.
self.glyph_pos = -1
self.scale = 1.0
self.color_mode = 2 #2 is vector, 1 is scalar, -1 none
self._initialize ()
self._gui_init ()
self.renwin.Render ()
Common.state.idle ()
示例2: __init__
def __init__(self, module_manager):
SimpleVTKClassModuleBase.__init__(
self, module_manager,
vtk.vtkArrowSource(), 'Processing.',
(), ('vtkPolyData',),
replaceDoc=True,
inputFunctions=None, outputFunctions=None)
示例3: setupGlyph
def setupGlyph(self,fUnitConv= 1.0):
self.polydata= self.getPolydata(fUnitConv)
# Generate the arrow for the glyphs
arrow = vtk.vtkArrowSource()
#arrow.SetRadius(0.1)
#arrow.SetHeight(0.5)
self.glyph = vtk.vtkGlyph3D()
self.glyph.SetInputData(self.polydata)
self.glyph.SetSourceConnection(arrow.GetOutputPort())
self.glyph.ScalingOn()
self.glyph.SetScaleModeToScaleByScalar()
self.glyph.SetVectorModeToUseVector()
self.glyph.OrientOn()
# Tell the filter to "clamp" the scalar range
#self.glyph.ClampingOn()
# Set the overall (multiplicative) scaling factor
self.glyph.SetScaleFactor(self.scaleFactor)
# Set the Range to "clamp" the data to
# -- see equations above for nonintuitive definition of "clamping"
# The fact that I'm setting the minimum value of the range below
# the minimum of my data (real min=0.0) with the equations above
# forces a minimum non-zero glyph size.
#self.glyph.SetRange(-10, 10) # Change these values to see effect on cone sizes
# Tell glyph which attribute arrays to use for what
self.glyph.SetInputArrayToProcess(0,0,0,0,self.lenghtsName) # scalars
self.glyph.SetInputArrayToProcess(1,0,0,0,self.vectorsName) # vectors
# self.glyph.SetInputArrayToProcess(2,0,0,0,'nothing') # normals
#self.glyph.SetInputArrayToProcess(3,0,0,0,self.lenghtsName) # colors
# Calling update because I'm going to use the scalar range to set the color map range
self.glyph.Update()
示例4: __init__
def __init__(self, scale=0.01, **kwargs):
kwargs["scale"] = scale
self.poly_data = vtk.vtkPolyData()
self.arrow_source = vtk.vtkArrowSource()
self.transform = vtk.vtkTransform()
self.transform_poly_data_filter = vtk.vtkTransformPolyDataFilter()
self.transform_poly_data_filter.SetTransform(self.transform)
self.transform_poly_data_filter.SetInputConnection(self.arrow_source.GetOutputPort())
self.glyph = vtk.vtkGlyph3D()
self.glyph.OrientOn()
self.glyph.SetVectorModeToUseNormal()
self.glyph.SetInput(self.poly_data)
self.glyph.SetSourceConnection(self.transform_poly_data_filter.GetOutputPort())
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInputConnection(self.glyph.GetOutputPort())
self.actor = vtk.vtkActor()
self.actor.SetMapper(self.mapper)
self._process_kwargs(**kwargs)
示例5: drawVtkSymb
def drawVtkSymb(symbType,renderer, RGBcolor, vPos, vDir, scale):
'''Adds to the renderer a symbol of type 'arrow', 'doubleArrow',
'cone', 'doubleCone', 'sphere', 'doubleSphere','cube' , 'doubleCube',
'cylinder', 'doubleCylinder'
:param symbType: type of symbol (available types: 'arrow', 'doubleArrow',
'cone', 'doubleCone', 'sphere', 'doubleSphere','cube' ,
'doubleCube', 'cylinder', 'doubleCylinder')
:param renderer: vtk renderer
:param RGBcolor: list [R,G,B] with the 3 components of color
:param vPos: list [x,y,z] with the 3 coordinates of the point where
to place the symbol.
:param vDir: director vector to orient the symbol
:param scale: scale to be applied to the symbol representation
'''
symTpLow=symbType.lower()
if 'arrow' in symTpLow:
symbSource=vtk.vtkArrowSource()
elif 'cone' in symTpLow:
symbSource=vtk.vtkConeSource()
elif 'sphere' in symTpLow:
symbSource=vtk.vtkSphereSource()
elif 'cube' in symTpLow:
symbSource=vtk.vtkCubeSource()
elif 'cylinder' in symTpLow:
symbSource=vtk.vtkCylinderSource()
vPosVx=[vPos[i]-scale/2.0*vDir[i] for i in range(3)] #vertex position
addSymb(symbSource,renderer, RGBcolor, vPosVx, vDir, scale)
if 'double' in symTpLow:
vPosVx=[vPosVx[i]-scale*vDir[i] for i in range(3)] #vertex position
addSymb(symbSource,renderer, RGBcolor, vPosVx, vDir, scale)
示例6: create_glyph
def create_glyph(self,plane_mapper):
#in here we do the arrows
arrows = vtk.vtkArrowSource()
ptMask = vtk.vtkMaskPoints()
ptMask.SetInputConnection(plane_mapper.GetOutputPort())
ptMask.SetOnRatio(10)
ptMask.RandomModeOn()
#in here we do the glyohs
glyph = vtk.vtkGlyph3D()
glyph.SetSourceConnection(arrows.GetOutputPort())
glyph.SetInputConnection(ptMask.GetOutputPort())
glyph.SetColorModeToColorByVector()
glyph.SetScaleFactor(20)
#Glyph mapper
gly_mapper = vtk.vtkPolyDataMapper()
gly_mapper.SetInputConnection(glyph.GetOutputPort())
gly_mapper.SetLookupTable(self.arrowColor)
#glyph actor
gly_actor = vtk.vtkActor()
gly_actor.SetMapper(gly_mapper)
return gly_actor
示例7: __init__
def __init__(self,data_reader):
self.lut=vtk.vtkLookupTable()
self.lut.SetNumberOfColors(256)
self.lut.SetTableRange(data_reader.get_scalar_range())
self.lut.SetHueRange(0,1)
self.lut.SetRange(data_reader.get_scalar_range())
self.lut.SetRange(data_reader.get_scalar_range())
self.lut.Build()
self.arrow=vtk.vtkArrowSource()
self.arrow.SetTipResolution(6)
self.arrow.SetTipRadius(0.1)
self.arrow.SetTipLength(0.35)
self.arrow.SetShaftResolution(6)
self.arrow.SetShaftRadius(0.03)
self.glyph=vtk.vtkGlyph3D()
self.glyph.SetInput(data_reader.get_data_set())
self.glyph.SetSource(self.arrow.GetOutput())
self.glyph.SetVectorModeToUseVector()
self.glyph.SetColorModeToColorByScalar()
self.glyph.SetScaleModeToScaleByVector()
self.glyph.OrientOn()
self.glyph.SetScaleFactor(0.002)
mapper=vtk.vtkPolyDataMapper()
mapper.SetInput(self.glyph.GetOutput())
mapper.SetLookupTable(self.lut)
mapper.ScalarVisibilityOn()
mapper.SetScalarRange(data_reader.get_scalar_range())
self.actor=vtk.vtkActor()
self.actor.SetMapper(mapper)
示例8: __init__
def __init__(self):
super(Arrow, self).__init__()
self.arrow = vtk.vtkArrowSource()
self.prim = vtk.vtkTransformPolyDataFilter()
self.end_point = [0, 0, 0]
self.start_point = [1, 0, 0]
self.shaft_radius = 0.03
self.tip_radius = 0.1
self.length_ratio = 0.35
示例9: create_arrow
def create_arrow(self):
source = vtk.vtkArrowSource()
# Create a mapper and actor
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.render.AddActor(actor)
示例10: __init__
def __init__(self, module_manager):
ModuleBase.__init__(self, module_manager)
InputArrayChoiceMixin.__init__(self)
self._config.scaling = True
self._config.scaleFactor = 1
self._config.scaleMode = glyphScaleMode.index('SCALE_BY_VECTOR')
self._config.colourMode = glyphColourMode.index('COLOUR_BY_VECTOR')
self._config.vectorMode = glyphVectorMode.index('USE_VECTOR')
self._config.mask_on_ratio = 5
self._config.mask_random = True
configList = [
('Scale glyphs:', 'scaling', 'base:bool', 'checkbox',
'Should the size of the glyphs be scaled?'),
('Scale factor:', 'scaleFactor', 'base:float', 'text',
'By how much should the glyph size be scaled if scaling is '
'active?'),
('Scale mode:', 'scaleMode', 'base:int', 'choice',
'Should scaling be performed by vector, scalar or only factor?',
glyphScaleModeTexts),
('Colour mode:', 'colourMode', 'base:int', 'choice',
'Colour is determined based on scalar or vector magnitude.',
glyphColourModeTexts),
('Vector mode:', 'vectorMode', 'base:int', 'choice',
'Should vectors or normals be used for scaling and orientation?',
glyphVectorModeTexts),
('Vectors selection:', 'vectorsSelection', 'base:str', 'choice',
'The attribute that will be used as vectors for the warping.',
(input_array_choice_mixin.DEFAULT_SELECTION_STRING,)),
('Mask on ratio:', 'mask_on_ratio', 'base:int', 'text',
'Every Nth point will be glyphed.'),
('Random masking:', 'mask_random', 'base:bool', 'checkbox',
'Pick random distribution of Nth points.')]
self._mask_points = vtk.vtkMaskPoints()
module_utils.setup_vtk_object_progress(self,
self._mask_points, 'Masking points.')
self._glyphFilter = vtk.vtkGlyph3D()
asrc = vtk.vtkArrowSource()
self._glyphFilter.SetSource(0, asrc.GetOutput())
self._glyphFilter.SetInput(self._mask_points.GetOutput())
module_utils.setup_vtk_object_progress(self, self._glyphFilter,
'Creating glyphs.')
ScriptedConfigModuleMixin.__init__(
self, configList,
{'Module (self)' : self,
'vtkGlyph3D' : self._glyphFilter})
self.sync_module_logic_with_config()
示例11: draw
def draw(self, graphics):
cell, pointnums = super(Arrow, self).draw(graphics)
assert len(pointnums) == 2
arrow = vtk.vtkArrowSource()
p1, p2 = graphics.get_points(*pointnums)
transform = vtk.vtkTransform()
transform.Translate(p1)
length = norm(p2-p1)
transform.Scale(length, length, length)
pass
示例12: render
def render(self, pointsData, scalarsArray, vectorsArray, nspecies, colouringOptions, vectorsOptions, lut,
invert=False):
"""
Render vectors.
"""
self._logger.debug("Rendering vectors")
# points
points = vtk.vtkPoints()
points.SetData(pointsData.getVTK())
# polydata
arrowPolyData = vtk.vtkPolyData()
arrowPolyData.SetPoints(points)
arrowPolyData.GetPointData().SetScalars(scalarsArray.getVTK())
arrowPolyData.GetPointData().SetVectors(vectorsArray.getVTK())
# arrow source
arrowSource = vtk.vtkArrowSource()
arrowSource.SetShaftResolution(vectorsOptions.vectorResolution)
arrowSource.SetTipResolution(vectorsOptions.vectorResolution)
if invert:
arrowSource.InvertOn()
arrowSource.Update()
# glyph mapper
arrowGlyph = vtk.vtkGlyph3DMapper()
arrowGlyph.OrientOn()
if vtk.vtkVersion.GetVTKMajorVersion() <= 5:
arrowGlyph.SetInputConnection(arrowPolyData.GetProducerPort())
else:
arrowGlyph.SetInputData(arrowPolyData)
arrowGlyph.SetSourceConnection(arrowSource.GetOutputPort())
arrowGlyph.SetScaleModeToScaleByMagnitude()
arrowGlyph.SetScaleArray("vectors")
arrowGlyph.SetScalarModeToUsePointFieldData()
arrowGlyph.SelectColorArray("colours")
arrowGlyph.SetScaleFactor(vectorsOptions.vectorScaleFactor)
arrowMapper = arrowGlyph
arrowMapper.SetLookupTable(lut)
utils.setMapperScalarRange(arrowMapper, colouringOptions, nspecies)
# actor
arrowActor = vtk.vtkActor()
arrowActor.SetMapper(arrowMapper)
# store attributes
self._actor = utils.ActorObject(arrowActor)
self._data["Points"] = pointsData
self._data["Scalars"] = scalarsArray
self._data["Vectors"] = vectorsArray
self._data["LUT"] = lut
self._data["Scale factor"] = vectorsOptions.vectorScaleFactor
示例13: addarrow
def addarrow(pos=(0,0,0),color=(1,0,0),opacity=1):
arrow = vtk.vtkArrowSource()
arrowm = vtk.vtkPolyDataMapper()
arrowm.SetInput(arrow.GetOutput())
arrowa= vtk.vtkActor()
arrowa.SetMapper(arrowm)
arrowa.GetProperty().SetColor(color)
arrowa.GetProperty().SetOpacity(opacity)
return arrowa
示例14: attach_vel
def attach_vel(self):
vel = self._vel * 1e-2
rad = self._rad
if vel is not None and rad is not None:
velMag = norm(vel, axis=1)
velMag_vtk = numpy_support.numpy_to_vtk(num_array=velMag.ravel(), deep=True, array_type=vtk.VTK_FLOAT)
velMag_vtk.SetName("veloMag")
vecVel = vtk.vtkFloatArray()
vecVel.SetNumberOfComponents(3)
for i, v in enumerate(vel):
vecVel.InsertTuple3(i, v[0], v[1], v[2])
#Put an arrow (vector) at each ball
arrow = vtk.vtkArrowSource()
arrow.SetTipRadius(rad.mean() * 10)
arrow.SetShaftRadius(rad.mean() * 10)
poly = vtk.vtkPolyData()
poly.SetPoints(self._points)
poly.GetPointData().AddArray(velMag_vtk)
poly.GetPointData().SetActiveScalars("veloMag")
arrowGlyph = vtk.vtkGlyph3D()
arrowGlyph.SetInputData(poly)
arrowGlyph.SetSourceConnection(arrow.GetOutputPort())
arrowGlyph.SetVectorModeToUseVector()
poly.GetPointData().SetVectors(vecVel)
# If we do not want the Arrow's size to depend on the Scalar
# then arrowGlyph.SetScaleModeToDataScalingOff() must be called
arrowMapper = vtk.vtkPolyDataMapper()
arrowMapper.SetInputConnection(arrowGlyph.GetOutputPort())
self._addScalarBar(velMag)
arrowMapper.SetLookupTable(self._colorTransferFunction)
arrowActor = vtk.vtkActor()
arrowActor.SetMapper(arrowMapper)
arrowActor.GetProperty().SetColor(1,1,0)
self._ren.AddActor(arrowActor)
else:
print("No particles found. Make sure the particles loaded have velocities and radii.")
示例15: renderthis
def renderthis(self):
# open a window and create a renderer
self.ren = vtk.vtkRenderer()
self.widget.GetRenderWindow().AddRenderer(self.ren)
# to generate polygonal data for a arrow.
Arrow = vtk.vtkArrowSource()
Arrow.SetShaftResolution(100)
Arrow.SetTipResolution(100)
#invert arrow so the point which is referenced is the top of the point
Arrow.InvertOn()
# take the polygonal data from the vtkArrowSource and assign to variable arrowmapper
ArrowMapper = vtk.vtkPolyDataMapper()
ArrowMapper.SetInputConnection(Arrow.GetOutputPort())
# create an actor for our scene (arrowactor)
self.ArrowActor = vtk.vtkActor()
self.ArrowActor.SetMapper(ArrowMapper)
self.ArrowActor.GetProperty().SetColor(1,1,0)
self.ArrowActor.GetProperty().SetOpacity(0.60)
self.ArrowActor.GetProperty().EdgeVisibilityOn()
self.ArrowActor.GetProperty().SetColor(0.1,0.1,0.1)
# set tip position to (0,0,0)
self.position=(0,0,0)
self.ArrowActor.SetPosition(self.position)
# get and print arrow position
self.ArrowPos = self.ArrowActor.GetPosition()
#print self.ArrowPos
# Add actor to renderer window
#self.ren.AddActor(self.ArrowActor)
# Background colour lightgrey
self.ren.SetBackground(0.9,0.9,0.9)
#create a X,Y,Z axes to show 3d position:
# create axes variable and load vtk axes actor
self.axes = vtk.vtkAxesActor()
self.marker = vtk.vtkOrientationMarkerWidget()
# set the interactor. self.widget._Iren is inbuilt python mechanism for current renderer window.
self.marker.SetInteractor(self.widget._Iren )
self.marker.SetOrientationMarker(self.axes )
# set size and position of window (Xmin,Ymin,Xmax,Ymax)
self.marker.SetViewport(0.75,0,1,0.25)
#Allow user input
self.marker.SetEnabled(1)
# #settings for renderer window
self.ren.ResetCamera()
self.ren.ResetCameraClippingRange()
self.isplotted = True
self.p=0