summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-03-10 23:50:03 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-03-10 23:50:03 (GMT)
commitae782bd7ac0d7f3342d4317cbcd487d4bfefc206 (patch)
tree43c7965a2a9a3014f8b27915e0a5685919907dd2
parent354a6dcc0120bc857a22736fb0eb3d7cdda11525 (diff)
downloadhdf5-ae782bd7ac0d7f3342d4317cbcd487d4bfefc206.zip
hdf5-ae782bd7ac0d7f3342d4317cbcd487d4bfefc206.tar.gz
hdf5-ae782bd7ac0d7f3342d4317cbcd487d4bfefc206.tar.bz2
[svn-r1132] Dataset region references are now finished and working correctly. Also, there
are five new API functions for querying selections: H5Sget_select_hyper_nblocks - retrieves the number of hyperslab blocks in current hyperslab selection for a dataspace H5Sget_select_elem_npoints - retrieves the number of element points in current element selection for a dataspace H5Sget_select_hyper_blocklist - retrieves a list of the hyperslab blocks in current hyperslab selection for a dataspace H5Sget_select_elem_pointlist - retrieves a list of the element points in current element selection for a dataspace H5Sget_select_bounds - retrieves a n-dimensional bounding box containing current selection.
-rw-r--r--src/H5R.c14
-rw-r--r--src/H5Sall.c50
-rw-r--r--src/H5Shyper.c58
-rw-r--r--src/H5Spoint.c58
-rw-r--r--src/H5Sprivate.h6
-rw-r--r--src/H5Spublic.h5
-rw-r--r--src/H5Sselect.c577
7 files changed, 700 insertions, 68 deletions
diff --git a/src/H5R.c b/src/H5R.c
index 261aae1..3844072 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -370,9 +370,6 @@ H5R_dereference(H5D_t *dset, H5R_type_t ref_type, void *_ref)
INT32DECODE(p,hobjid.idx);
/* Get the dataset region from the heap (allocate inside routine) */
- printf("%s: hobjid.addr=",FUNC);
- H5F_addr_print(stdout,&hobjid.addr);
- printf(", hobjid.idx=%d\n", hobjid.idx);
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL,
"Unable to read dataset region information");
@@ -528,13 +525,18 @@ H5R_get_region(H5D_t *dset, H5R_type_t __unused__ ref_type, void *_ref)
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found");
}
-/* Unserialize the selection */
+ /* Unserialize the selection */
+ if (H5S_select_deserialize(ret_value,p) < 0) {
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection");
+ }
/* Free the buffer allocated in H5HG_read() */
H5MM_xfree(buf);
-/* Close the dataset we opened */
-
+ /* Close the dataset we opened */
+ if (H5D_close(dataset) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "not found");
+ }
done:
FUNC_LEAVE(ret_value);
diff --git a/src/H5Sall.c b/src/H5Sall.c
index c5cf909..3a6eb0a 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -640,3 +640,53 @@ H5S_all_select_deserialize (H5S_t *space, const uint8_t __unused__ *buf)
done:
FUNC_LEAVE (ret_value);
} /* H5S_all_select_deserialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_all_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_all_bounds(space, hsize_t *start, hsize_t *end)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8). Calling this function on a "none" selection
+ returns fail.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+{
+ intn rank; /* Dataspace rank */
+ intn i; /* index variable */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_all_bounds, FAIL);
+
+ assert(space);
+ assert(start);
+ assert(end);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Just copy over the complete extent */
+ for(i=0; i<rank; i++) {
+ start[i]=0;
+ end[i]=space->extent.u.simple.size[i]-1;
+ } /* end for */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_all_bounds() */
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 62ac6f0..c2a94fb 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -2863,3 +2863,61 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_select_deserialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_hyper_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_hyper_bounds(space, hsize_t *start, hsize_t *end)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8).
+ The bounding box calculations _does_ include the current offset of the
+ selection within the dataspace extent.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+{
+ H5S_hyper_node_t *node; /* Hyperslab node */
+ intn rank; /* Dataspace rank */
+ intn i; /* index variable */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_hyper_bounds, FAIL);
+
+ assert(space);
+ assert(start);
+ assert(end);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Iterate through the node, copying each hyperslab's information */
+ node=space->select.sel_info.hslab.hyper_lst->head;
+ while(node!=NULL) {
+ for(i=0; i<rank; i++) {
+ if(start[i]>(hsize_t)(node->start[i]+space->select.offset[i]))
+ start[i]=node->start[i]+space->select.offset[i];
+ if(end[i]<(hsize_t)(node->end[i]+space->select.offset[i]))
+ end[i]=node->end[i]+space->select.offset[i];
+ } /* end for */
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_hyper_bounds() */
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 581a1c3..60a816c 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -1010,3 +1010,61 @@ done:
FUNC_LEAVE (ret_value);
} /* H5S_point_select_deserialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_point_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_point_bounds(space, hsize_t *start, hsize_t *end)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8).
+ The bounding box calculations _does_ include the current offset of the
+ selection within the dataspace extent.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+{
+ H5S_pnt_node_t *node; /* Point node */
+ intn rank; /* Dataspace rank */
+ intn i; /* index variable */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_point_bounds, FAIL);
+
+ assert(space);
+ assert(start);
+ assert(end);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Iterate through the node, checking the bounds on each element */
+ node=space->select.sel_info.pnt_lst->head;
+ while(node!=NULL) {
+ for(i=0; i<rank; i++) {
+ if(start[i]>(hsize_t)(node->pnt[i]+space->select.offset[i]))
+ start[i]=node->pnt[i]+space->select.offset[i];
+ if(end[i]<(hsize_t)(node->pnt[i]+space->select.offset[i]))
+ end[i]=node->pnt[i]+space->select.offset[i];
+ } /* end for */
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_point_bounds() */
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index cb0f6f4..e81aa4f 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -333,6 +333,7 @@ __DLL__ herr_t H5S_register(H5S_sel_type cls, const H5S_fconv_t *fconv,
__DLL__ hssize_t H5S_select_serial_size(const H5S_t *space);
__DLL__ herr_t H5S_select_serialize(const H5S_t *space, uint8_t *buf);
__DLL__ herr_t H5S_select_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_get_select_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
/* Point select functions */
__DLL__ herr_t H5S_point_add(H5S_t *space, size_t num_elemn,
@@ -344,12 +345,14 @@ __DLL__ htri_t H5S_point_select_valid(const H5S_t *space);
__DLL__ hssize_t H5S_point_select_serial_size(const H5S_t *space);
__DLL__ herr_t H5S_point_select_serialize(const H5S_t *space, uint8_t *buf);
__DLL__ herr_t H5S_point_select_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_point_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
/* "All" select functions */
__DLL__ herr_t H5S_all_release(H5S_t *space);
__DLL__ hsize_t H5S_all_npoints(const H5S_t *space);
__DLL__ herr_t H5S_all_select_serialize(const H5S_t *space, uint8_t *buf);
__DLL__ herr_t H5S_all_select_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_all_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
/* Hyperslab selection functions */
__DLL__ herr_t H5S_hyper_add(H5S_t *space, const hssize_t *start,
@@ -370,6 +373,7 @@ __DLL__ herr_t H5S_hyper_clip(H5S_t *space, H5S_hyper_node_t *nodes,
__DLL__ hssize_t H5S_hyper_select_serial_size(const H5S_t *space);
__DLL__ herr_t H5S_hyper_select_serialize(const H5S_t *space, uint8_t *buf);
__DLL__ herr_t H5S_hyper_select_deserialize(H5S_t *space, const uint8_t *buf);
+__DLL__ herr_t H5S_hyper_bounds(H5S_t *space, hsize_t *start, hsize_t *end);
/* "None" selection functions */
__DLL__ herr_t H5S_none_select_serialize(const H5S_t *space, uint8_t *buf);
@@ -401,5 +405,7 @@ __DLL__ herr_t H5S_mpio_spaces_write(H5F_t *f,
/* Global var whose value comes from environment variable */
__DLLVAR__ hbool_t H5_mpi_opt_types_g;
#endif /* _H5S_IN_H5S_C */
+
#endif /* HAVE_PARALLEL */
+
#endif /* _H5Sprivate_H */
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 14ab189..5e0fd28 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -82,6 +82,11 @@ __DLL__ herr_t H5Sselect_all(hid_t spaceid);
__DLL__ herr_t H5Sselect_none(hid_t spaceid);
__DLL__ herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset);
__DLL__ htri_t H5Sselect_valid(hid_t spaceid);
+__DLL__ hssize_t H5Sget_select_hyper_nblocks(hid_t spaceid);
+__DLL__ hssize_t H5Sget_select_elem_npoints(hid_t spaceid);
+__DLL__ herr_t H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t *buf);
+__DLL__ herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t *buf);
+__DLL__ herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end);
#ifdef __cplusplus
}
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 8f1384d..5efa4d8 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -21,6 +21,11 @@
#define INTERFACE_INIT NULL
static intn interface_initialize_g = 0;
+static hssize_t H5S_get_select_hyper_nblocks(H5S_t *space);
+static hssize_t H5S_get_select_elem_npoints(H5S_t *space);
+static herr_t H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t *buf);
+static herr_t H5S_get_select_elem_pointlist(H5S_t *space, hsize_t *buf);
+
/*--------------------------------------------------------------------------
NAME
@@ -159,68 +164,6 @@ H5S_select_release (H5S_t *space)
FUNC_LEAVE (ret_value);
} /* H5S_select_release() */
-/*--------------------------------------------------------------------------
- NAME
- H5Sselect_hyperslab
- PURPOSE
- Specify a hyperslab to combine with the current hyperslab selection
- USAGE
- herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block)
- hid_t dsid; IN: Dataspace ID of selection to modify
- H5S_seloper_t op; IN: Operation to perform on current selection
- const hssize_t *start; IN: Offset of start of hyperslab
- const hssize_t *stride; IN: Hyperslab stride
- const hssize_t *count; IN: Number of blocks included in hyperslab
- const hssize_t *block; IN: Size of block in hyperslab
- RETURNS
- Non-negative on success/Negative on failure
- DESCRIPTION
- Combines a hyperslab selection with the current selection for a dataspace.
- If the current selection is not a hyperslab, it is freed and the hyperslab
- parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a
- selection composing the entire current extent). Currently, only the
- H5S_SELECT_SET & H5S_SELECT_OR operations are supported. If STRIDE or
- BLOCK is NULL, they are assumed to be set to all '1'.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-herr_t
-H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
- const hssize_t start[/*space_id*/],
- const hsize_t _stride[/*space_id*/],
- const hsize_t count[/*space_id*/],
- const hsize_t _block[/*space_id*/])
-{
- H5S_t *space = NULL; /* Dataspace to modify selection of */
-
- FUNC_ENTER (H5Sselect_hyperslab, FAIL);
- H5TRACE6("e","iSs*[a0]Hs*[a0]h*[a0]h*[a0]h",space_id,op,start,_stride,
- count,_block);
-
- /* Check args */
- if (H5I_DATASPACE != H5I_get_type(space_id) ||
- NULL == (space=H5I_object(space_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if(start==NULL || count==NULL) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
- } /* end if */
-
- if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID)) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
- } /* end if */
-
- if (H5S_select_hyperslab(space, op, start, _stride, count, _block)<0) {
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "unable to set hyperslab selection");
- }
-
- FUNC_LEAVE (SUCCEED);
-}
-
-
/*-------------------------------------------------------------------------
* Function: H5S_select_hyperslab
*
@@ -435,6 +378,67 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5Sselect_hyperslab
+ PURPOSE
+ Specify a hyperslab to combine with the current hyperslab selection
+ USAGE
+ herr_t H5Sselect_hyperslab(dsid, op, start, stride, count, block)
+ hid_t dsid; IN: Dataspace ID of selection to modify
+ H5S_seloper_t op; IN: Operation to perform on current selection
+ const hssize_t *start; IN: Offset of start of hyperslab
+ const hssize_t *stride; IN: Hyperslab stride
+ const hssize_t *count; IN: Number of blocks included in hyperslab
+ const hssize_t *block; IN: Size of block in hyperslab
+ RETURNS
+ Non-negative on success/Negative on failure
+ DESCRIPTION
+ Combines a hyperslab selection with the current selection for a dataspace.
+ If the current selection is not a hyperslab, it is freed and the hyperslab
+ parameters passed in are combined with the H5S_SEL_ALL hyperslab (ie. a
+ selection composing the entire current extent). Currently, only the
+ H5S_SELECT_SET & H5S_SELECT_OR operations are supported. If STRIDE or
+ BLOCK is NULL, they are assumed to be set to all '1'.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op,
+ const hssize_t start[/*space_id*/],
+ const hsize_t _stride[/*space_id*/],
+ const hsize_t count[/*space_id*/],
+ const hsize_t _block[/*space_id*/])
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+
+ FUNC_ENTER (H5Sselect_hyperslab, FAIL);
+ H5TRACE6("e","iSs*[a0]Hs*[a0]h*[a0]h*[a0]h",space_id,op,start,_stride,
+ count,_block);
+
+ /* Check args */
+ if (H5I_DATASPACE != H5I_get_type(space_id) ||
+ NULL == (space=H5I_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if(start==NULL || count==NULL) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
+ } /* end if */
+
+ if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
+ } /* end if */
+
+ if (H5S_select_hyperslab(space, op, start, _stride, count, _block)<0) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "unable to set hyperslab selection");
+ }
+
+ FUNC_LEAVE (SUCCEED);
+}
+
+/*--------------------------------------------------------------------------
+ NAME
H5S_select_elements
PURPOSE
Specify a series of elements in the dataspace to select
@@ -1127,3 +1131,452 @@ H5S_select_deserialize (H5S_t *space, const uint8_t *buf)
FUNC_LEAVE (ret_value);
} /* H5S_select_deserialize() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_hyper_nblocks
+ PURPOSE
+ Get the number of hyperslab blocks in current hyperslab selection
+ USAGE
+ hssize_t H5S_get_select_hyper_nblocks(space)
+ H5S_t *space; IN: Dataspace ptr of selection to query
+ RETURNS
+ The number of hyperslab blocks in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of hyperslab blocks in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static hssize_t
+H5S_get_select_hyper_nblocks(H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5S_get_select_hyper_nblocks, FAIL);
+
+ assert(space);
+
+ ret_value = space->select.sel_info.hslab.hyper_lst->count;
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_nblocks() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_hyper_nblocks
+ PURPOSE
+ Get the number of hyperslab blocks in current hyperslab selection
+ USAGE
+ hssize_t H5Sget_select_hyper_nblocks(dsid)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ RETURNS
+ The number of hyperslab blocks in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of hyperslab blocks in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5Sget_select_hyper_nblocks(hid_t spaceid)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Sget_select_hyper_nblocks, FAIL);
+
+ /* Check args */
+ if (H5I_DATASPACE != H5I_get_type(spaceid) ||
+ NULL == (space=H5I_object(spaceid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if(space->select.type!=H5S_SEL_HYPERSLABS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+
+ ret_value = H5S_get_select_hyper_nblocks(space);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_nblocks() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_elem_npoints
+ PURPOSE
+ Get the number of points in current element selection
+ USAGE
+ hssize_t H5S_get_select_elem_npoints(space)
+ H5S_t *space; IN: Dataspace ptr of selection to query
+ RETURNS
+ The number of element points in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of element points in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static hssize_t
+H5S_get_select_elem_npoints(H5S_t *space)
+{
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5S_get_select_elem_npoints, FAIL);
+
+ assert(space);
+
+ ret_value = space->select.num_elem;
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_npoints() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_elem_npoints
+ PURPOSE
+ Get the number of points in current element selection
+ USAGE
+ hssize_t H5Sget_select_elem_npoints(dsid)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ RETURNS
+ The number of element points in selection on success, negative on failure
+ DESCRIPTION
+ Returns the number of element points in current selection for dataspace.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+hssize_t
+H5Sget_select_elem_npoints(hid_t spaceid)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ hssize_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Sget_select_elem_npoints, FAIL);
+
+ /* Check args */
+ if (H5I_DATASPACE != H5I_get_type(spaceid) ||
+ NULL == (space=H5I_object(spaceid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if(space->select.type!=H5S_SEL_POINTS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection");
+
+ ret_value = H5S_get_select_elem_npoints(space);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_npoints() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_hyper_blocklist
+ PURPOSE
+ Get the list of hyperslab blocks currently selected
+ USAGE
+ herr_t H5S_get_select_hyper_blocklist(space, hsize_t *buf)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *buf; OUT: List of hyperslab blocks selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the hyperslab blocks into the user's buffer. The block
+ coordinates have the same dimensionality (rank) as the dataspace they
+ are located within. The list of blocks is formatted as follows:
+ <"start" coordinate> immediately followed by <"opposite" corner coordinate>,
+ followed by the next "start" coordinate, etc. until all the block
+ information in the selection have been put into the user's buffer. No
+ guarantee of any order of the blocks is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t *buf)
+{
+ H5S_hyper_node_t *node; /* Hyperslab node */
+ intn rank; /* Dataspace rank */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_get_select_hyper_blocklist, FAIL);
+
+ assert(space);
+ assert(buf);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Iterate through the node, copying each hyperslab's information */
+ node=space->select.sel_info.hslab.hyper_lst->head;
+ while(node!=NULL) {
+ HDmemcpy(buf,node->start,sizeof(hsize_t)*rank);
+ buf+=rank;
+ HDmemcpy(buf,node->end,sizeof(hsize_t)*rank);
+ buf+=rank;
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_blocklist() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_hyper_blocklist
+ PURPOSE
+ Get the list of hyperslab blocks currently selected
+ USAGE
+ herr_t H5Sget_select_hyper_blocklist(dsid, hsize_t *buf)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ hsize_t *buf; OUT: List of hyperslab blocks selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the hyperslab blocks into the user's buffer. The block
+ coordinates have the same dimensionality (rank) as the dataspace they
+ are located within. The list of blocks is formatted as follows:
+ <"start" coordinate> immediately followed by <"opposite" corner coordinate>,
+ followed by the next "start" coordinate, etc. until all the block
+ information in the selection have been put into the user's buffer. No
+ guarantee of any order of the blocks is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t *buf)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Sget_select_hyper_blocklist, FAIL);
+
+ /* Check args */
+ if(buf==NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (H5I_DATASPACE != H5I_get_type(spaceid) ||
+ NULL == (space=H5I_object(spaceid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if(space->select.type!=H5S_SEL_HYPERSLABS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+
+ ret_value = H5S_get_select_hyper_blocklist(space,buf);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_hyper_blocklist() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_elem_pointlist
+ PURPOSE
+ Get the list of element points currently selected
+ USAGE
+ herr_t H5S_get_select_elem_pointlist(space, hsize_t *buf)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *buf; OUT: List of element points selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the element points into the user's buffer. The point
+ coordinates have the same dimensionality (rank) as the dataspace they
+ are located within. The list of points is formatted as follows:
+ <coordinate> followed by the next coordinate, etc. until all the point
+ information in the selection have been put into the user's buffer. No
+ guarantee of any order of the elements is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_get_select_elem_pointlist(H5S_t *space, hsize_t *buf)
+{
+ H5S_pnt_node_t *node; /* Point node */
+ intn rank; /* Dataspace rank */
+ herr_t ret_value=SUCCEED; /* return value */
+
+ FUNC_ENTER (H5S_get_select_elem_pointlist, FAIL);
+
+ assert(space);
+ assert(buf);
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Iterate through the node, copying each hyperslab's information */
+ node=space->select.sel_info.pnt_lst->head;
+ while(node!=NULL) {
+ HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank);
+ buf+=rank;
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_pointlist() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_elem_pointlist
+ PURPOSE
+ Get the list of element points currently selected
+ USAGE
+ herr_t H5Sget_select_elem_pointlist(dsid, hsize_t *buf)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ hsize_t *buf; OUT: List of element points selected
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Puts a list of the element points into the user's buffer. The point
+ coordinates have the same dimensionality (rank) as the dataspace they
+ are located within. The list of points is formatted as follows:
+ <coordinate> followed by the next coordinate, etc. until all the point
+ information in the selection have been put into the user's buffer. No
+ guarantee of any order of the elements is implied.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t *buf)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Sget_select_elem_pointlist, FAIL);
+
+ /* Check args */
+ if(buf==NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (H5I_DATASPACE != H5I_get_type(spaceid) ||
+ NULL == (space=H5I_object(spaceid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if(space->select.type!=H5S_SEL_POINTS)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection");
+
+ ret_value = H5S_get_select_elem_pointlist(space,buf);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_elem_pointlist() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_get_select_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_get_select_bounds(space, hsize_t *start, hsize_t *end)
+ H5S_t *space; IN: Dataspace pointer of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8). Calling this function on a "none" selection
+ returns fail.
+ The bounding box calculations _does_ include the current offset of the
+ selection within the dataspace extent.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+static herr_t
+H5S_get_select_bounds(H5S_t *space, hsize_t *start, hsize_t *end)
+{
+ intn rank; /* Dataspace rank */
+ intn i; /* index variable */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5S_get_select_bounds, FAIL);
+
+ assert(space);
+ assert(start);
+ assert(end);
+
+ /* Set all the start and end arrays up */
+ rank=space->extent.u.simple.rank;
+ for(i=0; i<rank; i++) {
+ start[i]=UINT_MAX;
+ end[i]=0;
+ } /* end for */
+
+ switch(space->select.type) {
+ case H5S_SEL_POINTS: /* Sequence of points selected */
+ ret_value=H5S_point_bounds(space,start,end);
+ break;
+
+ case H5S_SEL_HYPERSLABS: /* Hyperslab selection defined */
+ ret_value=H5S_hyper_bounds(space,start,end);
+ break;
+
+ case H5S_SEL_ALL: /* Entire extent selected */
+ ret_value=H5S_all_bounds(space,start,end);
+ break;
+
+ case H5S_SEL_NONE: /* Nothing selected */
+ case H5S_SEL_ERROR:
+ case H5S_SEL_N:
+ break;
+ }
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_bounds() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5Sget_select_bounds
+ PURPOSE
+ Gets the bounding box containing the selection.
+ USAGE
+ herr_t H5S_get_select_bounds(space, start, end)
+ hid_t dsid; IN: Dataspace ID of selection to query
+ hsize_t *start; OUT: Starting coordinate of bounding box
+ hsize_t *end; OUT: Opposite coordinate of bounding box
+ RETURNS
+ Non-negative on success, negative on failure
+ DESCRIPTION
+ Retrieves the bounding box containing the current selection and places
+ it into the user's buffers. The start and end buffers must be large
+ enough to hold the dataspace rank number of coordinates. The bounding box
+ exactly contains the selection, ie. if a 2-D element selection is currently
+ defined with the following points: (4,5), (6,8) (10,7), the bounding box
+ with be (4, 5), (10, 8). Calling this function on a "none" selection
+ returns fail.
+ The bounding box calculations _does_ include the current offset of the
+ selection within the dataspace extent.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
+{
+ H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=FAIL; /* return value */
+
+ FUNC_ENTER (H5Sget_select_bounds, FAIL);
+
+ /* Check args */
+ if(start==NULL || end==NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ if (H5I_DATASPACE != H5I_get_type(spaceid) ||
+ NULL == (space=H5I_object(spaceid))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+
+ ret_value = H5S_get_select_bounds(space,start,end);
+
+ FUNC_LEAVE (ret_value);
+} /* H5Sget_select_bounds() */