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


Python vtk.vtkCompositeDataPipeline函数代码示例

本文整理汇总了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;未经允许,请勿转载。