本文整理汇总了Python中vtk.vtkSTLReader方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkSTLReader方法的具体用法?Python vtk.vtkSTLReader怎么用?Python vtk.vtkSTLReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkSTLReader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read_stl
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSTLReader [as 别名]
def _read_stl(file_name):
'''Internal function to read stl mesh files
'''
reader = vtk.vtkSTLReader()
reader.SetFileName(file_name)
reader.Update()
mesh_data = PanelMesh(file_name)
mesh_data.orig_type = 'Stereolithography (.stl)'
mesh_data.num_faces = int(reader.GetOutput().GetNumberOfCells())
mesh_data.num_points = mesh_data.num_faces * 3
for i in range(mesh_data.num_faces):
n = i*3
mesh_data.faces.append(np.array([n,n+1,n+2,n+2]))
mesh_data.points.append(np.array(vtk_to_numpy(reader.GetOutput().GetCell(i).GetPoints().GetData())))
mesh_data.points = np.array(mesh_data.points).reshape([mesh_data.num_faces*3,3])
return mesh_data
示例2: stl2actor
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSTLReader [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
示例3: __setup_pipeline_objs
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSTLReader [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
示例4: CreateFromSTL
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkSTLReader [as 别名]
def CreateFromSTL(self, filename):
"Create a visualization object from a given STL file"
if not filename.lower().endswith(".stl"):
raise Exception("Not an STL file")
reader = vtk.vtkSTLReader()
reader.SetFileName(filename)
reader.Update()
self.pd = vtk.vtkPolyData()
self.pd.DeepCopy(reader.GetOutput())
self.SetupPipelineMesh()