diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2019-11-18 17:53:50 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-05-20 14:19:38 (GMT) |
commit | c7c302a64be0210ee6306f3733abac44bff929da (patch) | |
tree | ead0ec34f705dfaeacd2880ad8afbf284f12e2b5 /src/H5Spoint.c | |
parent | fcfc5700df042ae6f084e8d951d84f60ede3fdef (diff) | |
download | hdf5-c7c302a64be0210ee6306f3733abac44bff929da.zip hdf5-c7c302a64be0210ee6306f3733abac44bff929da.tar.gz hdf5-c7c302a64be0210ee6306f3733abac44bff929da.tar.bz2 |
Replace H5Sselect_adjust_u() and H5Shyper_adjust_s() with
H5Sselect_adjust. Implement "adjust_s" callback for all selection
types. Add range checking to H5Sselect_adjust().
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r-- | src/H5Spoint.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c index ea6c9c5..d501a4a 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -78,7 +78,8 @@ static htri_t H5S__point_shape_same(const H5S_t *space1, const H5S_t *space2); static htri_t H5S__point_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end); static herr_t H5S__point_adjust_u(H5S_t *space, const hsize_t *offset); -static herr_t H5S__point_project_scalar(const H5S_t *space, hsize_t *offset); +static herr_t H5S__point_adjust_s(H5S_t *space, const hssize_t *offset); +static herr_t H5S__point_project_scalar(const H5S_t *spasce, hsize_t *offset); static herr_t H5S__point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset); static herr_t H5S__point_iter_init(const H5S_t *space, H5S_sel_iter_t *iter); @@ -128,6 +129,7 @@ const H5S_select_class_t H5S_sel_point[1] = {{ H5S__point_shape_same, H5S__point_intersect_block, H5S__point_adjust_u, + H5S__point_adjust_s, H5S__point_project_scalar, H5S__point_project_simple, H5S__point_iter_init, @@ -2114,6 +2116,64 @@ H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) } /* end H5S__point_adjust_u() */ +/*-------------------------------------------------------------------------- + NAME + H5S__point_adjust_s + PURPOSE + Adjust a "point" selection by subtracting an offset + USAGE + herr_t H5S__point_adjust_u(space, offset) + H5S_t *space; IN/OUT: Pointer to dataspace to adjust + const hssize_t *offset; IN: Offset to subtract + RETURNS + Non-negative on success, negative on failure + DESCRIPTION + Moves a point selection by subtracting an offset from it. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static herr_t +H5S__point_adjust_s(H5S_t *space, const hssize_t *offset) +{ + H5S_pnt_node_t *node; /* Point node */ + unsigned rank; /* Dataspace rank */ + unsigned u; /* Local index variable */ + + FUNC_ENTER_STATIC_NOERR + + HDassert(space); + HDassert(offset); + + /* Iterate through the nodes, checking the bounds on each element */ + node = space->select.sel_info.pnt_lst->head; + rank = space->extent.rank; + while(node) { + /* Adjust each coordinate for point node */ + for(u = 0; u < rank; u++) { + /* Check for offset moving selection negative */ + HDassert((hssize_t)node->pnt[u] >= offset[u]); + + /* Adjust node's coordinate location */ + node->pnt[u] = (hsize_t)((hssize_t)node->pnt[u] - offset[u]); + } /* end for */ + + /* Advance to next point node in selection */ + node = node->next; + } /* end while */ + + /* update the bound box of the selection */ + for(u = 0; u < rank; u++) { + HDassert((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] >= offset[u]); + space->select.sel_info.pnt_lst->low_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->low_bounds[u] - offset[u]); + space->select.sel_info.pnt_lst->high_bounds[u] = (hsize_t)((hssize_t)space->select.sel_info.pnt_lst->high_bounds[u] - offset[u]); + } /* end for */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5S__point_adjust_s() */ + + /*------------------------------------------------------------------------- * Function: H5S__point_project_scalar * |