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

Python common.is_old_pipeline函数代码示例

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

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



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

示例1: render

 def render(self):
     """Invokes render on the scene, this in turn invokes Render on
     the VTK pipeline.
     """
     s = self.scene
     if s is not None:
         s.render()
     elif self.running:
         # If there is no scene and we are running, we flush the
         # pipeline manually by calling update.
         for actor in self.actors:
             if hasattr(actor, 'mapper'):
                 m = actor.mapper
                 if m is not None:
                     if tvtk_common.is_old_pipeline():
                         m.update()
                     else:
                         m.update(0)
         if tvtk_common.is_old_pipeline():
             for widget in self.widgets:
                 if hasattr(widget, 'input'):
                     input = widget.input
                     if input is not None:
                         input.update()
     if hasattr(self, 'components'):
         for component in self.components:
                 component.render()
开发者ID:bergtholdt,项目名称:mayavi,代码行数:27,代码来源:pipeline_base.py


示例2: surf_fill2

        def surf_fill2(vertices, polys, mat, shape):
            from tvtk.common import is_old_pipeline
            voxverts = nibabel.affines.apply_affine(numpy.linalg.inv(mat), vertices)

            pd = tvtk.PolyData(points=voxverts, polys=polys)

            if is_old_pipeline():
                whiteimg = tvtk.ImageData(dimensions = shape, scalar_type = 'unsigned_char')
            else:
                whiteimg = tvtk.ImageData(dimensions = shape)
            whiteimg.point_data.scalars = numpy.ones(numpy.prod(shape), dtype=numpy.uint8)

            pdtis = tvtk.PolyDataToImageStencil()
            if is_old_pipeline():
                pdtis.input = pd
            else:
                pdtis.set_input_data(pd)
                                                                             
            pdtis.output_whole_extent = whiteimg.extent
            pdtis.update()

            imgstenc = tvtk.ImageStencil()
            if is_old_pipeline():
                imgstenc.input = whiteimg
                imgstenc.stencil = pdtis.output
            else:
                imgstenc.set_input_data(whiteimg)
            imgstenc.set_stencil_data(pdtis.output)
            imgstenc.background_value = 0
            imgstenc.update()

            data = imgstenc.output.point_data.scalars.to_array().reshape(shape[::-1]).transpose(2,1,0)
            return data
开发者ID:inej,项目名称:toad,代码行数:33,代码来源:02-parcellation.py


示例3: setUp

    def setUp(self):

        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        # e = Engine()
        e.start()
        s = e.new_scene()

        image_data = BuiltinImage()
        e.add_source(image_data)

        outline = Outline()
        e.add_module(outline)

        surface = Surface()
        e.add_module(surface)

        image_data.data_source.radius = array([80.0, 80.0, 80.0])
        image_data.data_source.center = array([150.0, 150.0, 0.0])
        image_data.data_source.whole_extent = array([10, 245, 10, 245, 0, 0])
        if is_old_pipeline():
            image_data.data_source.update_whole_extent()
        else:
            image_data.data_source.set_update_extent_to_whole_extent()

        self.e = e
        self.scene = e.current_scene

        return
开发者ID:B-Rich,项目名称:mayavi,代码行数:29,代码来源:test_builtin_image.py


示例4: __deepcopy__

 def __deepcopy__(self, memo):
     """Method used by copy.deepcopy().  This also uses the
     state_pickler to work correctly.
     """
     # Create a new instance.
     new = self.__class__()
     # If we have a saved state, use it for the new instance.  If
     # not, get our state and save that.
     saved_state = self._saved_state
     if len(saved_state) == 0:
         state = state_pickler.get_state(self)
         # FIXME: This is for streamline seed point widget position which
         # does not get serialized correctly
         if not is_old_pipeline():
             try:
                 st = state.children[0].children[4]
                 l_pos = st.seed.widget.position
                 st.seed.widget.position = [pos.item() for pos in l_pos]
             except (IndexError, AttributeError):
                 pass
         saved_state = cPickle.dumps(state)
     new._saved_state = saved_state
     # In the unlikely case that a new instance is running, load
     # the saved state.
     if new.running:
         new._load_saved_state()
     return new
开发者ID:B-Rich,项目名称:mayavi,代码行数:27,代码来源:base.py


