[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44319] trunk/blender/source/blender/ python/bmesh/bmesh_py_types.c: bmesh py api - function to remove vert/edge/ faces
Campbell Barton
ideasman42 at gmail.com
Wed Feb 22 12:53:03 CET 2012
Revision: 44319
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44319
Author: campbellbarton
Date: 2012-02-22 11:52:56 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
bmesh py api - function to remove vert/edge/faces
Modified Paths:
--------------
trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-02-22 11:31:07 UTC (rev 44318)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-02-22 11:52:56 UTC (rev 44319)
@@ -743,7 +743,100 @@
}
}
+static PyObject *bpy_bmvert_seq_remove(BPy_BMElemSeq *self, BPy_BMVert *value)
+{
+ BPY_BM_CHECK_OBJ(self);
+ if(!BPy_BMVert_Check(value)) {
+ return NULL;
+ }
+ else {
+ BMesh *bm = self->bm;
+
+ BPY_BM_CHECK_OBJ(value);
+
+ if (value->bm != bm) {
+ PyErr_SetString(PyExc_TypeError,
+ "faces.remove(vert): vertex is from another mesh");
+ }
+
+ BM_vert_kill(bm, value->v);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;;
+ }
+}
+
+static PyObject *bpy_bmedge_seq_remove(BPy_BMElemSeq *self, BPy_BMEdge *value)
+{
+ BPY_BM_CHECK_OBJ(self);
+
+ if(!BPy_BMEdge_Check(value)) {
+ return NULL;
+ }
+ else {
+ BMesh *bm = self->bm;
+
+ BPY_BM_CHECK_OBJ(value);
+
+ if (value->bm != bm) {
+ PyErr_SetString(PyExc_TypeError,
+ "faces.remove(vert): vertex is from another mesh");
+ }
+
+ BM_edge_kill(bm, value->e);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;;
+ }
+}
+
+static PyObject *bpy_bmface_seq_remove(BPy_BMElemSeq *self, BPy_BMFace *value)
+{
+ BPY_BM_CHECK_OBJ(self);
+
+ if(!BPy_BMFace_Check(value)) {
+ return NULL;
+ }
+ else {
+ BMesh *bm = self->bm;
+
+ BPY_BM_CHECK_OBJ(value);
+
+ if (value->bm != bm) {
+ PyErr_SetString(PyExc_TypeError,
+ "faces.remove(vert): vertex is from another mesh");
+ }
+
+ BM_face_kill(bm, value->f);
+ bpy_bm_generic_invalidate((BPy_BMGeneric *)value);
+
+ Py_RETURN_NONE;;
+ }
+}
+
+
+PyDoc_STRVAR(bpy_bm_seq_remove_doc,
+ ".. method:: remove()\n"
+ "\n"
+ " Remove a vert/edge/face.\n"
+ );
+static PyObject *bpy_bm_seq_remove(BPy_BMElemSeq *self, PyObject *value)
+{
+ switch ((BMIterType)self->itype) {
+ case BM_VERTS_OF_MESH:
+ return bpy_bmvert_seq_remove(self, (BPy_BMVert *)value);
+ case BM_EDGES_OF_MESH:
+ return bpy_bmedge_seq_remove(self, (BPy_BMEdge *)value);
+ case BM_FACES_OF_MESH:
+ return bpy_bmface_seq_remove(self, (BPy_BMFace *)value);
+ default:
+ PyErr_SetString(PyExc_TypeError,
+ ".remove(item): function is not valid for this sequence");
+ return NULL;
+ }
+}
+
static struct PyMethodDef bpy_bmesh_methods[] = {
{"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc},
{"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc},
@@ -777,6 +870,7 @@
static struct PyMethodDef bpy_bm_seq_methods[] = {
{"new", (PyCFunction)bpy_bm_seq_new, METH_VARARGS, bpy_bm_seq_new_doc},
+ {"remove", (PyCFunction)bpy_bm_seq_remove, METH_O, bpy_bm_seq_remove_doc},
{NULL, NULL, 0, NULL}
};
More information about the Bf-blender-cvs
mailing list