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
* The Original Code is Copyright (C) 2012 Blender Foundation.
19
* All rights reserved.
21
* Contributor(s): Campbell Barton
23
* ***** END GPL LICENSE BLOCK *****
26
/** \file blender/python/bmesh/bmesh_py_types.h
30
#ifndef __BMESH_TYPES_H__
31
#define __BMESH_TYPES_H__
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;
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;
45
extern PyTypeObject BPy_BMIter_Type;
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)
59
/* cast from _any_ bmesh type - they all have BMesh first */
60
typedef struct BPy_BMGeneric {
62
struct BMesh *bm; /* keep first */
65
/* BPy_BMVert/BPy_BMEdge/BPy_BMFace/BPy_BMLoop can cast to this */
66
typedef struct BPy_BMElem {
68
struct BMesh *bm; /* keep first */
72
typedef struct BPy_BMesh {
74
struct BMesh *bm; /* keep first */
79
typedef struct BPy_BMVert {
81
struct BMesh *bm; /* keep first */
85
typedef struct BPy_BMEdge {
87
struct BMesh *bm; /* keep first */
91
typedef struct BPy_BMFace {
93
struct BMesh *bm; /* keep first */
97
typedef struct BPy_BMLoop {
99
struct BMesh *bm; /* keep first */
107
* - BPy_BMElemSeq_Type
108
* - BPy_BMVertSeq_Type
109
* - BPy_BMEdgeSeq_Type
110
* - BPy_BMFaceSeq_Type
111
* - BPy_BMLoopSeq_Type
113
typedef struct BPy_BMElemSeq {
115
struct BMesh *bm; /* keep first */
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 */
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 */
130
typedef struct BPy_BMIter {
132
struct BMesh *bm; /* keep first */
136
void BPy_BM_init_types(void);
138
PyObject *BPyInit_bmesh_types(void);
141
BPY_BMFLAG_NOP = 0, /* do nothing */
142
BPY_BMFLAG_IS_WRAPPED = 1 /* the mesh is owned by editmode */
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);
157
PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele); /* just checks type and creates v/e/f/l */
159
int bpy_bm_generic_valid_check(BPy_BMGeneric *self);
160
void bpy_bm_generic_invalidate(BPy_BMGeneric *self);
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,
164
const char do_unique_check, const char do_bm_check,
165
const char *error_prefix);
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);
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
176
#define BPY_BM_IS_VALID(obj) (LIKELY((obj)->bm != NULL))
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 : \
187
ele = BM_iter_step(iter))
189
#endif /* __BMESH_TYPES_H__ */