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