Open3DMotionGroup / Open3DMotion

Other
5 stars 2 forks source link

Allow a time sequence object to be re-allocated given a new time range to reduce code required in calculations #23

Closed drjrm closed 6 years ago

drjrm commented 6 years ago

If a calculation method needs to return multiple time sequences this can become unwieldy, for example

void Get_a_and_b(TimeSequence** a, TimeSequence** b)
{

  // Get memfactory and time range somehow
  BinMemFactory memfactory = ...
  TimeRange rt = ...

  *a = TSFactory.New(tr, memfactory);
  *b = TSFactory.New(tr, memfactory);

  // Operations will now involve complicated-looking things like
  size_t n = (*a)->NumFrames();
}

And even more so when a vector is needed.

If a time sequence can be re-allocated then it could be passed by reference, and then we can say things like a.NumFrames() which is much more concise. This has the added benefit that use of auto-pointers can be avoided when used locally - time sequences can be allocated on the heap (and it's only the metadata that would use the heap, everything else will use memory allocation via the mem factory).