Author Topic: Writing a modifier that operates on several frames  (Read 291 times)

matteoc

  • Newbie
  • *
  • Posts: 3
Writing a modifier that operates on several frames
« on: February 02, 2018, 01:02:45 PM »
I am using the experimental version of Ovito, and according to the version history, now modifiers can be used to analyze several frames, not just the one we are currently at.
Is there a description on how to do that?
More precisely, how should I change the function "modify(frame, input, output)" and how do I access a certain frame?

Thank you in advance,
Matteo

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 435
Re: Writing a modifier that operates on several frames
« Reply #1 on: February 02, 2018, 01:18:00 PM »
Hi Matteo,

so far that statement only applies to native modifiers written in C++, not Python script modifiers. The latter still have only access to the data from the upstream pipeline evaluated at the current time.
I haven't spent much thoughts yet on how (and if) the Python modifier interface can be extended to also support more advanced scenarios. But I will definitely do it when I find more time to work on the new architecture.

Perhaps you can briefly describe what kind of user-defined modifier function you have in mind that requires access to other simulation times. I can take this into account in the design. Would your function need information about the entire simulation trajectory, or particular frames only like the first or the preceding frame?

-Alex

matteoc

  • Newbie
  • *
  • Posts: 3
Re: Writing a modifier that operates on several frames
« Reply #2 on: February 02, 2018, 03:27:32 PM »
Thank you very much for the reply!
Right now I would need to analyze a certain interval of frames around the current frame, let's say an interval [t - Delta, t + Delta] from which I calculate some average quantity out of the particle's data.
Maybe I can try to figure out how to do it from the cpp files.
Thank you !
Best,
Matteo

Alexander Stukowski

  • Administrator
  • Sr. Member
  • *****
  • Posts: 435
Re: Writing a modifier that operates on several frames
« Reply #3 on: February 02, 2018, 03:42:52 PM »
I see. So far I already implemented the InterpolateTrajectoryModifier as a prototypical example for a modifier that samples the input trajectory at several different times.
It queries in the upstream data pipeline at one additional animation time to obtain two snapshots of the particle configuration between which it interpolates. In a similar fashion one could write a time-averaging modifier that queries an input particle property at several times within a window and then outputs the average value.

matteoc

  • Newbie
  • *
  • Posts: 3
Re: Writing a modifier that operates on several frames
« Reply #4 on: February 02, 2018, 04:01:57 PM »
Yes, I was indeed looking at InterpolateTrajectoryModifier !
I will try to work on it.
Thanks again.
Matteo