Blender V5.3
BPy_UnaryFunction1DEdgeNature.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "../BPy_Convert.h"
13#include "../BPy_Interface1D.h"
14
16
17using namespace Freestyle;
18
20
21//-------------------MODULE INITIALIZATION--------------------------------
22
23int UnaryFunction1DEdgeNature_Init(PyObject *module)
24{
25 if (module == nullptr) {
26 return -1;
27 }
28
29 if (PyType_Ready(&UnaryFunction1DEdgeNature_Type) < 0) {
30 return -1;
31 }
32 PyModule_AddObjectRef(
33 module, "UnaryFunction1DEdgeNature", (PyObject *)&UnaryFunction1DEdgeNature_Type);
34
35 if (PyType_Ready(&CurveNatureF1D_Type) < 0) {
36 return -1;
37 }
38 PyModule_AddObjectRef(module, "CurveNatureF1D", (PyObject *)&CurveNatureF1D_Type);
39
40 return 0;
41}
42
43//------------------------INSTANCE METHODS ----------------------------------
44
46 /* Wrap. */
47 UnaryFunction1DEdgeNature___doc__,
48 "Class hierarchy: :class:`UnaryFunction1D` > :class:`UnaryFunction1DEdgeNature`\n"
49 "\n"
50 "Base class for unary functions (functors) that work on\n"
51 ":class:`Interface1D` and return a :class:`Nature` object.\n"
52 "\n"
53 ".. method:: __init__(*args)\n"
54 "\n"
55 " Accepted call signatures:\n"
56 "\n"
57 " - ``__init__()``\n"
58 " - ``__init__(integration_type)``\n"
59 "\n"
60 " Builds a unary 1D function using the default constructor\n"
61 " or the integration method given as an argument.\n"
62 "\n"
63 " :param integration_type: An integration method.\n"
64 " :type integration_type: :class:`IntegrationType`\n");
66 PyObject *args,
67 PyObject *kwds)
68{
69 static const char *kwlist[] = {"integration", nullptr};
70 PyObject *obj = nullptr;
71
72 if (!PyArg_ParseTupleAndKeywords(args,
73 kwds,
74 "|" /* Optional arguments. */
75 "O!" /* `integration` */
76 ":__init__",
77 (char **)kwlist,
79 &obj))
80 {
81 return -1;
82 }
83
84 if (!obj) {
86 }
87 else {
90 }
91
92 self->uf1D_edgenature->py_uf1D = (PyObject *)self;
93
94 return 0;
95}
96
98{
99 delete self->uf1D_edgenature;
100 UnaryFunction1D_Type.tp_dealloc((PyObject *)self);
101}
102
104{
105 return PyUnicode_FromFormat(
106 "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf1D_edgenature);
107}
108
110 PyObject *args,
111 PyObject *kwds)
112{
113 static const char *kwlist[] = {"inter", nullptr};
114 PyObject *obj = nullptr;
115
116 if (!PyArg_ParseTupleAndKeywords(args,
117 kwds,
118 "O!" /* `inter` */
119 ":__call__",
120 (char **)kwlist,
122 &obj))
123 {
124 return nullptr;
125 }
126
127 if (typeid(*(self->uf1D_edgenature)) == typeid(UnaryFunction1D<Nature::EdgeNature>)) {
128 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
129 return nullptr;
130 }
131 if (self->uf1D_edgenature->operator()(*(((BPy_Interface1D *)obj)->if1D)) < 0) {
132 if (!PyErr_Occurred()) {
133 string class_name(Py_TYPE(self)->tp_name);
134 PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
135 }
136 return nullptr;
137 }
139}
140
141/*----------------------UnaryFunction1DEdgeNature get/setters ----------------------------*/
142
144 /* Wrap. */
145 integration_type_doc,
146 "The integration method.\n"
147 "\n"
148 ":type: :class:`IntegrationType`\n");
153
155 PyObject *value,
156 void * /*closure*/)
157{
158 if (!BPy_IntegrationType_Check(value)) {
159 PyErr_SetString(PyExc_TypeError, "value must be an IntegrationType");
160 return -1;
161 }
163 return 0;
164}
165
167 {"integration_type",
168 (getter)integration_type_get,
169 (setter)integration_type_set,
170 integration_type_doc,
171 nullptr},
172 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
173};
174
175/*-----------------------BPy_UnaryFunction1DEdgeNature type definition --------------------------*/
176
178 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
179 /*tp_name*/ "UnaryFunction1DEdgeNature",
180 /*tp_basicsize*/ sizeof(BPy_UnaryFunction1DEdgeNature),
181 /*tp_itemsize*/ 0,
182 /*tp_dealloc*/ (destructor)UnaryFunction1DEdgeNature___dealloc__,
183 /*tp_vectorcall_offset*/ 0,
184 /*tp_getattr*/ nullptr,
185 /*tp_setattr*/ nullptr,
186 /*tp_as_async*/ nullptr,
187 /*tp_repr*/ (reprfunc)UnaryFunction1DEdgeNature___repr__,
188 /*tp_as_number*/ nullptr,
189 /*tp_as_sequence*/ nullptr,
190 /*tp_as_mapping*/ nullptr,
191 /*tp_hash*/ nullptr,
192 /*tp_call*/ (ternaryfunc)UnaryFunction1DEdgeNature___call__,
193 /*tp_str*/ nullptr,
194 /*tp_getattro*/ nullptr,
195 /*tp_setattro*/ nullptr,
196 /*tp_as_buffer*/ nullptr,
197 /*tp_flags*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
198 /*tp_doc*/ UnaryFunction1DEdgeNature___doc__,
199 /*tp_traverse*/ nullptr,
200 /*tp_clear*/ nullptr,
201 /*tp_richcompare*/ nullptr,
202 /*tp_weaklistoffset*/ 0,
203 /*tp_iter*/ nullptr,
204 /*tp_iternext*/ nullptr,
205 /*tp_methods*/ nullptr,
206 /*tp_members*/ nullptr,
208 /*tp_base*/ &UnaryFunction1D_Type,
209 /*tp_dict*/ nullptr,
210 /*tp_descr_get*/ nullptr,
211 /*tp_descr_set*/ nullptr,
212 /*tp_dictoffset*/ 0,
213 /*tp_init*/ (initproc)UnaryFunction1DEdgeNature___init__,
214 /*tp_alloc*/ nullptr,
215 /*tp_new*/ nullptr,
216};
217
PyObject * BPy_Nature_from_Nature(ushort n)
IntegrationType IntegrationType_from_BPy_IntegrationType(PyObject *obj)
PyObject * BPy_IntegrationType_from_IntegrationType(IntegrationType i)
PyTypeObject CurveNatureF1D_Type
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
PyTypeObject IntegrationType_Type
#define BPy_IntegrationType_Check(v)
PyTypeObject Interface1D_Type
PyTypeObject UnaryFunction1DEdgeNature_Type
static void UnaryFunction1DEdgeNature___dealloc__(BPy_UnaryFunction1DEdgeNature *self)
static PyObject * integration_type_get(BPy_UnaryFunction1DEdgeNature *self, void *)
static PyGetSetDef BPy_UnaryFunction1DEdgeNature_getseters[]
int UnaryFunction1DEdgeNature_Init(PyObject *module)
static PyObject * UnaryFunction1DEdgeNature___repr__(BPy_UnaryFunction1DEdgeNature *self)
static int integration_type_set(BPy_UnaryFunction1DEdgeNature *self, PyObject *value, void *)
static PyObject * UnaryFunction1DEdgeNature___call__(BPy_UnaryFunction1DEdgeNature *self, PyObject *args, PyObject *kwds)
static int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction1D_Type
IntegrationType getIntegrationType() const
Definition Functions1D.h:97
void setIntegrationType(IntegrationType integration)
Definition Functions1D.h:91
inherits from class Rep
Definition AppCanvas.cpp:20
Freestyle::UnaryFunction1D< Freestyle::Nature::EdgeNature > * uf1D_edgenature