30 #include <Structure.h>
59 if (btp->type() != dods_structure_c)
60 throw Error(
"In function roi(): Expected an Array of Structures for the slice information.");
64 Constructor::Vars_iter i = slice->var_begin();
65 if (i == slice->var_end() || (*i)->name() !=
"start" || (*i)->type() != dods_int32_c)
66 throw Error(
"In function roi(): Could not find valid 'start' field in slice information");
69 if (i == slice->var_end() || (*i)->name() !=
"stop" || (*i)->type() != dods_int32_c)
70 throw Error(
"In function roi(): Could not find valid 'stop' field in slice information");
73 if (i == slice->var_end() || (*i)->name() !=
"name" || (*i)->type() != dods_str_c)
74 throw Error(
"In function roi(): Could not find valid 'name' field in slice information");
93 throw InternalErr(__FILE__, __LINE__,
"Function called with null slice array.");
95 if (btp->type() != dods_array_c)
96 throw Error(
"Function expected last argument to be a Bounding Box (i.e., an Array of Structures) (1).");
98 Array *slices =
static_cast<Array*
>(btp);
99 if (slices->dimensions() != 1)
100 throw Error(
"Function expected last argument to be a Bounding Box (i.e., an Array of Structures) (2).");
102 int rank = slices->dimension_size(slices->dim_begin());
103 for (
int i = 0; i < rank; ++i) {
124 BaseType *btp = slices->var(i);
127 Constructor::Vars_iter vi = slice->var_begin();
129 start =
static_cast<Int32*
>(*vi++)->value();
130 stop =
static_cast<Int32*
>(*vi++)->value();
131 name =
static_cast<Str*
>(*vi++)->value();
158 start->set_value(start_value);
159 slice->add_var_nocopy(start);
162 stop->set_value(stop_value);
163 slice->add_var_nocopy(stop);
165 Str *name =
new Str(
"name");
166 name->set_value(dim_name);
167 slice->add_var_nocopy(name);
169 slice->set_read_p(
true);
170 slice->set_send_p(
true);
198 proto->add_var_nocopy(
new Int32(
"start"));
199 proto->add_var_nocopy(
new Int32(
"stop"));
200 proto->add_var_nocopy(
new Str(
"name"));
202 auto_ptr<Array> response(
new Array(bbox_name, proto));
204 response->append_dim(num_dim, bbox_name);
void roi_bbox_valid_slice(BaseType *btp)
Each Bounding Box is made up of a number of 'slices' - test if a given one is valid.
void roi_bbox_get_slice_data(Array *slices, unsigned int i, int &start, int &stop, string &name)
This method extracts values from one element of the Bounding Box (i.e., Array of Structures).
unsigned int roi_valid_bbox(BaseType *btp)
Is the bound box valid?
Structure * roi_bbox_build_slice(unsigned int start_value, unsigned int stop_value, const string &dim_name)
Build a single element of a bounding box.
static class NCMLUtil overview
auto_ptr< Array > roi_bbox_build_empty_bbox(unsigned int num_dim, const string &bbox_name)
Build an empty Bounding Box using DAP variables.