27 Integrator_integrate_doc,
28 ".. function:: integrate(func, it, it_end, integration_type)\n"
30 " Returns a single value from a set of values evaluated at each 0D\n"
31 " element of this 1D element.\n"
33 " :arg func: The UnaryFunction0D used to compute a value at each\n"
35 " :type func: :class:`UnaryFunction0D`\n"
36 " :arg it: The Interface0DIterator used to iterate over the 0D\n"
37 " elements of this 1D element. The integration will occur over\n"
38 " the 0D elements starting from the one pointed by it.\n"
39 " :type it: :class:`Interface0DIterator`\n"
40 " :arg it_end: The Interface0DIterator pointing the end of the 0D\n"
41 " elements of the 1D element.\n"
42 " :type it_end: :class:`Interface0DIterator`\n"
43 " :arg integration_type: The integration method used to compute a\n"
44 " single value from a set of values.\n"
45 " :type integration_type: :class:`IntegrationType`\n"
46 " :return: The single value obtained for the 1D element. The return\n"
47 " value type is float if func is of the :class:`UnaryFunction0DDouble`\n"
48 " or :class:`UnaryFunction0DFloat` type, and int if func is of the\n"
49 " :class:`UnaryFunction0DUnsigned` type.\n"
50 " :rtype: int | float");
54 static const char *kwlist[] = {
"func",
"it",
"it_end",
"integration_type",
nullptr};
55 PyObject *obj1, *obj4 =
nullptr;
58 if (!PyArg_ParseTupleAndKeywords(args,
79 double res =
integrate(*fun, it, it_end, t);
80 return PyFloat_FromDouble(res);
84 float res =
integrate(*fun, it, it_end, t);
85 return PyFloat_FromDouble(res);
90 return PyLong_FromLong(res);
93 string class_name(Py_TYPE(obj1)->tp_name);
94 PyErr_SetString(PyExc_TypeError, (
"unsupported function type: " + class_name).c_str());
103 "The Blender Freestyle.Integrator submodule\n"
110# pragma clang diagnostic push
111# pragma clang diagnostic ignored "-Wcast-function-type"
113# pragma GCC diagnostic push
114# pragma GCC diagnostic ignored "-Wcast-function-type"
121 METH_VARARGS | METH_KEYWORDS,
122 Integrator_integrate_doc},
123 {
nullptr,
nullptr, 0,
nullptr},
128# pragma clang diagnostic pop
130# pragma GCC diagnostic pop
138 "Freestyle.Integrator",
153 "Class hierarchy: int > :class:`IntegrationType`\n"
155 "Different integration methods that can be invoked to integrate into a\n"
156 "single value the set of values obtained from each 0D element of an 1D\n"
159 "* IntegrationType.MEAN: The value computed for the 1D element is the\n"
160 " mean of the values obtained for the 0D elements.\n"
161 "* IntegrationType.MIN: The value computed for the 1D element is the\n"
162 " minimum of the values obtained for the 0D elements.\n"
163 "* IntegrationType.MAX: The value computed for the 1D element is the\n"
164 " maximum of the values obtained for the 0D elements.\n"
165 "* IntegrationType.FIRST: The value computed for the 1D element is the\n"
166 " first of the values obtained for the 0D elements.\n"
167 "* IntegrationType.LAST: The value computed for the 1D element is the\n"
168 " last of the values obtained for the 0D elements.");
171 PyVarObject_HEAD_INIT(
nullptr, 0)
173 sizeof(PyLongObject),
227#define ADD_TYPE_CONST(id) \
228 PyLong_subtype_add_to_dict( \
229 IntegrationType_Type.tp_dict, &IntegrationType_Type, STRINGIFY(id), id)
243 PyModule_AddObjectRef(
module,
"Integrator", m);
246 d = PyModule_GetDict(m);
248 f = PyDict_GetItemString(d, p->ml_name);
249 PyModule_AddObjectRef(
module, p->ml_name, f);
static PyModuleDef module_definition
static PyMethodDef module_functions[]
IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj)
PyDoc_STRVAR(Integrator_integrate_doc, ".. function:: integrate(func, it, it_end, integration_type)\n" "\n" " Returns a single value from a set of values evaluated at each 0D\n" " element of this 1D element.\n" "\n" " :arg func: The UnaryFunction0D used to compute a value at each\n" " Interface0D.\n" " :type func: :class:`UnaryFunction0D`\n" " :arg it: The Interface0DIterator used to iterate over the 0D\n" " elements of this 1D element. The integration will occur over\n" " the 0D elements starting from the one pointed by it.\n" " :type it: :class:`Interface0DIterator`\n" " :arg it_end: The Interface0DIterator pointing the end of the 0D\n" " elements of the 1D element.\n" " :type it_end: :class:`Interface0DIterator`\n" " :arg integration_type: The integration method used to compute a\n" " single value from a set of values.\n" " :type integration_type: :class:`IntegrationType`\n" " :return: The single value obtained for the 1D element. The return\n" " value type is float if func is of the :class:`UnaryFunction0DDouble`\n" " or :class:`UnaryFunction0DFloat` type, and int if func is of the\n" " :class:`UnaryFunction0DUnsigned` type.\n" " :rtype: int | float")
PyTypeObject IntegrationType_Type
int IntegrationType_Init(PyObject *module)
#define ADD_TYPE_CONST(id)
static PyObject * Integrator_integrate(PyObject *, PyObject *args, PyObject *kwds)
PyTypeObject Interface0DIterator_Type
#define BPy_UnaryFunction0DDouble_Check(v)
#define BPy_UnaryFunction0DFloat_Check(v)
#define BPy_UnaryFunction0DUnsigned_Check(v)
PyTypeObject UnaryFunction0D_Type
T integrate(UnaryFunction0D< T > &fun, Interface0DIterator it, Interface0DIterator it_end, IntegrationType integration_type=MEAN)
static struct PyModuleDef module
Freestyle::Interface0DIterator * if0D_it