MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / box2TupleConstructor1

Function box2TupleConstructor1

src/python/PyImath/PyImathBox.cpp:48–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template <class T>
48static Box<T> * box2TupleConstructor1(const tuple &t)
49{
50 if(t.attr("__len__")() == 2)
51 {
52 // The constructor was called like this:
53 // Box2f ((V2f(1,2), V2f(3,4))) or
54 // Box2f (((1,2), (3,4)))
55
56 PyObject *t0Obj = extract <object> (t[0])().ptr();
57 PyObject *t1Obj = extract <object> (t[1])().ptr();
58 T t0, t1;
59 if (V2<typename T::BaseType>::convert (t0Obj, &t0) &&
60 V2<typename T::BaseType>::convert (t1Obj, &t1))
61 {
62 return new Box<T> (t0, t1);
63 }
64
65 // The constructor was called like this:
66 // Box2f ((1,2))
67
68 else
69 {
70 T point;
71 point.x = extract<typename T::BaseType>(t[0]);
72 point.y = extract<typename T::BaseType>(t[1]);
73 return new Box<T>(point);
74 }
75 }
76 else
77 throw std::invalid_argument ( "Invalid input to Box tuple constructor");
78}
79
80template <class T>
81static Box<T> * box2TupleConstructor2(const tuple &t0, const tuple &t1)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected