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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-22 15:52:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-22 15:52:56 +0400
commit361de47cf50460a668239fa7aa06746f645e2948 (patch)
treebc5fe4cc0a815934dc54ac8a9a811578d09f24eb /source
parent91353bc71685f04cb9e1596258165fc7b018d7af (diff)
bmesh py api - function to remove vert/edge/faces
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 256c17ef052..9f8b318746e 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -743,6 +743,99 @@ static PyObject *bpy_bm_seq_new(BPy_BMElemSeq *self, PyObject *args)
}
}
+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},
@@ -777,6 +870,7 @@ static struct PyMethodDef bpy_bmloop_methods[] = {
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}
};