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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-22 13:19:53 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-22 13:19:53 +0400
commite7d98179eabcb44d8042d85b3be55f604833a088 (patch)
tree3f79235118ed0b61b2f6cd25b2cb472eb2045bd8 /source/blender/python/bmesh/bmesh_py_types.h
parent3788adb8cbe227e68d6c4442d8896f8d00c502fb (diff)
initial bmesh python api.
corrently allows to create and loop over verts/edges/faces, access selection and selection modes. this is still WIP, access to face, edge verts is still missing, no access to UV's, no access to editing operations yet. When the api is ready it will be documented by sphinx like mathutils, blf, aud.
Diffstat (limited to 'source/blender/python/bmesh/bmesh_py_types.h')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.h124
1 files changed, 124 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h
new file mode 100644
index 00000000000..51d5e6aa5ee
--- /dev/null
+++ b/source/blender/python/bmesh/bmesh_py_types.h
@@ -0,0 +1,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__ */