diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 22:39:37 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 22:39:37 +0400 |
commit | 4465d2f419a8515df41a8fc415774eedaef0e6f6 (patch) | |
tree | 8ea0e2d76fe6f937e4b8b132d614de7909ee4406 /source | |
parent | 3865276eb8c0f73646a32c05dbe9d8f65babe332 (diff) |
bmesh api functions, not used yet:
BM_iter_elem_count_flag()
BM_iter_mesh_count_flag()
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 44 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.h | 2 |
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 384715d74f7..8103ae1ee11 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -104,6 +104,50 @@ int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, cons return i; } +/** + * \brief Elem Iter Flag Count + * + * Counts how many flagged / unflagged items are found in this element. + */ +int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, const short value) +{ + BMIter iter; + BMElem *ele; + int count = 0; + + BLI_assert(ELEM(value, TRUE, FALSE)); + + for (ele = BM_iter_new(&iter, NULL, itype, data); ele; ele = BM_iter_step(&iter)) { + if (BM_elem_flag_test_bool(ele, hflag) == value) { + count++; + } + } + + return count; +} + +/** + * \brief Mesh Iter Flag Count + * + * Counts how many flagged / unflagged items are found in this mesh. + */ +int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const short value) +{ + BMIter iter; + BMElem *ele; + int count = 0; + + BLI_assert(ELEM(value, TRUE, FALSE)); + + for (ele = BM_iter_new(&iter, bm, itype, NULL); ele; ele = BM_iter_step(&iter)) { + if (BM_elem_flag_test_bool(ele, hflag) == value) { + count++; + } + } + + return count; +} + /** * \brief Init Iterator diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h index c687e4b4e7a..1361a91a692 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.h +++ b/source/blender/bmesh/intern/bmesh_iterators.h @@ -117,6 +117,8 @@ typedef struct BMIter { void *BM_iter_at_index(BMesh *bm, const char itype, void *data, int index); int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len); +int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, const short value); +int BM_iter_mesh_count_flag(const char itype, BMesh *bm, const char hflag, const short value); /* private for bmesh_iterators_inline.c */ void bmiter__vert_of_mesh_begin(struct BMIter *iter); |