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

Function box3TupleConstructor1

src/python/PyImath/PyImathBox.cpp:106–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105template <class T>
106static Box<T> * box3TupleConstructor1(const tuple &t)
107{
108 if(t.attr("__len__")() == 3)
109 {
110 // The constructor was called like this:
111 // Box3f ((1,2,3))
112
113 T point;
114 point.x = extract<typename T::BaseType>(t[0]);
115 point.y = extract<typename T::BaseType>(t[1]);
116 point.z = extract<typename T::BaseType>(t[2]);
117 return new Box<T>(point);
118 }
119
120 else if (t.attr("__len__")() == 2)
121 {
122 // The constructor was called like this:
123 // Box3f ((V3f(1,2,3), V3f(4,5,6))) or
124 // Box3f (((1,2,3), (4,5,6)))
125
126 PyObject *t0Obj = extract <object> (t[0])().ptr();
127 PyObject *t1Obj = extract <object> (t[1])().ptr();
128 T t0, t1;
129 if (V3<typename T::BaseType>::convert (t0Obj, &t0) &&
130 V3<typename T::BaseType>::convert (t1Obj, &t1))
131 {
132 return new Box<T> (t0, t1);
133 }
134 else
135 throw std::invalid_argument ("Invalid input to Box tuple constructor");
136 }
137
138 else
139 throw std::invalid_argument ("Invalid input to Box tuple constructor");
140}
141
142template <class T>
143static Box<T> * box3TupleConstructor2(const tuple &t0, const tuple &t1)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected