本文整理汇总了Python中vtk.vtkPolyDataMapper方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkPolyDataMapper方法的具体用法?Python vtk.vtkPolyDataMapper怎么用?Python vtk.vtkPolyDataMapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkPolyDataMapper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __getattr__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __getattr__(self, name):
""" Forwards unknown attribute requests to vtk object.
Examples
--------
>>> import vtk
>>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper
>>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper())
>>> m1.GetArrayId() # same as self.VTKObject.GetArrayId()
-1
>>> self.arrayId # same as self.VTKObject.GetArrayId()
-1
"""
# We are here cause name is not in self
# First forward to vtkobject
# If it doesn't exist, look for it in vtk_map, find its corresponding
# vtk name and forward again
try:
return VTKMethodWrapper(super().__getattr__(name))
except:
return self._handle_call('get', name, None)
示例2: __setattr__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __setattr__(self, name, value):
""" Forwards unknown set requests to vtk object.
Examples
--------
>>> import vtk
>>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper
>>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper())
>>> m1.GetArrayId()
-1
>>> self.arrayId = 3 # same as self.VTKObject.SetArrayId(3)
>>> m1.GetArrayId()
3
"""
# Check self attributes first
# Note: With this we cannot create attributes dynamically
if name in self.__dict__:
VTKMethodWrapper(super().__setattr__(name, value))
else:
self._handle_call('set', name, value)
示例3: stl2actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def stl2actor(ageometry_path, ageometry_name, ageometry_color):
appendfilter = vtk.vtkAppendPolyData()
render_lib = vtk.vtkSTLReader()
polydata = vtk.vtkPolyData()
render_lib.SetFileName(os.path.join(ageometry_path, ageometry_name+".stl"))
render_lib.Update()
polydata.ShallowCopy(render_lib.GetOutput())
appendfilter.AddInputConnection(polydata.GetProducerPort())
appendfilter.Update()
# Remove any duplicate points.
cleanfilter = vtk.vtkCleanPolyData()
cleanfilter.SetInputConnection(appendfilter.GetOutputPort())
cleanfilter.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(cleanfilter.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(ageometry_color)
return actor, polydata
示例4: points2actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def points2actor(xyz, apoint_size):
import vtk
points = vtk.vtkPoints()
# Create the topology of the point (a vertex)
vertices = vtk.vtkCellArray()
# Add points
for i in range(0, len(xyz)):
p = xyz.loc[i].values.tolist()
point_id = points.InsertNextPoint(p)
vertices.InsertNextCell(1)
vertices.InsertCellPoint(point_id)
# Create a poly data object
polydata = vtk.vtkPolyData()
# Set the points and vertices we created as the geometry and topology of the polydata
polydata.SetPoints(points)
polydata.SetVerts(vertices)
polydata.Modified()
# Mapper for points
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(polydata)
# ACTOR for points
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetPointSize(apoint_size)
return actor, polydata
示例5: face_points2actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def face_points2actor(fps_df):
cell_array = vtk.vtkCellArray()
points = vtk.vtkPoints()
point_id = 0
for i in range(fps_df.shape[0]):
polygon = vtk.vtkPolygon()
polygon.GetPointIds().SetNumberOfIds(3)
for n in range(3):
points.InsertNextPoint(fps_df.ix[i, 0+3*n], fps_df.ix[i, 1+3*n], fps_df.ix[i, 2+3*n])
polygon.GetPointIds().SetId(n, point_id)
point_id += 1
cell_array.InsertNextCell(polygon)
polydata = vtk.vtkPolyData()
polydata.SetPoints(points)
polydata.SetPolys(cell_array)
# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(polydata)
# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
return actor, polydata
示例6: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6):
"""
Initialize class
:param zMin: minimum depth
:param zMax: maximum depth
:param maxNumPoints: maximum number of points
:return: None
"""
self.maxNumPoints = int(maxNumPoints)
self.vtkPolyData = vtk.vtkPolyData()
self.clearPoints()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(self.vtkPolyData)
mapper.SetColorModeToDefault()
mapper.SetScalarRange(zMin, zMax)
mapper.SetScalarVisibility(1)
self.vtkActor = vtk.vtkActor()
self.vtkActor.SetMapper(mapper)
示例7: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __init__(self, pts=None, zMin=-10.0, zMax=10.0, maxNumPoints=1e6, color='depth'):
"""
Initialize class
:param zMin: minimum depth
:param zMax: maximum depth
:param maxNumPoints: maximum number of points
:return: None
"""
self.color = color
self.maxNumPoints = int(maxNumPoints)
self.vtkPolyData = vtk.vtkPolyData()
self.clearPoints()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(self.vtkPolyData)
mapper.SetColorModeToDefault()
mapper.SetScalarRange(zMin, zMax)
mapper.SetScalarVisibility(1)
self.vtkActor = vtk.vtkActor()
self.vtkActor.SetMapper(mapper)
self.vtkActor.GetProperty().SetPointSize(3.0)
self.rng = numpy.random.RandomState(23455)
if pts is not None:
self.addPoints(pts)
示例8: __setup_pipeline_objs
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __setup_pipeline_objs(self):
"""
Internal function to initialise vtk objects.
:return: reader_list, actor_list, mapper_list
"""
reader_list = [0] * len(self.stl_files)
actor_list = [0] * len(self.stl_files)
mapper_list = [0] * len(self.stl_files)
for i in range(len(self.stl_files)):
reader_list[i] = vtk.vtkSTLReader()
loc = pkg_resources.resource_filename("robopy", '/'.join(('media', self.name, self.stl_files[i])))
reader_list[i].SetFileName(loc)
mapper_list[i] = vtk.vtkPolyDataMapper()
mapper_list[i].SetInputConnection(reader_list[i].GetOutputPort())
actor_list[i] = vtk.vtkActor()
actor_list[i].SetMapper(mapper_list[i])
actor_list[i].GetProperty().SetColor(self.colors[i]) # (R,G,B)
return reader_list, actor_list, mapper_list
示例9: s_highlightPoint
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def s_highlightPoint(self, grid, index):
if self.actorpt is not None:
self._vtkren.RemoveActor(self.actorpt)
if grid is None:
return
(i, j, k) = index
filter = vtk.vtkStructuredGridGeometryFilter()
if VTK_VERSION_MAJOR < 8:
raise RuntimeError("VTK version is too old, please upgrade")
filter.SetInputData(grid)
filter.SetExtent(i - 1, i - 1, j - 1, j - 1, k - 1, k - 1)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(filter.GetOutputPort())
self.actorpt = vtk.vtkActor()
self.actorpt.SetMapper(mapper)
self.actorpt.GetProperty().SetColor(0, 1, 0)
self.actorpt.GetProperty().SetPointSize(6)
self.actorpt.PickableOff()
self.actorpt.DragableOff()
self._vtkren.AddActor(self.actorpt)
self._iren.Render()
示例10: create_pointcloud_actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def create_pointcloud_actor(points, colors=None):
"""Creates a vtkActor with the point cloud from numpy arrays
points: numpy.ndarray
pointcloud with shape (n,3)
colors: numpy.ndarray
uint8 array with colors for each point. shape is (n,3)
Returns vtkActor object
"""
import vtk
vpoly = create_pointcloud_polydata(points, colors)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(vpoly)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetPointSize(3)
return actor
示例11: create_pointcloud_actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def create_pointcloud_actor(points, colors=None):
"""Creates a vtkActor with the point cloud from numpy arrays
points: numpy.ndarray
pointcloud with shape (n,3)
colors: numpy.ndarray
uint8 array with colors for each point. shape is (n,3)
Returns vtkActor object
"""
vpoly = create_pointcloud_polydata(points, colors)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(vpoly)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetPointSize(5)
return actor
示例12: make_render_window
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def make_render_window():
#cone actor
cone = vtk.vtkConeSource()
coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection(cone.GetOutputPort())
coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)
#text actor following camera
text = vtk.vtkVectorText()
text.SetText("Origin")
textMapper = vtk.vtkPolyDataMapper()
textMapper.SetInputConnection(text.GetOutputPort())
textActor = vtk.vtkFollower()
textActor.SetMapper(textMapper)
ren = vtk.vtkRenderer()
ren.AddActor(coneActor)
ren.AddActor(textActor)
textActor.SetCamera(ren.GetActiveCamera())
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
return renWin
示例13: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def __init__(self, zMin=-10.0, zMax=10.0, maxNumPoints=1e6):
"""
Initialize class
:param zMin: minimum depth
:param zMax: maximum depth
:param maxNumPoints: maximum number of points
:return: None
"""
self.maxNumPoints = int(maxNumPoints)
self.vtkPolyData = vtk.vtkPolyData()
self.clearPoints()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(self.vtkPolyData)
mapper.SetColorModeToDefault()
mapper.SetScalarRange(zMin, zMax)
mapper.SetScalarVisibility(1)
self.vtkActor = vtk.vtkActor()
self.vtkActor.SetMapper(mapper)
self.vtkActor.GetProperty().SetPointSize(3.0)
self.rng = numpy.random.RandomState(23455)
示例14: tessellate
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def tessellate(self, f, tessagon_class, **kwargs):
extra_args = {'function': f,
'adaptor_class': VtkAdaptor}
tessagon = tessagon_class(**{**kwargs, **extra_args})
poly_data = tessagon.create_mesh()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(poly_data)
mapper.SetLookupTable(self.lut)
mapper.SetScalarRange(poly_data.GetScalarRange())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(tomato)
actor.GetProperty().SetEdgeColor(0.0, 0.0, 0.0)
actor.GetProperty().EdgeVisibilityOn()
actor.SetPosition(kwargs['position'])
self.ren.AddActor(actor)
示例15: create_camera_actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkPolyDataMapper [as 别名]
def create_camera_actor(R, t, color=(1.0, 0.0, 0.0), camera_obj_scale=0.25):
"""Creates a vtkActor object with a camera mesh"""
import vtk
vpoly = create_camera_polydata(R, t, only_polys=False, scale=camera_obj_scale)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(vpoly)
color = (int(255.0*color[0]), int(255.0*color[1]), int(255.0*color[2]))
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().LightingOff()
actor.GetProperty().SetLineWidth(2)
actor.GetProperty().SetColor(color[0], color[1], color[2])
return actor