[vtkusers] CreateRepeatingTimer Loop with memory

David Gobbi david.gobbi at gmail.com
Tue Nov 20 16:24:10 EST 2018


Basically what Elvis said: you can store whatever you want in the callback.
For example, you can do this:

   cb.actor = actor
   cb.mapper = mapper

And then in the callback execute() method, you can do whatever you want
with cb.mapper, i.e. you can give the mapper a new input.

Whether you really want to do this, though, depends on exactly what you are
trying to achieve at each iteration.  If you just want to adjust the
position or orientation, then it's best to just do something similar to
what the example does.  Actually getting the output and using it as the
next input is computationally expensive, whereas changing the position and
orientation of an actor is cheap.

If you are hoping to get the output of the Render() and feed it back into
the mapper, that is actually impossible.  The Render() draws to the screen,
so its output is a 2D bitmap, which isn't something you can feed back into
the pipeline as a replacement of the original polydata.

  David



On Tue, Nov 20, 2018 at 2:07 PM Elvis Stansvik <elvis.stansvik at orexplore.com>
wrote:

> Den tis 20 nov. 2018 kl 21:49 skrev Andreas Pedroni <anpedroni at gmail.com>:
> >
> > Dear list
> >
> > Is there a way to use a RepeatingTimer as in this example:
> https://www.vtk.org/Wiki/VTK/Examples/Python/Animation in which the loop
> for the animation (in the example the method execute()) can return output
> in each iteration that is used in the the next iteration? In other words,
> is there a way to use information that is calculated in one iteration for
> the next iteration? Sorry, I am not sure if the question is understandable.
>
> I think you have your answer right there in that example :) In each
> iteration, the self.timer_count field holds the output from the
> previous iteration.
>
> So yes, I think you can simply save the output from one iteration in a
> field of the callback class, and use that as input in the next
> iteration.
>
> Hope that makes sense.
>
> Cheers,
> Elvis
>
> >
> > best
> > Andreas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20181120/bd049ba6/attachment.html>


More information about the vtkusers mailing list