// // SPDX-License-Identifier: BSD-3-Clause // Copyright Contributors to the OpenEXR Project. // // clang-format off #ifndef _PyImathLine_h_ #define _PyImathLine_h_ #include #include #include #include "PyImath.h" namespace PyImath { template boost::python::class_ > register_Line(); // // Other code in the Zeno code base assumes the existance of a class with the // same name as the Imath class, and with static functions wrap() and // convert() to produce a PyImath object from an Imath object and vice-versa, // respectively. The class Boost generates from the Imath class does not // have these properties, so we define a companion class here. // The template argument, T, is the element type (e.g.,float, double). template class L3 { public: static PyObject * wrap (const IMATH_NAMESPACE::Line3 &l); static int convert (PyObject *p, IMATH_NAMESPACE::Line3 *l); }; template PyObject * L3::wrap (const IMATH_NAMESPACE::Line3 &l) { typename boost::python::return_by_value::apply < IMATH_NAMESPACE::Line3 >::type converter; PyObject *p = converter (l); return p; } template int L3::convert (PyObject *p, IMATH_NAMESPACE::Line3 *l) { boost::python::extract extractorLf (p); if (extractorLf.check()) { IMATH_NAMESPACE::Line3f e = extractorLf(); l->pos.setValue (e.pos); l->dir.setValue (e.dir); return 1; } boost::python::extract extractorLd (p); if (extractorLd.check()) { IMATH_NAMESPACE::Line3d e = extractorLd(); l->pos.setValue (e.pos); l->dir.setValue (e.dir); return 1; } return 0; } typedef L3 Line3f; typedef L3 Line3d; } #endif