32#include <libdap/BaseType.h>
33#include <libdap/Int32.h>
34#include <libdap/Str.h>
35#include <libdap/Array.h>
36#include <libdap/Structure.h>
38#include <libdap/D4RValue.h>
39#include <libdap/Error.h>
40#include <libdap/debug.h>
41#include <libdap/util.h>
42#include <libdap/ServerFunctionsList.h>
47#include "RoiFunction.h"
48#include "functions_util.h"
77function_dap2_roi(
int argc, BaseType *argv[], DDS &, BaseType **btpp)
79 const string wrong_args =
"Wrong number of arguments to roi(). Expected one or more Arrays and bounding box";
88 throw Error(malformed_expr, wrong_args);
90 rank = roi_valid_bbox(argv[argc-1]);
93 unique_ptr<Structure> response(
new Structure(
"roi_subset_unwrap"));
95 auto bbox =
static_cast<Array*
>(argv[argc-1]);
97 for (
int i = 0; i < argc-1; ++i) {
99 auto the_array =
static_cast<Array*
>(argv[i]);
109 for (
int i = rank-1; i >= 0; --i) {
113 roi_bbox_get_slice_data(bbox, i, start, stop, name);
115 for (
auto iter = the_array->dim_begin(); iter< the_array->dim_end(); iter++){
116 string cname = the_array->dimension_name(iter);
117 if (the_array->dimension_name(iter) != name)
continue;
118 the_array->add_constraint(iter, start, 1 , stop);
123 the_array->set_send_p(
true);
129 the_array->set_read_p(
false);
131 the_array->set_read_p(
true);
133 response->add_var(the_array);
136 response->set_send_p(
true);
137 response->set_read_p(
true);
139 *btpp = response.release();
151BaseType *function_dap4_roi(D4RValueList *, DMR &)
153 throw Error(malformed_expr,
"Not yet implemented for DAP4 functions.");