• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkCompositeDataPipeline函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vtk.vtkCompositeDataPipeline函数的典型用法代码示例。如果您正苦于以下问题:Python vtkCompositeDataPipeline函数的具体用法?Python vtkCompositeDataPipeline怎么用?Python vtkCompositeDataPipeline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了vtkCompositeDataPipeline函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: vtkGetDataRoot

#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

# create a rendering window and renderer
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.StereoCapableWindowOn()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
reader = vtk.vtkGenericEnSightReader()
# Make sure all algorithms use the composite data pipeline
cdp = vtk.vtkCompositeDataPipeline()
reader.SetDefaultExecutivePrototype(cdp)
reader.SetCaseFileName("" + str(VTK_DATA_ROOT) + "/Data/EnSight/blow2_bin.case")
reader.SetTimeValue(1)
geom = vtk.vtkGeometryFilter()
geom.SetInputConnection(reader.GetOutputPort())
mapper = vtk.vtkHierarchicalPolyDataMapper()
mapper.SetInputConnection(geom.GetOutputPort())
mapper.SetColorModeToMapScalars()
mapper.SetScalarModeToUsePointFieldData()
mapper.ColorByArrayComponent("displacement",0)
mapper.SetScalarRange(0,2.08)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# assign our actor to the renderer
ren1.AddActor(actor)
# enable user interface interactor
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:EnSightBlow2Bin.py


示例2: setFileName

    def setFileName(self, file_name, lut):

        try:
            self.currently_has_actor = True
            self.lut = lut

            self.file_name = file_name
            self.reader = vtk.vtkExodusIIReader()
            self.reader.SetFileName(self.file_name)
            self.reader.UpdateInformation()

            self.current_dim = self.reader.GetDimensionality()

            self.min_timestep = 0
            self.max_timestep = 0
            range = self.reader.GetTimeStepRange()
            self.min_timestep = range[0]
            self.max_timestep = range[1]

            self.reader.SetAllArrayStatus(vtk.vtkExodusIIReader.ELEM_BLOCK, 1)
            self.reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL, 1)
            self.reader.SetAllArrayStatus(vtk.vtkExodusIIReader.NODAL_TEMPORAL, 1)
            self.reader.SetTimeStep(self.max_timestep)
            self.reader.Update()
            self.current_variable_point_data = {}
            self.current_nodal_variables = []
            self.current_elemental_variables = []
            self.current_nodal_components = {}
            self.current_elemental_components = {}
            self.component_index = -1

            num_blocks = self.reader.GetNumberOfElementBlockArrays()
            self.blocks = set()
            self.block_to_name = {}
            for i in xrange(num_blocks):
                block_num = self.reader.GetObjectId(vtk.vtkExodusIIReader.ELEM_BLOCK,i)
                self.blocks.add(block_num)
                if 'Unnamed' not in self.reader.GetObjectName(vtk.vtkExodusIIReader.ELEM_BLOCK,i).split(' '):
                    self.block_to_name[block_num] = self.reader.GetObjectName(vtk.vtkExodusIIReader.ELEM_BLOCK,i).split(' ')[0]

            cdp = vtk.vtkCompositeDataPipeline()
            vtk.vtkAlgorithm.SetDefaultExecutivePrototype(cdp)

            self.output = self.reader.GetOutput()
            self.geom = vtk.vtkCompositeDataGeometryFilter()
            self.geom.SetInputConnection(0,self.reader.GetOutputPort(0))
            self.geom.Update()

            self.data = self.geom.GetOutput()

            num_nodal_variables = self.data.GetPointData().GetNumberOfArrays()
            for var_num in xrange(num_nodal_variables):
                var_name = self.data.GetPointData().GetArrayName(var_num)
                self.current_nodal_variables.append(var_name)
                components = self.data.GetPointData().GetVectors(var_name).GetNumberOfComponents()
                self.current_nodal_components[var_name] = components
                # self.data.GetPointData().GetVectors(value_string).GetComponentName(0)

            num_elemental_variables = self.data.GetCellData().GetNumberOfArrays()
            for var_num in xrange(num_elemental_variables):
                var_name = self.data.GetCellData().GetArrayName(var_num)
                self.current_elemental_variables.append(var_name)
                components = self.data.GetCellData().GetVectors(var_name).GetNumberOfComponents()
                self.current_elemental_components[var_name] = components

            self.application_filter = self.render_widget.application.filterResult(self.geom)

            self.mapper = vtk.vtkPolyDataMapper()
    #    self.mapper.SetInputConnection(self.tf.GetOutputPort())
            self.mapper.SetInputConnection(self.application_filter.GetOutputPort())
            self.mapper.ScalarVisibilityOn()
            self.mapper.SetLookupTable(lut)
            self.mapper.SetColorModeToMapScalars()
            self.mapper.InterpolateScalarsBeforeMappingOn()

            self.actor = vtk.vtkActor()
            self.current_actors.append(self.actor)
            self.actor.SetMapper(self.mapper)
            self.current_actor = self.actor

            self.clipper = vtk.vtkTableBasedClipDataSet()
            if vtk.VTK_MAJOR_VERSION <= 5:
                self.clipper.SetInput(self.output)
            else:
                self.clipper.SetInputData(self.output)
            self.clipper.SetClipFunction(self.plane)
            self.clipper.Update()

            self.clip_geom = vtk.vtkCompositeDataGeometryFilter()
            self.clip_geom.SetInputConnection(0,self.clipper.GetOutputPort(0))
            self.clip_geom.Update()

            self.clip_data = self.clip_geom.GetOutput()

            self.clip_application_filter = self.render_widget.application.filterResult(self.clip_geom)

            self.clip_mapper = vtk.vtkPolyDataMapper()
            self.clip_mapper.SetInputConnection(self.clip_application_filter.GetOutputPort())
            self.clip_mapper.ScalarVisibilityOn()
            self.clip_mapper.SetLookupTable(lut)
#.........这里部分代码省略.........
开发者ID:aeslaughter,项目名称:moose,代码行数:101,代码来源:ExodusResult.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkConeSource函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkColorTransferFunction函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap