From 6cdb555e6ebef2b9c3dde8672deef027d9d70d1a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 9 Nov 2012 14:52:05 +0000 Subject: bmesh refactor - rename some of the BM_****_share_****_count() functions to BM_***_share_check() some of these were only returning a boolean, others returned a count even though only a boolean was needed. split some of the functions in two as well where check/count are both needed. --- source/blender/bmesh/intern/bmesh_queries.c | 63 ++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'source/blender/bmesh/intern/bmesh_queries.c') diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 8eb87cf29be..1e1d7d1becb 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -724,6 +724,47 @@ int BM_edge_is_boundary(BMEdge *e) } #endif +/** + * Returns the number of faces that are adjacent to both f1 and f2, + * \note Could be sped up a bit by not using iterators and by tagging + * faces on either side, then count the tags rather then searching. + */ +int BM_face_share_face_count(BMFace *f1, BMFace *f2) +{ + BMIter iter1, iter2; + BMEdge *e; + BMFace *f; + int count = 0; + + 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)) + count++; + } + } + + return count; +} + +/** + * same as #BM_face_share_face_count but returns a bool + */ +int BM_face_share_face_check(BMFace *f1, BMFace *f2) +{ + BMIter iter1, iter2; + BMEdge *e; + BMFace *f; + + 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 FALSE; +} + /** * Counts the number of edges two faces share (if any) */ @@ -743,10 +784,28 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2) return count; } +/** + * Returns TRUE if the faces share an edge + */ +int BM_face_share_edge_check(BMFace *f1, BMFace *f2) +{ + BMLoop *l_iter; + BMLoop *l_first; + + l_iter = l_first = BM_FACE_FIRST_LOOP(f1); + do { + if (bmesh_radial_face_find(l_iter->e, f2)) { + return TRUE; + } + } while ((l_iter = l_iter->next) != l_first); + + return FALSE; +} + /** * Test if e1 shares any faces with e2 */ -int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2) +int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) { BMLoop *l; BMFace *f; @@ -767,7 +826,7 @@ int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2) /** * Tests to see if e1 shares a vertex with e2 */ -int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2) +int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2) { return (e1->v1 == e2->v1 || e1->v1 == e2->v2 || -- cgit v1.2.3