diff options
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 43 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index f61f9666d6d..549cc44c338 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -952,6 +952,49 @@ float BM_vert_calc_mean_tagged_edge_length(BMVert *v) /** + * Returns the shortest edge in f. + */ +BMEdge *BM_face_find_shortest_edge(BMFace *f) +{ + BMIter iter; + BMEdge *shortest_edge = NULL, *e; + float shortest_len = FLT_MAX; + + BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) { + float len = BM_edge_calc_length(e); + + if (len <= shortest_len) { + shortest_edge = e; + shortest_len = len; + } + } + + return shortest_edge; +} + +/** + * Returns the longest edge in f. + */ +BMEdge *BM_face_find_longest_edge(BMFace *f) +{ + BMIter iter; + BMEdge *longest_edge = NULL, *e; + float longest_len = 0; + + BM_ITER_ELEM(e, &iter, f, BM_EDGES_OF_FACE) { + float len = BM_edge_calc_length(e); + + if (len >= longest_len) { + longest_edge = e; + longest_len = len; + } + } + + return longest_edge; +} + + +/** * Returns the edge existing between v1 and v2, or NULL if there isn't one. * * \note multiple edges may exist between any two vertices, and therefore diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 08e15884b3f..9712c0066b7 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -67,6 +67,9 @@ float BM_vert_calc_edge_angle(BMVert *v); float BM_vert_calc_shell_factor(BMVert *v); float BM_vert_calc_mean_tagged_edge_length(BMVert *v); +BMEdge *BM_face_find_shortest_edge(BMFace *f); +BMEdge *BM_face_find_longest_edge(BMFace *f); + BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2); int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); |