~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 * ***** END GPL LICENSE BLOCK *****
 
19
 */
 
20
 
 
21
/** \file source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVectorViewShape.cpp
 
22
 *  \ingroup freestyle
 
23
 */
 
24
 
 
25
#include "BPy_UnaryFunction0DVectorViewShape.h"
 
26
 
 
27
#include "../BPy_Convert.h"
 
28
#include "../Iterator/BPy_Interface0DIterator.h"
 
29
 
 
30
#include "UnaryFunction0D_vector_ViewShape/BPy_GetOccludersF0D.h"
 
31
 
 
32
#ifdef __cplusplus
 
33
extern "C" {
 
34
#endif
 
35
 
 
36
///////////////////////////////////////////////////////////////////////////////////////////
 
37
 
 
38
//-------------------MODULE INITIALIZATION--------------------------------
 
39
 
 
40
int UnaryFunction0DVectorViewShape_Init(PyObject *module)
 
41
{
 
42
        if (module == NULL)
 
43
                return -1;
 
44
 
 
45
        if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0)
 
46
                return -1;
 
47
        Py_INCREF(&UnaryFunction0DVectorViewShape_Type);
 
48
        PyModule_AddObject(module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type);
 
49
 
 
50
        if (PyType_Ready(&GetOccludersF0D_Type) < 0)
 
51
                return -1;
 
52
        Py_INCREF(&GetOccludersF0D_Type);
 
53
        PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type);
 
54
 
 
55
        return 0;
 
56
}
 
57
 
 
58
//------------------------INSTANCE METHODS ----------------------------------
 
59
 
 
60
static char UnaryFunction0DVectorViewShape___doc__[] =
 
61
"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVectorViewShape`\n"
 
62
"\n"
 
63
"Base class for unary functions (functors) that work on\n"
 
64
":class:`Interface0DIterator` and return a list of :class:`ViewShape`\n"
 
65
"objects.\n"
 
66
"\n"
 
67
".. method:: __init__()\n"
 
68
"\n"
 
69
"   Default constructor.\n";
 
70
 
 
71
static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape *self,
 
72
                                                   PyObject *args, PyObject *kwds)
 
73
{
 
74
        static const char *kwlist[] = {NULL};
 
75
 
 
76
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
 
77
                return -1;
 
78
        self->uf0D_vectorviewshape = new UnaryFunction0D< std::vector<ViewShape*> >();
 
79
        self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
 
80
        return 0;
 
81
}
 
82
 
 
83
static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVectorViewShape *self)
 
84
{
 
85
        if (self->uf0D_vectorviewshape)
 
86
                delete self->uf0D_vectorviewshape;
 
87
        UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
 
88
}
 
89
 
 
90
static PyObject *UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape *self)
 
91
{
 
92
        return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vectorviewshape);
 
93
}
 
94
 
 
95
static PyObject *UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVectorViewShape *self,
 
96
                                                         PyObject *args, PyObject *kwds)
 
97
{
 
98
        static const char *kwlist[] = {"it", NULL};
 
99
        PyObject *obj;
 
100
 
 
101
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
 
102
                return NULL;
 
103
 
 
104
        if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D< std::vector<ViewShape*> >)) {
 
105
                PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
 
106
                return NULL;
 
107
        }
 
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());
 
112
                }
 
113
                return NULL;
 
114
        }
 
115
        PyObject *list = PyList_New(0);
 
116
        PyObject *item;
 
117
        for (unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) {
 
118
                ViewShape *v = self->uf0D_vectorviewshape->result[i];
 
119
                if (v) {
 
120
                        item = BPy_ViewShape_from_ViewShape(*v);
 
121
                }
 
122
                else {
 
123
                        item = Py_None;
 
124
                        Py_INCREF(item);
 
125
                }
 
126
                PyList_Append(list, item);
 
127
        }
 
128
        
 
129
        return list;
 
130
}
 
131
 
 
132
/*-----------------------BPy_UnaryFunction0DVectorViewShape type definition ------------------------------*/
 
133
 
 
134
PyTypeObject UnaryFunction0DVectorViewShape_Type = {
 
135
        PyVarObject_HEAD_INIT(NULL, 0)
 
136
        "UnaryFunction0DVectorViewShape", /* tp_name */
 
137
        sizeof(BPy_UnaryFunction0DVectorViewShape), /* tp_basicsize */
 
138
        0,                              /* tp_itemsize */
 
139
        (destructor)UnaryFunction0DVectorViewShape___dealloc__, /* tp_dealloc */
 
140
        0,                              /* tp_print */
 
141
        0,                              /* tp_getattr */
 
142
        0,                              /* tp_setattr */
 
143
        0,                              /* tp_reserved */
 
144
        (reprfunc)UnaryFunction0DVectorViewShape___repr__, /* tp_repr */
 
145
        0,                              /* tp_as_number */
 
146
        0,                              /* tp_as_sequence */
 
147
        0,                              /* tp_as_mapping */
 
148
        0,                              /* tp_hash  */
 
149
        (ternaryfunc)UnaryFunction0DVectorViewShape___call__, /* tp_call */
 
150
        0,                              /* tp_str */
 
151
        0,                              /* tp_getattro */
 
152
        0,                              /* tp_setattro */
 
153
        0,                              /* tp_as_buffer */
 
154
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 
155
        UnaryFunction0DVectorViewShape___doc__, /* tp_doc */
 
156
        0,                              /* tp_traverse */
 
157
        0,                              /* tp_clear */
 
158
        0,                              /* tp_richcompare */
 
159
        0,                              /* tp_weaklistoffset */
 
160
        0,                              /* tp_iter */
 
161
        0,                              /* tp_iternext */
 
162
        0,                              /* tp_methods */
 
163
        0,                              /* tp_members */
 
164
        0,                              /* tp_getset */
 
165
        &UnaryFunction0D_Type,          /* tp_base */
 
166
        0,                              /* tp_dict */
 
167
        0,                              /* tp_descr_get */
 
168
        0,                              /* tp_descr_set */
 
169
        0,                              /* tp_dictoffset */
 
170
        (initproc)UnaryFunction0DVectorViewShape___init__, /* tp_init */
 
171
        0,                              /* tp_alloc */
 
172
        0,                              /* tp_new */
 
173
};
 
174
 
 
175
///////////////////////////////////////////////////////////////////////////////////////////
 
176
 
 
177
#ifdef __cplusplus
 
178
}
 
179
#endif