Blender V4.3
BPy_UnaryFunction0DDouble.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
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29using namespace Freestyle;
30
32
33//-------------------MODULE INITIALIZATION--------------------------------
34
36{
37 if (module == nullptr) {
38 return -1;
39 }
40
41 if (PyType_Ready(&UnaryFunction0DDouble_Type) < 0) {
42 return -1;
43 }
44 PyModule_AddObjectRef(module, "UnaryFunction0DDouble", (PyObject *)&UnaryFunction0DDouble_Type);
45
46 if (PyType_Ready(&DensityF0D_Type) < 0) {
47 return -1;
48 }
49 PyModule_AddObjectRef(module, "DensityF0D", (PyObject *)&DensityF0D_Type);
50
51 if (PyType_Ready(&LocalAverageDepthF0D_Type) < 0) {
52 return -1;
53 }
54 PyModule_AddObjectRef(module, "LocalAverageDepthF0D", (PyObject *)&LocalAverageDepthF0D_Type);
55
56 if (PyType_Ready(&Curvature2DAngleF0D_Type) < 0) {
57 return -1;
58 }
59 PyModule_AddObjectRef(module, "Curvature2DAngleF0D", (PyObject *)&Curvature2DAngleF0D_Type);
60
61 if (PyType_Ready(&GetProjectedXF0D_Type) < 0) {
62 return -1;
63 }
64 PyModule_AddObjectRef(module, "GetProjectedXF0D", (PyObject *)&GetProjectedXF0D_Type);
65
66 if (PyType_Ready(&GetProjectedYF0D_Type) < 0) {
67 return -1;
68 }
69 PyModule_AddObjectRef(module, "GetProjectedYF0D", (PyObject *)&GetProjectedYF0D_Type);
70
71 if (PyType_Ready(&GetProjectedZF0D_Type) < 0) {
72 return -1;
73 }
74 PyModule_AddObjectRef(module, "GetProjectedZF0D", (PyObject *)&GetProjectedZF0D_Type);
75
76 if (PyType_Ready(&GetXF0D_Type) < 0) {
77 return -1;
78 }
79 PyModule_AddObjectRef(module, "GetXF0D", (PyObject *)&GetXF0D_Type);
80
81 if (PyType_Ready(&GetYF0D_Type) < 0) {
82 return -1;
83 }
84 PyModule_AddObjectRef(module, "GetYF0D", (PyObject *)&GetYF0D_Type);
85
86 if (PyType_Ready(&GetZF0D_Type) < 0) {
87 return -1;
88 }
89 PyModule_AddObjectRef(module, "GetZF0D", (PyObject *)&GetZF0D_Type);
90
91 if (PyType_Ready(&ZDiscontinuityF0D_Type) < 0) {
92 return -1;
93 }
94 PyModule_AddObjectRef(module, "ZDiscontinuityF0D", (PyObject *)&ZDiscontinuityF0D_Type);
95
96 return 0;
97}
98
99//------------------------INSTANCE METHODS ----------------------------------
100
102 /* Wrap. */
103 UnaryFunction0DDouble___doc__,
104 "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble`\n"
105 "\n"
106 "Base class for unary functions (functors) that work on\n"
107 ":class:`Interface0DIterator` and return a float value.\n"
108 "\n"
109 ".. method:: __init__()\n"
110 "\n"
111 " Default constructor.\n");
112
114 PyObject *args,
115 PyObject *kwds)
116{
117 static const char *kwlist[] = {nullptr};
118
119 if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
120 return -1;
121 }
122 self->uf0D_double = new UnaryFunction0D<double>();
123 self->uf0D_double->py_uf0D = (PyObject *)self;
124 return 0;
125}
126
128{
129 delete self->uf0D_double;
130 UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
131}
132
134{
135 return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_double);
136}
137
139 PyObject *args,
140 PyObject *kwds)
141{
142 static const char *kwlist[] = {"it", nullptr};
143 PyObject *obj;
144
145 if (!PyArg_ParseTupleAndKeywords(
146 args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
147 {
148 return nullptr;
149 }
150
151 if (typeid(*(self->uf0D_double)) == typeid(UnaryFunction0D<double>)) {
152 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
153 return nullptr;
154 }
155 if (self->uf0D_double->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
156 if (!PyErr_Occurred()) {
157 string class_name(Py_TYPE(self)->tp_name);
158 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
159 }
160 return nullptr;
161 }
162 return PyFloat_FromDouble(self->uf0D_double->result);
163}
164
165/*-----------------------BPy_UnaryFunction0DDouble type definition ------------------------------*/
166
168 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
169 /*tp_name*/ "UnaryFunction0DDouble",
170 /*tp_basicsize*/ sizeof(BPy_UnaryFunction0DDouble),
171 /*tp_itemsize*/ 0,
172 /*tp_dealloc*/ (destructor)UnaryFunction0DDouble___dealloc__,
173 /*tp_vectorcall_offset*/ 0,
174 /*tp_getattr*/ nullptr,
175 /*tp_setattr*/ nullptr,
176 /*tp_as_async*/ nullptr,
177 /*tp_repr*/ (reprfunc)UnaryFunction0DDouble___repr__,
178 /*tp_as_number*/ nullptr,
179 /*tp_as_sequence*/ nullptr,
180 /*tp_as_mapping*/ nullptr,
181 /*tp_hash*/ nullptr,
182 /*tp_call*/ (ternaryfunc)UnaryFunction0DDouble___call__,
183 /*tp_str*/ nullptr,
184 /*tp_getattro*/ nullptr,
185 /*tp_setattro*/ nullptr,
186 /*tp_as_buffer*/ nullptr,
187 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
188 /*tp_doc*/ UnaryFunction0DDouble___doc__,
189 /*tp_traverse*/ nullptr,
190 /*tp_clear*/ nullptr,
191 /*tp_richcompare*/ nullptr,
192 /*tp_weaklistoffset*/ 0,
193 /*tp_iter*/ nullptr,
194 /*tp_iternext*/ nullptr,
195 /*tp_methods*/ nullptr,
196 /*tp_members*/ nullptr,
197 /*tp_getset*/ nullptr,
198 /*tp_base*/ &UnaryFunction0D_Type,
199 /*tp_dict*/ nullptr,
200 /*tp_descr_get*/ nullptr,
201 /*tp_descr_set*/ nullptr,
202 /*tp_dictoffset*/ 0,
203 /*tp_init*/ (initproc)UnaryFunction0DDouble___init__,
204 /*tp_alloc*/ nullptr,
205 /*tp_new*/ nullptr,
206};
207
209
210#ifdef __cplusplus
211}
212#endif
PyTypeObject Curvature2DAngleF0D_Type
PyTypeObject DensityF0D_Type
PyTypeObject GetProjectedXF0D_Type
PyTypeObject GetProjectedYF0D_Type
PyTypeObject GetProjectedZF0D_Type
PyTypeObject GetXF0D_Type
PyTypeObject GetYF0D_Type
PyTypeObject GetZF0D_Type
PyTypeObject Interface0DIterator_Type
PyTypeObject LocalAverageDepthF0D_Type
PyDoc_STRVAR(UnaryFunction0DDouble___doc__, "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DDouble`\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")
static PyObject * UnaryFunction0DDouble___call__(BPy_UnaryFunction0DDouble *self, PyObject *args, PyObject *kwds)
static void UnaryFunction0DDouble___dealloc__(BPy_UnaryFunction0DDouble *self)
int UnaryFunction0DDouble_Init(PyObject *module)
static int UnaryFunction0DDouble___init__(BPy_UnaryFunction0DDouble *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0DDouble_Type
static PyObject * UnaryFunction0DDouble___repr__(BPy_UnaryFunction0DDouble *self)
PyTypeObject UnaryFunction0D_Type
PyTypeObject ZDiscontinuityF0D_Type
PyObject * self
inherits from class Rep
Definition AppCanvas.cpp:20
static struct PyModuleDef module
Definition python.cpp:991