Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-09 18:52:05 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-09 18:52:05 +0400
commit6cdb555e6ebef2b9c3dde8672deef027d9d70d1a (patch)
tree68b97830e3aac79b755eaf2ac25c58799c6701fb /source/blender/bmesh/intern/bmesh_queries.c
parentdc5ba03945c9f9cc8cbc93c91ff872a29c38659c (diff)
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.
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_queries.c')
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c63
1 files changed, 61 insertions, 2 deletions
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
@@ -725,6 +725,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)
*/
int BM_face_share_edge_count(BMFace *f1, BMFace *f2)
@@ -744,9 +785,27 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2)
}
/**
+ * 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 ||