31 Integrator_integrate_doc,
32 ".. function:: integrate(func, it, it_end, integration_type)\n"
34 " Returns a single value from a set of values evaluated at each 0D\n"
35 " element of this 1D element.\n"
37 " :arg func: The UnaryFunction0D used to compute a value at each\n"
39 " :type func: :class:`UnaryFunction0D`\n"
40 " :arg it: The Interface0DIterator used to iterate over the 0D\n"
41 " elements of this 1D element. The integration will occur over\n"
42 " the 0D elements starting from the one pointed by it.\n"
43 " :type it: :class:`Interface0DIterator`\n"
44 " :arg it_end: The Interface0DIterator pointing the end of the 0D\n"
45 " elements of the 1D element.\n"
46 " :type it_end: :class:`Interface0DIterator`\n"
47 " :arg integration_type: The integration method used to compute a\n"
48 " single value from a set of values.\n"
49 " :type integration_type: :class:`IntegrationType`\n"
50 " :return: The single value obtained for the 1D element. The return\n"
51 " value type is float if func is of the :class:`UnaryFunction0DDouble`\n"
52 " or :class:`UnaryFunction0DFloat` type, and int if func is of the\n"
53 " :class:`UnaryFunction0DUnsigned` type.\n"
54 " :rtype: int | float");
58 static const char *kwlist[] = {
"func",
"it",
"it_end",
"integration_type",
nullptr};
59 PyObject *obj1, *obj4 =
nullptr;
62 if (!PyArg_ParseTupleAndKeywords(args,
83 double res =
integrate(*fun, it, it_end, t);
84 return PyFloat_FromDouble(res);
88 float res =
integrate(*fun, it, it_end, t);
89 return PyFloat_FromDouble(res);
94 return PyLong_FromLong(res);
97 string class_name(Py_TYPE(obj1)->tp_name);
98 PyErr_SetString(PyExc_TypeError, (
"unsupported function type: " + class_name).c_str());
107 "The Blender Freestyle.Integrator submodule\n"
115 METH_VARARGS | METH_KEYWORDS,
116 Integrator_integrate_doc},
117 {
nullptr,
nullptr, 0,
nullptr},
123 PyModuleDef_HEAD_INIT,
124 "Freestyle.Integrator",
139 "Class hierarchy: int > :class:`IntegrationType`\n"
141 "Different integration methods that can be invoked to integrate into a\n"
142 "single value the set of values obtained from each 0D element of an 1D\n"
145 "* IntegrationType.MEAN: The value computed for the 1D element is the\n"
146 " mean of the values obtained for the 0D elements.\n"
147 "* IntegrationType.MIN: The value computed for the 1D element is the\n"
148 " minimum of the values obtained for the 0D elements.\n"
149 "* IntegrationType.MAX: The value computed for the 1D element is the\n"
150 " maximum of the values obtained for the 0D elements.\n"
151 "* IntegrationType.FIRST: The value computed for the 1D element is the\n"
152 " first of the values obtained for the 0D elements.\n"
153 "* IntegrationType.LAST: The value computed for the 1D element is the\n"
154 " last of the values obtained for the 0D elements.");
157 PyVarObject_HEAD_INIT(
nullptr, 0)
159 sizeof(PyLongObject),
213#define ADD_TYPE_CONST(id) \
214 PyLong_subtype_add_to_dict( \
215 IntegrationType_Type.tp_dict, &IntegrationType_Type, STRINGIFY(id), id)
229 PyModule_AddObjectRef(
module,
"Integrator", m);
232 d = PyModule_GetDict(m);
234 f = PyDict_GetItemString(d, p->ml_name);
235 PyModule_AddObjectRef(
module, p->ml_name, f);
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 PyModuleDef module_definition
static PyObject * Integrator_integrate(PyObject *, PyObject *args, PyObject *kwds)
static PyMethodDef module_functions[]
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