[Numpy-discussion] constant shaded triangle mesh in mayavi2

Robert Kern robert.kern@gmail....
Fri Oct 1 09:44:01 CDT 2010


On Thu, Sep 30, 2010 at 23:04, Geoffrey Irving <irving@naml.us> wrote:
> On Fri, Oct 1, 2010 at 11:39 AM, Robert Kern <robert.kern@gmail.com> wrote:

>>  s = mlab.pipeline.triangular_mesh_source(x,y,z,triangles)
>>  s.data.cell_data.scalars = .... # Your data here.
>>  surf = mlab.pipeline.surface(s)
>>  surf.contours.filled_contours = True
>
> Cool, that seems to work for static plots (with "contours" replaced
> with "contour").  However, it breaks dynamic updates if I change data
> interactively on trait changes.  For vertex data, I'm using the
> following code for interactive updates:
>
>    @on_trait_change('threshold')
>    def update_plot(self):
>        self.plot.mlab_source.set(scalars=self.scalars())
>
> borrowed from
>
>    http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/example_mlab_interactive_dialog.html#example-mlab-interactive-dialog
>
> where plot is generated with triangular_mesh().  How do I force an
> update of the surface if I generate it myself and use cell data?

surf.render()

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the NumPy-Discussion mailing list