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