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

This commit is contained in:
Campbell Barton 2014-07-17 12:22:09 +10:00
parent 7f4735ab3b
commit 49a5115497

@ -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))); 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, PyDoc_STRVAR(bpy_bm_utils_vert_separate_doc,
".. method:: vert_separate(vert, edges)\n" ".. method:: vert_separate(vert, edges)\n"
"\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_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_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_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}, {"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_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}, {"edge_rotate", (PyCFunction)bpy_bm_utils_edge_rotate, METH_VARARGS, bpy_bm_utils_edge_rotate_doc},