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.
This commit is contained in:
Campbell Barton 2012-11-09 14:52:05 +00:00
parent dc5ba03945
commit 6cdb555e6e
8 changed files with 74 additions and 31 deletions

@ -828,8 +828,6 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
mcol = DM_get_tessface_data_layer(dm, colType);
}
printf("%s: %p(%d/%d)\n", __func__, mcol, CD_ID_MCOL, colType);
cdDM_update_normals_from_pbvh(dm);
/* back-buffer always uses legacy since VBO's would need the

@ -118,7 +118,7 @@ int BM_disk_dissolve(BMesh *bm, BMVert *v)
e = v->e;
do {
e = bmesh_disk_edge_next(e, v);
if (!(BM_edge_share_face_count(e, v->e))) {
if (!(BM_edge_share_face_check(e, v->e))) {
keepedge = e;
baseedge = v->e;
break;

@ -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 ||

@ -84,9 +84,13 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface);
int BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len);
int BM_face_exists_multi_edge(BMEdge **earr, int len);
int BM_face_share_face_count(BMFace *f1, BMFace *f2);
int BM_face_share_edge_count(BMFace *f1, BMFace *f2);
int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2);
int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2);
int BM_face_share_face_check(BMFace *f1, BMFace *f2);
int BM_face_share_edge_check(BMFace *f1, BMFace *f2);
int BM_edge_share_face_check(BMEdge *e1, BMEdge *e2);
int BM_edge_share_vert_check(BMEdge *e1, BMEdge *e2);
BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2);
BMLoop *BM_face_vert_share_loop(BMFace *f, BMVert *v);

@ -1177,10 +1177,10 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
}
if (edges1 && BLI_array_count(edges1) > 2 &&
BM_edge_share_vert_count(edges1[0], edges1[BLI_array_count(edges1) - 1]))
BM_edge_share_vert_check(edges1[0], edges1[BLI_array_count(edges1) - 1]))
{
if (edges2 && BLI_array_count(edges2) > 2 &&
BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
{
BLI_array_free(edges1);
BLI_array_free(edges2);
@ -1193,7 +1193,7 @@ void bmo_edgenet_prepare(BMesh *bm, BMOperator *op)
}
if (edges2 && BLI_array_count(edges2) > 2 &&
BM_edge_share_vert_count(edges2[0], edges2[BLI_array_count(edges2) - 1]))
BM_edge_share_vert_check(edges2[0], edges2[BLI_array_count(edges2) - 1]))
{
edges2 = NULL;
}

@ -825,7 +825,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op)
}
/* make sure the two edges have a valid angle to each other */
if (totesel == 2 && BM_edge_share_vert_count(e1, e2)) {
if (totesel == 2 && BM_edge_share_vert_check(e1, e2)) {
sub_v3_v3v3(vec1, e1->v2->co, e1->v1->co);
sub_v3_v3v3(vec2, e2->v2->co, e2->v1->co);
normalize_v3(vec1);

@ -261,7 +261,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
lasteed = eed;
}
if (lasteed != startedge && BM_edge_share_face_count(lasteed, startedge)) {
if (lasteed != startedge && BM_edge_share_face_check(lasteed, startedge)) {
v[1][0] = v[0][0];
v[1][1] = v[0][1];

@ -1354,24 +1354,6 @@ static void add_quad_from_tris(SkinOutput *so, BMEdge *e, BMFace *adj[2])
add_poly(so, quad[0], quad[1], quad[2], quad[3]);
}
/* Returns the number of faces that are adjacent to both f1 and f2 */
static 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_count(f, f2))
count++;
}
}
return count;
}
static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
{
BMIter iter;
@ -1434,7 +1416,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd)
* share a border with another face, output as a quad */
if (!BM_elem_flag_test(adj[0], BM_ELEM_TAG) &&
!BM_elem_flag_test(adj[1], BM_ELEM_TAG) &&
!BM_face_share_face_count(adj[0], adj[1]))
!BM_face_share_face_check(adj[0], adj[1]))
{
add_quad_from_tris(so, e, adj);
BM_elem_flag_enable(adj[0], BM_ELEM_TAG);