fix for BM_edge_other_loop() not working right (own error in recent commit), and add new function BM_vert_step_fan_loop() for stepping around the loops of a face fan with manifold edges.

This commit is contained in:
Campbell Barton
2012-10-20 16:48:04 +00:00
parent 29392dc2b4
commit d20128bbbc
2 changed files with 53 additions and 1 deletions

View File

@@ -346,7 +346,9 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l)
BLI_assert(BM_edge_is_manifold(e));
BLI_assert(BM_vert_in_edge(e, l->v));
l_other = (e->l == l) ? l->radial_next : l;
l_other = (l->e == e) ? l : l->prev;
l_other = l_other->radial_next;
BLI_assert(l_other->e == e);
if (l_other->v == l->v) {
/* pass */
@@ -361,6 +363,55 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l)
return l_other;
}
/**
* Utility function to step around a fan of loops,
* using an edge to mark the previous side.
*
* \note all edges must be manifold,
* once a non manifold edge is hit, return NULL.
*
* <pre>
* ,.,-->|
* _,-' |
* ,' | (notice how 'e_step'
* / | and 'l' define the
* / | direction the arrow
* | return | points).
* | loop --> |
* ---------------------+---------------------
* ^ l --> |
* | |
* assign e_step |
* |
* begin e_step ----> |
* |
* </pre>
*/
BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step)
{
BMEdge *e_prev = *e_step;
BMEdge *e_next;
if (l->e == e_prev) {
e_next = l->prev->e;
}
else if (l->prev->e == e_prev) {
e_next = l->e;
}
else {
BLI_assert(0);
}
if (BM_edge_is_manifold(e_next)) {
return BM_edge_other_loop((*e_step = e_next), l);
}
else {
return NULL;
}
}
/**
* The function takes a vertex at the center of a fan and returns the opposite edge in the fan.
* All edges in the fan must be manifold, otherwise return NULL.

View File

@@ -44,6 +44,7 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l);
BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v);
BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v);
BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v);
BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step);
BMLoop *BM_vert_find_first_loop(BMVert *v);
int BM_vert_edge_count_nonwire(BMVert *v);