diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-27 14:14:09 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-27 14:14:09 +0400 |
commit | cb6f4160cce25fb3f233e0e0a623d035836caa32 (patch) | |
tree | 4cd9f0760f178f90bedd828871e76230b5425435 /source/blender/bmesh/intern | |
parent | 93d5e106aac81fb1054d8ba0502f8d336f29b2c5 (diff) |
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.
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 28 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operator_api.h | 6 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operator_api_inline.h | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 19 |
5 files changed, 29 insertions, 27 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 44b76df7432..a1dde035224 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -170,7 +170,7 @@ int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, cons 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 @@ int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, cons } /** + * \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 @@ int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const 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++; } diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h index 3b795a253bd..5fb226ae11d 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.h +++ b/source/blender/bmesh/intern/bmesh_iterators.h @@ -132,6 +132,7 @@ __attribute__((warn_unused_result)) #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 */ diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h index 978aec0c610..180bc53c2e3 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api.h +++ b/source/blender/bmesh/intern/bmesh_operator_api.h @@ -83,7 +83,7 @@ struct GHashIterator; #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 @@ int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_na 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], diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.h b/source/blender/bmesh/intern/bmesh_operator_api_inline.h index 0e1d4fec4d3..724ddcf3b04 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.h +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.h @@ -43,7 +43,7 @@ BLI_INLINE short _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short 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; } diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index f52dd7f2be9..a358623834f 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1075,25 +1075,6 @@ void BMO_slot_buffer_hflag_disable(BMesh *bm, } } -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 * |