8 #ifndef _PyImathVec4ArrayImpl_h_
9 #define _PyImathVec4ArrayImpl_h_
18 #define HBOOST_BIND_GLOBAL_PLACEHOLDERS
19 #include <hboost/python.hpp>
20 #include <hboost/python/make_constructor.hpp>
21 #include <hboost/format.hpp>
32 using namespace hboost::python;
38 template <
class T,
int index>
40 Vec4Array_get(FixedArray<IMATH_NAMESPACE::Vec4<T> > &va)
42 return FixedArray<T>(&(va.unchecked_index(0)[
index]),
43 va.len(), 4*va.stride(), va.handle(), va.writable());
48 setItemTuple(FixedArray<IMATH_NAMESPACE::Vec4<T> > &va, Py_ssize_t
index,
const tuple &
t)
50 if(t.attr(
"__len__")() == 4)
53 v.
x = extract<T>(t[0]);
54 v.
y = extract<T>(t[1]);
55 v.
z = extract<T>(t[2]);
56 v.
w = extract<T>(t[3]);
58 va[va.canonical_index(index)] =
v;
61 throw std::invalid_argument (
"tuple of length 4 expected");
65 static IMATH_NAMESPACE::Vec4<T>
66 Vec4Array_min(
const FixedArray<IMATH_NAMESPACE::Vec4<T> > &
a) {
71 for (
size_t i=1; i < len; ++i)
86 static IMATH_NAMESPACE::Vec4<T>
87 Vec4Array_max(
const FixedArray<IMATH_NAMESPACE::Vec4<T> > &
a)
93 for (
size_t i=1; i < len; ++i)
112 generate_member_bindings<op_vecLength<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"length",
"");
113 generate_member_bindings<op_vecNormalize<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"normalize",
"");
114 generate_member_bindings<op_vecNormalized<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"normalized",
"");
115 generate_member_bindings<op_vecNormalizeExc<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"normalizeExc",
"");
116 generate_member_bindings<op_vecNormalizedExc<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"normalizedExc",
"");
127 class_<FixedArray<IMATH_NAMESPACE::Vec4<T> > >
130 using hboost::mpl::true_;
134 .add_property(
"x",&Vec4Array_get<T,0>)
135 .add_property(
"y",&Vec4Array_get<T,1>)
136 .add_property(
"z",&Vec4Array_get<T,2>)
137 .add_property(
"w",&Vec4Array_get<T,3>)
138 .def(
"__setitem__", &setItemTuple<T>)
139 .def(
"min", &Vec4Array_min<T>)
140 .def(
"max", &Vec4Array_max<T>)
143 add_arithmetic_math_functions(vec4Array_class);
144 add_comparison_functions(vec4Array_class);
147 generate_member_bindings<op_vecLength2<IMATH_NAMESPACE::Vec4<T> > >(vec4Array_class,
"length2",
"");
148 generate_member_bindings<op_vecDot<IMATH_NAMESPACE::Vec4<T> >,true_>(vec4Array_class,
"dot",
"return the inner product of (self,x)",
hboost::python::args(
"x"));
149 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec4<T>,
T>, true_>(vec4Array_class,
"__mul__" ,
"self*x",
hboost::python::args(
"x"));
150 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__rmul__",
"x*self",
hboost::python::args(
"x"));
151 generate_member_bindings<op_imul<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__imul__",
"self*=x",
hboost::python::args(
"x"));
152 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__div__" ,
"self/x",
hboost::python::args(
"x"));
153 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__truediv__" ,
"self/x",
hboost::python::args(
"x"));
154 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__idiv__",
"self/=x",
hboost::python::args(
"x"));
155 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec4<T>,T>, true_>(vec4Array_class,
"__itruediv__",
"self/=x",
hboost::python::args(
"x"));
159 return vec4Array_class;
165 #endif // _PyImathVec4ArrayImpl_h_
hboost::python::class_< PyImath::FixedArray< IMATH_NAMESPACE::Vec4< T > > > register_Vec4Array()
GLsizei const GLfloat * value
GLdouble GLdouble GLdouble z
GLboolean GLboolean GLboolean GLboolean a
void register_Vec4Array_floatonly(class_< FixedArray< Vec4< T >>> &vec4Array_class)
**If you just want to fire and args
GLubyte GLubyte GLubyte GLubyte w
hboost::python::class_< T, X1, X2, X3 > & decoratecopy(hboost::python::class_< T, X1, X2, X3 > &cls)