[vtkusers] Persistent data across time step changes in programmable filter
Sean Ziegeler
sean.ziegeler at nrlssc.navy.mil
Wed Nov 28 11:43:08 EST 2012
I came up with a rather simple solution. If I'm trying to cache some
numpy array x (or really any variable x) for the next time step's
execution in the Programmable Filter, I just make x a member of the
object. For example:
if 'x' in dir(self):
x = self.x
else:
x = make_my_x()
self.x = x
do_whatever_with_x(x)
I realize this also reuses self.x for other pipeline updates, including
changes applied to the Programmable Filter code or changes to the
upstream pipeline data. I'm sure I could check for upstream grid
modifications (if anyone has suggestions, I'd appreciate them). For now
though, I just add an extra boolean flag to override the caching manually.
However, are there any pitfalls in using this approach?
Thanks,
Sean
On 11/15/12 16:50, Sean Ziegeler wrote:
> I previously sent this to the ParaView list and got no answer, but I
> realize now that it's really more of a VTK pipeline question anyway.
>
> I'm writing a programmable filter that makes changes to a vector field
> based on grid point properties (it's a polar orthographic transform
> using a highly accurate Earth shape model).
>
> This works well. However, when one changes the timestep, it recomputes
> those grid point properties to apply to the next timestep's vector
> field. This is a very expensive operation, and is quite unnecessary
> since the grid doesn't change over time. I'd like to somehow cache the
> grid point property array so that I could simply reuse it for future
> timesteps if it's already been computed.
>
> I thought about storing it as a Field Data array. However, with some
> experimentation, I find that Field Data arrays are cleared from the
> filter output when the pipeline re-executes for a new timestep. Is
> there a way to keep a Field Data array around for subsequent time steps?
> If not, is there some other mechanism for a programmable filter to
> retain data that won't change after the first timestep?
>
> Thanks!
> Sean
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list