Esempio n. 1
0
def glyph():
    """The script itself.  We needn't have defined a function but
    having a function makes this more reusable.
    """
    # 'mayavi' is always defined on the interpreter.
    # Create a new VTK scene.
    mayavi.new_scene()

    # Read a VTK (old style) data file.
    r = VTKXMLFileReader()
    r.initialize(
        join(mayavi2.get_data_dir(dirname(abspath(__file__))), 'fire_ug.vtu'))
    mayavi.add_source(r)

    # Create an outline and a vector cut plane.
    mayavi.add_module(Outline())

    v = VectorCutPlane()
    mayavi.add_module(v)
    v.glyph.color_mode = 'color_by_scalar'

    # Now mask the points and show glyphs (we could also use
    # Vectors but glyphs are a bit more generic)
    m = MaskPoints()
    m.filter.trait_set(on_ratio=10, random_mode=True)
    mayavi.add_filter(m)

    g = Glyph()
    mayavi.add_module(g)
    # Note that this adds the module to the filtered output.
    g.glyph.scale_mode = 'scale_by_vector'
    # Use arrows to view the scalars.
    gs = g.glyph.glyph_source
    gs.glyph_source = gs.glyph_dict['arrow_source']
Esempio n. 2
0
 def setup_pipeline(self):
     mask = MaskPoints()
     mask.filter.set(generate_vertices=True, random_mode=True)
     self.mask = mask
     v = UserDefined(filter=tvtk.SelectVisiblePoints(),
                     name='VisiblePoints')
     self.visible_points = Optional(filter=v, enabled=False)
     mapper = tvtk.LabeledDataMapper()
     self.mapper = mapper
     self.actor = Actor2D(mapper=mapper)
     self.property = mapper.label_text_property
     self.property.on_trait_change(self.render)
     self.components = [self.mask, self.visible_points, self.actor]