diff options
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.c | 50 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_iterators.h | 12 |
2 files changed, 62 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_iterators.c b/source/blender/bmesh/intern/bmesh_iterators.c index 4014d29966a..1ee629d203b 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.c +++ b/source/blender/bmesh/intern/bmesh_iterators.c @@ -31,6 +31,7 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_bitmap.h" #include "bmesh.h" #include "intern/bmesh_private.h" @@ -250,6 +251,55 @@ void *BMO_iter_as_arrayN( } } +int BM_iter_mesh_bitmap_from_filter( + const char itype, BMesh *bm, + BLI_bitmap *bitmap, + bool (*test_fn)(BMElem *, void *user_data), + void *user_data) +{ + BMIter iter; + BMElem *ele; + int i; + + BM_ITER_MESH_INDEX (ele, &iter, bm, itype, i) { + BLI_BITMAP_SET(bitmap, i, test_fn(ele, user_data)); + } + + return i; +} + +/** + * Needed when we want to check faces, but return a loop aligned array. + */ +int BM_iter_mesh_bitmap_from_filter_tessface( + BMesh *bm, + BLI_bitmap *bitmap, + bool (*test_fn)(BMFace *, void *user_data), + void *user_data) +{ + BMIter iter; + BMFace *f; + int i; + int j = 0; + + BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, i) { + if (test_fn(f, user_data)) { + for (int A = 2; A < f->len; A++) { + BLI_BITMAP_ENABLE(bitmap, j); + j++; + } + } + else { + for (int A = 2; A < f->len; A++) { + BLI_BITMAP_DISABLE(bitmap, j); + j++; + } + } + } + + return j; +} + /** * \brief Elem Iter Flag Count * diff --git a/source/blender/bmesh/intern/bmesh_iterators.h b/source/blender/bmesh/intern/bmesh_iterators.h index 336e9d88dea..0551d824131 100644 --- a/source/blender/bmesh/intern/bmesh_iterators.h +++ b/source/blender/bmesh/intern/bmesh_iterators.h @@ -208,6 +208,18 @@ void *BMO_iter_as_arrayN( int *r_len, /* optional args to avoid an alloc (normally stack array) */ void **stack_array, int stack_array_size); + +int BM_iter_mesh_bitmap_from_filter( + const char itype, BMesh *bm, + unsigned int *bitmap, + bool (*test_fn)(BMElem *, void *user_data), + void *user_data); +int BM_iter_mesh_bitmap_from_filter_tessface( + BMesh *bm, + unsigned int *bitmap, + bool (*test_fn)(BMFace *, void *user_data), + void *user_data); + 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(const char itype, BMesh *bm); |