Debian Codegraph @

src/python/PyImath/PyImathVec2fd.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 "PyImathVec2Impl.h"
9 #include "PyImathExport.h"
10
11 namespace PyImath {
12 template <> const char *PyImath::V2fArray::name() { return "V2fArray"; }
13 template <> const char *PyImath::V2dArray::name() { return "V2dArray"; }
14
15 using namespace boost::python;
16 using namespace IMATH_NAMESPACE;
17
18 template<> const char *Vec2Name<float>::value = "V2f";
19 template<> const char *Vec2Name<double>::value = "V2d";
20
21 // Specialization for float to full precision
22 template <>
23 std::string Vec2_repr(const Vec2<float> &v)
24 {
25 return (boost::format("%s(%.9g, %.9g)")
26 % Vec2Name<float>::value % v.x % v.y).str();
27 }
28
29 // Specialization for double to full precision
30 template <>
31 std::string Vec2_repr(const Vec2<double> &v)
32 {
33 return (boost::format("%s(%.17g, %.17g)")
34 % Vec2Name<double>::value % v.x % v.y).str();
35 }
36
37 template PYIMATH_EXPORT class_<IMATH_NAMESPACE::Vec2<float> > register_Vec2<float>();
38 template PYIMATH_EXPORT class_<IMATH_NAMESPACE::Vec2<double> > register_Vec2<double>();
39
40 template PYIMATH_EXPORT class_<FixedArray<IMATH_NAMESPACE::Vec2<float> > > register_Vec2Array<float>();
41 template PYIMATH_EXPORT class_<FixedArray<IMATH_NAMESPACE::Vec2<double> > > register_Vec2Array<double>();
42
43 template<> IMATH_NAMESPACE::Vec2<float> PYIMATH_EXPORT FixedArrayDefaultValue<IMATH_NAMESPACE::Vec2<float> >::value() { return IMATH_NAMESPACE::Vec2<float>(0,0); }
44 template<> IMATH_NAMESPACE::Vec2<double> PYIMATH_EXPORT FixedArrayDefaultValue<IMATH_NAMESPACE::Vec2<double> >::value() { return IMATH_NAMESPACE::Vec2<double>(0,0); }
45 }
46