Blender V5.0
BPy_UnaryFunction0DFloat.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "../BPy_Convert.h"
13
20
21using namespace Freestyle;
22
24
25//-------------------MODULE INITIALIZATION--------------------------------
26
28{
29 if (module == nullptr) {
30 return -1;
31 }
32
33 if (PyType_Ready(&UnaryFunction0DFloat_Type) < 0) {
34 return -1;
35 }
36 PyModule_AddObjectRef(module, "UnaryFunction0DFloat", (PyObject *)&UnaryFunction0DFloat_Type);
37
38 if (PyType_Ready(&GetCurvilinearAbscissaF0D_Type) < 0) {
39 return -1;
40 }
41 PyModule_AddObjectRef(
42 module, "GetCurvilinearAbscissaF0D", (PyObject *)&GetCurvilinearAbscissaF0D_Type);
43
44 if (PyType_Ready(&GetParameterF0D_Type) < 0) {
45 return -1;
46 }
47 PyModule_AddObjectRef(module, "GetParameterF0D", (PyObject *)&GetParameterF0D_Type);
48
49 if (PyType_Ready(&GetViewMapGradientNormF0D_Type) < 0) {
50 return -1;
51 }
52 PyModule_AddObjectRef(
53 module, "GetViewMapGradientNormF0D", (PyObject *)&GetViewMapGradientNormF0D_Type);
54
55 if (PyType_Ready(&ReadCompleteViewMapPixelF0D_Type) < 0) {
56 return -1;
57 }
58 PyModule_AddObjectRef(
59 module, "ReadCompleteViewMapPixelF0D", (PyObject *)&ReadCompleteViewMapPixelF0D_Type);
60
61 if (PyType_Ready(&ReadMapPixelF0D_Type) < 0) {
62 return -1;
63 }
64 PyModule_AddObjectRef(module, "ReadMapPixelF0D", (PyObject *)&ReadMapPixelF0D_Type);
65
66 if (PyType_Ready(&ReadSteerableViewMapPixelF0D_Type) < 0) {
67 return -1;
68 }
69 PyModule_AddObjectRef(
70 module, "ReadSteerableViewMapPixelF0D", (PyObject *)&ReadSteerableViewMapPixelF0D_Type);
71
72 return 0;
73}
74
75//------------------------INSTANCE METHODS ----------------------------------
76
78 /* Wrap. */
79 UnaryFunction0DFloat___doc__,
80 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat`\n"
81 "\n"
82 "Base class for unary functions (functors) that work on\n"
83 ":class:`Interface0DIterator` and return a float value.\n"
84 "\n"
85 ".. method:: __init__()\n"
86 "\n"
87 " Default constructor.\n");
89 PyObject *args,
90 PyObject *kwds)
91{
92 static const char *kwlist[] = {nullptr};
93
94 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
95 return -1;
96 }
97 self->uf0D_float = new UnaryFunction0D<float>();
98 self->uf0D_float->py_uf0D = (PyObject *)self;
99 return 0;
100}
101
103{
104 delete self->uf0D_float;
105 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
106}
107
109{
110 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_float);
111}
112
114 PyObject *args,
115 PyObject *kwds)
116{
117 static const char *kwlist[] = {"it", nullptr};
118 PyObject *obj;
119
120 if (!PyArg_ParseTupleAndKeywords(
121 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
122 {
123 return nullptr;
124 }
125
126 if (typeid(*(self->uf0D_float)) == typeid(UnaryFunction0D<float>)) {
127 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
128 return nullptr;
129 }
130 if (self->uf0D_float->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
131 if (!PyErr_Occurred()) {
132 string class_name(Py_TYPE(self)->tp_name);
133 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
134 }
135 return nullptr;
136 }
137 return PyFloat_FromDouble(self->uf0D_float->result);
138}
139
140/*-----------------------BPy_UnaryFunction0DFloat type definition ------------------------------*/
141
143 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
144 /*tp_name*/ "UnaryFunction0DFloat",
145 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DFloat),
146 /*tp_itemsize*/ 0,
147 /*tp_dealloc*/ (destructor)UnaryFunction0DFloat___dealloc__,
148 /*tp_vectorcall_offset*/ 0,
149 /*tp_getattr*/ nullptr,
150 /*tp_setattr*/ nullptr,
151 /*tp_as_async*/ nullptr,
152 /*tp_repr*/ (reprfunc)UnaryFunction0DFloat___repr__,
153 /*tp_as_number*/ nullptr,
154 /*tp_as_sequence*/ nullptr,
155 /*tp_as_mapping*/ nullptr,
156 /*tp_hash*/ nullptr,
157 /*tp_call*/ (ternaryfunc)UnaryFunction0DFloat___call__,
158 /*tp_str*/ nullptr,
159 /*tp_getattro*/ nullptr,
160 /*tp_setattro*/ nullptr,
161 /*tp_as_buffer*/ nullptr,
162 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
163 /*tp_doc*/ UnaryFunction0DFloat___doc__,
164 /*tp_traverse*/ nullptr,
165 /*tp_clear*/ nullptr,
166 /*tp_richcompare*/ nullptr,
167 /*tp_weaklistoffset*/ 0,
168 /*tp_iter*/ nullptr,
169 /*tp_iternext*/ nullptr,
170 /*tp_methods*/ nullptr,
171 /*tp_members*/ nullptr,
172 /*tp_getset*/ nullptr,
173 /*tp_base*/ &UnaryFunction0D_Type,
174 /*tp_dict*/ nullptr,
175 /*tp_descr_get*/ nullptr,
176 /*tp_descr_set*/ nullptr,
177 /*tp_dictoffset*/ 0,
178 /*tp_init*/ (initproc)UnaryFunction0DFloat___init__,
179 /*tp_alloc*/ nullptr,
180 /*tp_new*/ nullptr,
181};
182
PyTypeObject GetCurvilinearAbscissaF0D_Type
PyTypeObject GetParameterF0D_Type
PyTypeObject GetViewMapGradientNormF0D_Type
PyTypeObject Interface0DIterator_Type
PyTypeObject ReadCompleteViewMapPixelF0D_Type
PyTypeObject ReadMapPixelF0D_Type
PyTypeObject ReadSteerableViewMapPixelF0D_Type
static int UnaryFunction0DFloat___init__(BPy_UnaryFunction0DFloat *self, PyObject *args, PyObject *kwds)
static PyObject * UnaryFunction0DFloat___repr__(BPy_UnaryFunction0DFloat *self)
static void UnaryFunction0DFloat___dealloc__(BPy_UnaryFunction0DFloat *self)
PyDoc_STRVAR(UnaryFunction0DFloat___doc__, "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DFloat`\n" "\n" "Base class for unary functions (functors) that work on\n" ":class:`Interface0DIterator` and return a float value.\n" "\n" ".. method:: __init__()\n" "\n" " Default constructor.\n")
int UnaryFunction0DFloat_Init(PyObject *module)
static PyObject * UnaryFunction0DFloat___call__(BPy_UnaryFunction0DFloat *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0DFloat_Type
PyTypeObject UnaryFunction0D_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:796