~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/python/bmesh/bmesh_py_types.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

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
 * The Original Code is Copyright (C) 2012 Blender Foundation.
 
19
 * All rights reserved.
 
20
 *
 
21
 * Contributor(s): Campbell Barton
 
22
 *
 
23
 * ***** END GPL LICENSE BLOCK *****
 
24
 */
 
25
 
 
26
/** \file blender/python/bmesh/bmesh_py_types.h
 
27
 *  \ingroup pybmesh
 
28
 */
 
29
 
 
30
#ifndef __BMESH_TYPES_H__
 
31
#define __BMESH_TYPES_H__
 
32
 
 
33
extern PyTypeObject BPy_BMesh_Type;
 
34
extern PyTypeObject BPy_BMVert_Type;
 
35
extern PyTypeObject BPy_BMEdge_Type;
 
36
extern PyTypeObject BPy_BMFace_Type;
 
37
extern PyTypeObject BPy_BMLoop_Type;
 
38
 
 
39
extern PyTypeObject BPy_BMElemSeq_Type;
 
40
extern PyTypeObject BPy_BMVertSeq_Type;
 
41
extern PyTypeObject BPy_BMEdgeSeq_Type;
 
42
extern PyTypeObject BPy_BMFaceSeq_Type;
 
43
extern PyTypeObject BPy_BMLoopSeq_Type;
 
44
 
 
45
extern PyTypeObject BPy_BMIter_Type;
 
46
 
 
47
#define BPy_BMesh_Check(v)      (Py_TYPE(v) == &BPy_BMesh_Type)
 
48
#define BPy_BMVert_Check(v)     (Py_TYPE(v) == &BPy_BMVert_Type)
 
49
#define BPy_BMEdge_Check(v)     (Py_TYPE(v) == &BPy_BMEdge_Type)
 
50
#define BPy_BMFace_Check(v)     (Py_TYPE(v) == &BPy_BMFace_Type)
 
51
#define BPy_BMLoop_Check(v)     (Py_TYPE(v) == &BPy_BMLoop_Type)
 
52
#define BPy_BMElemSeq_Check(v)  (Py_TYPE(v) == &BPy_BMElemSeq_Type)
 
53
#define BPy_BMVertSeq_Check(v)  (Py_TYPE(v) == &BPy_BMVertSeq_Type)
 
54
#define BPy_BMEdgeSeq_Check(v)  (Py_TYPE(v) == &BPy_BMEdgeSeq_Type)
 
55
#define BPy_BMFaceSeq_Check(v)  (Py_TYPE(v) == &BPy_BMFaceSeq_Type)
 
56
#define BPy_BMLoopSeq_Check(v)  (Py_TYPE(v) == &BPy_BMLoopSeq_Type)
 
57
#define BPy_BMIter_Check(v)     (Py_TYPE(v) == &BPy_BMIter_Type)
 
58
 
 
59
/* cast from _any_ bmesh type - they all have BMesh first */
 
60
typedef struct BPy_BMGeneric {
 
61
        PyObject_VAR_HEAD
 
62
        struct BMesh *bm; /* keep first */
 
63
} BPy_BMGeneric;
 
64
 
 
65
/* BPy_BMVert/BPy_BMEdge/BPy_BMFace/BPy_BMLoop can cast to this */
 
66
typedef struct BPy_BMElem {
 
67
        PyObject_VAR_HEAD
 
68
        struct BMesh *bm; /* keep first */
 
69
        struct BMElem *ele;
 
70
} BPy_BMElem;
 
71
 
 
72
typedef struct BPy_BMesh {
 
73
        PyObject_VAR_HEAD
 
74
        struct BMesh *bm; /* keep first */
 
75
        int flag;
 
76
} BPy_BMesh;
 
77
 
 
78
/* element types */
 
79
typedef struct BPy_BMVert {
 
80
        PyObject_VAR_HEAD
 
81
        struct BMesh *bm; /* keep first */
 
82
        struct BMVert *v;
 
83
} BPy_BMVert;
 
84
 
 
85
typedef struct BPy_BMEdge {
 
86
        PyObject_VAR_HEAD
 
87
        struct BMesh *bm; /* keep first */
 
88
        struct BMEdge *e;
 
89
} BPy_BMEdge;
 
90
 
 
91
typedef struct BPy_BMFace {
 
92
        PyObject_VAR_HEAD
 
93
        struct BMesh *bm; /* keep first */
 
94
        struct BMFace *f;
 
95
} BPy_BMFace;
 
96
 
 
97
typedef struct BPy_BMLoop {
 
98
        PyObject_VAR_HEAD
 
99
        struct BMesh *bm; /* keep first */
 
100
        struct BMLoop *l;
 
101
} BPy_BMLoop;
 
102
 
 
103
 
 
104
/* iterators */
 