示例5: _set_data_name

    def _set_data_name(self, data_type, attr_type, value):
        if value is None:
            return

        dataset = self.data
        if len(value) == 0:
            # If the value is empty then we deactivate that attribute.
            d = getattr(dataset, attr_type + '_data')
            method = getattr(d, 'set_active_%s'%data_type)
            method(None)
            self.data_changed = True
            return

        aa = self._assign_attribute
        data = None
        if attr_type == 'point':
            data = dataset.point_data
        elif attr_type == 'cell':
            data = dataset.cell_data
        method = getattr(data, 'set_active_%s'%data_type)
        method(value)
        aa.assign(value, data_type.upper(), attr_type.upper() +'_DATA')
        if data_type == 'scalars' and dataset.is_a('vtkImageData'):
            # Set the scalar_type for image data, if not you can either
            # get garbage rendered or worse.
            s = getattr(dataset, attr_type + '_data').scalars
            r = s.range
            if is_old_pipeline():
                dataset.scalar_type = s.data_type
                aa.output.scalar_type = s.data_type
        aa.update()
        # Fire an event, so the changes propagate.
        self.data_changed = True
开发者ID:dmsurti,项目名称:mayavi,代码行数:33,代码来源:vtk_data_source.py


示例6: _update_probe

 def _update_probe(self):
     pd = self.probe_data
     dims = self.dimensions
     spacing = self.spacing
     extent = (0, dims[0] -1, 0, dims[1] -1, 0, dims[2] -1)
     if tvtk_common.is_old_pipeline():
         pd.set(extent=extent,
                update_extent=extent,
                whole_extent=extent,
                dimensions=dims,
                spacing=spacing)
     else:
         pd.set(extent=extent,
                dimensions=dims,
                spacing=spacing)
     pd.modified()
     fil = self.filter
     w = fil.global_warning_display
     fil.global_warning_display = False
     fil.remove_all_inputs()
     self.configure_input_data(fil, pd)
     fil.update_whole_extent()
     fil.update()
     self._rescale_scalars_changed(self.rescale_scalars)
     fil.global_warning_display = w
     self.data_changed = True
开发者ID:PerryZh,项目名称:mayavi,代码行数:26,代码来源:image_data_probe.py


示例7: save_visualization

 def save_visualization(self, file_or_fname):
     """Given a file or a file name, this saves the current
     visualization to the file.
     """
     # Save the state of VTK's global warning display.
     o = vtk.vtkObject
     w = o.GetGlobalWarningDisplay()
     o.SetGlobalWarningDisplay(0) # Turn it off.
     try:
         #FIXME: This is for streamline seed point widget position which
         #does not get serialized correctly
         if is_old_pipeline():
             state_pickler.dump(self, file_or_fname)
         else:
             state = state_pickler.get_state(self)
             st = state.scenes[0].children[0].children[0].children[4]
             l_pos = st.seed.widget.position
             st.seed.widget.position = [pos.item() for pos in l_pos]
             saved_state = state_pickler.dumps(state)
             file_or_fname.write(saved_state)
     except (IndexError, AttributeError):
         state_pickler.dump(self, file_or_fname)
     finally:
         # Reset the warning state.
         o.SetGlobalWarningDisplay(w)
开发者ID:PerryZh,项目名称:mayavi,代码行数:25,代码来源:engine.py


示例8: test_ipw

    def test_ipw(self):
        """Test the image plane widget."""
        arr1, arr2, arr3 = self.first, self.second, self.third
        ipw = self.ipw.ipw
        
        scalars = ipw.input.point_data.scalars

        r = scalars.range
        expect = min(arr1), max(arr1)
        self.assertEqual(r, expect)
        o = self.src.outputs[0]
        o.update_traits()
        if is_old_pipeline():
            st = ipw.input.scalar_type
        else:
            st = ipw.input.scalar_type_as_string
        self.assertEqual(scalars.data_type, 10)
        self.assertEqual(st, 'float')

        self.src.point_scalars_name = 'second'
        scalars = ipw.input.point_data.scalars
        r = scalars.range
        expect = min(arr2), max(arr2)
        self.assertEqual(r, expect)
        o.update_traits()
        if is_old_pipeline():
            st = ipw.input.scalar_type
        else:
            st = ipw.input.scalar_type_as_string
        self.assertEqual(scalars.data_type, 11)
        self.assertEqual(st, 'double')

        self.src.point_scalars_name = 'third'
        scalars = ipw.input.point_data.scalars
        r = scalars.range
        expect = min(arr3), max(arr3)
        self.assertEqual(r, expect)
        o.update_traits()
        if is_old_pipeline():
            st = ipw.input.scalar_type
        else:
            st = ipw.input.scalar_type_as_string
        self.assertEqual(scalars.data_type, 10)
        self.assertEqual(st, 'float')
