[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55623] trunk/blender/source/blender/bmesh : api cleanup: replace BMO_vert_edge_flags_count() with more reusable function - BMO_iter_elem_count_flag().

Campbell Barton ideasman42 at gmail.com
Wed Mar 27 11:14:10 CET 2013


Revision: 55623
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55623
Author:   campbellbarton
Date:     2013-03-27 10:14:09 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
api cleanup: replace BMO_vert_edge_flags_count() with more reusable function - BMO_iter_elem_count_flag().
closely matching existing BM_iter_elem_count_flag() function but checks tool-flags instead.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_iterators.c
    trunk/blender/source/blender/bmesh/intern/bmesh_iterators.h
    trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
    trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
    trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
    trunk/blender/source/blender/bmesh/operators/bmo_edgeloop_fill.c
    trunk/blender/source/blender/bmesh/operators/bmo_edgenet.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_iterators.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_iterators.c	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_iterators.c	2013-03-27 10:14:09 UTC (rev 55623)
@@ -170,7 +170,7 @@
 	BMElem *ele;
 	int count = 0;
 
-	for (ele = BM_iter_new(&iter, NULL, itype, data); ele; ele = BM_iter_step(&iter)) {
+	BM_ITER_ELEM (ele, &iter, data, itype) {
 		if (BM_elem_flag_test_bool(ele, hflag) == value) {
 			count++;
 		}
@@ -180,6 +180,30 @@
 }
 
 /**
+ * \brief Elem Iter Tool Flag Count
+ *
+ * Counts how many flagged / unflagged items are found in this element.
+ */
+int BMO_iter_elem_count_flag(BMesh *bm, const char itype, void *data,
+                             const short oflag, const bool value)
+{
+	BMIter iter;
+	BMElemF *ele;
+	int count = 0;
+
+	/* loops have no header flags */
+	BLI_assert(bm_iter_itype_htype_map[itype] != BM_LOOP);
+
+	BM_ITER_ELEM (ele, &iter, data, itype) {
+		if (BMO_elem_flag_test_bool(bm, ele, oflag) == value) {
+			count++;
+		}
+	}
+	return count;
+}
+
+
+/**
  * \brief Mesh Iter Flag Count
  *
  * Counts how many flagged / unflagged items are found in this mesh.
@@ -190,7 +214,7 @@
 	BMElem *ele;
 	int count = 0;
 
-	for (ele = BM_iter_new(&iter, bm, itype, NULL); ele; ele = BM_iter_step(&iter)) {
+	BM_ITER_MESH (ele, &iter, bm, itype) {
 		if (BM_elem_flag_test_bool(ele, hflag) == value) {
 			count++;
 		}

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_iterators.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_iterators.h	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_iterators.h	2013-03-27 10:14:09 UTC (rev 55623)
@@ -132,6 +132,7 @@
 #endif
 ;
 int     BM_iter_elem_count_flag(const char itype, void *data, const char hflag, const bool value);
+int     BMO_iter_elem_count_flag(BMesh *bm, const char itype, void *data, const short oflag, const bool value);
 int     BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const bool value);
 
 /* private for bmesh_iterators_inline.c */

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api.h	2013-03-27 10:14:09 UTC (rev 55623)
@@ -83,7 +83,7 @@
 #define BMO_elem_flag_toggle(   bm, ele, oflag)      _bmo_elem_flag_toggle   (bm, (ele)->oflags, oflag)
 
 BLI_INLINE short _bmo_elem_flag_test(     BMesh *bm, BMFlagLayer *oflags, const short oflag);
-BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag);
+BLI_INLINE bool  _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag);
 BLI_INLINE void  _bmo_elem_flag_enable(   BMesh *bm, BMFlagLayer *oflags, const short oflag);
 BLI_INLINE void  _bmo_elem_flag_disable(  BMesh *bm, BMFlagLayer *oflags, const short oflag);
 BLI_INLINE void  _bmo_elem_flag_set(      BMesh *bm, BMFlagLayer *oflags, const short oflag, int val);
@@ -391,10 +391,6 @@
 void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot,
                          const void *element, const void *data, const int len);
 
-/* Counts the number of edges with tool flag toolflag around
- */
-int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag);
-
 /* flags all elements in a mapping.  note that the mapping must only have
  * bmesh elements in it.*/
 void BMO_slot_map_to_flag(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS],

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operator_api_inline.h	2013-03-27 10:14:09 UTC (rev 55623)
@@ -43,7 +43,7 @@
 	return oflags[bm->stackdepth - 1].f & oflag;
 }
 
-BLI_INLINE short _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag)
+BLI_INLINE bool _bmo_elem_flag_test_bool(BMesh *bm, BMFlagLayer *oflags, const short oflag)
 {
 	return (oflags[bm->stackdepth - 1].f & oflag) != 0;
 }

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_operators.c	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_operators.c	2013-03-27 10:14:09 UTC (rev 55623)
@@ -1075,25 +1075,6 @@
 	}
 }
 
-int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag)
-{
-	int count = 0;
-
-	if (v->e) {
-		BMEdge *curedge;
-		const int len = bmesh_disk_count(v);
-		int i;
-		
-		for (i = 0, curedge = v->e; i < len; i++) {
-			if (BMO_elem_flag_test(bm, curedge, oflag))
-				count++;
-			curedge = bmesh_disk_edge_next(curedge, v);
-		}
-	}
-
-	return count;
-}
-
 /**
  * \brief BMO_FLAG_BUFFER
  *

Modified: trunk/blender/source/blender/bmesh/operators/bmo_edgeloop_fill.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_edgeloop_fill.c	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/operators/bmo_edgeloop_fill.c	2013-03-27 10:14:09 UTC (rev 55623)
@@ -84,7 +84,7 @@
 	for (i = 0; i < totv; i++) {
 		v = verts[i];
 		/* count how many flagged edges this vertex uses */
-		if (BMO_vert_edge_flags_count(bm, v, EDGE_MARK) != 2) {
+		if (BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, v, EDGE_MARK, true) != 2) {
 			ok = false;
 			break;
 		}

Modified: trunk/blender/source/blender/bmesh/operators/bmo_edgenet.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_edgenet.c	2013-03-27 10:05:31 UTC (rev 55622)
+++ trunk/blender/source/blender/bmesh/operators/bmo_edgenet.c	2013-03-27 10:14:09 UTC (rev 55623)
@@ -1112,7 +1112,7 @@
 	 * disk cycle around each of it's vertices */
 	BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
 		for (i = 0; i < 2; i++) {
-			count = BMO_vert_edge_flags_count(bm, i ? e->v2 : e->v1, EDGE_MARK);
+			count = BMO_iter_elem_count_flag(bm,  BM_EDGES_OF_VERT, (i ? e->v2 : e->v1), EDGE_MARK, true);
 			if (count > 2) {
 				ok = 0;
 				break;
@@ -1134,8 +1134,8 @@
 	while (1) {
 		BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
 			if (!BMO_elem_flag_test(bm, e, EDGE_VIS)) {
-				if (BMO_vert_edge_flags_count(bm, e->v1, EDGE_MARK) == 1 ||
-				    BMO_vert_edge_flags_count(bm, e->v2, EDGE_MARK) == 1)
+				if (BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, e->v1, EDGE_MARK, true) == 1 ||
+				    BMO_iter_elem_count_flag(bm, BM_EDGES_OF_VERT, e->v2, EDGE_MARK, true) == 1)
 				{
 					break;
 				}




More information about the Bf-blender-cvs mailing list