diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-10-30 10:05:22 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2013-10-30 10:05:22 (GMT) |
commit | dc08c1e4cb0bb26e02219f49bb3f6eb9801fe764 (patch) | |
tree | 6568d123b2f2824f27792eaa0206563c93563ca9 /src/lib/tng_io.c | |
parent | 10bea89dbf552570f6d356e1576f27bc40b095f3 (diff) |
Added utility function to get time of frame.
Diffstat (limited to 'src/lib/tng_io.c')
-rw-r--r-- | src/lib/tng_io.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 69dbadd..dccbf03 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -14652,6 +14652,32 @@ tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_close return(tng_trajectory_destroy(tng_data_p)); } +tng_function_status DECLSPECDLLEXPORT tng_util_time_of_frame_get + (tng_trajectory_t tng_data, + const int64_t frame_nr, + double *time) +{ + int64_t first_frame; + + tng_trajectory_frame_set_t frame_set; + tng_function_status stat; + + stat = tng_frame_set_of_frame_find(tng_data, frame_nr); + if(stat != TNG_SUCCESS) + { + printf("Cannot find frame nr %"PRId64". %s: %d\n", + frame_nr, __FILE__, __LINE__); + return(stat); + } + + frame_set = &tng_data->current_trajectory_frame_set; + first_frame = frame_set->first_frame; + + *time = frame_set->first_frame_time + (tng_data->time_per_frame * frame_nr - first_frame); + + return(TNG_SUCCESS); +} + tng_function_status DECLSPECDLLEXPORT tng_util_trajectory_molecules_get (tng_trajectory_t tng_data, int64_t *n_mols, |