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


Python common.configure_input函数代码示例

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


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

示例1: convert_to_poly_data

def convert_to_poly_data(obj):
    """Given a VTK dataset object, this returns the data as PolyData.
    This is primarily used to convert the data suitably for filters
    that only work for PolyData.
    """
    if obj.is_a('vtkDataSet'):
        data = obj
    else:
        # FIXME
        data = obj.output

    if obj.is_a('vtkPolyData') or data.is_a('vtkPolyData'):
        return obj


    conv = {'vtkStructuredPoints': tvtk.ImageDataGeometryFilter,
            'vtkImageData': tvtk.ImageDataGeometryFilter,
            'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter,
            'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter,
            'vtkUnstructuredGrid':tvtk.GeometryFilter}

    fil = None
    for name, fil_class in conv.items():
        if data.is_a(name):
            fil = fil_class()
            break

    if fil is not None:
        configure_input(fil, obj)
        fil.update()
        return fil
    else:
        error('Given object is not a VTK dataset: %s'%data.__class__.__name__)
开发者ID:PerryZh,项目名称:mayavi,代码行数:33,代码来源:common.py

示例2: __init__

    def __init__(self, renwin, **traits):
        super(Picker, self).__init__(**traits)

        self.renwin = renwin
        self.pointpicker = tvtk.PointPicker()
        self.cellpicker = tvtk.CellPicker()
        self.worldpicker = tvtk.WorldPointPicker()
        self.probe_data = tvtk.PolyData()
        self._tolerance_changed(self.tolerance)

        # Use a set of axis to show the picked point.
        self.p_source = tvtk.Axes()
        self.p_mapper = tvtk.PolyDataMapper()
        self.p_actor = tvtk.Actor ()
        self.p_source.symmetric = 1
        self.p_actor.pickable = 0
        self.p_actor.visibility = 0
        prop = self.p_actor.property
        prop.line_width = 2
        prop.ambient = 1.0
        prop.diffuse = 0.0
        configure_input(self.p_mapper, self.p_source)
        self.p_actor.mapper = self.p_mapper

        self.probe_data.points = [[0.0, 0.0, 0.0]]

        self.ui = None
开发者ID:enthought,项目名称:mayavi,代码行数:27,代码来源:picker.py

示例3: main

def main(hdf5_animation_file):
    weights = None
    with h5py.File(hdf5_animation_file, 'r') as f:
        verts = f['verts'].value
        tris = f['tris'].value
        if 'weights' in f:
            weights = f['weights'].value

    pd = tvtk.PolyData(points=verts[0], polys=tris)
    normals = tvtk.PolyDataNormals(splitting=False)
    configure_input_data(normals, pd)
    actor = tvtk.Actor(mapper=tvtk.PolyDataMapper())
    configure_input(actor.mapper, normals)
    actor.property.set(edge_color=(0.5, 0.5, 0.5), ambient=0.0,
                       specular=0.15, specular_power=128., shading=True, diffuse=0.8)

    fig = mlab.figure(bgcolor=(1,1,1))
    fig.scene.add_actor(actor)

    @mlab.animate(delay=40, ui=False)
    def animation():
        for i in count():
            if weights is not None:
                w_str = ",".join(["%0.2f"] * weights.shape[1])
                print ("Frame %d Weights = " + w_str) % tuple([i] + weights[i].tolist())
            frame = i % len(verts)
            pd.points = verts[frame]
            fig.scene.render()
            yield

    a = animation()
    fig.scene.z_minus_view()
    mlab.show()
开发者ID:tneumann,项目名称:splocs,代码行数:33,代码来源:view_animation.py

示例4: _volume_mapper_type_changed

    def _volume_mapper_type_changed(self, value):
        if self.module_manager is None:
            return

        old_vm = self._volume_mapper
        if old_vm is not None:
            old_vm.on_trait_change(self.render, remove=True)

        ray_cast_functions = ['']
        if value == 'RayCastMapper':
            new_vm = self._get_mapper(tvtk.VolumeRayCastMapper)
            vrc_func = tvtk.VolumeRayCastCompositeFunction()
            new_vm.volume_ray_cast_function = vrc_func
            ray_cast_functions = ['RayCastCompositeFunction',
                                  'RayCastMIPFunction',
                                  'RayCastIsosurfaceFunction']
        elif value == 'TextureMapper2D':
            new_vm = self._get_mapper(tvtk.VolumeTextureMapper2D)
        elif value == 'VolumeTextureMapper3D':
            new_vm = self._get_mapper(tvtk.VolumeTextureMapper3D)
        elif value == 'VolumeProMapper':
            new_vm = self._get_mapper(tvtk.VolumeProMapper)
        elif value == 'FixedPointVolumeRayCastMapper':
            new_vm = self._get_mapper(tvtk.FixedPointVolumeRayCastMapper)
        else:
            msg = "Unsupported volume mapper type: '{0}'".format(value)
            raise ValueError(msg)

        self._volume_mapper = new_vm
        self._ray_cast_functions = ray_cast_functions

        configure_input(new_vm, self.module_manager.source.outputs[0])
        self.volume.mapper = new_vm
        new_vm.on_trait_change(self.render)
