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