[Bf-blender-cvs] [49a5115] master: bmesh py api: add bmesh.utils.vert_splice(...)

Campbell Barton noreply at git.blender.org
Thu Jul 17 04:26:50 CEST 2014


Commit: 49a51154970569b0154196ac25f82a9db4e712a0
Author: Campbell Barton
Date:   Thu Jul 17 12:22:09 2014 +1000
https://developer.blender.org/rB49a51154970569b0154196ac25f82a9db4e712a0

bmesh py api: add bmesh.utils.vert_splice(...)

===================================================================

M	source/blender/python/bmesh/bmesh_py_utils.c

===================================================================

diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c
index 56a6daf..3c412cf 100644
--- a/source/blender/python/bmesh/bmesh_py_utils.c
+++ b/source/blender/python/bmesh/bmesh_py_utils.c
@@ -198,6 +198,65 @@ static PyObject *bpy_bm_utils_vert_dissolve(PyObject *UNUSED(self), PyObject *ar
 	return PyBool_FromLong((BM_vert_dissolve(bm, py_vert->v)));
 }
 
+PyDoc_STRVAR(bpy_bm_utils_vert_splice_doc,
+".. method:: vert_splice(vert, vert_target)\n"
+"\n"
+"   Splice vert into vert_target.\n"
+"\n"
+"   :arg vert: The vertex to be removed.\n"
+"   :type vert: :class:`bmesh.types.BMVert`\n"
+"   :arg vert_target: The vertex to use.\n"
+"   :type vert_target: :class:`bmesh.types.BMVert`\n"
+"\n"
+"   .. note:: The verts mustn't share an edge or face.\n"
+);
+static PyObject *bpy_bm_utils_vert_splice(PyObject *UNUSED(self), PyObject *args)
+{
+	BPy_BMVert *py_vert;
+	BPy_BMVert *py_vert_target;
+
+	BMesh *bm;
+
+	bool ok;
+
+	if (!PyArg_ParseTuple(args, "O!O!:vert_splice",
+	                      &BPy_BMVert_Type, &py_vert,
+	                      &BPy_BMVert_Type, &py_vert_target))
+	{
+		return NULL;
+	}
+
+	BPY_BM_CHECK_OBJ(py_vert);
+	BPY_BM_CHECK_OBJ(py_vert_target);
+
+	bm = py_vert->bm;
+	BPY_BM_CHECK_SOURCE_OBJ(bm, "vert_splice", py_vert_target);
+
+	if (py_vert->v == py_vert_target->v) {
+		PyErr_SetString(PyExc_ValueError,
+		                "vert_splice(...): vert arguments match");
+		return NULL;
+	}
+
+	if (BM_edge_exists(py_vert->v, py_vert_target->v)) {
+		PyErr_SetString(PyExc_ValueError,
+		                "vert_splice(...): verts can't share an edge");
+		return NULL;
+	}
+
+	if (BM_vert_pair_share_face_check(py_vert->v, py_vert_target->v)) {
+		PyErr_SetString(PyExc_ValueError,
+		                "vert_splice(...): verts can't share a face");
+		return NULL;
+	}
+
+	/* should always succeed */
+	ok = BM_vert_splice(bm, py_vert->v, py_vert_target->v);
+	BLI_assert(ok == true);
+
+	Py_RETURN_NONE;
+}
+
 PyDoc_STRVAR(bpy_bm_utils_vert_separate_doc,
 ".. method:: vert_separate(vert, edges)\n"
 "\n"
@@ -718,6 +777,7 @@ static struct PyMethodDef BPy_BM_utils_methods[] = {
 	{"vert_collapse_edge",  (PyCFunction)bpy_bm_utils_vert_collapse_edge,  METH_VARARGS, bpy_bm_utils_vert_collapse_edge_doc},
 	{"vert_collapse_faces", (PyCFunction)bpy_bm_utils_vert_collapse_faces, METH_VARARGS, bpy_bm_utils_vert_collapse_faces_doc},
 	{"vert_dissolve",       (PyCFunction)bpy_bm_utils_vert_dissolve,       METH_VARARGS, bpy_bm_utils_vert_dissolve_doc}, /* could use METH_O */
+	{"vert_splice",         (PyCFunction)bpy_bm_utils_vert_splice,         METH_VARARGS, bpy_bm_utils_vert_splice_doc},
 	{"vert_separate",       (PyCFunction)bpy_bm_utils_vert_separate,       METH_VARARGS, bpy_bm_utils_vert_separate_doc},
 	{"edge_split",          (PyCFunction)bpy_bm_utils_edge_split,          METH_VARARGS, bpy_bm_utils_edge_split_doc},
 	{"edge_rotate",         (PyCFunction)bpy_bm_utils_edge_rotate,         METH_VARARGS, bpy_bm_utils_edge_rotate_doc},




More information about the Bf-blender-cvs mailing list