当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkSTLReader方法代码示例

本文整理汇总了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 
开发者ID:NREL,项目名称:OpenWARP,代码行数:21,代码来源:mesh.py

示例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 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:25,代码来源:visualization.py

示例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 
开发者ID:adityadua24,项目名称:robopy,代码行数:21,代码来源:serial_link.py

示例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() 
开发者ID:poodarchu,项目名称:Det3D,代码行数:16,代码来源:pointobject.py


注:本文中的vtk.vtkSTLReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。