diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-07-14 15:31:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-07-14 15:32:37 +0400 |
commit | a8e338cee593c6a0b4130356d0fb4a2a993d8e83 (patch) | |
tree | 47dec9781a500fe934dae594936a2f6839864528 /source/blender/python/bmesh/bmesh_py_utils.c | |
parent | 1bda27f6928a4bb1e48a6eaffadbf242977a6c83 (diff) |
Py/API: add bmesh.utils.face_split_edgenet
Diffstat (limited to 'source/blender/python/bmesh/bmesh_py_utils.c')
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_utils.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_utils.c b/source/blender/python/bmesh/bmesh_py_utils.c index 4f1ca568bb0..cc76012fdda 100644 --- a/source/blender/python/bmesh/bmesh_py_utils.c +++ b/source/blender/python/bmesh/bmesh_py_utils.c @@ -477,6 +477,80 @@ static PyObject *bpy_bm_utils_face_split(PyObject *UNUSED(self), PyObject *args, } +PyDoc_STRVAR(bpy_bm_utils_face_split_edgenet_doc, +".. method:: face_split_edgenet(face, edgenet)\n" +"\n" +" Splits a face into any number of regions defined by an edgenet.\n" +"\n" +" :arg face: The face to split.\n" +" :type face: :class:`bmesh.types.BMFace`\n" +" :arg face: The face to split.\n" +" :type face: :class:`bmesh.types.BMFace`\n" +" :arg edgenet: Sequence of faces.\n" +" :type edgenet: :class:`bmesh.types.BMFace`\n" +" :return: The newly created faces.\n" +" :rtype: tuple of (:class:`bmesh.types.BMFace`)\n" +); +static PyObject *bpy_bm_utils_face_split_edgenet(PyObject *UNUSED(self), PyObject *args, PyObject *kw) +{ + static const char *kwlist[] = {"face", "edgenet", NULL}; + + BPy_BMFace *py_face; + PyObject *edge_seq; + + BMEdge **edge_array; + Py_ssize_t edge_array_len; + + BMesh *bm; + + BMFace **face_arr; + int face_arr_len; + bool ok; + + + if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O:face_split_edgenet", (char **)kwlist, + &BPy_BMFace_Type, &py_face, + &edge_seq)) + { + return NULL; + } + + BPY_BM_CHECK_OBJ(py_face); + + bm = py_face->bm; + + edge_array = BPy_BMElem_PySeq_As_Array(&bm, edge_seq, 1, PY_SSIZE_T_MAX, + &edge_array_len, BM_EDGE, + true, true, "face_split_edgenet(...)"); + + if (edge_array == NULL) { + return NULL; + } + + /* --- main function body --- */ + + ok = BM_face_split_edgenet(bm, py_face->f, edge_array, edge_array_len, + &face_arr, &face_arr_len); + + PyMem_FREE(edge_array); + + if (ok) { + PyObject *ret = PyTuple_New(face_arr_len); + int i; + for (i = 0; i < face_arr_len; i++) { + PyTuple_SET_ITEM(ret, i, BPy_BMFace_CreatePyObject(bm, face_arr[i])); + } + MEM_freeN(face_arr); + return ret; + } + else { + PyErr_SetString(PyExc_ValueError, + "face_split_edgenet(...): couldn't split the face, internal error"); + return NULL; + } +} + + PyDoc_STRVAR(bpy_bm_utils_face_join_doc, ".. method:: face_join(faces, remove=True)\n" "\n" @@ -652,6 +726,7 @@ static struct PyMethodDef BPy_BM_utils_methods[] = { {"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}, {"face_split", (PyCFunction)bpy_bm_utils_face_split, METH_VARARGS | METH_KEYWORDS, bpy_bm_utils_face_split_doc}, + {"face_split_edgenet", (PyCFunction)bpy_bm_utils_face_split_edgenet, METH_VARARGS | METH_KEYWORDS, bpy_bm_utils_face_split_edgenet_doc}, {"face_join", (PyCFunction)bpy_bm_utils_face_join, METH_VARARGS, bpy_bm_utils_face_join_doc}, {"face_vert_separate", (PyCFunction)bpy_bm_utils_face_vert_separate, METH_VARARGS, bpy_bm_utils_face_vert_separate_doc}, {"face_flip", (PyCFunction)bpy_bm_utils_face_flip, METH_O, bpy_bm_utils_face_flip_doc}, |