From 57a9c1194860f4073dc4d33ad9c824919d5e7f26 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Nov 2009 21:46:53 +0000 Subject: [PATCH] tag implementation, bugfixes ... --- .gitattributes | 2 + src/H5Fed_tags.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++ src/H5Fed_tags.h | 40 ++++++++++ 3 files changed, 243 insertions(+) create mode 100644 src/H5Fed_tags.c create mode 100644 src/H5Fed_tags.h diff --git a/.gitattributes b/.gitattributes index 2ab546b..e6fc3f2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -363,6 +363,8 @@ src/H5Fed_retrieve.c -text src/H5Fed_retrieve.h -text src/H5Fed_store.c -text src/H5Fed_store.h -text +src/H5Fed_tags.c -text +src/H5Fed_tags.h -text src/H5Part.c -text src/H5Part.h -text src/H5_inquiry.c -text diff --git a/src/H5Fed_tags.c b/src/H5Fed_tags.c new file mode 100644 index 0000000..7f6e0b4 --- /dev/null +++ b/src/H5Fed_tags.c @@ -0,0 +1,201 @@ +/* + Copyright 2007-2009 + Paul Scherrer Institut, Villigen, Switzerland; + Achim Gsell + All rights reserved. + + Authors + Achim Gsell + + Warning + This code is under development. + + */ +#include +#include "h5_core/h5_core.h" +#include "H5Fed.h" + +/*! + Add a tagset to the current mesh. + + \param[in] f file handle + \param[in] name name of tagset + \param[in] type data type of tagset + + \return H5_SUCCESS or error code + */ +h5_err_t +H5FedAddMTagset ( + h5_file_t * const f, + char * name, + h5_id_t type + ) { + SET_FNAME ( f, __func__ ); + return h5t_add_mtagset ( f, name, type ); +} + +/*! + Remove a tagset from the current mesh. + + \param[in] f file handle + \param[in] name name of tagset to remove + + \return H5_SUCCESS or error code + */ +h5_err_t +H5FedRemoveMTagset ( + h5_file_t *const f, + char name[] + ) { + SET_FNAME ( f, __func__ ); + return h5t_remove_mtagset (f, name ); +} + +/*! + Get available tagsets in current mesh. + + \param[in] f file handle + \param[out] names names of available tagsets + + \return Number of tagsets or error code + */ +h5_size_t +H5FedGetMTagsets ( + h5_file_t *const f, + char **names[] + ) { + SET_FNAME ( f, __func__ ); + return h5t_get_mtagsets ( f, names ); +} + +/*! + Get type of tagset in current mesh. + + \param[in] f file handle + \param[in] name name of tagset + + \return H5_SUCCESS or error code + */ +h5_id_t +H5FedGetTypeOfMTagset ( + h5_file_t *const f, + char name[] + ) { + SET_FNAME ( f, __func__ ); + return h5t_get_mtagset_type ( f, name ); +} + +/*! + Set tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity + \param[in] dim dimension of value + \param[in] val tag value + + \return H5_SUCCESS or error code + */ +h5_err_t +H5FedSetMTag ( + h5_file_t *const f, + char name[], + h5_id_t id, + const size_t dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + return h5t_set_mtag ( f, name, id, dims, val ); +} + +h5_err_t +H5FedSetMTagToVertex ( + h5_file_t *const f, + char name[], + h5_id_t id, + const size_t dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + id = _h5t_set_entity_type ( H5T_ETYPE_VERTEX, id ); + return h5t_set_mtag ( f, name, id, dims, val ); +} + +h5_err_t +H5FedSetMTagToEdge ( + h5_file_t *const f, + char name[], + h5_id_t id, + const size_t dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + id = _h5t_set_entity_type ( H5T_ETYPE_EDGE, id ); + return h5t_set_mtag ( f, name, id, dims, val ); +} + +h5_err_t +H5FedSetMTagToTriangle ( + h5_file_t *const f, + char name[], + h5_id_t id, + const size_t dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + id = _h5t_set_entity_type ( H5T_ETYPE_TRIANGLE, id ); + return h5t_set_mtag ( f, name, id, dims, val ); +} + +h5_err_t +H5FedSetMTagToTet ( + h5_file_t *const f, + char name[], + h5_id_t id, + const size_t dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + id = _h5t_set_entity_type ( H5T_ETYPE_TET, id ); + return h5t_set_mtag ( f, name, id, dims, val ); +} + +/*! + Set tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity + \param[out] dim dimension of value + \param[out] val tag value + + \return H5_SUCCESS or error code + */ +h5_err_t +H5FedGetMTag ( + h5_file_t *const f, + const char name[], + const h5_id_t id, + size_t *dims, + void *val + ) { + SET_FNAME ( f, __func__ ); + return h5t_get_mtag ( f, name, id, dims, val ); +} + +/*! + Remove tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity +*/ +h5_err_t +H5FedRemoveMTag ( + h5_file_t *const f, + const char name[], + const h5_id_t id + ) { + SET_FNAME ( f, __func__ ); + return h5t_remove_mtag ( f, name, id ); +} diff --git a/src/H5Fed_tags.h b/src/H5Fed_tags.h new file mode 100644 index 0000000..aa880aa --- /dev/null +++ b/src/H5Fed_tags.h @@ -0,0 +1,40 @@ +#ifndef __H5FED_TAGS_H +#define __H5FED_TAGS_H +h5_err_t H5FedAddMTagset ( h5_file_t * const f, + char * name, + h5_id_t type ); +h5_err_t H5FedRemoveMTagset ( h5_file_t *const f, + char name[] ); +h5_size_t H5FedGetMTagsets ( h5_file_t *const f, + char **names[] ); +h5_id_t H5FedGetTypeOfMTagset ( h5_file_t *const f, + char name[] ); +h5_err_t H5FedSetMTag ( h5_file_t *const f, + char name[], h5_id_t id, + const size_t dims, void *val ); +h5_err_t H5FedSetMTagToVertex ( h5_file_t *const f, + char name[], h5_id_t id, + const size_t dims, void *val ); +h5_err_t H5FedSetMTagToEdge ( h5_file_t *const f, + char name[], h5_id_t id, + const size_t dims, void *val ); +h5_err_t H5FedSetMTagToTriangle ( h5_file_t *const f, + char name[], h5_id_t id, + const size_t dims, void *val ); +h5_err_t H5FedSetMTagToTet ( h5_file_t *const f, + char name[], h5_id_t id, + const size_t dims, void *val ); + +h5_err_t H5FedGetMTag ( h5_file_t *const f, + const char name[], const h5_id_t id, + size_t *dims, void *val ); +h5_err_t H5FedRemoveMTag ( h5_file_t *const f, + const char name[], const h5_id_t id ); + +/* + Get descriptor for a tagset + Get tag value by descriptor + get size of value + Get tagset names for specific entity +*/ +#endif