Revision: 44356
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44356
Author:   campbellbarton
Date:     2012-02-23 05:20:09 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
bmesh py api, new submodules
* bmesh.types, just allows access to BMVert, BMEdge etc.
* bmesh.utils, so far only added edge_split() function, this module will give 
access to mesh editing functions.

Modified Paths:
--------------
    trunk/blender/source/blender/python/bmesh/CMakeLists.txt
    trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_api.h
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_types.h

Added Paths:
-----------
    trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_utils.h

Modified: trunk/blender/source/blender/python/bmesh/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/bmesh/CMakeLists.txt    2012-02-23 
05:17:07 UTC (rev 44355)
+++ trunk/blender/source/blender/python/bmesh/CMakeLists.txt    2012-02-23 
05:20:09 UTC (rev 44356)
@@ -23,7 +23,6 @@
        ../../bmesh
        ../../blenkernel
        ../../blenlib
-       ../../blenloader
        ../../makesdna
        ../../../../intern/guardedalloc
 )
@@ -35,9 +34,11 @@
 set(SRC
        bmesh_py_api.c
        bmesh_py_types.c
+       bmesh_py_utils.c
 
        bmesh_py_api.h
        bmesh_py_types.h
+       bmesh_py_utils.h
 )
 
 blender_add_lib(bf_python_bmesh "${SRC}" "${INC}" "${INC_SYS}")

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.c    2012-02-23 
05:17:07 UTC (rev 44355)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.c    2012-02-23 
05:20:09 UTC (rev 44356)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
  * All rights reserved.
  *
  * Contributor(s): Campbell Barton
@@ -23,10 +23,10 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/python/generic/blf_py_api.c
- *  \ingroup pygen
+/** \file blender/python/bmesh/bmesh_py_api.c
+ *  \ingroup pybmesh
  *
- * This file defines the 'bme' bmesh main module.
+ * This file defines the 'bmesh' module.
  */
 
 #include <Python.h>
@@ -34,6 +34,7 @@
 #include "bmesh.h"
 
 #include "bmesh_py_types.h"
+#include "bmesh_py_utils.h"
 
 #include "BLI_utildefines.h"
 
@@ -93,5 +94,9 @@
 
        submodule = PyModule_Create(&BPy_BM_module_def);
 
+       /* bmesh.types */
+       PyModule_AddObject(submodule, "types", BPyInit_bmesh_types());
+       PyModule_AddObject(submodule, "utils", BPyInit_bmesh_utils());
+
        return submodule;
 }

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.h
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.h    2012-02-23 
05:17:07 UTC (rev 44355)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.h    2012-02-23 
05:20:09 UTC (rev 44356)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
  * All rights reserved.
  *
  * Contributor(s): Campbell Barton
@@ -23,7 +23,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/python/bmesh/bme.h
+/** \file blender/python/bmesh/bmesh_py_api.h
  *  \ingroup pybmesh
  */
 

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c  2012-02-23 
05:17:07 UTC (rev 44355)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c  2012-02-23 
05:20:09 UTC (rev 44356)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
  * All rights reserved.
  *
  * Contributor(s): Campbell Barton
@@ -23,7 +23,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/python/bmesh/bme_types.c
+/** \file blender/python/bmesh/bmesh_py_types.c
  *  \ingroup pybmesh
  */
 
@@ -797,7 +797,7 @@
 
        BPY_BM_CHECK_OBJ(self);
 
