| 1 |
// |
| 2 |
// SPDX-License-Identifier: BSD-3-Clause |
| 3 |
// Copyright Contributors to the OpenEXR Project. |
| 4 |
// |
| 5 |
|
| 6 |
// clang-format off |
| 7 |
|
| 8 |
#include "PyImathVec4Impl.h" |
| 9 |
#include "PyImathVec4ArrayImpl.h" |
| 10 |
#include "PyImathExport.h" |
| 11 |
|
| 12 |
namespace PyImath { |
| 13 |
template <> const char *PyImath::V4fArray::name() { return "V4fArray"; } |
| 14 |
template <> const char *PyImath::V4dArray::name() { return "V4dArray"; } |
| 15 |
|
| 16 |
using namespace boost::python; |
| 17 |
using namespace IMATH_NAMESPACE; |
| 18 |
|
| 19 |
template<> const char *Vec4Name<float>::value() { return "V4f"; } |
| 20 |
template<> const char *Vec4Name<double>::value() { return "V4d"; } |
| 21 |
|
| 22 |
// Specialization for float to full precision |
| 23 |
template <> |
| 24 |
std::string Vec4_repr(const Vec4<float> &v) |
| 25 |
{ |
| 26 |
return (boost::format("%s(%.9g, %.9g, %.9g, %.9g)") |
| 27 |
% Vec4Name<float>::value() % v.x % v.y % v.z % v.w).str(); |
| 28 |
} |
| 29 |
|
| 30 |
// Specialization for double to full precision |
| 31 |
template <> |
| 32 |
std::string Vec4_repr(const Vec4<double> &v) |
| 33 |
{ |
| 34 |
return (boost::format("%s(%.17g, %.17g, %.17g, %.17g)") |
| 35 |
% Vec4Name<double>::value() % v.x % v.y % v.z % v.w).str(); |
| 36 |
} |
| 37 |
|
| 38 |
template PYIMATH_EXPORT class_<IMATH_NAMESPACE::Vec4<float> > register_Vec4<float>(); |
| 39 |
template PYIMATH_EXPORT class_<IMATH_NAMESPACE::Vec4<double> > register_Vec4<double>(); |
| 40 |
|
| 41 |
template PYIMATH_EXPORT class_<FixedArray<IMATH_NAMESPACE::Vec4<float> > > register_Vec4Array<float>(); |
| 42 |
template PYIMATH_EXPORT class_<FixedArray<IMATH_NAMESPACE::Vec4<double> > > register_Vec4Array<double>(); |
| 43 |
|
| 44 |
template<> PYIMATH_EXPORT IMATH_NAMESPACE::Vec4<float> PyImath::FixedArrayDefaultValue<IMATH_NAMESPACE::Vec4<float> >::value() { return IMATH_NAMESPACE::Vec4<float>(0,0,0,0); } |
| 45 |
template<> PYIMATH_EXPORT IMATH_NAMESPACE::Vec4<double> PyImath::FixedArrayDefaultValue<IMATH_NAMESPACE::Vec4<double> >::value() { return IMATH_NAMESPACE::Vec4<double>(0,0,0,0); } |
| 46 |
} |