2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* ***** END GPL LICENSE BLOCK *****
21
/** \file source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
25
#include "BPy_UnaryFunction0DVectorViewShape.h"
27
#include "../BPy_Convert.h"
28
#include "../Iterator/BPy_Interface0DIterator.h"
30
#include "UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h"
36
///////////////////////////////////////////////////////////////////////////////////////////
38
//-------------------MODULE INITIALIZATION--------------------------------
40
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
45
if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0)
47
Py_INCREF(&UnaryFunction0DVectorViewShape_Type);
48
PyModule_AddObject(module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type);
50
if (PyType_Ready(&GetOccludersF0D_Type) < 0)
52
Py_INCREF(&GetOccludersF0D_Type);
53
PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type);
58
//------------------------INSTANCE METHODS ----------------------------------
60
static char UnaryFunction0DVectorViewShape___doc__[] =
61
"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n"
63
"Base class for unary functions (functors) that work on\n"
64
":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n"
67
".. method:: __init__()\n"
69
" Default constructor.\n";
71
static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape *self,
72
PyObject *args, PyObject *kwds)
74
static const char *kwlist[] = {NULL};
76
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
78
self->uf0D_vectorviewshape = new UnaryFunction0D< std::vector<ViewShape*> >();
79
self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
83
static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape *self)
85
if (self->uf0D_vectorviewshape)
86
delete self->uf0D_vectorviewshape;
87
UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
90
static PyObject *UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape *self)
92
return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vectorviewshape);
95
static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVectorViewShape *self,
96
PyObject *args, PyObject *kwds)
98
static const char *kwlist[] = {"it", NULL};
101
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
104
if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D< std::vector<ViewShape*> >)) {
105
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
108
if (self->uf0D_vectorviewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
109
if (!PyErr_Occurred()) {
110
string class_name(Py_TYPE(self)->tp_name);
111
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
115
PyObject *list = PyList_New(0);
117
for (unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) {
118
ViewShape *v = self->uf0D_vectorviewshape->result[i];
120
item = BPy_ViewShape_from_ViewShape(*v);
126
PyList_Append(list, item);
132
/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ------------------------------*/
134
PyTypeObject UnaryFunction0DVectorViewShape_Type = {
135
PyVarObject_HEAD_INIT(NULL, 0)
136
"UnaryFunction0DVectorViewShape", /* tp_name */
137
sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */
139
(destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */
144
(reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */
145
0, /* tp_as_number */
146
0, /* tp_as_sequence */
147
0, /* tp_as_mapping */
149
(ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
153
0, /* tp_as_buffer */
154
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
155
UnaryFunction0DVectorViewShape___doc__, /* tp_doc */
158
0, /* tp_richcompare */
159
0, /* tp_weaklistoffset */
165
&UnaryFunction0D_Type, /* tp_base */
167
0, /* tp_descr_get */
168
0, /* tp_descr_set */
169
0, /* tp_dictoffset */
170
(initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */
175
///////////////////////////////////////////////////////////////////////////////////////////