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