Commit ee408e76 authored by Théotime Bollengier's avatar Théotime Bollengier
Browse files

fail

parent 89b4b97d
......@@ -254,8 +254,65 @@ static VALUE vibes_figure_set_axis_labels(VALUE self, VALUE arr)
}
/* Draw a N-D box.
* @return [self]
* @overload draw_box(box)
* @param box [Rubex::Box] an interval vector
* @overload draw_box(i1, i2, ...)
* @param i1 [Numeric, Array<Numeric>, Range, Rubex::Interval]
*/
static VALUE vibes_figure_draw_box(int argc, VALUE *argv, VALUE self)
{
VALUE arr = Qnil, opt = Qnil, el, beg, end;
std::vector<double> coordvec();
std::string format();
vibes::Params params();
int arlen, i, ail;
double tmp, l, u;
rb_scan_args(argc, argv, "00*0:", &arr, &opt);
if (arr != Qnil) {
arlen = rb_array_len(arr);
for (i = 0; i < arlen; i++) {
el = rb_ary_entry(arr, i);
if (rb_obj_is_kind_of(el, rb_cString))
format = std::string(StringValueCStr(el));
else if (rb_obj_is_kind_of(el, rb_cNumeric))
coordvec.push_back(NUM2DBL(el));
else if (rb_obj_is_kind_of(el, rb_cRange)) {
rb_range_values(el, &beg, &end, NULL);
l = NUM2DBL(beg);
u = NUM2DBL(end);
if (l > u) {
tmp = l;
l = u;
u = tmp;
}
coordvec.push_back(l);
coordvec.push_back(u);
}
else if (rb_obj_is_kind_of(el, rb_cArray)) {
ail = rb_array_len(el);
if (ail < 1 || ail > 2)
rb_raise(rb_eArgError, "an array taken as interval should have 1 or to elements, not %d", ail);
l = NUM2DBL(rb_ary_entry(el, 0));
if (ail == 2)
u = NUM2DBL(rb_ary_entry(el, 1));
else
u = l;
if (l > u) {
tmp = l;
l = u;
u = tmp;
}
coordvec.push_back(l);
coordvec.push_back(u);
}
}
}
vibes::drawBox(coordvec, format, params);
return self;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment