diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 20:42:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 20:42:43 +0400 |
commit | b27854bd47104300a484e3b06185b2cb1fa0b774 (patch) | |
tree | 3be00fa743238e3a50283f56d595d978ed36667b /source/blender/bmesh/intern/bmesh_queries.c | |
parent | 6cdbd1b1aaae0f8b3018ecf2648699a0ea6d6be8 (diff) |
use booleans for bmesh api.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_queries.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index b5b6c69bd7e..23d7af5277c 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -43,7 +43,7 @@ * Returns whether or not a given vertex is * is part of a given edge. */ -int BM_vert_in_edge(BMEdge *e, BMVert *v) +bool BM_vert_in_edge(BMEdge *e, BMVert *v) { return bmesh_vert_in_edge(e, v); } @@ -208,9 +208,9 @@ BMLoop *BM_vert_find_first_loop(BMVert *v) } /** - * Returns TRUE if the vertex is used in a given face. + * Returns true if the vertex is used in a given face. */ -int BM_vert_in_face(BMFace *f, BMVert *v) +bool BM_vert_in_face(BMFace *f, BMVert *v) { BMLoop *l_iter, *l_first; @@ -226,19 +226,19 @@ int BM_vert_in_face(BMFace *f, BMVert *v) #endif do { if (l_iter->v == v) { - return TRUE; + return true; } } while ((l_iter = l_iter->next) != l_first); } - return FALSE; + return false; } /** * Compares the number of vertices in an array * that appear in a given face */ -int BM_verts_in_face(BMFace *f, BMVert **varr, int len) +int BM_verts_in_face_count(BMFace *f, BMVert **varr, int len) { BMLoop *l_iter, *l_first; @@ -281,7 +281,7 @@ int BM_verts_in_face(BMFace *f, BMVert **varr, int len) /** * Returns whether or not a given edge is is part of a given face. */ -int BM_edge_in_face(BMFace *f, BMEdge *e) +bool BM_edge_in_face(BMFace *f, BMEdge *e) { BMLoop *l_iter; BMLoop *l_first; @@ -290,17 +290,17 @@ int BM_edge_in_face(BMFace *f, BMEdge *e) do { if (l_iter->e == e) { - return TRUE; + return true; } } while ((l_iter = l_iter->next) != l_first); - return FALSE; + return false; } /** * Returns whether or not a given edge is is part of a given loop. */ -int BM_edge_in_loop(BMEdge *e, BMLoop *l) +bool BM_edge_in_loop(BMEdge *e, BMLoop *l) { return (l->e == e || l->prev->e == e); } @@ -309,7 +309,7 @@ int BM_edge_in_loop(BMEdge *e, BMLoop *l) * Returns whether or not two vertices are in * a given edge */ -int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e) +bool BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e) { return bmesh_verts_in_edge(v1, v2, e); } @@ -487,9 +487,9 @@ float BM_edge_calc_length_squared(BMEdge *e) * Utility function, since enough times we have an edge * and want to access 2 connected faces. * - * \return TRUE when only 2 faces are found. + * \return true when only 2 faces are found. */ -int BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb) +bool BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb) { BMLoop *la, *lb; @@ -500,12 +500,12 @@ int BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb) { *r_fa = la->f; *r_fb = lb->f; - return TRUE; + return true; } else { *r_fa = NULL; *r_fb = NULL; - return FALSE; + return false; } } @@ -513,9 +513,9 @@ int BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb) * Utility function, since enough times we have an edge * and want to access 2 connected loops. * - * \return TRUE when only 2 faces are found. + * \return true when only 2 faces are found. */ -int BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb) +bool BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb) { BMLoop *la, *lb; @@ -526,12 +526,12 @@ int BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb) { *r_la = la; *r_lb = lb; - return TRUE; + return true; } else { *r_la = NULL; *r_lb = NULL; - return FALSE; + return false; } } @@ -589,7 +589,7 @@ int BM_vert_face_count(BMVert *v) * Tests whether or not the vertex is part of a wire edge. * (ie: has no faces attached to it) */ -int BM_vert_is_wire(BMVert *v) +bool BM_vert_is_wire(BMVert *v) { if (v->e) { BMEdge *e_first, *e_iter; @@ -597,14 +597,14 @@ int BM_vert_is_wire(BMVert *v) e_first = e_iter = v->e; do { if (e_iter->l) { - return FALSE; + return false; } } while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -612,9 +612,9 @@ int BM_vert_is_wire(BMVert *v) * Tests whether or not the edge is part of a wire. * (ie: has no faces attached to it) */ -int BM_edge_is_wire(BMEdge *e) +bool BM_edge_is_wire(BMEdge *e) { - return (e->l) ? FALSE : TRUE; + return (e->l == NULL); } /** @@ -624,7 +624,7 @@ int BM_edge_is_wire(BMEdge *e) * 3: Is part of a an edge with more than 2 faces. * 4: Is part of a wire edge. */ -int BM_vert_is_manifold(BMVert *v) +bool BM_vert_is_manifold(BMVert *v) { BMEdge *e, *oe; BMLoop *l; @@ -632,7 +632,7 @@ int BM_vert_is_manifold(BMVert *v) if (v->e == NULL) { /* loose vert */ - return FALSE; + return false; } /* count edges while looking for non-manifold edges */ @@ -643,7 +643,7 @@ int BM_vert_is_manifold(BMVert *v) * edges with 1 face user are OK, otherwise we could * use BM_edge_is_manifold() here */ if (e->l == NULL || bmesh_radial_length(e->l) > 2) { - return FALSE; + return false; } len++; } while ((e = bmesh_disk_edge_next(e, v)) != oe); @@ -677,10 +677,10 @@ int BM_vert_is_manifold(BMVert *v) if (count < len) { /* vert shared by multiple regions */ - return FALSE; + return false; } - return TRUE; + return true; } /** @@ -689,7 +689,7 @@ int BM_vert_is_manifold(BMVert *v) */ #if 1 /* fast path for checking manifold */ -int BM_edge_is_manifold(BMEdge *e) +bool BM_edge_is_manifold(BMEdge *e) { const BMLoop *l = e->l; return (l && (l->radial_next != l) && /* not 0 or 1 face users */ @@ -700,10 +700,10 @@ int BM_edge_is_manifold(BMEdge *e) { int count = BM_edge_face_count(e); if (count == 2) { - return TRUE; + return true; } else { - return FALSE; + return false; } } #endif @@ -714,7 +714,7 @@ int BM_edge_is_manifold(BMEdge *e) */ #if 1 /* fast path for checking boundary */ -int BM_edge_is_boundary(BMEdge *e) +bool BM_edge_is_boundary(BMEdge *e) { const BMLoop *l = e->l; return (l && (l->radial_next == l)); @@ -724,10 +724,10 @@ int BM_edge_is_boundary(BMEdge *e) { int count = BM_edge_face_count(e); if (count == 1) { - return TRUE; + return true; } else { - return FALSE; + return false; } } #endif @@ -757,7 +757,7 @@ int BM_face_share_face_count(BMFace *f1, BMFace *f2) /** * same as #BM_face_share_face_count but returns a bool */ -int BM_face_share_face_check(BMFace *f1, BMFace *f2) +bool BM_face_share_face_check(BMFace *f1, BMFace *f2) { BMIter iter1, iter2; BMEdge *e; @@ -766,11 +766,11 @@ int BM_face_share_face_check(BMFace *f1, BMFace *f2) BM_ITER_ELEM (e, &iter1, f1, BM_EDGES_OF_FACE) { BM_ITER_ELEM (f, &iter2, e, BM_FACES_OF_EDGE) { if (f != f1 && f != f2 && BM_face_share_edge_check(f, f2)) - return TRUE; + return true; } } - return FALSE; + return false; } /** @@ -793,9 +793,9 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2) } /** - * Returns TRUE if the faces share an edge + * Returns true if the faces share an edge */ -int BM_face_share_edge_check(BMFace *f1, BMFace *f2) +bool BM_face_share_edge_check(BMFace *f1, BMFace *f2) { BMLoop *l_iter; BMLoop *l_first; @@ -803,17 +803,17 @@ int BM_face_share_edge_check(BMFace *f1, BMFace *f2) l_iter = l_first = BM_FACE_FIRST_LOOP(f1); do { if (bmesh_radial_face_find(l_iter->e, f2)) { - return TRUE; + return true; } } while ((l_iter = l_iter->next) != l_first); - return FALSE; + return false; } /** - * Test if e1 shares any faces with e2 + * Test if e1 shares any faces with e2 */ -int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) +bool BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) { BMLoop *l; BMFace *f; @@ -823,18 +823,18 @@ int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) do { f = l->f; if (bmesh_radial_face_find(e2, f)) { - return TRUE; + return true; } l = l->radial_next; } while (l != e1->l); } - return FALSE; + return false; } /** * Test if e1 shares any quad faces with e2 */ -int BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2) +bool BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2) { BMLoop *l; BMFace *f; @@ -845,19 +845,19 @@ int BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2) f = l->f; if (f->len == 4) { if (bmesh_radial_face_find(e2, f)) { - return TRUE; + return true; } } l = l->radial_next; } while (l != e1->l); } - return FALSE; + return false; } /** * Tests to see if e1 shares a vertex with e2 */ -int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2) +bool BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2) { return (e1->v1 == e2->v1 || e1->v1 == e2->v2 || @@ -1007,7 +1007,7 @@ void BM_loop_calc_face_tangent(BMLoop *l, float r_tangent[3]) normalize_v3(v_prev); normalize_v3(v_next); - if (compare_v3v3(v_prev, v_next, FLT_EPSILON) == FALSE) { + if (compare_v3v3(v_prev, v_next, FLT_EPSILON) == false) { float dir[3]; float nor[3]; /* for this purpose doesn't need to be normalized */ add_v3_v3v3(dir, v_prev, v_next); @@ -1279,10 +1279,10 @@ BMEdge *BM_edge_find_double(BMEdge *e) * \note Making a face here is valid but in some cases you wont want to * make a face thats part of another. * - * \returns TRUE for overlap + * \returns true for overlap * */ -int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) +bool BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) { BMIter viter; BMFace *f; @@ -1290,12 +1290,12 @@ int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) for (i = 0; i < len; i++) { BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) { - amount = BM_verts_in_face(f, varr, len); + amount = BM_verts_in_face_count(f, varr, len); if (amount >= len) { if (r_overlapface) { *r_overlapface = f; } - return TRUE; + return true; } } } @@ -1304,7 +1304,7 @@ int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) *r_overlapface = NULL; } - return FALSE; + return false; } /** @@ -1312,7 +1312,7 @@ int BM_face_exists_overlap(BMVert **varr, int len, BMFace **r_overlapface) * there is a face with exactly those vertices * (and only those vertices). */ -int BM_face_exists(BMVert **varr, int len, BMFace **r_existface) +bool BM_face_exists(BMVert **varr, int len, BMFace **r_existface) { BMIter viter; BMFace *f; @@ -1320,12 +1320,12 @@ int BM_face_exists(BMVert **varr, int len, BMFace **r_existface) for (i = 0; i < len; i++) { BM_ITER_ELEM (f, &viter, varr[i], BM_FACES_OF_VERT) { - amount = BM_verts_in_face(f, varr, len); + amount = BM_verts_in_face_count(f, varr, len); if (amount == len && amount == f->len) { if (r_existface) { *r_existface = f; } - return TRUE; + return true; } } } @@ -1333,7 +1333,7 @@ int BM_face_exists(BMVert **varr, int len, BMFace **r_existface) if (r_existface) { *r_existface = NULL; } - return FALSE; + return false; } @@ -1349,12 +1349,12 @@ int BM_face_exists(BMVert **varr, int len, BMFace **r_existface) * * \a earr and \a varr can be in any order, however they _must_ form a closed loop. */ -int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) +bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) { BMFace *f; BMEdge *e; BMVert *v; - int ok; + bool ok; int tot_tag; BMIter fiter; @@ -1394,10 +1394,10 @@ int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) for (i = 0; i < len; i++) { BM_ITER_ELEM (f, &fiter, earr[i], BM_FACES_OF_EDGE) { if (!BM_elem_flag_test(f, BM_ELEM_INTERNAL_TAG)) { - ok = TRUE; + ok = true; BM_ITER_ELEM (v, &viter, f, BM_VERTS_OF_FACE) { if (!BM_elem_flag_test(v, BM_ELEM_INTERNAL_TAG)) { - ok = FALSE; + ok = false; break; } } @@ -1416,20 +1416,20 @@ int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) if (tot_tag == 0) { /* no faces use only boundary verts, quit early */ - return FALSE; + return false; } /* 2) loop over non-boundary edges that use boundary verts, * check each have 2 tagges faces connected (faces that only use 'varr' verts) */ - ok = TRUE; + ok = true; for (i = 0; i < len; i++) { BM_ITER_ELEM (e, &fiter, varr[i], BM_EDGES_OF_VERT) { if (/* non-boundary edge */ - BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG) == FALSE && + BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG) == false && /* ...using boundary verts */ - BM_elem_flag_test(e->v1, BM_ELEM_INTERNAL_TAG) == TRUE && - BM_elem_flag_test(e->v2, BM_ELEM_INTERNAL_TAG) == TRUE) + BM_elem_flag_test(e->v1, BM_ELEM_INTERNAL_TAG) == true && + BM_elem_flag_test(e->v2, BM_ELEM_INTERNAL_TAG) == true) { int tot_face_tag = 0; BM_ITER_ELEM (f, &fiter, e, BM_FACES_OF_EDGE) { @@ -1439,14 +1439,14 @@ int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) } if (tot_face_tag != 2) { - ok = FALSE; + ok = false; break; } } } - if (ok == FALSE) { + if (ok == false) { break; } } @@ -1455,25 +1455,25 @@ int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len) } /* same as 'BM_face_exists_multi' but built vert array from edges */ -int BM_face_exists_multi_edge(BMEdge **earr, int len) +bool BM_face_exists_multi_edge(BMEdge **earr, int len) { BMVert **varr = BLI_array_alloca(varr, len); - int ok; + bool ok; int i, i_next; /* first check if verts have edges, if not we can bail out early */ - ok = TRUE; + ok = true; for (i = len - 1, i_next = 0; i_next < len; (i = i_next++)) { if (!(varr[i] = BM_edge_share_vert(earr[i], earr[i_next]))) { - ok = FALSE; + ok = false; break; } } - if (ok == FALSE) { + if (ok == false) { BMESH_ASSERT(0); - return FALSE; + return false; } ok = BM_face_exists_multi(varr, earr, len); @@ -1482,13 +1482,13 @@ int BM_face_exists_multi_edge(BMEdge **earr, int len) } /* convenience functions for checking flags */ -int BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag) +bool BM_edge_is_any_vert_flag_test(BMEdge *e, const char hflag) { return (BM_elem_flag_test(e->v1, hflag) || BM_elem_flag_test(e->v2, hflag)); } -int BM_face_is_any_vert_flag_test(BMFace *f, const char hflag) +bool BM_face_is_any_vert_flag_test(BMFace *f, const char hflag) { BMLoop *l_iter; BMLoop *l_first; @@ -1496,13 +1496,13 @@ int BM_face_is_any_vert_flag_test(BMFace *f, const char hflag) l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { if (BM_elem_flag_test(l_iter->v, hflag)) { - return TRUE; + return true; } } while ((l_iter = l_iter->next) != l_first); - return FALSE; + return false; } -int BM_face_is_any_edge_flag_test(BMFace *f, const char hflag) +bool BM_face_is_any_edge_flag_test(BMFace *f, const char hflag) { BMLoop *l_iter; BMLoop *l_first; @@ -1510,8 +1510,8 @@ int BM_face_is_any_edge_flag_test(BMFace *f, const char hflag) l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { if (BM_elem_flag_test(l_iter->e, hflag)) { - return TRUE; + return true; } } while ((l_iter = l_iter->next) != l_first); - return FALSE; + return false; } |