开发者ID:B-Rich,项目名称:mayavi,代码行数:44,代码来源:test_ipw_multiple_scalars.py


示例9: _scalar_data_changed

    def _scalar_data_changed(self, data):
        img_data = self.image_data
        if data is None:
            img_data.point_data.scalars = None
            self.data_changed = True
            return
        dims = list(data.shape)
        if len(dims) == 2:
            dims.append(1)

        # set the dimension indices
        dim0, dim1, dim2 = self.dimensions_order

        img_data.origin = tuple(self.origin)
        img_data.dimensions = tuple(dims)
        img_data.extent = 0, dims[dim0]-1, 0, dims[dim1]-1, 0, dims[dim2]-1
        if VTK_MAJOR_VERSION <= 7:
            if is_old_pipeline():
                img_data.update_extent = 0, dims[dim0]-1, 0, dims[dim1]-1, 0, dims[dim2]-1
            else:
                update_extent = [0, dims[dim0]-1, 0, dims[dim1]-1, 0, dims[dim2]-1]
                self.change_information_filter.set_update_extent(update_extent)
        if self.transpose_input_array:
            img_data.point_data.scalars = np.ravel(np.transpose(data))
        else:
            img_data.point_data.scalars = np.ravel(data)
        img_data.point_data.scalars.name = self.scalar_name
        # This is very important and if not done can lead to a segfault!
        typecode = data.dtype
        if is_old_pipeline():
            img_data.scalar_type = get_vtk_array_type(typecode)
            img_data.update() # This sets up the extents correctly.
        else:
            filter_out_info = self.change_information_filter.get_output_information(0)
            img_data.set_point_data_active_scalar_info(filter_out_info,
                                                       get_vtk_array_type(typecode), -1)
            img_data.modified()
        img_data.update_traits()
        self.change_information_filter.update()

        # Now flush the mayavi pipeline.
        self.data_changed = True
开发者ID:bergtholdt,项目名称:mayavi,代码行数:42,代码来源:array_source.py


示例10: _manual_bounds_changed

 def _manual_bounds_changed(self):
     if self.manual_bounds:
         if is_old_pipeline():
             self.outline_filter.input = self.outline_source.output
         else:
             self.outline_filter.input_connection = self.outline_source.output_port
     else:
         # Set the input of the filter.
         mm = self.module_manager
         self.configure_connection(self.outline_filter, mm.source)
     self.render()
开发者ID:fish2000,项目名称:mayavi,代码行数:11,代码来源:outline.py


示例11: _update_limits

 def _update_limits(self):
     if is_old_pipeline():
         extents = self.filter.input.whole_extent
     else:
         extents = self.filter.get_update_extent()
     self._x_low, self._x_high = extents[:2]
     self._y_low, self._y_high = extents[2:4]
     self._z_low, self._z_high = extents[4:]
     self._x_s_high = max(1, self._x_high)
     self._y_s_high = max(1, self._y_high)
     self._z_s_high = max(1, self._z_high)
开发者ID:PerryZh,项目名称:mayavi,代码行数:11,代码来源:extract_grid.py


示例12: setUp

    def setUp(self):
        """Initial setting up of test fixture, automatically called by
        TestCase before any other test method is invoked"""
        e = NullEngine()
        # Uncomment to see visualization for debugging etc.
        #e = Engine()
        e.start()
        s=e.new_scene()
        self.e=e
        self.s=s

        ############################################################
        # Create a new scene and set up the visualization.

        #Make the grid
        grid = self.make_grid4scatter()
        e.add_source(grid)

        eg = ExtractGrid()
        e.add_filter(eg)

        nb_ticks = 6

        eg.x_ratio = eg.y_ratio = eg.z_ratio = 100/(nb_ticks-1)/2

        gpx = GridPlane()
        e.add_module(gpx)
        gpx.grid_plane.axis = 'x'

        gpy = GridPlane()
        e.add_module(gpy)
        gpy.grid_plane.axis = 'y'

        gpz = GridPlane()
        e.add_module(gpz)
        gpz.grid_plane.axis = 'z'

        #Add the scatter
        d = VTKDataSource()
        d.data = self.make_scatter()
        e.add_source(d)
        if is_old_pipeline():
            a = Axes()
            e.add_module(a)
            a.axes.number_of_labels = nb_ticks

        self.eg = eg
        self.gpx = gpx
        self.gpy = gpy
        self.gpz = gpz
        self.scene = e.current_scene
        return