-       if(!PyArg_ParseTuple(args, "|O:verts.new", py_co)) {
+       if (!PyArg_ParseTuple(args, "|O:verts.new", py_co)) {
                return NULL;
        }
        else {
@@ -831,7 +831,7 @@
 
        BPY_BM_CHECK_OBJ(self);
 
-       if(!PyArg_ParseTuple(args, "O!O!:edges.new",
+       if (!PyArg_ParseTuple(args, "O!O!:edges.new",
                             &BPy_BMVert_Type, &v1,
                             &BPy_BMVert_Type, &v2))
        {
@@ -877,7 +877,7 @@
 
        BPY_BM_CHECK_OBJ(self);
 
-       if(!PyArg_ParseTuple(args, "O:faces.new", &vert_seq)) {
+       if (!PyArg_ParseTuple(args, "O:faces.new", &vert_seq)) {
                return NULL;
        }
        else {
@@ -1001,7 +1001,7 @@
 {
        BPY_BM_CHECK_OBJ(self);
 
-       if(!BPy_BMVert_Check(value)) {
+       if (!BPy_BMVert_Check(value)) {
                return NULL;
        }
        else {
@@ -1025,7 +1025,7 @@
 {
        BPY_BM_CHECK_OBJ(self);
 
-       if(!BPy_BMEdge_Check(value)) {
+       if (!BPy_BMEdge_Check(value)) {
                return NULL;
        }
        else {
@@ -1049,7 +1049,7 @@
 {
        BPY_BM_CHECK_OBJ(self);
 
-       if(!BPy_BMFace_Check(value)) {
+       if (!BPy_BMFace_Check(value)) {
                return NULL;
        }
        else {
@@ -1572,7 +1572,43 @@
        PyType_Ready(&BPy_BMIter_Type);
 }
 
+/* bmesh.types submodule
+ * ********************* */
 
+static struct PyModuleDef BPy_BM_types_module_def = {
+       PyModuleDef_HEAD_INIT,
+       "bmesh.types",  /* m_name */
+       NULL,  /* m_doc */
+       0,  /* m_size */
+       NULL,  /* m_methods */
+       NULL,  /* m_reload */
+       NULL,  /* m_traverse */
+       NULL,  /* m_clear */
+       NULL,  /* m_free */
+};
+
+PyObject *BPyInit_bmesh_types(void)
+{
+       PyObject *submodule;
+
+       submodule = PyModule_Create(&BPy_BM_types_module_def);
+
+#define mod_type_add(s, t) \
+       PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject 
*)&t)
+
+       mod_type_add(submodule, BPy_BMesh_Type);
+       mod_type_add(submodule, BPy_BMVert_Type);
+       mod_type_add(submodule, BPy_BMEdge_Type);
+       mod_type_add(submodule, BPy_BMFace_Type);
+       mod_type_add(submodule, BPy_BMLoop_Type);
+       mod_type_add(submodule, BPy_BMElemSeq_Type);
+       mod_type_add(submodule, BPy_BMIter_Type);
+
+#undef mod_type_add
+
+       return submodule;
+}
+
 /* Utility Functions
  * ***************** */
 

Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.h
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.h  2012-02-23 
05:17:07 UTC (rev 44355)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.h  2012-02-23 
05:20:09 UTC (rev 44356)
@@ -15,7 +15,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
  * All rights reserved.
  *
  * Contributor(s): Campbell Barton
@@ -23,7 +23,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/python/bmesh/bme_types.h
+/** \file blender/python/bmesh/bmesh_py_types.h
  *  \ingroup pybmesh
  */
 
@@ -117,6 +117,8 @@
 
 void BPy_BM_init_types(void);
 
+PyObject *BPyInit_bmesh_types(void);
+
 PyObject *BPy_BMesh_CreatePyObject(BMesh *bm);
 PyObject *BPy_BMVert_CreatePyObject(BMesh *bm, BMVert *v);
 PyObject *BPy_BMEdge_CreatePyObject(BMesh *bm, BMEdge *e);

Added: trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c                  
        (rev 0)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c  2012-02-23 
05:20:09 UTC (rev 44356)
@@ -0,0 +1,133 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/bmesh/bmesh_py_api.c
+ *  \ingroup pybmesh
+ *
+ * This file defines the 'bmesh.utils' module.
+ * Utility functions for operating on 'bmesh.types'
+ */
+
+
+
+#include <Python.h>
+
+#include "bmesh.h"
+
+#include "bmesh_py_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "bmesh_py_utils.h" /* own include */
+
+PyDoc_STRVAR(bpy_bm_utils_edge_split_doc,
+".. method:: edge_split(vert, edge, fac)\n"
+"\n"
+"   Split an edge, return the newly created data.\n"
+"\n"
+"   :arg edge: The edge to split.\n"
+"   :type edge: :class:`bmesh.tupes.BMEdge`\n"
+"   :arg vert: One of the verts on the edge, defines the split direction.\n"
+"   :type vert: :class:`bmesh.tupes.BMVert`\n"
+"   :arg fac: The point on the edge where the new vert will be created.\n"
+"   :type fac: float\n"
+"   :return: The newly created (edge, vert) pair.\n"
+"   :rtype: tuple\n"
+);
+
+static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject 
*args)
+{
+       BPy_BMEdge *py_edge;
+       BPy_BMVert *py_vert;
+       float fac;
+
+       BMesh *bm;
+       BMVert *v_new = NULL;
+       BMEdge *e_new = NULL;
+
+       if (!PyArg_ParseTuple(args, "O!O!f:edge_split",
+                             &BPy_BMEdge_Type, &py_edge,
+                             &BPy_BMVert_Type, &py_vert,
+                             &fac))
+       {
+               return NULL;
+       }
+
+       BPY_BM_CHECK_OBJ(py_edge);
+       BPY_BM_CHECK_OBJ(py_vert);
+
+       if (!(py_edge->e->v1 == py_vert->v ||
+             py_edge->e->v2 == py_vert->v))
+       {
+               PyErr_SetString(PyExc_ValueError,
+                               "edge_split(edge, vert): the vertex is not 
found in the edge");
+               return NULL;
+       }
+
+       bm = py_edge->bm;
+
+       v_new = BM_edge_split(bm, py_edge->e, py_vert->v, &e_new, fac);
+
+       if (v_new && e_new) {
+               PyObject *ret = PyTuple_New(2);
+               PyTuple_SET_ITEM(ret, 0, BPy_BMEdge_CreatePyObject(bm, e_new));
+               PyTuple_SET_ITEM(ret, 1, BPy_BMVert_CreatePyObject(bm, v_new));
+               return ret;
+       }
+       else {
+               PyErr_SetString(PyExc_ValueError,
+                               "edge_split(edge, vert): couldn't split the 
edge, internal error");
+               return NULL;
+       }
+}
+
+static struct PyMethodDef BPy_BM_utils_methods[] = {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to