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

« back to all changes in this revision

Viewing changes to source/blender/freestyle/intern/python/UnaryFunction0D/BPy_UnaryFunction0DVec2f.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_UnaryFunction0DVec2f.cpp
 
22
 *  \ingroup freestyle
 
23
 */
 
24
 
 
25
#include "BPy_UnaryFunction0DVec2f.h"
 
26
 
 
27
#include "../BPy_Convert.h"
 
28
#include "../Iterator/BPy_Interface0DIterator.h"
 
29
 
 
30
#include "UnaryFunction0D_Vec2f/BPy_Normal2DF0D.h"
 
31
#include "UnaryFunction0D_Vec2f/BPy_VertexOrientation2DF0D.h"
 
32
 
 
33
#ifdef __cplusplus
 
34
extern "C" {
 
35
#endif
 
36
 
 
37
///////////////////////////////////////////////////////////////////////////////////////////
 
38
 
 
39
//-------------------MODULE INITIALIZATION--------------------------------
 
40
 
 
41
int UnaryFunction0DVec2f_Init(PyObject *module)
 
42
{
 
43
        if (module == NULL)
 
44
                return -1;
 
45
 
 
46
        if (PyType_Ready(&UnaryFunction0DVec2f_Type) < 0)
 
47
                return -1;
 
48
        Py_INCREF(&UnaryFunction0DVec2f_Type);
 
49
        PyModule_AddObject(module, "UnaryFunction0DVec2f", (PyObject *)&UnaryFunction0DVec2f_Type);
 
50
 
 
51
        if (PyType_Ready(&Normal2DF0D_Type) < 0)
 
52
                return -1;
 
53
        Py_INCREF(&Normal2DF0D_Type);
 
54
        PyModule_AddObject(module, "Normal2DF0D", (PyObject *)&Normal2DF0D_Type);
 
55
 
 
56
        if (PyType_Ready(&VertexOrientation2DF0D_Type) < 0)
 
57
                return -1;
 
58
        Py_INCREF(&VertexOrientation2DF0D_Type);
 
59
        PyModule_AddObject(module, "VertexOrientation2DF0D", (PyObject *)&VertexOrientation2DF0D_Type);
 
60
 
 
61
        return 0;
 
62
}
 
63
 
 
64
//------------------------INSTANCE METHODS ----------------------------------
 
65
 
 
66
static char UnaryFunction0DVec2f___doc__[] =
 
67
"Class hierarchy: :class:`UnaryFunction0D` > :class:`UnaryFunction0DVec2f`\n"
 
68
"\n"
 
69
"Base class for unary functions (functors) that work on\n"
 
70
":class:`Interface0DIterator` and return a 2D vector.\n"
 
71
"\n"
 
72
".. method:: __init__()\n"
 
73
"\n"
 
74
"   Default constructor.\n";
 
75
 
 
76
static int UnaryFunction0DVec2f___init__(BPy_UnaryFunction0DVec2f *self, PyObject *args, PyObject *kwds)
 
77
{
 
78
        static const char *kwlist[] = {NULL};
 
79
 
 
80
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
 
81
                return -1;
 
82
        self->uf0D_vec2f = new UnaryFunction0D<Vec2f>();
 
83
        self->uf0D_vec2f->py_uf0D = (PyObject *)self;
 
84
        return 0;
 
85
}
 
86
 
 
87
static void UnaryFunction0DVec2f___dealloc__(BPy_UnaryFunction0DVec2f *self)
 
88
{
 
89
        if (self->uf0D_vec2f)
 
90
                delete self->uf0D_vec2f;
 
91
        UnaryFunction0D_Type.tp_dealloc((PyObject *)self);
 
92
}
 
93
 
 
94
static PyObject *UnaryFunction0DVec2f___repr__(BPy_UnaryFunction0DVec2f *self)
 
95
{
 
96
        return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vec2f);
 
97
}
 
98
 
 
99
static PyObject *UnaryFunction0DVec2f___call__(BPy_UnaryFunction0DVec2f *self, PyObject *args, PyObject *kwds)
 
100
{
 
101
        static const char *kwlist[] = {"it", NULL};
 
102
        PyObject *obj;
 
103
 
 
104
        if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
 
105
                return NULL;
 
106
 
 
107
        if (typeid(*(self->uf0D_vec2f)) == typeid(UnaryFunction0D<Vec2f>)) {
 
108
                PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
 
109
                return NULL;
 
110
        }
 
111
        if (self->uf0D_vec2f->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
 
112
                if (!PyErr_Occurred()) {
 
113
                        string class_name(Py_TYPE(self)->tp_name);
 
114
                        PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
 
115
                }
 
116
                return NULL;
 
117
        }
 
118
        return Vector_from_Vec2f(self->uf0D_vec2f->result);
 
119
}
 
120
 
 
121
/*-----------------------BPy_UnaryFunction0DVec2f type definition ------------------------------*/
 
122
 
 
123
PyTypeObject UnaryFunction0DVec2f_Type = {
 
124
        PyVarObject_HEAD_INIT(NULL, 0)
 
125
        "UnaryFunction0DVec2f",         /* tp_name */
 
126
        sizeof(BPy_UnaryFunction0DVec2f), /* tp_basicsize */
 
127
        0,                              /* tp_itemsize */
 
128
        (destructor)UnaryFunction0DVec2f___dealloc__, /* tp_dealloc */
 
129
        0,                              /* tp_print */
 
130
        0,                              /* tp_getattr */
 
131
        0,                              /* tp_setattr */
 
132
        0,                              /* tp_reserved */
 
133
        (reprfunc)UnaryFunction0DVec2f___repr__, /* tp_repr */
 
134
        0,                              /* tp_as_number */
 
135
        0,                              /* tp_as_sequence */
 
136
        0,                              /* tp_as_mapping */
 
137
        0,                              /* tp_hash  */
 
138
        (ternaryfunc)UnaryFunction0DVec2f___call__, /* tp_call */
 
139
        0,                              /* tp_str */
 
140
        0,                              /* tp_getattro */
 
141
        0,                              /* tp_setattro */
 
142
        0,                              /* tp_as_buffer */
 
143
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
 
144
        UnaryFunction0DVec2f___doc__,   /* tp_doc */
 
145
        0,                              /* tp_traverse */
 
146
        0,                              /* tp_clear */
 
147
        0,                              /* tp_richcompare */
 
148
        0,                              /* tp_weaklistoffset */
 
149
        0,                              /* tp_iter */
 
150
        0,                              /* tp_iternext */
 
151
        0,                              /* tp_methods */
 
152
        0,                              /* tp_members */
 
153
        0,                              /* tp_getset */
 
154
        &UnaryFunction0D_Type,          /* tp_base */
 
155
        0,                              /* tp_dict */
 
156
        0,                              /* tp_descr_get */
 
157
        0,                              /* tp_descr_set */
 
158
        0,                              /* tp_dictoffset */
 
159
        (initproc)UnaryFunction0DVec2f___init__, /* tp_init */
 
160
        0,                              /* tp_alloc */
 
161
        0,                              /* tp_new */
 
162
};
 
163
 
 
164
///////////////////////////////////////////////////////////////////////////////////////////
 
165
 
 
166
#ifdef __cplusplus
 
167
}
 
168
#endif