Debian Codegraph @

src/python/PyImath/PyImathVec3fd.cpp

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