Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bmesh_py_types.h « bmesh « python « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 51d5e6aa5ee0c74af6888b6eb492b0bc228b26ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2011 Blender Foundation.
 * All rights reserved.
 *
 * Contributor(s): Campbell Barton
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file blender/python/bmesh/bme_types.h
 *  \ingroup pybmesh
 */

#ifndef __BMESH_TYPES_H__
#define __BMESH_TYPES_H__

extern PyTypeObject BPy_BMesh_Type;
extern PyTypeObject BPy_BMVert_Type;
extern PyTypeObject BPy_BMEdge_Type;
extern PyTypeObject BPy_BMFace_Type;
extern PyTypeObject BPy_BMLoop_Type;
extern PyTypeObject BPy_BMVertSeq_Type;
extern PyTypeObject BPy_BMEdgeSeq_Type;
extern PyTypeObject BPy_BMFaceSeq_Type;
extern PyTypeObject BPy_BMIter_Type;

#define BPy_BMesh_Check(v)      (Py_TYPE(v) == &BPy_BMesh_Type)
#define BPy_BMVert_Check(v)     (Py_TYPE(v) == &BPy_BMVert_Type)
#define BPy_BMEdge_Check(v)     (Py_TYPE(v) == &BPy_BMEdge_Type)
#define BPy_BMFace_Check(v)     (Py_TYPE(v) == &BPy_BMFace_Type)
#define BPy_BMLoop_Check(v)     (Py_TYPE(v) == &BPy_BMLoop_Type)
#define BPy_BMVertSeq_Check(v)  (Py_TYPE(v) == &BPy_BMVertSeq_Type)
#define BPy_BMEdgeSeq_Check(v)  (Py_TYPE(v) == &BPy_BMEdgeSeq_Type)
#define BPy_BMFaceSeq_Check(v)  (Py_TYPE(v) == &BPy_BMFaceSeq_Type)
#define BPy_BMIter_Check(v)     (Py_TYPE(v) == &BPy_BMIter_Type)

/* cast from _any_ bmesh type - they all have BMesh first */
typedef struct BPy_BMGeneric {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
} BPy_BMGeneric;

/* BPy_BMVert/BPy_BMEdge/BPy_BMFace/BPy_BMLoop can cast to this */
typedef struct BPy_BMElem {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	struct BMHeader *ele;
} BPy_BMElem;

typedef struct BPy_BMesh {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
} BPy_BMesh;

/* element types */
typedef struct BPy_BMVert {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	struct BMVert *v;
} BPy_BMVert;

typedef struct BPy_BMEdge {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	struct BMEdge *e;
} BPy_BMEdge;

typedef struct BPy_BMFace {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	struct BMFace *f;
} BPy_BMFace;

typedef struct BPy_BMLoop {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	struct BMLoop *l;
} BPy_BMLoop;


/* iterators */
typedef struct BPy_BMIter {
	PyObject_VAR_HEAD
	struct BMesh *bm; /* keep first */
	BMIter iter;
} BPy_BMIter;

void BPy_BM_init_types(void);

PyObject *BPy_BMesh_CreatePyObject(BMesh *bm);
PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v);
PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e);
PyObject *BPy_BMFace_CreatePyObject(BMesh *bm, BMFace *f);
PyObject *BPy_BMLoop_CreatePyObject(BMesh *bm, BMLoop *l);
PyObject *BPy_BMVertSeq_CreatePyObject(BMesh *bm);
PyObject *BPy_BMEdgeSeq_CreatePyObject(BMesh *bm);
PyObject *BPy_BMFaceSeq_CreatePyObject(BMesh *bm);
PyObject *BPy_BMIter_CreatePyObject(BMesh *bm);

PyObject *BPy_BMElem_CreatePyObject(BMesh *bm, BMHeader *ele); /* just checks type and creates v/e/f/l */

int  bpy_bm_generic_valid_check(BPy_BMGeneric *self);
void bpy_bm_generic_invalidate(BPy_BMGeneric *self);

#define BPY_BM_CHECK_OBJ(obj) if (bpy_bm_generic_valid_check((BPy_BMGeneric *)obj) == -1) { return NULL; } (void)NULL
#define BPY_BM_CHECK_INT(obj) if (bpy_bm_generic_valid_check((BPy_BMGeneric *)obj) == -1) { return -1; }   (void)NULL

#endif /* __BMESH_TYPES_H__ */