Blender  V2.93
BPy_UnaryFunction0DViewShape.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 
23 #include "../BPy_Convert.h"
24 #include "../Iterator/BPy_Interface0DIterator.h"
25 
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 using namespace Freestyle;
34 
36 
37 //-------------------MODULE INITIALIZATION--------------------------------
38 
40 {
41  if (module == nullptr) {
42  return -1;
43  }
44 
45  if (PyType_Ready(&UnaryFunction0DViewShape_Type) < 0) {
46  return -1;
47  }
49  PyModule_AddObject(
50  module, "UnaryFunction0DViewShape", (PyObject *)&UnaryFunction0DViewShape_Type);
51 
52  if (PyType_Ready(&GetOccludeeF0D_Type) < 0) {
53  return -1;
54  }
55  Py_INCREF(&GetOccludeeF0D_Type);
56  PyModule_AddObject(module, "GetOccludeeF0D", (PyObject *)&GetOccludeeF0D_Type);
57 
58  if (PyType_Ready(&GetShapeF0D_Type) < 0) {
59  return -1;
60  }
61  Py_INCREF(&GetShapeF0D_Type);
62  PyModule_AddObject(module, "GetShapeF0D", (PyObject *)&GetShapeF0D_Type);
63 
64  return 0;
65 }
66 
67 //------------------------INSTANCE METHODS ----------------------------------
68 
70  "Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DViewShape`\n"
71  "\n"
72  "Base class for unary functions (functors) that work on\n"
73  ":class:`Interface0DIterator` and return a :class:`ViewShape` object.\n"
74  "\n"
75  ".. method:: __init__()\n"
76  "\n"
77  " Default constructor.\n";
78 
80  PyObject *args,
81  PyObject *kwds)
82 {
83  static const char *kwlist[] = {nullptr};
84 
85  if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
86  return -1;
87  }
88  self->uf0D_viewshape = new UnaryFunction0D<ViewShape *>();
89  self->uf0D_viewshape->py_uf0D = (PyObject *)self;
90  return 0;
91 }
92 
94 {
95  delete self->uf0D_viewshape;
96  UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
97 }
98 
100 {
101  return PyUnicode_FromFormat(
102  "type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_viewshape);
103 }
104 
106  PyObject *args,
107  PyObject *kwds)
108 {
109  static const char *kwlist[] = {"it", nullptr};
110  PyObject *obj;
111 
112  if (!PyArg_ParseTupleAndKeywords(
113  args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj)) {
114  return nullptr;
115  }
116 
117  if (typeid(*(self->uf0D_viewshape)) == typeid(UnaryFunction0D<ViewShape *>)) {
118  PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
119  return nullptr;
120  }
121  if (self->uf0D_viewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
122  if (!PyErr_Occurred()) {
123  string class_name(Py_TYPE(self)->tp_name);
124  PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
125  }
126  return nullptr;
127  }
128  return BPy_ViewShape_from_ViewShape(*(self->uf0D_viewshape->result));
129 }
130 
131 /*-----------------------BPy_UnaryFunction0DViewShape type definition ---------------------------*/
132 
134  PyVarObject_HEAD_INIT(nullptr, 0) "UnaryFunction0DViewShape", /* tp_name */
135  sizeof(BPy_UnaryFunction0DViewShape), /* tp_basicsize */
136  0, /* tp_itemsize */
137  (destructor)UnaryFunction0DViewShape___dealloc__, /* tp_dealloc */
138  0, /* tp_vectorcall_offset */
139  nullptr, /* tp_getattr */
140  nullptr, /* tp_setattr */
141  nullptr, /* tp_reserved */
142  (reprfunc)UnaryFunction0DViewShape___repr__, /* tp_repr */
143  nullptr, /* tp_as_number */
144  nullptr, /* tp_as_sequence */
145  nullptr, /* tp_as_mapping */
146  nullptr, /* tp_hash */
147  (ternaryfunc)UnaryFunction0DViewShape___call__, /* tp_call */
148  nullptr, /* tp_str */
149  nullptr, /* tp_getattro */
150  nullptr, /* tp_setattro */
151  nullptr, /* tp_as_buffer */
152  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
154  nullptr, /* tp_traverse */
155  nullptr, /* tp_clear */
156  nullptr, /* tp_richcompare */
157  0, /* tp_weaklistoffset */
158  nullptr, /* tp_iter */
159  nullptr, /* tp_iternext */
160  nullptr, /* tp_methods */
161  nullptr, /* tp_members */
162  nullptr, /* tp_getset */
163  &UnaryFunction0D_Type, /* tp_base */
164  nullptr, /* tp_dict */
165  nullptr, /* tp_descr_get */
166  nullptr, /* tp_descr_set */
167  0, /* tp_dictoffset */
168  (initproc)UnaryFunction0DViewShape___init__, /* tp_init */
169  nullptr, /* tp_alloc */
170  nullptr, /* tp_new */
171 };
172 
174 
175 #ifdef __cplusplus
176 }
177 #endif
PyObject * BPy_ViewShape_from_ViewShape(ViewShape &vs)
PyTypeObject GetOccludeeF0D_Type
PyTypeObject GetShapeF0D_Type
PyTypeObject Interface0DIterator_Type
static int UnaryFunction0DViewShape___init__(BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds)
static void UnaryFunction0DViewShape___dealloc__(BPy_UnaryFunction0DViewShape *self)
static PyObject * UnaryFunction0DViewShape___repr__(BPy_UnaryFunction0DViewShape *self)
int UnaryFunction0DViewShape_Init(PyObject *module)
static char UnaryFunction0DViewShape___doc__[]
PyTypeObject UnaryFunction0DViewShape_Type
static PyObject * UnaryFunction0DViewShape___call__(BPy_UnaryFunction0DViewShape *self, PyObject *args, PyObject *kwds)
PyTypeObject UnaryFunction0D_Type
static struct PyModuleDef module
PyObject * self
Definition: bpy_driver.c:185
inherits from class Rep
Definition: AppCanvas.cpp:32