PyObject * PyOCIO_MatrixTransform_setValue(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pymatrix = 0; PyObject* pyoffset = 0; if (!PyArg_ParseTuple(args, "OO:setValue", &pymatrix, &pyoffset)) return NULL; std::vector<float> matrix; std::vector<float> offset; if(!FillFloatVectorFromPySequence(pymatrix, matrix) || (matrix.size() != 16)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 16"); return 0; } if(!FillFloatVectorFromPySequence(pyoffset, offset) || (offset.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Second argument must be a float array, size 4"); return 0; } MatrixTransformRcPtr transform = GetEditableMatrixTransform(self); transform->setValue(&matrix[0], &offset[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_AllocationTransform_setVars(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject * pyvars = 0; if (!PyArg_ParseTuple(args,"O:setVars", &pyvars)) return NULL; std::vector<float> vars; if(!FillFloatVectorFromPySequence(pyvars, vars)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array."); return 0; } AllocationTransformRcPtr transform = GetEditableAllocationTransform(self); if(!vars.empty()) transform->setVars(static_cast<int>(vars.size()), &vars[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_CDLTransform_setSOP(PyObject * self, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pyData = 0; if (!PyArg_ParseTuple(args, "O:setSOP", &pyData)) return NULL; CDLTransformRcPtr transform = GetEditableCDLTransform(self); std::vector<float> data; if(!FillFloatVectorFromPySequence(pyData, data) || (data.size() != 9)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 9"); return 0; } transform->setSOP(&data[0]); Py_RETURN_NONE; OCIO_PYTRY_EXIT(NULL) }
PyObject * PyOCIO_MatrixTransform_Fit(PyObject * /*self*/, PyObject * args) { OCIO_PYTRY_ENTER() PyObject* pyoldmin = 0; PyObject* pyoldmax = 0; PyObject* pynewmin = 0; PyObject* pynewmax = 0; if (!PyArg_ParseTuple(args,"OOOO:Fit", &pyoldmin, &pyoldmax, &pynewmin, &pynewmax)) return NULL; std::vector<float> oldmin; if(!FillFloatVectorFromPySequence(pyoldmin, oldmin) || (oldmin.size() != 4)) { PyErr_SetString(PyExc_TypeError, "First argument must be a float array, size 4"); return 0; } std::vector<float> oldmax; if(!FillFloatVectorFromPySequence(pyoldmax, oldmax) || (oldmax.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Second argument must be a float array, size 4"); return 0; } std::vector<float> newmin; if(!FillFloatVectorFromPySequence(pynewmin, newmin) || (newmin.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Third argument must be a float array, size 4"); return 0; } std::vector<float> newmax; if(!FillFloatVectorFromPySequence(pynewmax, newmax) || (newmax.size() != 4)) { PyErr_SetString(PyExc_TypeError, "Fourth argument must be a float array, size 4"); return 0; } std::vector<float> matrix(16); std::vector<float> offset(4); MatrixTransform::Fit(&matrix[0], &offset[0], &oldmin[0], &oldmax[0], &newmin[0], &newmax[0]); PyObject* pymatrix = CreatePyListFromFloatVector(matrix); PyObject* pyoffset = CreatePyListFromFloatVector(offset); PyObject* pyreturnval = Py_BuildValue("(OO)", pymatrix, pyoffset); Py_DECREF(pymatrix); Py_DECREF(pyoffset); return pyreturnval; OCIO_PYTRY_EXIT(NULL) }