8 #ifndef _PyImathBoxArrayImpl_h_
9 #define _PyImathBoxArrayImpl_h_
18 #define HBOOST_BIND_GLOBAL_PLACEHOLDERS
19 #include <hboost/python.hpp>
20 #include <hboost/python/make_constructor.hpp>
21 #include <hboost/format.hpp>
33 using namespace hboost::python;
36 template <
class T,
int index>
38 BoxArray_get(FixedArray<IMATH_NAMESPACE::Box<T> > &va)
41 FixedArray<T>(&(va.unchecked_index(0).min),
42 va.len(),2*va.stride(),va.handle(),va.writable()) :
43 FixedArray<T>(&(va.unchecked_index(0).max),
44 va.len(),2*va.stride(),va.handle(),va.writable());
49 setItemTuple(FixedArray<IMATH_NAMESPACE::Box<T> > &va, Py_ssize_t
index,
const tuple &
t)
51 if(t.attr(
"__len__")() == 2)
54 v.
min = extract<T>(t[0]);
55 v.
max = extract<T>(t[1]);
56 va[(size_t)va.canonical_index(index)] =
v;
59 throw std::invalid_argument (
"tuple of length 2 expected");
63 class_<FixedArray<IMATH_NAMESPACE::Box<T> > >
66 using hboost::mpl::true_;
67 using hboost::mpl::false_;
71 .add_property(
"min",&BoxArray_get<T,0>)
72 .add_property(
"max",&BoxArray_get<T,1>)
73 .def(
"__setitem__", &setItemTuple<T>)
76 add_comparison_functions(boxArray_class);
79 return boxArray_class;
84 #endif // _PyImathBoxArrayImpl_h_
V max
The maximum value of the box.
V min
The minimum value of the box.
hboost::python::class_< FixedArray< IMATH_NAMESPACE::Box< T > > > register_BoxArray()
hboost::python::class_< T, X1, X2, X3 > & decoratecopy(hboost::python::class_< T, X1, X2, X3 > &cls)