8 #ifndef _PyImathVec3ArrayImpl_h_
9 #define _PyImathVec3ArrayImpl_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;
39 template <
class T,
int index>
41 Vec3Array_get(FixedArray<IMATH_NAMESPACE::Vec3<T> > &va)
43 return FixedArray<T>(&(va.unchecked_index(0)[
index]),
44 va.len(), 3*va.stride(), va.handle(), va.writable());
49 setItemTuple(FixedArray<IMATH_NAMESPACE::Vec3<T> > &va, Py_ssize_t
index,
const tuple &
t)
51 if(t.attr(
"__len__")() == 3)
54 v.
x = extract<T>(t[0]);
55 v.
y = extract<T>(t[1]);
56 v.
z = extract<T>(t[2]);
57 va[va.canonical_index(index)] =
v;
60 throw std::invalid_argument (
"tuple of length 3 expected");
64 static IMATH_NAMESPACE::Vec3<T>
65 Vec3Array_min(
const FixedArray<IMATH_NAMESPACE::Vec3<T> > &
a)
71 for (
size_t i=1; i < len; ++i)
84 static IMATH_NAMESPACE::Vec3<T>
85 Vec3Array_max(
const FixedArray<IMATH_NAMESPACE::Vec3<T> > &
a)
91 for (
size_t i=1; i < len; ++i)
104 static IMATH_NAMESPACE::Box<IMATH_NAMESPACE::Vec3<T> >
105 Vec3Array_bounds(
const FixedArray<IMATH_NAMESPACE::Vec3<T> > &
a)
108 size_t len =
a.len();
109 for (
size_t i=0; i < len; ++i)
119 generate_member_bindings<op_vecLength<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"length",
"");
120 generate_member_bindings<op_vecNormalize<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"normalize",
"");
121 generate_member_bindings<op_vecNormalized<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"normalized",
"");
122 generate_member_bindings<op_vecNormalizeExc<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"normalizeExc",
"");
123 generate_member_bindings<op_vecNormalizedExc<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"normalizedExc",
"");
134 class_<FixedArray<IMATH_NAMESPACE::Vec3<T> > >
137 using hboost::mpl::true_;
138 using hboost::mpl::false_;
142 .add_property(
"x",&Vec3Array_get<T,0>)
143 .add_property(
"y",&Vec3Array_get<T,1>)
144 .add_property(
"z",&Vec3Array_get<T,2>)
145 .def(
"__setitem__", &setItemTuple<T>)
146 .def(
"min", &Vec3Array_min<T>)
147 .def(
"max", &Vec3Array_max<T>)
148 .def(
"bounds", &Vec3Array_bounds<T>)
151 add_arithmetic_math_functions(vec3Array_class);
152 add_comparison_functions(vec3Array_class);
155 generate_member_bindings<op_vecLength2<IMATH_NAMESPACE::Vec3<T> > >(vec3Array_class,
"length2",
"");
157 generate_member_bindings<op_vec3Cross<T>, true_>(vec3Array_class,
"cross",
"return the cross product of (self,x)",
hboost::python::args(
"x"));
158 generate_member_bindings<op_vecDot<IMATH_NAMESPACE::Vec3<T> >,true_>(vec3Array_class,
"dot",
"return the inner product of (self,x)",
hboost::python::args(
"x"));
160 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec3<T>,
T>, true_>(vec3Array_class,
"__mul__" ,
"self*x",
hboost::python::args(
"x"));
164 generate_member_bindings<op_mul<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__rmul__",
"x*self",
hboost::python::args(
"x"));
165 generate_member_bindings<op_imul<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__imul__",
"self*=x",
hboost::python::args(
"x"));
166 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__div__" ,
"self/x",
hboost::python::args(
"x"));
167 generate_member_bindings<op_div<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__truediv__" ,
"self/x",
hboost::python::args(
"x"));
168 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__idiv__",
"self/=x",
hboost::python::args(
"x"));
169 generate_member_bindings<op_idiv<IMATH_NAMESPACE::Vec3<T>,T>, true_>(vec3Array_class,
"__itruediv__",
"self/=x",
hboost::python::args(
"x"));
173 return vec3Array_class;
178 #endif // _PyImathVec3ArrayImpl_h_
Matrix44< float > M44f
4x4 matrix of float
GLsizei const GLfloat * value
GLdouble GLdouble GLdouble z
IMATH_HOSTDEVICE void extendBy(const V &point) IMATH_NOEXCEPT
Extend the box to include the given point.
GLboolean GLboolean GLboolean GLboolean a
void register_Vec3Array_floatonly(class_< FixedArray< Vec3< T >>> &vec3Array_class)
hboost::python::class_< FixedArray< IMATH_NAMESPACE::Vec3< T > > > register_Vec3Array()
Matrix44< double > M44d
4x4 matrix of double
**If you just want to fire and args
hboost::python::class_< T, X1, X2, X3 > & decoratecopy(hboost::python::class_< T, X1, X2, X3 > &cls)