diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-12-17 10:06:05 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-12-17 10:06:05 +0300 |
commit | b6a49eb9498e5025bd7920f620bae1a44f34104e (patch) | |
tree | 91e017e2d5c9c706f6c46f06bc482e79bea8b20b /source/blender/bmesh | |
parent | d7723df8466a9aa34ab51f5c3640ae17d48637eb (diff) |
BMesh: add BM_face_share_vert_check/count
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 37 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 10 |
2 files changed, 44 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index e7a93c6aad5..f8cc66fc0df 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -1216,6 +1216,43 @@ bool BM_face_share_edge_check(BMFace *f1, BMFace *f2) } /** + * Counts the number of verts two faces share (if any). + */ +int BM_face_share_vert_count(BMFace *f_a, BMFace *f_b) +{ + BMLoop *l_iter; + BMLoop *l_first; + int count = 0; + + l_iter = l_first = BM_FACE_FIRST_LOOP(f_a); + do { + if (BM_vert_in_face(l_iter->v, f_b)) { + count++; + } + } while ((l_iter = l_iter->next) != l_first); + + return count; +} + +/** + * Returns true if the faces share a vert. + */ +bool BM_face_share_vert_check(BMFace *f_a, BMFace *f_b) +{ + BMLoop *l_iter; + BMLoop *l_first; + + l_iter = l_first = BM_FACE_FIRST_LOOP(f_a); + do { + if (BM_vert_in_face(l_iter->v, f_b)) { + return true; + } + } while ((l_iter = l_iter->next) != l_first); + + return false; +} + +/** * Test if e1 shares any faces with e2 */ bool BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index cfe291732de..257743be3dd 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -143,10 +143,14 @@ bool BM_face_exists_overlap(BMVert **varr, const int len, BMFace **r_f_overla bool BM_face_exists_overlap_subset(BMVert **varr, const int len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); int BM_face_share_face_count(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -int BM_face_share_edge_count(BMFace *f1, BMFace *f2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BM_face_share_edge_count(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +int BM_face_share_vert_count(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + +bool BM_face_share_face_check(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +bool BM_face_share_edge_check(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); +bool BM_face_share_vert_check(BMFace *f_a, BMFace *f_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); + -bool BM_face_share_face_check(BMFace *f1, BMFace *f2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); -bool BM_face_share_edge_check(BMFace *f1, BMFace *f2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_edge_share_face_check(BMEdge *e1, BMEdge *e2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_edge_share_quad_check(BMEdge *e1, BMEdge *e2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); |