开发者ID:dmsurti,项目名称:ensemble,代码行数:34,代码来源:volume_3d.py

示例5: concave_hull

def concave_hull(polydata):
    """extract the concave hull of a vtk polydata object"""
    # setup the extraction pipeline
    extract = tvtk.FeatureEdges()
    # we're only interested in the boundaries
    extract.feature_edges = False
    extract.boundary_edges = True
    extract.manifold_edges = False
    extract.non_manifold_edges = False
    configure_input(extract, polydata)
    # compute edges
    extract.update()
    # extract the points
    points = extract.output.points.to_array()

    # slice every 2nd and 3rd point
    line_ids = np.c_[
        extract.output.lines.to_array()[1::3],
        extract.output.lines.to_array()[2::3]
    ]
    # 1st points should all be 2
    assert (extract.output.lines.to_array()[0::3] == 2).all(), "expected only lines"

    # construct a directed graph
    D = networkx.DiGraph(data=line_ids.tolist())
    # find the first cycle
    first_cycle = networkx.find_cycle(D)
    # create the index to lookup points, including last point
    cycle = [x[0] for x in first_cycle] + [first_cycle[0][0]]
    # fill in index and return first 2 coordinates
    return points[cycle, :2]
开发者ID:openearth,项目名称:flowmap,代码行数:31,代码来源:topology.py

示例6: add_base

        def add_base(index, mirror, B):
            """
            build pipeline, for given basis
            """
            B = util.normalize(B.T).T

            PP = np.dot(B, self.complex.geometry.decomposed.T).T       #primal coords transformed into current frame


            x,y,z = PP.T
            FV = self.complex.topology.FV[:,::np.sign(np.linalg.det(B))]        #reverse vertex order depending on orientation
            source  = self.scene.mlab.pipeline.triangular_mesh_source(x,y,z, FV)

            #put these guys under a ui list
            l=lut_manager.tvtk.LookupTable()
            lut_manager.set_lut(l, lut_manager.pylab_luts['jet'])
##            lut_manager.set_lut(l, lut_manager.pylab_luts.values()[0])

            #add polydatamapper, to control color mapping and interpolation
            mapper = tvtk.PolyDataMapper(lookup_table=l)

            from tvtk.common import configure_input
            configure_input(mapper, source.outputs[0])

            ##            mapper = tvtk.PolyDataMapper(input=source.outputs[0])
            mapper.interpolate_scalars_before_mapping = True
            mapper.immediate_mode_rendering = False

            return mirror, source, mapper
开发者ID:EelcoHoogendoorn,项目名称:Escheresque,代码行数:29,代码来源:height_editor.py

示例7: write_flux

def write_flux(file_name, surface, surface_density, surface_va, surface_beta,
               surface_cs, Fpar, Fperp, Fphi):
    pd_density = tvtk.PointData(scalars=surface_density)
    pd_density.scalars.name = "surface_density"

    pd_va = tvtk.PointData(scalars=surface_va)
    pd_va.scalars.name = "surface_va"

    pd_beta = tvtk.PointData(scalars=surface_beta)
    pd_beta.scalars.name = "surface_beta"

    pd_cs = tvtk.PointData(scalars=surface_cs)
    pd_cs.scalars.name = "surface_cs"

    pd_Fpar = tvtk.PointData(scalars=Fpar)
    pd_Fpar.scalars.name = "Fpar"

    pd_Fperp = tvtk.PointData(scalars=Fperp)
    pd_Fperp.scalars.name = "Fperp"

    pd_Fphi = tvtk.PointData(scalars=Fphi)
    pd_Fphi.scalars.name = "Fphi"

    poly_out = surface
    poly_out.point_data.add_array(pd_density.scalars)
    poly_out.point_data.add_array(pd_va.scalars)
    poly_out.point_data.add_array(pd_beta.scalars)
    poly_out.point_data.add_array(pd_cs.scalars)
    poly_out.point_data.add_array(pd_Fpar.scalars)
    poly_out.point_data.add_array(pd_Fperp.scalars)
    poly_out.point_data.add_array(pd_Fphi.scalars)

    w = tvtk.XMLPolyDataWriter(file_name=file_name)
    tvtk_common.configure_input(w, poly_out)
    w.write()
