[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48323] trunk/blender/source/blender: bmesh.ops module for bmesh operator access, only remove_doubles and convex_hull at the moment.
Campbell Barton
ideasman42 at gmail.com
Tue Jun 26 23:40:06 CEST 2012
Revision: 48323
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48323
Author: campbellbarton
Date: 2012-06-26 21:40:01 +0000 (Tue, 26 Jun 2012)
Log Message:
-----------
bmesh.ops module for bmesh operator access, only remove_doubles and convex_hull at the moment.
Modified Paths:
--------------
trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
trunk/blender/source/blender/bmesh/intern/bmesh_operators_private.h
trunk/blender/source/blender/bmesh/operators/bmo_primitive.c
trunk/blender/source/blender/bmesh/operators/bmo_removedoubles.c
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_types.h
trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c
Added Paths:
-----------
trunk/blender/source/blender/python/bmesh/bmesh_py_ops.c
trunk/blender/source/blender/python/bmesh/bmesh_py_ops.h
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2012-06-26 21:40:01 UTC (rev 48323)
@@ -245,12 +245,12 @@
* Finds groups of vertices closer then dist and merges them together,
* using the weld verts bmop.
*/
-static BMOpDefine bmo_removedoubles_def = {
- "removedoubles",
+static BMOpDefine bmo_remove_doubles_def = {
+ "remove_doubles",
{{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input verts
{BMO_OP_SLOT_FLT, "dist"}, //minimum distance
{0, /* null-terminating sentinel */}},
- bmo_removedoubles_exec,
+ bmo_remove_doubles_exec,
BMO_OP_FLAG_UNTAN_MULTIRES,
};
@@ -1199,7 +1199,7 @@
&bmo_contextual_create_def,
&bmo_makevert_def,
&bmo_weldverts_def,
- &bmo_removedoubles_def,
+ &bmo_remove_doubles_def,
&bmo_finddoubles_def,
&bmo_mirror_def,
&bmo_edgebisect_def,
Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators_private.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators_private.h 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators_private.h 2012-06-26 21:40:01 UTC (rev 48323)
@@ -57,7 +57,7 @@
void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op);
void bmo_dissolve_edgeloop_exec(BMesh *bm, BMOperator *op);
void bmo_weldverts_exec(BMesh *bm, BMOperator *op);
-void bmo_removedoubles_exec(BMesh *bm, BMOperator *op);
+void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op);
void bmo_finddoubles_exec(BMesh *bm, BMOperator *op);
void bmo_mirror_exec(BMesh *bm, BMOperator *op);
void bmo_edgebisect_exec(BMesh *bm, BMOperator *op);
Modified: trunk/blender/source/blender/bmesh/operators/bmo_primitive.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_primitive.c 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/bmesh/operators/bmo_primitive.c 2012-06-26 21:40:01 UTC (rev 48323)
@@ -365,7 +365,7 @@
len2 = len_v3v3(vec, vec2);
/* use shortest segment length divided by 3 as merge threshold */
- BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f);
+ BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, MIN2(len, len2) / 3.0f);
}
/* and now do imat */
@@ -661,7 +661,7 @@
BM_face_create_quad_tri(bm, v1, v2, firstv2, firstv1, NULL, FALSE);
- BMO_op_callf(bm, "removedoubles verts=%fv dist=%f", VERT_MARK, 0.000001);
+ BMO_op_callf(bm, "remove_doubles verts=%fv dist=%f", VERT_MARK, 0.000001);
BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
}
Modified: trunk/blender/source/blender/bmesh/operators/bmo_removedoubles.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_removedoubles.c 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/bmesh/operators/bmo_removedoubles.c 2012-06-26 21:40:01 UTC (rev 48323)
@@ -557,7 +557,7 @@
BLI_array_free(verts);
}
-void bmo_removedoubles_exec(BMesh *bm, BMOperator *op)
+void bmo_remove_doubles_exec(BMesh *bm, BMOperator *op)
{
BMOperator weldop;
Modified: trunk/blender/source/blender/python/bmesh/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/bmesh/CMakeLists.txt 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/python/bmesh/CMakeLists.txt 2012-06-26 21:40:01 UTC (rev 48323)
@@ -33,6 +33,7 @@
set(SRC
bmesh_py_api.c
+ bmesh_py_ops.c
bmesh_py_types.c
bmesh_py_types_customdata.c
bmesh_py_types_meshdata.c
@@ -40,6 +41,7 @@
bmesh_py_utils.c
bmesh_py_api.h
+ bmesh_py_ops.h
bmesh_py_types.h
bmesh_py_types_customdata.h
bmesh_py_types_meshdata.h
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_api.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_api.c 2012-06-26 20:36:19 UTC (rev 48322)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_api.c 2012-06-26 21:40:01 UTC (rev 48323)
@@ -40,6 +40,7 @@
#include "bmesh_py_types_customdata.h"
#include "bmesh_py_types_meshdata.h"
+#include "bmesh_py_ops.h"
#include "bmesh_py_utils.h"
#include "BKE_tessmesh.h"
@@ -143,6 +144,10 @@
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
+ PyModule_AddObject(mod, "ops", (submodule = BPyInit_bmesh_ops()));
+ PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
+ Py_INCREF(submodule);
+
PyModule_AddObject(mod, "utils", (submodule = BPyInit_bmesh_utils()));
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
Added: trunk/blender/source/blender/python/bmesh/bmesh_py_ops.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_ops.c (rev 0)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_ops.c 2012-06-26 21:40:01 UTC (rev 48323)
@@ -0,0 +1,200 @@
+/*
+ * ***** 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_ops.c
+ * \ingroup pybmesh
+ *
+ * This file defines the 'bmesh.ops' module.
+ * Operators from 'opdefines' are wrapped.
+ */
+
+#include <Python.h>
+
+#include "BLI_utildefines.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "../generic/py_capi_utils.h"
+
+#include "../mathutils/mathutils.h"
+
+#include "bmesh.h"
+
+#include "bmesh_py_types.h"
+
+#include "bmesh_py_utils.h" /* own include */
+
+static int bpy_bm_op_as_py_error(BMesh *bm)
+{
+ if (BMO_error_occurred(bm)) {
+ const char *errmsg;
+ if (BMO_error_get(bm, &errmsg, NULL)) {
+ PyErr_Format(PyExc_RuntimeError,
+ "bmesh operator: %.200s",
+ errmsg);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+PyDoc_STRVAR(bpy_bm_ops_convex_hull_doc,
+".. method:: convex_hull(bmesh, filter)\n"
+"\n"
+" Face split with optional intermediate points.\n"
+"\n"
+" :arg bmesh: The face to cut.\n"
+" :type bmesh: :class:`bmesh.types.BMFace`\n"
+" :arg filter: Set containing vertex flags to apply the operator.\n"
+" :type filter: set\n"
+);
+static PyObject *bpy_bm_ops_convex_hull(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ static const char *kwlist[] = {"bmesh", "filter", NULL};
+
+ BPy_BMesh *py_bm;
+ BMesh *bm;
+
+ PyObject *filter;
+ int filter_flags;
+ BMOperator bmop;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!:convex_hull", (char **)kwlist,
+ &BPy_BMesh_Type, &py_bm,
+ &PySet_Type, &filter))
+ {
+ return NULL;
+ }
+
+ BPY_BM_CHECK_OBJ(py_bm);
+ bm = py_bm->bm;
+
+ if (filter != NULL && PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter,
+ &filter_flags, "convex_hull") == -1)
+ {
+ return NULL;
+ }
+
+ BMO_op_initf(bm, &bmop,
+ "convex_hull input=%hv",
+ filter_flags);
+ BMO_op_exec(bm, &bmop);
+ BMO_op_finish(bm, &bmop);
+
+ if (bpy_bm_op_as_py_error(bm) == -1) {
+ return NULL;
+ }
+
+ /* TODO, return values */
+ Py_RETURN_NONE;
+}
+
+PyDoc_STRVAR(bpy_bm_ops_remove_doubles_doc,
+".. method:: remove_doubles(bmesh, filter, dist)\n"
+"\n"
+" Face split with optional intermediate points.\n"
+"\n"
+" :arg bmesh: The face to cut.\n"
+" :type bmesh: :class:`bmesh.types.BMFace`\n"
+" :arg filter: Set containing vertex flags to apply the operator.\n"
+" :type filter: set\n"
+" :arg dist: Distance limit.\n"
+" :type dist: float\n"
+);
+static PyObject *bpy_bm_ops_remove_doubles(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
+{
+ static const char *kwlist[] = {"bmesh", "filter", "dist", NULL};
+
+ BPy_BMesh *py_bm;
+ BMesh *bm;
+
+ PyObject *filter;
+ int filter_flags;
+ float dist = 0.0f;
+
+ BMOperator bmop;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kw, "O!O!|f:remove_doubles", (char **)kwlist,
+ &BPy_BMesh_Type, &py_bm,
+ &PySet_Type, &filter,
+ &dist))
+ {
+ return NULL;
+ }
+
+ BPY_BM_CHECK_OBJ(py_bm);
+ bm = py_bm->bm;
+
+ if (filter != NULL && PyC_FlagSet_ToBitfield(bpy_bm_hflag_all_flags, filter,
+ &filter_flags, "remove_doubles") == -1)
+ {
+ return NULL;
+ }
+
+ BMO_op_initf(bm, &bmop,
+ "remove_doubles verts=%hv dist=%f",
+ filter_flags, dist);
+ BMO_op_exec(bm, &bmop);
+ BMO_op_finish(bm, &bmop);
+
+ if (bpy_bm_op_as_py_error(bm) == -1) {
+ return NULL;
+ }
+
+ /* TODO, return values */
+ Py_RETURN_NONE;
+}
+
+static struct PyMethodDef BPy_BM_ops_methods[] = {
+ {"convex_hull", (PyCFunction)bpy_bm_ops_convex_hull, METH_VARARGS | METH_KEYWORDS, bpy_bm_ops_convex_hull_doc},
+ {"remove_doubles", (PyCFunction)bpy_bm_ops_remove_doubles, METH_VARARGS | METH_KEYWORDS, bpy_bm_ops_remove_doubles_doc},
+ {NULL, NULL, 0, NULL}
+};
+
+
+PyDoc_STRVAR(BPy_BM_ops_doc,
+ "This module provides access to bmesh operators (EXPEREMENTAL)."
+ );
+static struct PyModuleDef BPy_BM_ops_module_def = {
+ PyModuleDef_HEAD_INIT,
+ "bmesh.ops", /* m_name */
+ BPy_BM_ops_doc, /* m_doc */
+ 0, /* m_size */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list