summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tng_io.h19
-rw-r--r--src/lib/tng_io.c91
2 files changed, 110 insertions, 0 deletions
diff --git a/include/tng_io.h b/include/tng_io.h
index e39797f..1e7f187 100644
--- a/include/tng_io.h
+++ b/include/tng_io.h
@@ -2736,6 +2736,25 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
char *type);
/**
+ * @brief Get the stride length of a specific data (particle dependency does not matter)
+ * block, either in the current frame set or of a specific frame.
+ * @param tng_data is the trajectory data container.
+ * @param block_id is the block ID of the data block, of which to retrieve the
+ * stride length of the data.
+ * @param frame is the frame from which to get the stride length. If frame is set to -1
+ * no specific frame will be used, but instead the first frame, starting from the last read
+ * frame set, containing the data block will be used.
+ * @param stride_length is set to the value of the stride length of the data block.
+ * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
+ * has occurred or TNG_CRITICAL (2) if a major error has occured.
+ */
+tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ int64_t frame,
+ int64_t *stride_length);
+
+/**
* @brief Get the date and time of initial file creation in ISO format (string).
* @param tng_data is a trajectory data container.
* @param time is a pointer to the string in which the date will be stored. Memory
diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c
index b91db67..7586e92 100644
--- a/src/lib/tng_io.c
+++ b/src/lib/tng_io.c
@@ -14729,6 +14729,92 @@ tng_function_status DECLSPECDLLEXPORT tng_particle_data_vector_interval_get
return(TNG_SUCCESS);
}
+tng_function_status DECLSPECDLLEXPORT tng_data_get_stride_length
+ (tng_trajectory_t tng_data,
+ const int64_t block_id,
+ int64_t frame,
+ int64_t *stride_length)
+{
+ tng_trajectory_frame_set_t frame_set;
+ tng_function_status stat;
+ tng_non_particle_data_t np_data;
+ tng_particle_data_t p_data;
+ long file_pos;
+ int is_particle_data;
+ int64_t data_first_frame;
+
+ frame_set = &tng_data->current_trajectory_frame_set;
+
+ if(tng_data->current_trajectory_frame_set_input_file_pos <= 0)
+ {
+ frame = 0;
+ }
+
+ if(frame >= 0)
+ {
+ stat = tng_frame_set_of_frame_find(tng_data, frame);
+ if(stat != TNG_SUCCESS)
+ {
+ return(stat);
+ }
+ }
+ stat = tng_data_find(tng_data, block_id, &np_data);
+ if(stat != TNG_SUCCESS)
+ {
+ stat = tng_particle_data_find(tng_data, block_id, &p_data);
+ if(stat != TNG_SUCCESS)
+ {
+ stat = tng_frame_set_read_current_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
+ /* If no specific frame was required read until this data block is found */
+ if(frame < 0)
+ {
+ file_pos = ftell(tng_data->input_file);
+ while(stat != TNG_SUCCESS && file_pos < tng_data->input_file_len)
+ {
+ stat = tng_frame_set_read_next_only_data_from_block_id(tng_data, TNG_USE_HASH, block_id);
+ file_pos = ftell(tng_data->input_file);
+ }
+ }
+ if(stat != TNG_SUCCESS)
+ {
+ return(stat);
+ }
+ stat = tng_data_find(tng_data, block_id, &np_data);
+ if(stat != TNG_SUCCESS)
+ {
+ stat = tng_particle_data_find(tng_data, block_id, &p_data);
+ if(stat != TNG_SUCCESS)
+ {
+ return(stat);
+ }
+ else
+ {
+ is_particle_data = 1;
+ }
+ }
+ else
+ {
+ is_particle_data = 0;
+ }
+ }
+ else
+ {
+ is_particle_data = 1;
+ }
+ }
+ else
+ {
+ is_particle_data = 0;
+ }
+ if(is_particle_data)
+ {
+ *stride_length = p_data->stride_length;
+ }
+ else
+ {
+ *stride_length = np_data->stride_length;
+ }
+}
tng_function_status DECLSPECDLLEXPORT tng_time_get_str
(const tng_trajectory_t tng_data,
@@ -15287,6 +15373,11 @@ tng_function_status DECLSPECDLLEXPORT tng_util_non_particle_data_next_frame_read
{
return(stat);
}
+ stat = tng_data_find(tng_data, block_id, &data);
+ if(stat != TNG_SUCCESS)
+ {
+ return(stat);
+ }
}
if(data->last_retrieved_frame < 0)
{
contact: Jan Huwald // Impressum