[MOAB-dev] r2806 - in MOAB/trunk/mhdf: include src
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Tue Apr 7 15:50:16 CDT 2009
Author: kraftche
Date: 2009-04-07 15:50:16 -0500 (Tue, 07 Apr 2009)
New Revision: 2806
Modified:
MOAB/trunk/mhdf/include/mhdf.h
MOAB/trunk/mhdf/src/file-desc.c
MOAB/trunk/mhdf/src/file-handle.h
MOAB/trunk/mhdf/src/names-and-paths.h
MOAB/trunk/mhdf/src/nodes.c
MOAB/trunk/mhdf/src/sets.c
MOAB/trunk/mhdf/src/util.h
Log:
o mhdf_getFileSummary shouldn't fail if the file contains no vertices
(e.g. ITS data containing only sets composing a tree).
o mhdf_getFileSummary shouldn't fail if the file contains no sets
o mhdf_getFileSummary returns flags indicating which set data,
if any, is present (contents, parents, children).
o Fix some warnings:
- make initialization in sets.c portable
- work around annoying GCC bug where it warns about c++-style
comments within an #ifdef __cplusplus block.
Modified: MOAB/trunk/mhdf/include/mhdf.h
===================================================================
--- MOAB/trunk/mhdf/include/mhdf.h 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/include/mhdf.h 2009-04-07 20:50:16 UTC (rev 2806)
@@ -241,6 +241,9 @@
struct mhdf_FileDesc {
struct mhdf_EntDesc nodes;
struct mhdf_EntDesc sets;
+ int have_set_contents;
+ int have_set_children;
+ int have_set_parents;
struct mhdf_ElemDesc* elems; /**< Array of element table descriptions */
int num_elem_desc;
struct mhdf_TagDesc* tags; /**< Array of tag descriptions */
@@ -360,6 +363,10 @@
/* Node Coordinates */
+int
+mhdf_haveNodes( mhdf_FileHandle file_handle, mhdf_Status* status );
+
+
/** \brief Create new table for node coordinate data
*
* \param file_handle The file.
@@ -2332,7 +2339,7 @@
#ifdef __cplusplus
-} // extern "C"
+} /* extern "C" */
#endif
#endif
Modified: MOAB/trunk/mhdf/src/file-desc.c
===================================================================
--- MOAB/trunk/mhdf/src/file-desc.c 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/file-desc.c 2009-04-07 20:50:16 UTC (rev 2806)
@@ -323,7 +323,7 @@
{
struct mhdf_FileDesc* result;
hid_t table_id;
- int i, j, k, size, *indices;
+ int i, j, k, size, *indices, have;
void* ptr;
char **elem_handles = 0, **tag_names = 0;
unsigned char *array, *matrix;
@@ -335,29 +335,57 @@
if (NULL == result) return NULL;
/* get node info */
- table_id = mhdf_openNodeCoords( file_handle,
- &result->nodes.count,
- &result->nodes.vals_per_ent,
- &result->nodes.start_id,
- status );
- if (table_id < 0) {
+ have = mhdf_haveNodes( file_handle, status );
+ if (mhdf_isError(status)) {
free( result );
return NULL;
+ }
+ if (have) {
+ table_id = mhdf_openNodeCoords( file_handle,
+ &result->nodes.count,
+ &result->nodes.vals_per_ent,
+ &result->nodes.start_id,
+ status );
+ if (table_id < 0) {
+ free( result );
+ return NULL;
+ }
+ mhdf_closeData( file_handle, table_id, status );
}
- mhdf_closeData( file_handle, table_id, status );
+ else {
+ result->nodes.count = 0;
+ result->nodes.vals_per_ent = 0;
+ result->nodes.start_id = 0;
+ }
+
/* get set info */
result->sets.vals_per_ent = -1;
- table_id = mhdf_openSetMeta( file_handle,
- &result->sets.count,
- &result->sets.start_id,
- status );
- if (table_id < 0) {
+ have = mhdf_haveSets( file_handle,
+ &result->have_set_contents,
+ &result->have_set_children,
+ &result->have_set_parents,
+ status );
+ if (mhdf_isError(status)) {
free( result );
return NULL;
+ }
+ if (have) {
+ table_id = mhdf_openSetMeta( file_handle,
+ &result->sets.count,
+ &result->sets.start_id,
+ status );
+ if (table_id < 0) {
+ free( result );
+ return NULL;
+ }
+ mhdf_closeData( file_handle, table_id, status );
}
- mhdf_closeData( file_handle, table_id, status );
+ else {
+ result->sets.count = 0;
+ result->sets.start_id = 0;
+ }
/* get element list */
Modified: MOAB/trunk/mhdf/src/file-handle.h
===================================================================
--- MOAB/trunk/mhdf/src/file-handle.h 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/file-handle.h 2009-04-07 20:50:16 UTC (rev 2806)
@@ -39,7 +39,7 @@
int mhdf_check_valid_file( FileHandle* handle, mhdf_Status* status );
#ifdef __cplusplus
-} // extern "C"
+} /* extern "C" */
#endif
#endif
Modified: MOAB/trunk/mhdf/src/names-and-paths.h
===================================================================
--- MOAB/trunk/mhdf/src/names-and-paths.h 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/names-and-paths.h 2009-04-07 20:50:16 UTC (rev 2806)
@@ -44,7 +44,8 @@
/* Node paths */
#define NODE_GROUP_NAME "nodes"
#define NODE_GROUP ROOT_GROUP NODE_GROUP_NAME "/"
-#define NODE_COORD_PATH NODE_GROUP "coordinates"
+#define NODE_COORD_NAME "coordinates"
+#define NODE_COORD_PATH NODE_GROUP NODE_COORD_NAME
#define NODE_TAG_GROUP NODE_GROUP DENSE_TAG_SUBGROUP
#define NODE_ADJCY_PATH NODE_GROUP ADJACENCY_NAME
Modified: MOAB/trunk/mhdf/src/nodes.c
===================================================================
--- MOAB/trunk/mhdf/src/nodes.c 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/nodes.c 2009-04-07 20:50:16 UTC (rev 2806)
@@ -16,12 +16,63 @@
#include <H5Tpublic.h>
#include <H5Dpublic.h>
#include <H5Ppublic.h>
+#include <H5Gpublic.h>
#include "mhdf.h"
#include "status.h"
#include "names-and-paths.h"
#include "util.h"
#include "file-handle.h"
+
+int
+mhdf_haveNodes( mhdf_FileHandle file, mhdf_Status* status )
+{
+ FileHandle* file_ptr = (FileHandle*)file;
+ hid_t root_id, node_id;
+ int result;
+ API_BEGIN;
+
+ if (!mhdf_check_valid_file( file_ptr, status ))
+ return -1;
+
+#if defined(H5Gopen_vers) && H5Gopen_vers > 1
+ root_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );
+#else
+ root_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );
+#endif
+ if (root_id < 0)
+ {
+ mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", ROOT_GROUP );
+ return -1;
+ }
+
+ result = mhdf_is_in_group( root_id, NODE_GROUP_NAME, status );
+ if (result < 1)
+ {
+ H5Gclose(root_id);
+ return result;
+ }
+
+#if defined(H5Gopen_vers) && H5Gopen_vers > 1
+ node_id = H5Gopen2( root_id, NODE_GROUP_NAME, H5P_DEFAULT );
+#else
+ node_id = H5Gopen( root_id, NODE_GROUP_NAME );
+#endif
+ H5Gclose( root_id );
+ if (node_id < 0)
+ {
+ mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", NODE_GROUP );
+ return -1;
+ }
+
+ result = mhdf_is_in_group( node_id, NODE_COORD_NAME, status );
+ if (result >= 0)
+ mhdf_setOkay( status );
+ H5Gclose( node_id );
+ API_END;
+ return result;
+}
+
hid_t
mhdf_createNodeCoords( mhdf_FileHandle file_handle,
int dimension,
Modified: MOAB/trunk/mhdf/src/sets.c
===================================================================
--- MOAB/trunk/mhdf/src/sets.c 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/sets.c 2009-04-07 20:50:16 UTC (rev 2806)
@@ -231,11 +231,13 @@
mhdf_Status* status )
{
hid_t slab_id, sslab_id, smem_id, mem_id;
- hsize_t offsets[2], counts[2], mcounts[2] = {count,4}, moffsets[2] = {0,0};
+ hsize_t offsets[2], counts[2], mcounts[2], moffsets[2] = {0,0};
herr_t rval = 0;
int dims, i;
const int fill_val = -1;
+ mcounts[0] = count;
+ mcounts[1] = 4;
if (offset < 0 || count < 0)
{
mhdf_setFail( status, "Invalid input for %s: "
Modified: MOAB/trunk/mhdf/src/util.h
===================================================================
--- MOAB/trunk/mhdf/src/util.h 2009-04-07 19:42:16 UTC (rev 2805)
+++ MOAB/trunk/mhdf/src/util.h 2009-04-07 20:50:16 UTC (rev 2806)
@@ -159,7 +159,7 @@
#ifdef __cplusplus
-} // extern "C"
+} /* extern "C" */
#endif
#endif
More information about the moab-dev
mailing list