开发者ID:SWAT-Sheffield,项目名称:pysac,代码行数:35,代码来源:tvtk_tube_functions.py

示例8: save_png

 def save_png(self, file_name):
     """Save to a PNG image file."""
     if len(file_name) != 0:
         w2if = self._get_window_to_image()
         ex = tvtk.PNGWriter()
         ex.file_name = file_name
         configure_input(ex, w2if)
         self._exporter_write(ex)
开发者ID:prabhuramachandran,项目名称:mayavi,代码行数:8,代码来源:tvtk_scene.py

示例9: save_ps

 def save_ps(self, file_name):
     """Saves the rendered scene to a rasterized PostScript image.
     For vector graphics use the save_gl2ps method."""
     if len(file_name) != 0:
         w2if = self._get_window_to_image()
         ex = tvtk.PostScriptWriter()
         ex.file_name = file_name
         configure_input(ex, w2if)
         self._exporter_write(ex)
开发者ID:prabhuramachandran,项目名称:mayavi,代码行数:9,代码来源:tvtk_scene.py

示例10: make_outline

def make_outline(input_obj):
    from tvtk.api import tvtk
    from tvtk.common import configure_input
    outline = tvtk.StructuredGridOutlineFilter()
    configure_input(outline, input_obj)
    outline_mapper = tvtk.PolyDataMapper(input_connection = outline.output_port)
    outline_actor = tvtk.Actor(mapper = outline_mapper)
    outline_actor.property.color = 0.3, 0.3, 0.3
    return outline_actor
开发者ID:Andor-Z,项目名称:scpy2,代码行数:9,代码来源:tvtkhelp.py

示例11: _mask_input_points_changed

 def _mask_input_points_changed(self, value):
     inputs = self.inputs
     if len(inputs) == 0:
         return
     if value:
         mask = self.mask_points
         tvtk_common.configure_input(mask, inputs[0].outputs[0])
     else:
         self.configure_connection(self.glyph, inputs[0])
开发者ID:B-Rich,项目名称:mayavi,代码行数:9,代码来源:glyph.py

示例12: add_actors_to_scene

    def add_actors_to_scene(self, scene_model, volume_actor):

        # An outline of the bounds of the Volume actor's data
        outline = tvtk.OutlineFilter()
        configure_input(outline, volume_actor.mapper.input)
        outline_mapper = tvtk.PolyDataMapper()
        configure_input(outline_mapper, outline.output)
        outline_actor = tvtk.Actor(mapper=outline_mapper)
        outline_actor.property.opacity = 0.3
        scene_model.renderer.add_actor(outline_actor)
开发者ID:dmsurti,项目名称:ensemble,代码行数:10,代码来源:volume_bounding_box.py

示例13: _mask_input_points_changed

def _mask_input_points_changed(self, value):
    from tvtk.common import configure_input
    inputs = self.inputs
    if len(inputs) == 0:
        return
    if value:
        mask = self.mask_points
        configure_input(mask, inputs[0].outputs[0])
        self.configure_connection(self.glyph, mask)
    else:
        self.configure_connection(self.glyph, inputs[0])
开发者ID:Andor-Z,项目名称:scpy2,代码行数:11,代码来源:fix_mayavi_bugs.py

示例14: scene_to_png

def scene_to_png(scene):
    w2if = tvtk.WindowToImageFilter()
    w2if.input = scene.render_window
    ex = tvtk.PNGWriter()
    ex.write_to_memory = True
    configure_input(ex, w2if)
    ex.update()
    ex.write()
    data = base64.b64encode(ex.result.to_array()).decode("ascii")
    html = '<img src="data:image/png;base64,%s" alt="PNG image"></img>'
    return html % data
开发者ID:prabhuramachandran,项目名称:mayavi,代码行数:11,代码来源:notebook.py

示例15: save_png

 def save_png(self, file_name):
     """Save to a PNG image file."""
     if len(file_name) != 0:
         w2if = tvtk.WindowToImageFilter(read_front_buffer=not self.off_screen_rendering)
         w2if.magnification = self.magnification
         self._lift()
         w2if.input = self._renwin
         ex = tvtk.PNGWriter()
         ex.file_name = file_name
         configure_input(ex, w2if)
         self._exporter_write(ex)
开发者ID:aestrivex,项目名称:mayavi,代码行数:11,代码来源:tvtk_scene.py


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