HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PyImathEuler.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright Contributors to the OpenEXR Project.
4 //
5 
6 // clang-format off
7 
8 #ifndef _PyImathEuler_h_
9 #define _PyImathEuler_h_
10 
11 #include <Python.h>
12 #define HBOOST_BIND_GLOBAL_PLACEHOLDERS
13 #include <hboost/python.hpp>
14 #include <ImathEuler.h>
15 #include <ImathVec.h>
16 #include "PyImath.h"
17 
18 namespace PyImath {
19 
20 template <class T> hboost::python::class_<IMATH_NAMESPACE::Euler<T>,hboost::python::bases<IMATH_NAMESPACE::Vec3<T> > > register_Euler();
21 template <class T> hboost::python::class_<PyImath::FixedArray<IMATH_NAMESPACE::Euler<T> > > register_EulerArray();
24 
25 //
26 
27 // Other code in the Zeno code base assumes the existance of a class with the
28 // same name as the Imath class, and with static functions wrap() and
29 // convert() to produce a PyImath object from an Imath object and vice-versa,
30 // respectively. The class Boost generates from the Imath class does not
31 // have these properties, so we define a companion class here.
32 // The template argument, T, is the element type for the axis vector
33 // (e.g.,float, double).
34 
35 template <class T>
36 class E {
37  public:
38  static PyObject * wrap (const IMATH_NAMESPACE::Euler<T> &e);
39  static int convert (PyObject *p, IMATH_NAMESPACE::Euler<T> *v);
40 };
41 
42 template <class T>
43 PyObject *
44 E<T>::wrap (const IMATH_NAMESPACE::Euler<T> &e)
45 {
46  typename hboost::python::return_by_value::apply < IMATH_NAMESPACE::Euler<T> >::type converter;
47  PyObject *p = converter (e);
48  return p;
49 }
50 
51 template <class T>
52 int
53 E<T>::convert (PyObject *p, IMATH_NAMESPACE::Euler<T> *v)
54 {
55  hboost::python::extract <IMATH_NAMESPACE::Eulerf> extractorEf (p);
56  if (extractorEf.check())
57  {
58  IMATH_NAMESPACE::Eulerf e = extractorEf();
59  v->x = T(e.x);
60  v->y = T(e.y);
61  v->z = T(e.z);
62  v->setOrder (typename IMATH_NAMESPACE::Euler<T>::Order (e.order()));
63  return 1;
64  }
65 
66  hboost::python::extract <IMATH_NAMESPACE::Eulerd> extractorEd (p);
67  if (extractorEd.check())
68  {
69  IMATH_NAMESPACE::Eulerd e = extractorEd();
70  v->x = T(e.x);
71  v->y = T(e.y);
72  v->z = T(e.z);
73  v->setOrder (typename IMATH_NAMESPACE::Euler<T>::Order (e.order()));
74  return 1;
75  }
76 
77  return 0;
78 }
79 
80 typedef E<float> Eulerf;
81 typedef E<double> Eulerd;
82 
83 }
84 
85 #endif
E< double > Eulerd
Definition: PyImathEuler.h:81
const GLdouble * v
Definition: glcorearb.h:837
FixedArray< IMATH_NAMESPACE::Eulerf > EulerfArray
Definition: PyImathEuler.h:22
E< float > Eulerf
Definition: PyImathEuler.h:80
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
FixedArray< IMATH_NAMESPACE::Eulerd > EulerdArray
Definition: PyImathEuler.h:23
Euler< float > Eulerf
Euler of type float.
Definition: ImathEuler.h:410
Euler< double > Eulerd
Euler of type double.
Definition: ImathEuler.h:412
hboost::python::class_< PyImath::FixedArray< IMATH_NAMESPACE::Euler< T > > > register_EulerArray()
static int convert(PyObject *p, IMATH_NAMESPACE::Euler< T > *v)
Definition: PyImathEuler.h:53
static PyObject * wrap(const IMATH_NAMESPACE::Euler< T > &e)
Definition: PyImathEuler.h:44
hboost::python::class_< IMATH_NAMESPACE::Euler< T >, hboost::python::bases< IMATH_NAMESPACE::Vec3< T > > > register_Euler()