本文整理匯總了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()