105
 
 
106
/* used for ...
 
107
 * - BPy_BMElemSeq_Type
 
108
 * - BPy_BMVertSeq_Type
 
109
 * - BPy_BMEdgeSeq_Type
 
110
 * - BPy_BMFaceSeq_Type
 
111
 * - BPy_BMLoopSeq_Type
 
112
 */
 
113
typedef struct BPy_BMElemSeq {
 
114
        PyObject_VAR_HEAD
 
115
        struct BMesh *bm; /* keep first */
 
116
 
 
117
        /* if this is a sequence on an existing element,
 
118
         * loops of faces for eg.
 
119
         * If this veriable is set, it will be used */
 
120
 
 
121
        /* we hold a reference to this.
 
122
         * check in case the owner becomes invalid on access */
 
123
        /* TODO - make this a GC'd object!, will function OK without this though */
 
124
        BPy_BMElem *py_ele;
 
125
 
 
126
        /* iterator type */
 
127
        short itype;
 
128
} BPy_BMElemSeq;
 
129
 
 
130
typedef struct BPy_BMIter {
 
131
        PyObject_VAR_HEAD
 
132
        struct BMesh *bm; /* keep first */
 
133
        BMIter iter;
 
134
} BPy_BMIter;
 
135
 
 
136
void BPy_BM_init_types(void);
 
137
 
 
138
PyObject *BPyInit_bmesh_types(void);
 
139
 
 
140
enum {
 
141
    BPY_BMFLAG_NOP = 0,       /* do nothing */
 
142
    BPY_BMFLAG_IS_WRAPPED = 1 /* the mesh is owned by editmode */
 
143
};
 
144
 
 
145
PyObject *BPy_BMesh_CreatePyObject(BMesh *bm, int flag);
 
146
PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v);
 
147
PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e);
 
148
PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f);
 
149
PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l);
 
150
PyObject *BPy_BMElemSeq_CreatePyObject(BMesh *bm, BPy_BMElem *py_ele, const char itype);
 
151
PyObject *BPy_BMVertSeq_CreatePyObject(BMesh *bm);
 
152
PyObject *BPy_BMEdgeSeq_CreatePyObject(BMesh *bm);
 
153
PyObject *BPy_BMFaceSeq_CreatePyObject(BMesh *bm);
 
154
PyObject *BPy_BMLoopSeq_CreatePyObject(BMesh *bm);
 
155
PyObject *BPy_BMIter_CreatePyObject(BMesh *bm);
 
156
 
 
157
PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele); /* just checks type and creates v/e/f/l */
 
158
 
 
159
int  bpy_bm_generic_valid_check(BPy_BMGeneric *self);
 
160
void bpy_bm_generic_invalidate(BPy_BMGeneric *self);
 
161
 
 
162
void *BPy_BMElem_PySeq_As_Array(BMesh **r_bm, PyObject *seq, Py_ssize_t min, Py_ssize_t max, Py_ssize_t *r_size,
 
163
                                const char htype,
 
164
                                const char do_unique_check, const char do_bm_check,
 
165
                                const char *error_prefix);
 
166
 
 
167
PyObject *BPy_BMElem_Array_As_Tuple(BMesh *bm, BMHeader **elem, Py_ssize_t elem_len);
 
168
int       BPy_BMElem_CheckHType(PyTypeObject *type, const char htype);
 
169
char     *BPy_BMElem_StringFromHType_ex(const char htype, char ret[32]);
 
170
char     *BPy_BMElem_StringFromHType(const char htype);
 
171
 
 
172
 
 
173
#define BPY_BM_CHECK_OBJ(obj) if (UNLIKELY(bpy_bm_generic_valid_check((BPy_BMGeneric *)obj) == -1)) { return NULL; } (void)0
 
174
#define BPY_BM_CHECK_INT(obj) if (UNLIKELY(bpy_bm_generic_valid_check((BPy_BMGeneric *)obj) == -1)) { return -1; }   (void)0
 
175
 
 
176
#define BPY_BM_IS_VALID(obj) (LIKELY((obj)->bm != NULL))
 
177
 
 
178
#define BM_ITER_BPY_BM_SEQ(ele, iter, bpy_bmelemseq)                          \
 
179
        for (ele = BM_iter_new(iter,                                              \
 
180
                               (bpy_bmelemseq)->bm,                               \
 
181
                               (bpy_bmelemseq)->itype,                            \
 
182
                               (bpy_bmelemseq)->py_ele ?                          \
 
183
                                   ((BPy_BMElem *)(bpy_bmelemseq)->py_ele)->ele : \
 
184
                                   NULL                                           \
 
185
                               );                                                 \
 
186
             ele;                                                                 \
 
187
             ele = BM_iter_step(iter))
 
188
 
 
189
#endif /* __BMESH_TYPES_H__ */