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.
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
@@ -179,6 +179,30 @@ int BM_iter_elem_count_flag(const char itype, void *data, const char hflag, cons
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* \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
|
||||
*
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -84,7 +84,7 @@ void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
|
||||
* 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 @@ void bmo_edgenet_prepare_exec(BMesh *bm, BMOperator *op)
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user