31#include <libdap/BaseType.h>
32#include <libdap/Int32.h>
33#include <libdap/Str.h>
34#include <libdap/Array.h>
35#include <libdap/Structure.h>
37#include <libdap/D4RValue.h>
38#include <libdap/Error.h>
39#include <libdap/debug.h>
40#include <libdap/util.h>
41#include <libdap/ServerFunctionsList.h>
43#include "BBoxCombFunction.h"
66function_dap2_bbox_comb(
int argc, BaseType *argv[], DDS &, BaseType **btpp)
68 const string wrong_args =
"Wrong number of arguments to bbox_comb(). Expected two bounding boxes";
70 unsigned int rank = 0;
72 unsigned int rnk2 = 0;
77 rnk1 = roi_valid_bbox(argv[0]);
78 rnk2 = roi_valid_bbox(argv[1]);
82 throw Error(malformed_expr, wrong_args);
91 vector<slice> combo(rank);
94 for (
unsigned int i = 0; i < rnk1; ++i) {
99 roi_bbox_get_slice_data(
static_cast<Array*
>(argv[0]), i, start, stop, name);
101 combo.at(i).start = start;
102 combo.at(i).stop = stop;
103 combo.at(i).name = name;
106 for (
unsigned int j = 0; j < rnk2; ++j) {
111 roi_bbox_get_slice_data(
static_cast<Array*
>(argv[1]), j, start, stop, name);
112 if(combo.at(j).name != name){
113 combo.at(rnk1+j).start = start;
114 combo.at(rnk1+j).stop = stop;
115 combo.at(rnk1+j).name = name;
120 unique_ptr<Array> response = roi_bbox_build_empty_bbox(rank);
121 for (
unsigned int k = 0; k < rank; ++k) {
122 Structure *
slice = roi_bbox_build_slice(combo.at(k).start, combo.at(k).stop, combo.at(k).name);
123 response->set_vec_nocopy(k,
slice);
126 *btpp = response.release();