本文整理汇总了Python中vtk.vtkPointSource函数的典型用法代码示例。如果您正苦于以下问题:Python vtkPointSource函数的具体用法?Python vtkPointSource怎么用?Python vtkPointSource使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkPointSource函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_config
def load_config (self, file):
debug ("In PointStreamer::load_config ()")
self.setup_pipeline ()
val = file.readline ()
try:
self.n_pnt, self.strmln_mode, self.integration_mode = eval (val)
except ValueError: # old format
self.n_pnt, self.strmln_mode = eval (val)
# For backward compatibility - the dummy is actually unused.
dummy_seed = vtk.vtkPointSource ()
p = vtkPipeline.vtkMethodParser.VtkPickler ()
for i in (self.sphere_src, self.sphere_map, self.sphere_act,
self.sphere_act.GetProperty (),
dummy_seed, self.strmln, self.ribbonf, self.tubef,
self.stream_map, self.stream_act,
self.stream_act.GetProperty ()):
p.load (i, file)
self.setup_stream_pipeline ()
self.radius = self.sphere_src.GetRadius ()
self.cen = list (self.sphere_src.GetCenter ())
self.color_mode = self.strmln.GetSpeedScalars ()
if self.stream_map.GetScalarVisibility () == 0:
self.color_mode = -1
self.do_color_mode ()
self.update ()
self.update_integration_mode ()
示例2: __init__
def __init__(self,ext_actors=None): #ext_actors is a list of any external vtkActors.
#initializations:
self.renderer = vtk.vtkRenderer()
self.window = vtk.vtkRenderWindow()
self.window.SetSize(1000,1000)
self.mapper = vtk.vtkPolyDataMapper()
self.points = vtk.vtkPoints()
self.poly_data = vtk.vtkPolyData()
self.glyph3d = vtk.vtkGlyph3D()
self.actor = vtk.vtkActor()
self.point_s = vtk.vtkPointSource()
self.sphere = vtk.vtkSphereSource()
self.interactor= vtk.vtkRenderWindowInteractor()
self.inter_sty = PdbInteractorStyle()
self.axes_actor= vtk.vtkAxesActor()
#configurations:
self.point_s.SetNumberOfPoints(1)
self.sphere.SetRadius(1.0)
self.interactor.SetInteractorStyle(self.inter_sty)
self.interactor.SetRenderWindow(self.window)
self.axes_actor.SetTotalLength(100,100,100)
if ext_actors:
self.ex_actors = ext_actors
else:
self.ex_actors=[]
示例3: create_stream_line
def create_stream_line(self,y1,y2,y3,n,r=10):
seeds = vtk.vtkPointSource()
seeds.SetNumberOfPoints(n)
seeds.SetCenter(y1, y2, y3)
seeds.SetRadius(r)
seeds.SetDistributionToShell()
integ = vtk.vtkRungeKutta4()
streamline = vtk.vtkStreamLine()
streamline.SetInputConnection(self.vec_reader.GetOutputPort())
streamline.SetSourceConnection(seeds.GetOutputPort())
streamline.SetMaximumPropagationTime(220)
streamline.SetIntegrationStepLength(0.05)
streamline.SetStepLength(0.5)
streamline.SpeedScalarsOn()
streamline.SetNumberOfThreads(1)
streamline.SetIntegrationDirectionToIntegrateBothDirections()
streamline.SetIntegrator(integ)
streamline.SetSpeedScalars(220);
streamlineMapper = vtk.vtkPolyDataMapper()
streamlineMapper.SetInputConnection(streamline.GetOutputPort())
streamlineMapper.SetLookupTable(self.arrowColor)
streamline_actor = vtk.vtkActor()
streamline_actor.SetMapper(streamlineMapper)
streamline_actor.VisibilityOn()
return streamline_actor
示例4: __init__
def __init__(self, parent = None):
super(VTKFrame, self).__init__(parent)
self.vtkWidget = QVTKRenderWindowInteractor(self)
vl = QtGui.QVBoxLayout(self)
vl.addWidget(self.vtkWidget)
vl.setContentsMargins(0, 0, 0, 0)
self.ren = vtk.vtkRenderer()
self.ren.SetBackground(0.1, 0.2, 0.4)
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
# Create source
source = vtk.vtkPointSource()
source.SetCenter(0, 0, 0)
source.SetNumberOfPoints(50)
source.SetRadius(5.0)
source.Update()
# Create a mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())
# Create an actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
self.ren.ResetCamera()
self._initialized = False
示例5: pointsource
def pointsource(center=[0, 0, 0], radius=1.0, numberofpoints=100):
"""Create a random cloud of points"""
points = vtk.vtkPointSource()
points.SetNumberOfPoints(numberofpoints)
points.SetCenter(center)
points.SetRadius(radius)
points.Update()
return points.GetOutput()
示例6: __init__
def __init__(self, center=(0,0,0), color=(1,2,3) ):
""" create point """
self.src = vtk.vtkPointSource()
self.src.SetCenter(center)
self.src.SetRadius(0)
self.src.SetNumberOfPoints(1)
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInput(self.src.GetOutput())
self.SetMapper(self.mapper)
self.SetColor(color)
示例7: save_config
def save_config (self, file):
debug ("In PointStreamer::save_config ()")
file.write ("%d, %d, %d\n"%(self.n_pnt, self.strmln_mode,
self.integration_mode))
# For backward compatibility - the dummy is actually unused.
dummy_seed = vtk.vtkPointSource ()
p = vtkPipeline.vtkMethodParser.VtkPickler ()
for i in (self.sphere_src, self.sphere_map, self.sphere_act,
self.sphere_act.GetProperty (),
dummy_seed, self.strmln, self.ribbonf, self.tubef,
self.stream_map, self.stream_act,
self.stream_act.GetProperty ()):
p.dump (i, file)
示例8: main
def main():
pointSource = vtk.vtkPointSource()
pointSource.SetNumberOfPoints(20)
pointSource.Update()
idFilter = vtk.vtkIdFilter()
idFilter.SetInputConnection(pointSource.GetOutputPort())
idFilter.SetIdsArrayName("OriginalIds")
idFilter.Update()
surfaceFilter = vtk.vtkDataSetSurfaceFilter()
surfaceFilter.SetInputConnection(idFilter.GetOutputPort())
surfaceFilter.Update()
poly_input = surfaceFilter.GetOutput()
# Create a mapper and actor
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInputConnection(poly_input.GetProducerPort())
else:
mapper.SetInputData(poly_input)
mapper.ScalarVisibilityOff()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Visualize
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
areaPicker = vtk.vtkAreaPicker()
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetPicker(areaPicker)
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.AddActor(actor)
#renderer.SetBackground(1,1,1) # Background color white
renderWindow.Render()
style = vtk.vtkRenderWindowInteractor()
#style = myInteractorStyle()
#style = InteractorStyle()
#style = QVTKRenderWindowInteractor()
#style.SetPoints(poly_input)
renderWindowInteractor.SetInteractorStyle(style)
renderWindowInteractor.Start()
示例9: getpsactor
def getpsactor(ps): # ps 是点云映射到Grid的空间坐标
# create source
"""
# vtkPointSource用来创建围绕特定中心点,特定直径的和特定数量点集合组成的球体。
# 默认点是随机分布在球体里面。也可以生产的点只分布在球面上。
# 基本用法:
# SetRadius()设置球体半径
# SetCenter()设置球体中心点
# SetNumberOfPoints()设置球中的点的个数
# SetDistributionToUniform()设置点的分布在球体内
# SetDistributionToShell()设置点分布在球面上。
"""
src = vtk.vtkPointSource()
src.SetCenter(0, 0, 0) # 设置圆心
src.SetNumberOfPoints(50) # 设置点的个数
src.SetRadius(5) # 设置半径
src.Update() # ???????
# ps = [[1,1,1],[2,2,2]]
# print src.GetOutput()
points = vtk.vtkPoints()
vertices = vtk.vtkCellArray() # 创建一个cell对象
for p in ps:
# Create the topology of the point (a vertex)
id = points.InsertNextPoint(p)
vertices.InsertNextCell(1) # 将cell的容量增加1
vertices.InsertCellPoint(id) # 将 id所指的点插入cell
# Create a polydata object # polydata : 多边形数据
point = vtk.vtkPolyData()
# vertex : 顶点 topology:拓扑
# Set the points and vertices we created as the geometry and topology of the polydata
point.SetPoints(points)
point.SetVerts(vertices)
# mapper
# mapper = vtk.vtkPolyDataMapper()
# Visualize
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(point)
else:
mapper.SetInputData(point)
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# actor.GetProperty().SetPointSize(2)
# assign actor to the renderer
return actor
示例10: __init__
def __init__(self, parent = None):
super(VTKFrame, self).__init__(parent)
self.vtkWidget = QVTKRenderWindowInteractor(self)
vl = QtGui.QVBoxLayout(self)
vl.addWidget(self.vtkWidget)
vl.setContentsMargins(0, 0, 0, 0)
self.ren = vtk.vtkRenderer()
self.ren.SetBackground(0.1, 0.2, 0.4)
self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
# Create source
pointSource = vtk.vtkPointSource()
pointSource.SetNumberOfPoints(5)
pointSource.Update()
points = pointSource.GetOutput().GetPoints()
xSpline = vtk.vtkKochanekSpline()
ySpline = vtk.vtkKochanekSpline()
zSpline = vtk.vtkKochanekSpline()
spline = vtk.vtkParametricSpline()
spline.SetXSpline(xSpline)
spline.SetYSpline(ySpline)
spline.SetZSpline(zSpline)
spline.SetPoints(points)
functionSource = vtk.vtkParametricFunctionSource()
functionSource.SetParametricFunction(spline)
functionSource.Update()
# Create a mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(functionSource.GetOutputPort())
# Create an actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
self.ren.AddActor(actor)
self.ren.ResetCamera()
self._initialized = False
示例11: initialize
def initialize (self, valid_coord):
""" Initializes the seed given an array of valid co-ordinate
directions. [x-axis, y-axis, z_axis] is the format. For
instance if x-axis == 0 then the data is along the YZ plane.
This method is responsible for actually creating the seed. """
debug ("In SeedManager::initialize ()")
assert len (valid_coord) == 3
self.dim = reduce (lambda x, y: x+y, valid_coord)
if self.dim == 3:
self.seed = vtk.vtkPointSource ()
else:
self.seed = vtk.vtkDiskSource ()
self.seed.SetRadialResolution (1)
self.seed.SetInnerRadius (0.0)
self.transform = vtk.vtkTransformFilter ()
self.transform.SetTransform (vtk.vtkTransform ())
self.transform.SetInput (self.seed.GetOutput ())
self.orient_2d (valid_coord)
示例12: create_stream_line
def create_stream_line(self,y1,y2,y3,n,r=10,tr=2):
seeds = vtk.vtkPointSource()
seeds.SetNumberOfPoints(n)
seeds.SetCenter(y1, y2, y3)
seeds.SetRadius(r)
seeds.SetDistributionToShell()
integ = vtk.vtkRungeKutta4()
streamline = vtk.vtkStreamLine()
streamline.SetInputConnection(self.vec_reader.GetOutputPort())
streamline.SetSourceConnection(seeds.GetOutputPort())
streamline.SetMaximumPropagationTime(220)
streamline.SetIntegrationStepLength(0.05)
streamline.SetStepLength(0.5)
streamline.SpeedScalarsOn()
streamline.SetNumberOfThreads(1)
streamline.SetIntegrationDirectionToIntegrateBothDirections()
streamline.SetIntegrator(integ)
streamline.SetSpeedScalars(220);
streamline_mapper = vtk.vtkPolyDataMapper()
streamline_mapper.SetInputConnection(streamline.GetOutputPort())
streamTube = vtk.vtkTubeFilter()
streamTube.SetInputConnection(streamline.GetOutputPort())
streamTube.SetRadius(tr)
streamTube.SetNumberOfSides(12)
streamTube.SetVaryRadiusToVaryRadiusByVector()
mapStreamTube = vtk.vtkPolyDataMapper()
mapStreamTube.SetInputConnection(streamTube.GetOutputPort())
mapStreamTube.SetLookupTable(self.arrowColor)
streamTubeActor = vtk.vtkActor()
streamTubeActor.SetMapper(mapStreamTube)
streamTubeActor.GetProperty().BackfaceCullingOn()
return streamTubeActor
示例13: getpsactor
def getpsactor(ps):
# create source
src = vtk.vtkPointSource()
src.SetCenter(0, 0, 0)
src.SetNumberOfPoints(50)
src.SetRadius(5)
src.Update()
# ps = [[1,1,1],[2,2,2]]
# print src.GetOutput()
points = vtk.vtkPoints()
vertices = vtk.vtkCellArray()
for p in ps:
# Create the topology of the point (a vertex)
if len(p) == 2:
p = [p[0], p[1], 0]
id = points.InsertNextPoint(p)
vertices.InsertNextCell(1)
vertices.InsertCellPoint(id)
# Create a polydata object
point = vtk.vtkPolyData()
# Set the points and vertices we created as the geometry and topology of the polydata
point.SetPoints(points)
point.SetVerts(vertices)
# mapper
# mapper = vtk.vtkPolyDataMapper()
# Visualize
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(point)
else:
mapper.SetInputData(point)
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# actor.GetProperty().SetPointSize(2)
# assign actor to the renderer
return actor
示例14: make_stream_actors
def make_stream_actors(position, color):
"""Create a stream and use two mappers. One to represent velocity with
the default colour, and the other to change the colour.
"""
seed = vtk.vtkPointSource()
seed.SetRadius(15)
seed.SetNumberOfPoints(100)
seed.SetCenter(*position)
stream_tracer = vtk.vtkStreamTracer()
stream_tracer.SetInputConnection(mixer.GetOutputPort())
stream_tracer.SetMaximumPropagation(500)
stream_tracer.SetIntegrator(vtk.vtkRungeKutta45())
stream_tracer.SetIntegrationDirectionToBoth()
stream_tracer.SetTerminalSpeed(0.0001)
stream_tracer.SetSource(seed.GetOutput())
stream_tube = vtk.vtkTubeFilter()
stream_tube.SetInputConnection(stream_tracer.GetOutputPort())
stream_tube.SetRadius(.2)
stream_tube.SetNumberOfSides(12)
# Solid transparent colour
stream_mapper1 = vtk.vtkPolyDataMapper()
stream_mapper1.SetInputConnection(stream_tube.GetOutputPort())
stream_mapper1.ScalarVisibilityOff()
stream_actor1 = vtk.vtkActor()
stream_actor1.GetProperty().SetColor(*color)
stream_actor1.SetMapper(stream_mapper1)
stream_actor1.GetProperty().SetOpacity(0.4)
# opaque velocity colour
stream_mapper2 = vtk.vtkPolyDataMapper()
stream_mapper2.SetInputConnection(stream_tube.GetOutputPort())
stream_actor2 = vtk.vtkActor()
stream_actor2.SetMapper(stream_mapper2)
stream_actor2.GetProperty().SetOpacity(1.)
return [stream_actor1, stream_actor2]
示例15:
import vtk
points = vtk.vtkPointSource()
points.SetCenter(0.0, 0.0, 0.0)
points.SetNumberOfPoints(500)
points.SetRadius(50.0)
m = vtk.vtkPolyDataMapper()
m.SetInput(points.GetOutput())
a = vtk.vtkActor()
a.SetMapper(m)
r = vtk.vtkRenderer()
r.AddActor(a)
w = vtk.vtkRenderWindow()
w.AddRenderer(r)
i = vtk.vtkRenderWindowInteractor()
i.SetRenderWindow(w)
i.Initialize()
i.Start()