开发者ID:enthought,项目名称:mayavi,代码行数:52,代码来源:test_extract_grid_filter.py


示例13: __reader_dict_default

    def __reader_dict_default(self):
        """Default value for reader dict."""
        if is_old_pipeline():
            rd = {'inp':tvtk.AVSucdReader(),
                 'neu':tvtk.GAMBITReader(),
                 'exii':tvtk.ExodusReader()
                }
        else:
            rd = {'inp':tvtk.AVSucdReader(),
                 'neu':tvtk.GAMBITReader(),
                 'ex2':tvtk.ExodusIIReader()
                }

        return rd
开发者ID:B-Rich,项目名称:mayavi,代码行数:14,代码来源:unstructured_grid_reader.py


示例14: _vector_data_changed

    def _vector_data_changed(self, data):
        img_data = self.image_data
        if data is None:
            img_data.point_data.vectors = None
            self.data_changed = True
            return
        dims = list(data.shape)
        if len(dims) == 3:
            dims.insert(2, 1)
            data = np.reshape(data, dims)

        img_data.origin = tuple(self.origin)
        img_data.dimensions = tuple(dims[:-1])
        img_data.extent = 0, dims[0]-1, 0, dims[1]-1, 0, dims[2]-1
        if VTK_MAJOR_VERSION <= 7:
            if is_old_pipeline():
                img_data.update_extent = 0, dims[0]-1, 0, dims[1]-1, 0, dims[2]-1
            else:
                self.change_information_filter.update_information()
                update_extent = [0, dims[0]-1, 0, dims[1]-1, 0, dims[2]-1]
                self.change_information_filter.set_update_extent(update_extent)
        sz = np.size(data)
        if self.transpose_input_array:
            data_t = np.transpose(data, (2, 1, 0, 3))
        else:
            data_t = data
        img_data.point_data.vectors = np.reshape(data_t, (sz//3, 3))
        img_data.point_data.vectors.name = self.vector_name
        if is_old_pipeline():
            img_data.update() # This sets up the extents correctly.
        else:
            img_data.modified()
        img_data.update_traits()
        self.change_information_filter.update()

        # Now flush the mayavi pipeline.
        self.data_changed = True
开发者ID:bergtholdt,项目名称:mayavi,代码行数:37,代码来源:array_source.py


示例15: make_grid4scatter

 def make_grid4scatter(self):
     src = VTKDataSource()
     xmin, xmax, dx = 100, 200, 2
     nx = int((xmax-xmin)/dx)+1
     ymin, ymax, dy = 100, 200, 2
     ny = int((ymax-ymin)/dy)+1
     zmin, zmax, dz = 100, 200, 2
     nz  = int((zmax-zmin)/dz)+1
     image_data = tvtk.ImageData(origin=(xmin, ymin, zmin),
                                 spacing=(dx, dy, dz),
                                 extent=(0, nx-1, 0, ny-1, 0, nz-1))
     if is_old_pipeline():
         image_data.whole_extent = image_data.extent
     src.data = image_data
     return src
开发者ID:enthought,项目名称:mayavi,代码行数:15,代码来源:test_extract_grid_filter.py


示例16: _apply_mask

def _apply_mask(volume_data, mask_data):
    """ Mask out a portion of the data.
    """
    mask_image_data = _image_data_from_array(mask_data, volume_data.spacing)
    masker = tvtk.ImageMask()
    if is_old_pipeline():
        masker.set_image_input(volume_data)
        masker.set_mask_input(mask_image_data)
    else:
        masker.set_image_input_data(volume_data)
        masker.set_mask_input_data(mask_image_data)
    masker.update()
    result = masker.output
    result.point_data.scalars.name = POINT_DATA_SCALARS_NAME
    return masker.output
开发者ID:enthought,项目名称:ensemble,代码行数:15,代码来源:volume_data.py


示例17: _update

    def _update(self):
        """Updates the traits for the fields that are available in the
        input data.
        """
        if len(self.inputs) == 0 or len(self.inputs[0].outputs) == 0:
            return

        input = self.inputs[0].get_output_object()
        if self._first and is_old_pipeline():
            # Force all attributes to be defined and computed
            input.update()
        pnt_attr, cell_attr = get_all_attributes(input)

        self._setup_data_traits(cell_attr, 'cell')
        self._setup_data_traits(pnt_attr, 'point')
        if self._first:
            self._first = False
开发者ID:B-Rich,项目名称:mayavi,代码行数:17,代码来源:set_active_attribute.py


示例18: _update_data

    def _update_data(self):
        if self.data is None:
            return
        pnt_attr, cell_attr = get_all_attributes(self.data)

        pd = self.data.point_data
        scalars = pd.scalars
        if self.data.is_a('vtkImageData') and scalars is not None:
            # For some reason getting the range of the scalars flushes
            # the data through to prevent some really strange errors
            # when using an ImagePlaneWidget.
            r = scalars.range
            if is_old_pipeline():
                self._assign_attribute.output.scalar_type = scalars.data_type
                self.data.scalar_type = scalars.data_type

        def _setup_data_traits(obj, attributes, d_type):
            """Given the object, the dict of the attributes from the
            `get_all_attributes` function and the data type
            (point/cell) data this will setup the object and the data.
            """
            attrs = ['scalars', 'vectors', 'tensors']
            aa = obj._assign_attribute
            data = getattr(obj.data, '%s_data'%d_type)
            for attr in attrs:
                values = attributes[attr]
                values.append('')
                setattr(obj, '_%s_%s_list'%(d_type, attr), values)
                if len(values) > 1:
                    default = getattr(obj, '%s_%s_name'%(d_type, attr))
                    if obj._first and len(default) == 0:
                        default = values[0]
                    getattr(data, 'set_active_%s'%attr)(default)
                    aa.assign(default, attr.upper(),
                              d_type.upper() +'_DATA')
                    aa.update()
                    kw = {'%s_%s_name'%(d_type, attr): default,
                          'trait_change_notify': False}
                    obj.set(**kw)

        _setup_data_traits(self, pnt_attr, 'point')
        _setup_data_traits(self, cell_attr, 'cell')
        if self._first:
            self._first = False
        # Propagate the data changed event.
        self.data_changed = True
开发者ID:dmsurti,项目名称:mayavi,代码行数:46,代码来源:vtk_data_source.py


示例19: update_data

    def update_data(self):
        """Override this method to do what is necessary when upstream
        data changes.

        This method is invoked (automatically) when any of the inputs
        sends a `data_changed` event.
        """
        # Invoke render to update any changes.
        if not is_old_pipeline():
            from mayavi.modules.outline import Outline
            from mayavi.components.glyph import Glyph
            #FIXME: A bad hack, but without these checks results in seg fault
            input = self.inputs[0]
            if isinstance(input, Outline) or isinstance(input, Glyph):
                self.mapper.update(0)
            else:
                self.mapper.update()
        self.render()
开发者ID:B-Rich,项目名称:mayavi,代码行数:18,代码来源:actor.py


示例20: _update_vtk_dataset_content

    def _update_vtk_dataset_content(self):
        vtk_dataset = self.data

        if vtk_dataset is None:
            return

        pnt_attr, cell_attr = get_all_attributes(vtk_dataset)

        scalars = vtk_dataset.point_data.scalars
        if vtk_dataset.is_a('vtkImageData') and scalars is not None:
            # For some reason getting the range of the scalars flushes
            # the data through to prevent some really strange errors
            # when using an ImagePlaneWidget.
            if is_old_pipeline():
                self._assign_attribute.output.scalar_type = scalars.data_type
                vtk_dataset.scalar_type = scalars.data_type

        self._update_vtk_pipeline_for_data('point', pnt_attr)
        self._update_vtk_pipeline_for_data('cell', cell_attr)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:19,代码来源:slim_cuds_source.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python core.make_middleware函数代码示例发布时间:2022-05-27
下一篇:
Python common.configure_input函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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